@@ -454,7 +454,7 @@ public function pwrsendFile($peer, $type, $path, $hash)
454454*/
455455 $ formattedPath = $ this ->formatFileName ($ path );
456456 $ cmd = "send_ " . $ type . " " . $ peer . " " . $ formattedPath ;
457- $ res = shell_exec ($ GLOBALS ["homedir " ] . "/tg/bin/telegram-cli --json --permanent-msg-ids -U pwrtelegram -WNRe " . escapeshellarg ($ cmd ) . " 2>&1 " );
457+ $ res = shell_exec (" export TELEGRAM_HOME= " . $ this -> tgpath . " ; " . $ GLOBALS ["homedir " ] . "/tg/bin/telegram-cli --json --permanent-msg-ids -U pwrtelegram -WNRe " . escapeshellarg ($ cmd ) . " 2>&1 " );
458458 $ newres = null ;
459459 $ finalres = null ;
460460 foreach (explode ("\n" , $ res ) as $ line ) {
@@ -476,14 +476,14 @@ public function pwrsendFile($peer, $type, $path, $hash)
476476 */
477477 public function getdFile ($ id , $ type )
478478 {
479- $ res = shell_exec ($ GLOBALS ["homedir " ] . "/tg/bin/telegram-cli --json --permanent-msg-ids -WNRe 'load_file $ id' 2>&1 | sed 's/[>]//g;/{/!d;/{ \"event \": \"download \"/!d;/^\s*$/d;s/^[^{]*{/{/;s/}[^}]*$/}/' " );
479+ $ res = shell_exec (" export TELEGRAM_HOME= " . $ this -> tgpath . " ; " . $ GLOBALS ["homedir " ] . "/tg/bin/telegram-cli --json --permanent-msg-ids -WNRe 'load_file $ id' 2>&1 | sed 's/[>]//g;/{/!d;/{ \"event \": \"download \"/!d;/^\s*$/d;s/^[^{]*{/{/;s/}[^}]*$/}/' " );
480480 error_log ($ res );
481481 return json_decode ($ res );
482482 }
483483 public function getFile ($ user , $ file_id , $ type )
484484 {
485485 $ script = escapeshellarg ($ GLOBALS ["pwrhomedir " ] . "/lua/download.lua " );
486- $ res = shell_exec ($ GLOBALS ["homedir " ] . "/tg/bin/telegram-cli --json -WNRs " . $ script . " --lua-param " .escapeshellarg ($ user ." " .$ file_id ." " .$ type )." 2>&1 " );
486+ $ res = shell_exec (" export TELEGRAM_HOME= " . $ this -> tgpath . " ; " . $ GLOBALS ["homedir " ] . "/tg/bin/telegram-cli --json -WNRs " . $ script . " --lua-param " .escapeshellarg ($ user ." " .$ file_id ." " .$ type )." 2>&1 " );
487487 foreach (explode ("\n" , $ res ) as $ line ) {
488488 if (preg_match ('|.*{"event":"download", "result"| ' , $ line )) $ res = preg_replace (array ('|.*{"event":"download", "result"| ' , "|}.*| " ), array ('{"event":"download", "result" ' , "} " ), $ line );
489489 }
0 commit comments