سلام ؛ وقت بخیر
ادامه هم مثه کدتکد:Type=="gif"||
به همین سادگی
با احترام .
سلام ؛ وقت بخیر
ادامه هم مثه کدتکد:Type=="gif"||
به همین سادگی
با احترام .
Web designer and programmer
Php , Html , Css , JavaScript , MVC , node.js , vuejs , React JS , NoSQL Couch & Mongo
Telegram: @coderwb
یعنی به این شکل ؟
دوست عزیز به این شکل وارد و سیو کردم نمیشه که نمیشه ..کد:function createImage($image){ $type = strtolower(substr($image, strrpos($image, "."), strlen($image)-strrpos($image, "."))); if($type==".jpeg" || $type==".jpg" || $type==".gif" || $type==".png"){ return imagecreatefromjpeg($image); }elseif($type==".gif"){ return imagecreatefromgif($image); }elseif($type==".png"){ return imagecreatefrompng($image); }else{ die("Immagine non valida"); } }
.
سلام ؛ وقت بخیر
خدمت شما :
با احترام.کد PHP:function createImage($image){
$type = strtolower(substr($image, strrpos($image, "."), strlen($image)-strrpos($image, ".")));
if($type==".jpeg" || $type==".jpg" || $type==".png" || $type==".gif"){
return imagecreatefromjpeg($image);
}
else
{
die("Immagine non valida");
}
}
Web designer and programmer
Php , Html , Css , JavaScript , MVC , node.js , vuejs , React JS , NoSQL Couch & Mongo
Telegram: @coderwb
نشد دوست عزیز من کلاً 2 تا فایل اصلی دارم اینا رو بررسی کنید عزیز و اخر سر مشکل رو بگید کجاست :
فایل img.class.php :
فایل prosess.php :کد:<?php class img { var $thumb_w = 172; // larghezza thumb var $thumb_h = 130; // altezza thumb var $max_w = 1350; // larghezza max var $max_h = 800; // altezza max var $pos_x = "CENTER"; // posizione logo var $pos_y = "MIDDLE"; // posizione logo var $img_folder = "uploads/"; // cartella immagine grande var $thumb_folder = ""; // cartella immagine thumb var $saveBIG = 1; //salvare immagine grande var $saveTHUMB = 1; //salvare thumb var $name = ""; //nome immagine senza estensione function AddLogo($image, $logo = NULL) { $this->im = $this->createImage($image); $this->im_width = imagesx($this->im); $this->im_height = imagesy($this->im); $this->wt_x = $this->calc_pos_x($this->pos_x); $this->wt_y = $this->calc_pos_y($this->pos_y); $this->new_image = $this->resizeImg(); $this->resizeForThumb(); if($logo != NULL) { $this->createTheLogo($logo); } if($this->name==""){ $this->name = substr($image, 0 , strrpos($image, ".")); } if($this->saveBIG == 1) { imagejpeg($this->new_image, $this->img_folder.$this->name."_varzeshiha.jpg"); } if($this->saveTHUMB == 1) { imagejpeg($this->thumb, $this->thumb_folder.$this->name."_small.jpg"); } } function createImage($image){ $type = strtolower(substr($image, strrpos($image, "."), strlen($image)-strrpos($image, "."))); if($type==".jpeg" || $type==".jpg" || $type==".png" || $type==".gif"){ return imagecreatefromjpeg($image); } else { die("Immagine non valida"); } } function createTheLogo($logo) { $this->logo = $this->createImage($logo); $this->logo_width = imagesx($this->logo); $this->logo_height = imagesy($this->logo); $this->wt_x = $this->calc_pos_x($this->pos_x); $this->wt_y = $this->calc_pos_y($this->pos_y); imagecopy($this->new_image, $this->logo, $this->wt_x, $this->wt_y, 0, 0, $this->logo_width, $this->logo_height); } function resizeImg() { if($this->im_width > $this->max_w && $this->im_height < $this->max_h) { $rapporto = $this->max_w / $this->im_width; $this->new_im_w = $this->im_width * $rapporto; $this->new_im_h = $this->im_height * $rapporto; } else if($this->im_width < $this->max_w && $this->im_height > $this->max_h) { $rapporto = $this->max_h / $this->im_height; $this->new_im_w = $this->im_width * $rapporto; $this->new_im_h = $this->im_height * $rapporto; } else if($this->im_width > $this->max_w && $this->im_height > $this->max_h) { $rapporto_1 = $this->max_w / $this->im_width; $rapporto_2 = $this->max_h / $this->im_height; if($rapporto_1 > $rapporto_2) { $rapporto = $rapporto_2; } else { $rapporto = $rapporto_1; } $this->new_im_w = $this->im_width * $rapporto; $this->new_im_h = $this->im_height * $rapporto; } else { $this->new_im_w = $this->im_width; $this->new_im_h = $this->im_height; } $this->new_image = imagecreatetruecolor($this->new_im_w, $this->new_im_h); imagecopyresized($this->new_image, $this->im, 0, 0, 0, 0, $this->new_im_w, $this->new_im_h, $this->im_width, $this->im_height); return $this->new_image; } function resizeForThumb(){ $thumb_w = $this->thumb_w; $thumb_h = $this->thumb_h; if($this->im_width > $this->im_height) { $rapporto = $this->im_height / $this->im_width; $thumb_h = $this->thumb_h * $rapporto; $thumb_w = $this->thumb_w * $rapporto; } else if($this->im_width < $this->im_height) { $rapporto = $this->im_width / $this->im_height; $thumb_w = $this->thumb_w * $rapporto; } else { $thumb_w = $this->thumb_w; $thumb_h = $this->thumb_h; } $this->thumb = imagecreatetruecolor($thumb_w, $thumb_h); imagecopyresized($this->thumb, $this->new_image, 0, 0, 0, 0, $thumb_w, $thumb_h, $this->new_im_w, $this->new_im_h); } function calc_pos_x($position_x) { $x = 0; switch($position_x) { case 'LEFT': $x = 0; break; case 'CENTER': $x = @$this->new_im_w / 2 - @$this->logo_width / 2; break; case 'RIGHT': $x = @$this->new_im_w - @$this->logo_width; break; default: $x = 0; } return $x; } function calc_pos_y($position_y) { $y = 0; switch($position_y) { case 'TOP': $y = 0; break; case 'MIDDLE': $y = @$this->new_im_h / 2 - @$this->logo_height / 2; break; case 'BOTTOM': $y = @$this->new_im_h - @$this->logo_height; break; default: $y = 0; } return $y; } } ?>
- - - Updated - - -کد:<?php require("img.class.php"); function pma($pic,$chat_id,$cap,$bot_id) { $array1=array('chat_id'=>$chat_id); $text.=" $cap"; $myphoto=$pic; $array2=array('photo'=>$myphoto); $ch = curl_init(); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_URL,"https://api.telegram.org/bot$bot_id/sendPhoto?caption=$text"); curl_custom_postfields($ch,$array1,$array2); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); $output=curl_exec($ch); print_r( $output); curl_close($ch); } function curl_custom_postfields($ch, array $assoc = array(), array $files = array()) { // invalid characters for "name" and "filename" static $disallow = array("\0", "\"", "\r", "\n"); // build normal parameters foreach ($assoc as $k => $v) { $k = str_replace($disallow, "_", $k); $body[] = implode("\r\n", array( "Content-Disposition: form-data; name=\"{$k}\"", "", filter_var($v), )); } // build file parameters foreach ($files as $k => $v) { $data = file_get_contents($v); $v = call_user_func("end", explode(DIRECTORY_SEPARATOR, $v)); $k = str_replace($disallow, "_", $k); $v = str_replace($disallow, "_", $v); $body[] = implode("\r\n", array( "Content-Disposition: form-data; name=\"{$k}\"; filename=\"{$v}\"", "Content-Type: image/jpeg", "Content-Type: image/jpg", "Content-Type: image/gif", "Content-Type: image/png", "", $data, )); } // generate safe boundary do { $boundary = "---------------------" . md5(mt_rand() . microtime()); } while (preg_grep("/{$boundary}/", $body)); // add boundary for each parameters array_walk($body, function (&$part) use ($boundary) { $part = "--{$boundary}\r\n{$part}"; }); // add final boundary $body[] = "--{$boundary}--"; $body[] = ""; // set options return @curl_setopt_array($ch, array( CURLOPT_POST => true, CURLOPT_POSTFIELDS => implode("\r\n", $body), CURLOPT_HTTPHEADER => array( "Expect: 100-continue", "Content-Type: multipart/form-data; boundary={$boundary}", // change Content-Type ), )); } function processMessage($message,$API_KEY) { // process incoming message $message_id = $message['message_id']; $chat_id = $message['chat']['id']; if (isset($message['photo'])) { // incoming photo message $text = $message['caption']; $photo = $message['photo']; // pmphoto($text,$photo,$chat_id,$API_KEY); $photo= $message['photo']; foreach($photo as $pic) $pict = $pic['file_id']; $getfile='https://api.telegram.org/bot'.$API_KEY.'/getFile?file_id='.$pict; $getfile=file_get_contents($getfile); $file=json_decode($getfile, true); $picurl='https://api.telegram.org/file/bot'.$API_KEY.'/'.$file['result']['file_path']; $img = new img; //variabili settabili (valori segnati default) $img->name = $pict; //nome immagine senza estensione, di default preso nome originale $img->thumb_w = 172; // larghezza thumb in px $img->thumb_h = 130; // altezza thumb in px $img->max_w = 1350; // larghezza max in px $img->max_h = 800; // altezza max in px $img->pos_x = "CENTER"; // posizione logo -> RIGHT, LEFT, CENTER $img->pos_y = "MIDDLE"; // posizione logo -> BOTTOM, TOP, MIDDLE $img->img_folder = "uploads/"; // cartella immagine grande (default-> cartella dell'immagine originale) $img->thumb_folder = ""; // cartella immagine thumb (default-> cartella dell'immagine originale) $img->saveBIG = 1; //salvare immagine grande 1 o 0 $img->saveTHUMB = 0; //salvare thumb -> 1 o 0 $img->AddLogo($picurl, "logo.png"); $newpic=$pict.'_varzeshiha.jpg'; $cap="upload"; pma($newpic,$chat_id,$cap,$API_KEY); }else{ $text = ' ������ سلام ، به ربات آپلود واترمارک بر روی عکس خوش آمدید ������ در این ربات عکس با همه فرمت ها ارسال کنید ☑️ با کلیک بر روی لینک زیر وارد کانال ورزشی ها شوید ������ @varzeshiha_channel '; $post = 'https://api.telegram.org/bot'.$API_KEY.'/sendMessage'; $matn = urlencode($text); $post.="?text=$matn&caption=@upload&chat_id=$chat_id"; echo file_get_contents($post); } } $content = file_get_contents("php://input"); $update = json_decode($content, true); $bot_id="filtershod"; if (isset($update["message"])) { processMessage($update["message"],$bot_id); } ?>
کسی نیست کمک کنه به خدا بدجور کارم لنگه
.
Web designer and programmer
Php , Html , Css , JavaScript , MVC , node.js , vuejs , React JS , NoSQL Couch & Mongo
Telegram: @coderwb
دوست عزیز این هستش :
http://fenj.ir/%D8%B1%D9%88%D8%A8%D8...8%D8%B1%D8%B3/
.
Web designer and programmer
Php , Html , Css , JavaScript , MVC , node.js , vuejs , React JS , NoSQL Couch & Mongo
Telegram: @coderwb
در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)