@@ -77,7 +77,6 @@ private static function log($string)
7777 return false ;
7878 }
7979
80- //$status = file_put_contents($path, self::$input . "\n", FILE_APPEND);
8180 $ status = file_put_contents ($ path , $ string . "\n" , FILE_APPEND );
8281 return $ status ;
8382 }
@@ -125,24 +124,18 @@ public static function executeCurl($action, array $data = null)
125124 $ curlConfig = array (
126125 CURLOPT_URL => 'https://api.telegram.org/bot ' . self ::$ telegram ->getApiKey () . '/ ' . $ action ,
127126 CURLOPT_POST => true ,
128- CURLOPT_RETURNTRANSFER => true
127+ CURLOPT_RETURNTRANSFER => true ,
128+ CURLOPT_SAFE_UPLOAD => true
129129 );
130130
131131 if (!empty ($ data )) {
132- if (!empty ($ data ['text ' ]) && substr ($ data ['text ' ], 0 , 1 ) === '@ ' ) {
133- $ data ['text ' ] = ' ' . $ data ['text ' ];
134- }
135132 $ curlConfig [CURLOPT_POSTFIELDS ] = $ data ;
136133 }
137134
138135 if (self ::$ telegram ->getLogVerbosity () >= 3 ) {
139136 $ curlConfig [CURLOPT_VERBOSE ] = true ;
140137 $ verbose = fopen ('php://temp ' , 'w+ ' );
141138 curl_setopt ($ ch , CURLOPT_STDERR , $ verbose );
142- //Not so useful
143- //$info = curl_getinfo($ch);
144- //echo "Info\n";
145- //print_r($info);
146139 }
147140
148141 curl_setopt_array ($ ch , $ curlConfig );
@@ -189,7 +182,7 @@ public static function downloadFile(File $file)
189182 throw new TelegramException ('Directory ' .$ dirname .' cant be created ' );
190183 }
191184 }
192- # open file to write
185+ // open file to write
193186 $ fp = fopen ($ loc_path , 'w+ ' );
194187 if ($ fp === false ) {
195188 throw new TelegramException ('File cant be created ' );
@@ -214,9 +207,9 @@ public static function downloadFile(File $file)
214207 if ($ result === false ) {
215208 throw new TelegramException (curl_error ($ ch ), curl_errno ($ ch ));
216209 }
217- # close curl
210+ // close curl
218211 curl_close ($ ch );
219- # close local file
212+ // close local file
220213 fclose ($ fp );
221214
222215 if (filesize ($ loc_path ) > 0 ) {
@@ -226,7 +219,6 @@ public static function downloadFile(File $file)
226219 }
227220 }
228221
229-
230222 protected static function encodeFile ($ file )
231223 {
232224 return new \CURLFile ($ file );
@@ -421,12 +413,14 @@ public static function getFile($data)
421413 $ result = self ::send ('getFile ' , $ data );
422414 return $ result ;
423415 }
416+
424417 /**
425418 * Send Message in all the active chat
426419 *
427420 *
428421 * @return bool
429422 */
423+
430424 public static function sendToActiveChats (
431425 $ callback_function ,
432426 array $ data ,
@@ -445,8 +439,6 @@ public static function sendToActiveChats(
445439
446440 $ results = [];
447441 foreach ($ chats as $ row ) {
448- //$result[] = $row;
449- //print_r($row);
450442 $ data ['chat_id ' ] = $ row ['chat_id ' ];
451443 $ results [] = call_user_func_array ($ callback_path .':: ' .$ callback_function , array ($ data ));
452444 }
0 commit comments