صفحه 1 از 2 12 آخرینآخرین
نمایش نتایج: از شماره 1 تا 10 , از مجموع 12

موضوع: یک مشکل ساده و کوچک در مورد php

  1. #1
    عضو انجمن DEFALT آواتار ها
    تاریخ عضویت
    Jun 2016
    محل سکونت
    C:\Windows
    نوشته ها
    215
    تشکر تشکر کرده 
    1,503
    تشکر تشکر شده 
    233
    تشکر شده در
    179 پست

    پیش فرض یک مشکل ساده و کوچک در مورد php

    سلام ،
    دوستان من یه فرمی دارم در php به شرح ذیل » ولی به جز jpg و jpeg فرمت دیگری نمیتونم آپلود کنم :|
    مثلاً میخوام فایل گیف یا png آپلود کنم نمیشه که نمیشه ..
    فرم به اینصورت می باشد :
    کد:
    	function createImage($image){
    		$type = strtolower(substr($image, strrpos($image, "."), strlen($image)-strrpos($image, ".")));
    		if($type==".jpeg" || $type==".jpg"){
    			return imagecreatefromjpeg($image);
    		}elseif($type==".gif"){
    			return imagecreatefromgif($image);
    		}elseif($type==".png"){
    			return imagecreatefrompng($image);
    		}else{
    			die("Immagine non valida");
    		}
    	}
    ممنون میشم طوری ویرایش و درستش کنید که هر 4 تا فرمت را آپلود کنم ♥
    .

  2. # ADS




     

  3. #2
    عضو انجمن :Hamed: آواتار ها
    تاریخ عضویت
    Dec 2017
    نوشته ها
    167
    تشکر تشکر کرده 
    27
    تشکر تشکر شده 
    275
    تشکر شده در
    144 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    سلام ؛ وقت بخیر
    کد:
    Type=="gif"||
    ادامه هم مثه کدت
    به همین سادگی
    با احترام .
    Web designer and programmer
    Php , Html , Css , JavaScript , MVC , node.js , vuejs , React JS , NoSQL Couch & Mongo
    Telegram: @coderwb

  4. تعداد تشکر ها از :Hamed: به دلیل پست مفید


  5. #3
    عضو انجمن DEFALT آواتار ها
    تاریخ عضویت
    Jun 2016
    محل سکونت
    C:\Windows
    نوشته ها
    215
    تشکر تشکر کرده 
    1,503
    تشکر تشکر شده 
    233
    تشکر شده در
    179 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    نقل قول نوشته اصلی توسط :Hamed: نمایش پست ها
    سلام ؛ وقت بخیر
    کد:
    Type=="gif"||
    ادامه هم مثه کدت
    به همین سادگی
    با احترام .
    یعنی به این شکل ؟
    کد:
    	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");
    		}
    	}
    دوست عزیز به این شکل وارد و سیو کردم نمیشه که نمیشه ..
    .

  6. #4
    عضو انجمن :Hamed: آواتار ها
    تاریخ عضویت
    Dec 2017
    نوشته ها
    167
    تشکر تشکر کرده 
    27
    تشکر تشکر شده 
    275
    تشکر شده در
    144 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    نقل قول نوشته اصلی توسط DEFALT نمایش پست ها
    یعنی به این شکل ؟
    کد:
        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($imagestrrpos($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

  7. تعداد تشکر ها از :Hamed: به دلیل پست مفید


  8. #5
    عضو انجمن DEFALT آواتار ها
    تاریخ عضویت
    Jun 2016
    محل سکونت
    C:\Windows
    نوشته ها
    215
    تشکر تشکر کرده 
    1,503
    تشکر تشکر شده 
    233
    تشکر شده در
    179 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    نقل قول نوشته اصلی توسط :Hamed: نمایش پست ها
    سلام ؛ وقت بخیر
    خدمت شما :

    کد PHP:
    function createImage($image){
        
    $type strtolower(substr($imagestrrpos($image"."), strlen($image)-strrpos($image".")));
        if(
    $type==".jpeg" || $type==".jpg" || $type==".png" || $type==".gif"){
          return 
    imagecreatefromjpeg($image);
        }
    else
    {
          die(
    "Immagine non valida");
        }
      } 
    با احترام.
    نشد دوست عزیز من کلاً 2 تا فایل اصلی دارم اینا رو بررسی کنید عزیز و اخر سر مشکل رو بگید کجاست :
    فایل img.class.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;
            
            }
            
    }
        
    ?>
    فایل prosess.php :
    کد:
    <?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);
    }
    
    
    
    
    ?>
    - - - Updated - - -

    کسی نیست کمک کنه به خدا بدجور کارم لنگه
    .

  9. #6
    عضو انجمن DEFALT آواتار ها
    تاریخ عضویت
    Jun 2016
    محل سکونت
    C:\Windows
    نوشته ها
    215
    تشکر تشکر کرده 
    1,503
    تشکر تشکر شده 
    233
    تشکر شده در
    179 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    یعنی این همه برنامه نویس این همه مهندس این همه با تجربه یکی یک مشکل خیلی کوچیک رو نمیتونن حل کنن ؟
    .

  10. #7
    کاربر اخراج شده
    تاریخ عضویت
    Jan 2018
    محل سکونت
    Iran , Turkye
    نوشته ها
    200
    تشکر تشکر کرده 
    383
    تشکر تشکر شده 
    465
    تشکر شده در
    328 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php


  11. #8
    عضو انجمن DEFALT آواتار ها
    تاریخ عضویت
    Jun 2016
    محل سکونت
    C:\Windows
    نوشته ها
    215
    تشکر تشکر کرده 
    1,503
    تشکر تشکر شده 
    233
    تشکر شده در
    179 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    نقل قول نوشته اصلی توسط NicCloud نمایش پست ها
    سلام چقدر خوب شما پشتیبان سایتی هستین که ازش هاست دارم خودتون میتونید بررسی کنید مشکل رو حل کنید دوست عزیزم ♥
    .

  12. #9
    عضو انجمن :Hamed: آواتار ها
    تاریخ عضویت
    Dec 2017
    نوشته ها
    167
    تشکر تشکر کرده 
    27
    تشکر تشکر شده 
    275
    تشکر شده در
    144 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    نقل قول نوشته اصلی توسط DEFALT نمایش پست ها
    نشد دوست عزیز من کلاً 2 تا فایل اصلی دارم اینا رو بررسی کنید عزیز و اخر سر مشکل رو بگید کجاست :
    فایل img.class.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;
            
            }
            
    }
        
    ?>
    فایل prosess.php :
    کد:
    <?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);
    }
    
    
    
    
    ?>
    - - - Updated - - -

    کسی نیست کمک کنه به خدا بدجور کارم لنگه
    سلام ؛ وقت بخیر
    دوست عزیز یا کل فایل هارو ارسال کنیدتا بتونم اجرا کنم تست بگیرم
    یا صبر کنید تا اخر شب فایل هایی که ارسال کردید رو بررسی کنم
    با احترام.
    Web designer and programmer
    Php , Html , Css , JavaScript , MVC , node.js , vuejs , React JS , NoSQL Couch & Mongo
    Telegram: @coderwb

  13. تعداد تشکر ها از :Hamed: به دلیل پست مفید


  14. #10
    عضو انجمن DEFALT آواتار ها
    تاریخ عضویت
    Jun 2016
    محل سکونت
    C:\Windows
    نوشته ها
    215
    تشکر تشکر کرده 
    1,503
    تشکر تشکر شده 
    233
    تشکر شده در
    179 پست

    پیش فرض پاسخ : یک مشکل ساده و کوچک در مورد php

    نقل قول نوشته اصلی توسط :Hamed: نمایش پست ها
    سلام ؛ وقت بخیر
    دوست عزیز یا کل فایل هارو ارسال کنیدتا بتونم اجرا کنم تست بگیرم
    یا صبر کنید تا اخر شب فایل هایی که ارسال کردید رو بررسی کنم
    با احترام.
    دوست عزیز این هستش :
    http://fenj.ir/%D8%B1%D9%88%D8%A8%D8...8%D8%B1%D8%B3/
    .

صفحه 1 از 2 12 آخرینآخرین

اطلاعات موضوع

کاربرانی که در حال مشاهده این موضوع هستند

در حال حاضر 1 کاربر در حال مشاهده این موضوع است. (0 کاربران و 1 مهمان ها)

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •