• 11-02-2025, 06:44:11
    #10
    Misafir adlı üyeden alıntı: mesajı görüntüle
    ekranda şuanda herhangi bir hata çıkmıyor ama error loga şunu yazdı [11-Feb-2025 06:35:01 Europe/Istanbul] PHP Fatal error: Uncaught Error: Call to undefined method ogcp_ssh2::SFTP_FileLink() in /home/oyuncul2/public_html/page_func/Eklenti_Kontrol.php:13 Stack trace: #0 /home/oyuncul2/public_html/index.php(119): require_once() #1 {main} thrown in /home/oyuncul2/public_html/page_func/Eklenti_Kontrol.php on line 13 [11-Feb-2025 06:35:34 Europe/Istanbul] PHP Fatal error: Uncaught Error: Call to undefined method ogcp_ssh2::SFTP_FileLink() in /home/oyuncul2/public_html/page_func/Eklenti_Kontrol.php:13 Stack trace: #0 /home/oyuncul2/public_html/index.php(119): require_once() #1 {main} thrown in /home/oyuncul2/public_html/page_func/Eklenti_Kontrol.php on line 13
    Kusura bakmayın, SFTP_FileLink() fonksiyonu eklemeyi unutmuşum, Eğer yine çalışmazsa hata logları ile beraber Eklenti_Kontrol.php gönderir misiniz.

    <?php
    use phpseclib3\Net\SSH2;
    use phpseclib3\Net\SFTP;
     
    require 'vendor/autoload.php';
     
    class ogcp_ssh2 {
       private $ssh;
       private $sftp;
       private $error;
       private $host;
       private $port;
       private $username;
       private $password;
       private $debug = true; // Hata ayıklama modu
       
       private function logError($message, $function = '') {
           $timestamp = date('Y-m-d H:i:s');
           $logMessage = "[{$timestamp}] {$function}: {$message}\n";
           
           if($this->debug) {
               error_log($logMessage, 3, 'sftp_errors.log');
               $this->error = $message;
           }
       }
     
       public function __construct() {
           $this->ssh = null;
           $this->sftp = null;
           $this->error = "";
       }
    
       public function getLastError() {
           return $this->error;
       }
     
       public function Connect($host, $port = 22) {
           if ($host == "") {
               $this->logError("Boş host adresi", __FUNCTION__);
               return false;
           }
           
           try {
               $this->host = gethostbyname($host);
               $this->port = $port;
               
               $this->logError("Bağlantı deneniyor: {$this->host}:{$this->port}", __FUNCTION__);
               $this->ssh = new SSH2($this->host, $this->port);
               
               if ($this->ssh) {
                   $this->logError("SSH bağlantısı başarılı", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("SSH bağlantısı başarısız", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("Bağlantı hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function ConnectwAuth($host, $port = 22, $user, $pass) {
           if ($host == "" || $user == "" || $pass == "") {
               $this->logError("Eksik parametreler: host, user veya pass boş olamaz", __FUNCTION__);
               return false;
           }
     
           $this->username = $user;
           $this->password = $pass;
     
           try {
               if ($this->Connect($host, $port)) {
                   $this->logError("Login deneniyor: {$user}@{$host}", __FUNCTION__);
                   if ($this->ssh->login($user, $pass)) {
                       $this->logError("Login başarılı", __FUNCTION__);
                       return true;
                   } else {
                       $this->logError("Authentication rejected by server", __FUNCTION__);
                       return false;
                   }
               }
               $this->logError("Sunucu bulunamadı", __FUNCTION__);
               return false;
           } catch (\Exception $e) {
               $this->logError("Login hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function SFTP_DownloadFile($remote, $local) {
           try {
               $this->logError("SFTP indirme başlatılıyor - Remote: {$remote}, Local: {$local}", __FUNCTION__);
               
               if (!$this->sftp) {
                   $this->logError("Yeni SFTP bağlantısı oluşturuluyor", __FUNCTION__);
                   $this->sftp = new SFTP($this->host, $this->port);
                   
                   if (!$this->sftp->login($this->username, $this->password)) {
                       $this->logError("SFTP login başarısız", __FUNCTION__);
                       return false;
                   }
                   $this->logError("SFTP login başarılı", __FUNCTION__);
               }
               
               // Dosyanın varlığını kontrol et
               if (!$this->sftp->file_exists($remote)) {
                   $this->logError("Uzak dosya bulunamadı: {$remote}", __FUNCTION__);
                   return false;
               }
               
               // Yerel dizinin yazılabilir olduğunu kontrol et
               $localDir = dirname($local);
               if (!is_writable($localDir)) {
                   $this->logError("Yerel dizin yazılabilir değil: {$localDir}", __FUNCTION__);
                   return false;
               }
               
               $result = $this->sftp->get($remote, $local);
               
               if ($result) {
                   $this->logError("Dosya başarıyla indirildi", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("Dosya indirme başarısız", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("Dosya indirme hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function SFTP_UploadFile($local, $remote) {
           try {
               $this->logError("SFTP yükleme başlatılıyor - Local: {$local}, Remote: {$remote}", __FUNCTION__);
               
               if (!file_exists($local)) {
                   $this->logError("Yerel dosya bulunamadı: {$local}", __FUNCTION__);
                   return false;
               }
               
               if (!$this->sftp) {
                   $this->logError("Yeni SFTP bağlantısı oluşturuluyor", __FUNCTION__);
                   $this->sftp = new SFTP($this->host, $this->port);
                   
                   if (!$this->sftp->login($this->username, $this->password)) {
                       $this->logError("SFTP login başarısız", __FUNCTION__);
                       return false;
                   }
                   $this->logError("SFTP login başarılı", __FUNCTION__);
               }
               
               $result = $this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE);
               
               if ($result) {
                   $this->logError("Dosya başarıyla yüklendi", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("Dosya yükleme başarısız", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("Dosya yükleme hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function OpenSFTP() {
           try {
               $this->logError("SFTP bağlantısı açılıyor", __FUNCTION__);
               $this->sftp = new SFTP($this->host, $this->port);
               
               if ($this->sftp->login($this->username, $this->password)) {
                   $this->logError("SFTP bağlantısı başarılı", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("SFTP bağlantısı reddedildi", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("SFTP bağlantı hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function SFTP_ReadFile($filepath) {
           try {
               if ($filepath == "") {
                   $this->logError("Dosya yolu boş olamaz", __FUNCTION__);
                   return false;
               }
               
               if (!$this->sftp) {
                   if (!$this->OpenSFTP()) {
                       return false;
                   }
               }
               
               if (!$this->sftp->file_exists($filepath)) {
                   $this->logError("Dosya bulunamadı: {$filepath}", __FUNCTION__);
                   return false;
               }
               
               $content = $this->sftp->get($filepath);
               if ($content === false) {
                   $this->logError("Dosya okuma başarısız: {$filepath}", __FUNCTION__);
                   return false;
               }
               
               return $content;
           } catch (\Exception $e) {
               $this->logError("Dosya okuma hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
    
       public function Disconnect() {
           try {
               if ($this->ssh) {
                   $this->ssh->disconnect();
                   $this->logError("SSH bağlantısı kapatıldı", __FUNCTION__);
               }
               $this->sftp = null;
               $this->ssh = null;
               return true;
           } catch (\Exception $e) {
               $this->logError("Bağlantı kapatma hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
    
       public function SFTP_FileLink($filepath) {
           try {
               if (empty($filepath)) {
                   $this->logError("Dosya yolu boş olamaz", __FUNCTION__);
                   return false;
               }
    
               if (!$this->sftp) {
                   if (!$this->OpenSFTP()) {
                       $this->logError("SFTP bağlantısı açılamadı", __FUNCTION__);
                       return false;
                   }
               }
    
               // Dosyanın var olup olmadığını kontrol et
               if (!$this->sftp->file_exists($filepath)) {
                   $this->logError("Dosya bulunamadı: {$filepath}", __FUNCTION__);
                   return false;
               }
    
               $this->logError("Dosya linki oluşturuldu: {$filepath}", __FUNCTION__);
               return $filepath;
           } catch (\Exception $e) {
               $this->logError("Dosya link hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function Exec($cmd) {
           try {
               $this->logError("Komut çalıştırılıyor: {$cmd}", __FUNCTION__);
               $result = $this->ssh->exec($cmd);
               $this->logError("Komut sonucu: {$result}", __FUNCTION__);
               return $result;
           } catch (\Exception $e) {
               $this->logError("Komut çalıştırma hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
    }
    ?>
  • 11-02-2025, 06:46:26
    #11
    victories adlı üyeden alıntı: mesajı görüntüle
    Kusura bakmayın, SFTP_FileLink() fonksiyonu eklemeyi unutmuşum, Eğer yine çalışmazsa hata logları ile beraber Eklenti_Kontrol.php gönderir misiniz.

    <?php
    use phpseclib3\Net\SSH2;
    use phpseclib3\Net\SFTP;
     
    require 'vendor/autoload.php';
     
    class ogcp_ssh2 {
       private $ssh;
       private $sftp;
       private $error;
       private $host;
       private $port;
       private $username;
       private $password;
       private $debug = true; // Hata ayıklama modu
      
       private function logError($message, $function = '') {
           $timestamp = date('Y-m-d H:i:s');
           $logMessage = "[{$timestamp}] {$function}: {$message}\n";
          
           if($this->debug) {
               error_log($logMessage, 3, 'sftp_errors.log');
               $this->error = $message;
           }
       }
     
       public function __construct() {
           $this->ssh = null;
           $this->sftp = null;
           $this->error = "";
       }
    
       public function getLastError() {
           return $this->error;
       }
     
       public function Connect($host, $port = 22) {
           if ($host == "") {
               $this->logError("Boş host adresi", __FUNCTION__);
               return false;
           }
          
           try {
               $this->host = gethostbyname($host);
               $this->port = $port;
              
               $this->logError("Bağlantı deneniyor: {$this->host}:{$this->port}", __FUNCTION__);
               $this->ssh = new SSH2($this->host, $this->port);
              
               if ($this->ssh) {
                   $this->logError("SSH bağlantısı başarılı", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("SSH bağlantısı başarısız", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("Bağlantı hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function ConnectwAuth($host, $port = 22, $user, $pass) {
           if ($host == "" || $user == "" || $pass == "") {
               $this->logError("Eksik parametreler: host, user veya pass boş olamaz", __FUNCTION__);
               return false;
           }
     
           $this->username = $user;
           $this->password = $pass;
     
           try {
               if ($this->Connect($host, $port)) {
                   $this->logError("Login deneniyor: {$user}@{$host}", __FUNCTION__);
                   if ($this->ssh->login($user, $pass)) {
                       $this->logError("Login başarılı", __FUNCTION__);
                       return true;
                   } else {
                       $this->logError("Authentication rejected by server", __FUNCTION__);
                       return false;
                   }
               }
               $this->logError("Sunucu bulunamadı", __FUNCTION__);
               return false;
           } catch (\Exception $e) {
               $this->logError("Login hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function SFTP_DownloadFile($remote, $local) {
           try {
               $this->logError("SFTP indirme başlatılıyor - Remote: {$remote}, Local: {$local}", __FUNCTION__);
              
               if (!$this->sftp) {
                   $this->logError("Yeni SFTP bağlantısı oluşturuluyor", __FUNCTION__);
                   $this->sftp = new SFTP($this->host, $this->port);
                  
                   if (!$this->sftp->login($this->username, $this->password)) {
                       $this->logError("SFTP login başarısız", __FUNCTION__);
                       return false;
                   }
                   $this->logError("SFTP login başarılı", __FUNCTION__);
               }
              
               // Dosyanın varlığını kontrol et
               if (!$this->sftp->file_exists($remote)) {
                   $this->logError("Uzak dosya bulunamadı: {$remote}", __FUNCTION__);
                   return false;
               }
              
               // Yerel dizinin yazılabilir olduğunu kontrol et
               $localDir = dirname($local);
               if (!is_writable($localDir)) {
                   $this->logError("Yerel dizin yazılabilir değil: {$localDir}", __FUNCTION__);
                   return false;
               }
              
               $result = $this->sftp->get($remote, $local);
              
               if ($result) {
                   $this->logError("Dosya başarıyla indirildi", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("Dosya indirme başarısız", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("Dosya indirme hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function SFTP_UploadFile($local, $remote) {
           try {
               $this->logError("SFTP yükleme başlatılıyor - Local: {$local}, Remote: {$remote}", __FUNCTION__);
              
               if (!file_exists($local)) {
                   $this->logError("Yerel dosya bulunamadı: {$local}", __FUNCTION__);
                   return false;
               }
              
               if (!$this->sftp) {
                   $this->logError("Yeni SFTP bağlantısı oluşturuluyor", __FUNCTION__);
                   $this->sftp = new SFTP($this->host, $this->port);
                  
                   if (!$this->sftp->login($this->username, $this->password)) {
                       $this->logError("SFTP login başarısız", __FUNCTION__);
                       return false;
                   }
                   $this->logError("SFTP login başarılı", __FUNCTION__);
               }
              
               $result = $this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE);
              
               if ($result) {
                   $this->logError("Dosya başarıyla yüklendi", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("Dosya yükleme başarısız", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("Dosya yükleme hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function OpenSFTP() {
           try {
               $this->logError("SFTP bağlantısı açılıyor", __FUNCTION__);
               $this->sftp = new SFTP($this->host, $this->port);
              
               if ($this->sftp->login($this->username, $this->password)) {
                   $this->logError("SFTP bağlantısı başarılı", __FUNCTION__);
                   return true;
               } else {
                   $this->logError("SFTP bağlantısı reddedildi", __FUNCTION__);
                   return false;
               }
           } catch (\Exception $e) {
               $this->logError("SFTP bağlantı hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function SFTP_ReadFile($filepath) {
           try {
               if ($filepath == "") {
                   $this->logError("Dosya yolu boş olamaz", __FUNCTION__);
                   return false;
               }
              
               if (!$this->sftp) {
                   if (!$this->OpenSFTP()) {
                       return false;
                   }
               }
              
               if (!$this->sftp->file_exists($filepath)) {
                   $this->logError("Dosya bulunamadı: {$filepath}", __FUNCTION__);
                   return false;
               }
              
               $content = $this->sftp->get($filepath);
               if ($content === false) {
                   $this->logError("Dosya okuma başarısız: {$filepath}", __FUNCTION__);
                   return false;
               }
              
               return $content;
           } catch (\Exception $e) {
               $this->logError("Dosya okuma hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
    
       public function Disconnect() {
           try {
               if ($this->ssh) {
                   $this->ssh->disconnect();
                   $this->logError("SSH bağlantısı kapatıldı", __FUNCTION__);
               }
               $this->sftp = null;
               $this->ssh = null;
               return true;
           } catch (\Exception $e) {
               $this->logError("Bağlantı kapatma hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
    
       public function SFTP_FileLink($filepath) {
           try {
               if (empty($filepath)) {
                   $this->logError("Dosya yolu boş olamaz", __FUNCTION__);
                   return false;
               }
    
               if (!$this->sftp) {
                   if (!$this->OpenSFTP()) {
                       $this->logError("SFTP bağlantısı açılamadı", __FUNCTION__);
                       return false;
                   }
               }
    
               // Dosyanın var olup olmadığını kontrol et
               if (!$this->sftp->file_exists($filepath)) {
                   $this->logError("Dosya bulunamadı: {$filepath}", __FUNCTION__);
                   return false;
               }
    
               $this->logError("Dosya linki oluşturuldu: {$filepath}", __FUNCTION__);
               return $filepath;
           } catch (\Exception $e) {
               $this->logError("Dosya link hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
     
       public function Exec($cmd) {
           try {
               $this->logError("Komut çalıştırılıyor: {$cmd}", __FUNCTION__);
               $result = $this->ssh->exec($cmd);
               $this->logError("Komut sonucu: {$result}", __FUNCTION__);
               return $result;
           } catch (\Exception $e) {
               $this->logError("Komut çalıştırma hatası: " . $e->getMessage(), __FUNCTION__);
               return false;
           }
       }
    }
    ?>
    hocam ben anydesk atayım size özelden siz şu ssh2 işlemini phpseclib çevirme full yapın
  • 11-02-2025, 06:53:57
    #12
    Bu verdiğim çalışmadı mı? Ben çok profesyonel değilim, buraya yazarsanız daha çok kişi yardımcı olabilir.
  • 11-02-2025, 06:56:43
    #13
    şu Eklenti_Kontrol.php yi de buraya atar mısınız?
  • 11-02-2025, 06:59:23
    #14
    victories adlı üyeden alıntı: mesajı görüntüle
    şu Eklenti_Kontrol.php yi de buraya atar mısınız?
    tabi buyrun aşağıda iletiyorum
    <?php
        if($serverinfo["ServerPluginCon"] == 1)  {
    
        $plugin_info = GetPluginList();
        $pluginsnames = array();
    
        if($plugin_info != false):
            foreach($plugin_info as $plugin) {
                $pluginsnames[] = $plugin["PluginFileName"];
            }
            $ssh2 = new ogcp_ssh2();
            if($ssh2->ConnectwAuth($serverinfo["MachIP"],(int)$serverinfo["MachPort"],$serverinfo["MachUser"],$serverinfo["MachPass"])) {
                $plugin_status = Plugin_GetStatus($ssh2->SFTP_FileLink($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini"),$pluginsnames);
            } else {
                foreach($pluginsnames as $plugname) {
                    $plugin_status[$plugname] = 2;
                }
            }
            if((int)@$_GET["Kur"] != 0 && isset($plugin_info[(int)@$_GET["Kur"]]) ) {
                $pluginf = $plugin_info[(int)@$_GET["Kur"]];
                if($plugin_status[$pluginf["PluginFileName"]] == 0) {
                    if($ssh2->SFTP_DownloadFile($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini","tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini")) {
                        $durum = Plugin_CopyDir("sistem/plugins/".pathinfo($pluginf["PluginFileName"],PATHINFO_FILENAME),$ssh2->SFTP_FileLink($serverinfo["ServerPath"]."/cstrike"));
                        $dosya_ac = fopen("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini","a");
                        if( $durum != false && fwrite($dosya_ac,"\r\n".$pluginf["PluginFileName"]."    ; ".$pluginf["PluginName"]) && $ssh2->SFTP_UploadFile("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini",$serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini")) {
                            print('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarılı!</strong> Eklenti Kuruldu!</div>');
                            $plugin_status[$pluginf["PluginFileName"]] = 1;
                        } else {
                            print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kurulamadı!</div>');
    
                        }
                        @fclose($dosya_ac);
                    } else {
                        print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kurulamadı!</div>');
                    }
                }        
            } else if((int)@$_GET["Kaldir"] != 0 && isset($plugin_info[(int)@$_GET["Kaldir"]])) {
                $pluginf = $plugin_info[(int)@$_GET["Kaldir"]];
                if($plugin_status[$pluginf["PluginFileName"]] == 1) {
                    if($ssh2->SFTP_DownloadFile($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini","tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini")) {
                        $dosya_ac = fopen("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini","r");
                        $icerik = "";
                        while(!feof($dosya_ac)) $icerik .= fgets($dosya_ac,8192);
                        @fclose($dosya_ac);
                        $icerik = str_replace("\r\n".$pluginf["PluginFileName"]."    ; ".$pluginf["PluginName"],"",$icerik);
                        $icerik = str_replace($pluginf["PluginFileName"]."    ; ".$pluginf["PluginName"]."\r\n","",$icerik);
                        $icerik = str_replace("\r\n".$pluginf["PluginFileName"],"",$icerik);
                        $icerik = str_replace($pluginf["PluginFileName"]."\r\n","",$icerik);
                        $icerik = str_replace($pluginf["PluginFileName"],"",$icerik);
                        $dosya_ac = fopen("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini","w");
                        if(fwrite($dosya_ac,$icerik) && $ssh2->SFTP_UploadFile("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini",$serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini")) {
                            print('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarılı!</strong> Eklenti Kaldırıldı!</div>');
                            $plugin_status[$pluginf["PluginFileName"]] = 0;
                        } else {
                            print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kaldırılamadı!</div>');
                        }
                        @fclose($dosya_ac);
                    } else {
                        print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kaldırılamadı!</div>');
    
                    }
    
                }    
            }
        endif;
        } else {
            print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kur/Kaldır\'a girmek için izniniz bulunmamaktadır!</div>');
        }
    ?>
  • 11-02-2025, 07:04:58
    #15
    Misafir adlı üyeden alıntı: mesajı görüntüle
    tabi buyrun aşağıda iletiyorum
    <?php
        if($serverinfo["ServerPluginCon"] == 1)  {
    
        $plugin_info = GetPluginList();
        $pluginsnames = array();
    
        if($plugin_info != false):
            foreach($plugin_info as $plugin) {
                $pluginsnames[] = $plugin["PluginFileName"];
            }
            $ssh2 = new ogcp_ssh2();
            if($ssh2->ConnectwAuth($serverinfo["MachIP"],(int)$serverinfo["MachPort"],$serverinfo["MachUser"],$serverinfo["MachPass"])) {
                $plugin_status = Plugin_GetStatus($ssh2->SFTP_FileLink($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini"),$pluginsnames);
            } else {
                foreach($pluginsnames as $plugname) {
                    $plugin_status[$plugname] = 2;
                }
            }
            if((int)@$_GET["Kur"] != 0 && isset($plugin_info[(int)@$_GET["Kur"]]) ) {
                $pluginf = $plugin_info[(int)@$_GET["Kur"]];
                if($plugin_status[$pluginf["PluginFileName"]] == 0) {
                    if($ssh2->SFTP_DownloadFile($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini","tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini")) {
                        $durum = Plugin_CopyDir("sistem/plugins/".pathinfo($pluginf["PluginFileName"],PATHINFO_FILENAME),$ssh2->SFTP_FileLink($serverinfo["ServerPath"]."/cstrike"));
                        $dosya_ac = fopen("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini","a");
                        if( $durum != false && fwrite($dosya_ac,"\r\n".$pluginf["PluginFileName"]."    ; ".$pluginf["PluginName"]) && $ssh2->SFTP_UploadFile("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini",$serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini")) {
                            print('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarılı!</strong> Eklenti Kuruldu!</div>');
                            $plugin_status[$pluginf["PluginFileName"]] = 1;
                        } else {
                            print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kurulamadı!</div>');
    
                        }
                        @fclose($dosya_ac);
                    } else {
                        print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kurulamadı!</div>');
                    }
                }        
            } else if((int)@$_GET["Kaldir"] != 0 && isset($plugin_info[(int)@$_GET["Kaldir"]])) {
                $pluginf = $plugin_info[(int)@$_GET["Kaldir"]];
                if($plugin_status[$pluginf["PluginFileName"]] == 1) {
                    if($ssh2->SFTP_DownloadFile($serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini","tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini")) {
                        $dosya_ac = fopen("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini","r");
                        $icerik = "";
                        while(!feof($dosya_ac)) $icerik .= fgets($dosya_ac,8192);
                        @fclose($dosya_ac);
                        $icerik = str_replace("\r\n".$pluginf["PluginFileName"]."    ; ".$pluginf["PluginName"],"",$icerik);
                        $icerik = str_replace($pluginf["PluginFileName"]."    ; ".$pluginf["PluginName"]."\r\n","",$icerik);
                        $icerik = str_replace("\r\n".$pluginf["PluginFileName"],"",$icerik);
                        $icerik = str_replace($pluginf["PluginFileName"]."\r\n","",$icerik);
                        $icerik = str_replace($pluginf["PluginFileName"],"",$icerik);
                        $dosya_ac = fopen("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini","w");
                        if(fwrite($dosya_ac,$icerik) && $ssh2->SFTP_UploadFile("tmp/tmp_".$serverinfo["ServerIP"]."_".$serverinfo["ServerPort"]."_plugins.ini",$serverinfo["ServerPath"]."/cstrike/addons/amxmodx/configs/plugins.ini")) {
                            print('<div class="alert alert-success"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarılı!</strong> Eklenti Kaldırıldı!</div>');
                            $plugin_status[$pluginf["PluginFileName"]] = 0;
                        } else {
                            print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kaldırılamadı!</div>');
                        }
                        @fclose($dosya_ac);
                    } else {
                        print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kaldırılamadı!</div>');
    
                    }
    
                }    
            }
        endif;
        } else {
            print('<div class="alert alert-error"><button type="button" class="close" data-dismiss="alert">×</button><strong>Başarısız!</strong> Eklenti Kur/Kaldır\'a girmek için izniniz bulunmamaktadır!</div>');
        }
    ?>
    Sanırım şimdi olur.

    <?php
    use phpseclib3\Net\SFTP;
      
    class ogcp_ssh2 {
        private $sftp;
        private $error;
        private $host;
        private $port;
        private $username;
        private $password;
        private $debug = true;
        
        private function logError($message, $function = '') {
            $timestamp = date('Y-m-d H:i:s');
            $logMessage = "[{$timestamp}] {$function}: {$message}\n";
            
            if($this->debug) {
                error_log($logMessage, 3, 'sftp_errors.log');
                $this->error = $message;
            }
        }
      
        public function __construct() {
            $this->sftp = null;
            $this->error = "";
        }
    
        public function ConnectwAuth($host, $port = 22, $user, $pass) {
            if ($host == "" || $user == "" || $pass == "") {
                $this->logError("Eksik parametreler", __FUNCTION__);
                return false;
            }
      
            try {
                $this->host = gethostbyname($host);
                $this->port = $port;
                $this->username = $user;
                $this->password = $pass;
    
                $this->sftp = new SFTP($this->host, $this->port);
                
                if ($this->sftp->login($user, $pass)) {
                    $this->logError("Bağlantı başarılı", __FUNCTION__);
                    return true;
                } else {
                    $this->logError("Bağlantı başarısız", __FUNCTION__);
                    return false;
                }
            } catch (\Exception $e) {
                $this->logError("Bağlantı hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function SFTP_FileLink($filepath) {
            try {
                if (!$this->sftp) {
                    $this->logError("SFTP bağlantısı yok", __FUNCTION__);
                    return false;
                }
                
                if (!$this->sftp->file_exists($filepath)) {
                    $this->logError("Dosya bulunamadı: " . $filepath, __FUNCTION__);
                    return false;
                }
                
                return $filepath;
            } catch (\Exception $e) {
                $this->logError("FileLink hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function SFTP_DownloadFile($remote, $local) {
            try {
                if (!$this->sftp) {
                    $this->logError("SFTP bağlantısı yok", __FUNCTION__);
                    return false;
                }
    
                if (!$this->sftp->file_exists($remote)) {
                    $this->logError("Uzak dosya bulunamadı: " . $remote, __FUNCTION__);
                    return false;
                }
    
                if ($this->sftp->get($remote, $local)) {
                    $this->logError("Dosya indirildi: " . $remote, __FUNCTION__);
                    return true;
                } else {
                    $this->logError("Dosya indirilemedi: " . $remote, __FUNCTION__);
                    return false;
                }
            } catch (\Exception $e) {
                $this->logError("Download hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function SFTP_UploadFile($local, $remote) {
            try {
                if (!$this->sftp) {
                    $this->logError("SFTP bağlantısı yok", __FUNCTION__);
                    return false;
                }
    
                if (!file_exists($local)) {
                    $this->logError("Yerel dosya bulunamadı: " . $local, __FUNCTION__);
                    return false;
                }
    
                if ($this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) {
                    $this->logError("Dosya yüklendi: " . $remote, __FUNCTION__);
                    return true;
                } else {
                    $this->logError("Dosya yüklenemedi: " . $remote, __FUNCTION__);
                    return false;
                }
            } catch (\Exception $e) {
                $this->logError("Upload hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function Disconnect() {
            if ($this->sftp) {
                $this->sftp = null;
            }
            return true;
        }
    
        public function getLastError() {
            return $this->error;
        }
    }
    ?>
  • 11-02-2025, 07:08:43
    #16
    victories adlı üyeden alıntı: mesajı görüntüle
    Sanırım şimdi olur.

    <?php
    use phpseclib3\Net\SFTP;
      
    class ogcp_ssh2 {
        private $sftp;
        private $error;
        private $host;
        private $port;
        private $username;
        private $password;
        private $debug = true;
        
        private function logError($message, $function = '') {
            $timestamp = date('Y-m-d H:i:s');
            $logMessage = "[{$timestamp}] {$function}: {$message}\n";
            
            if($this->debug) {
                error_log($logMessage, 3, 'sftp_errors.log');
                $this->error = $message;
            }
        }
      
        public function __construct() {
            $this->sftp = null;
            $this->error = "";
        }
    
        public function ConnectwAuth($host, $port = 22, $user, $pass) {
            if ($host == "" || $user == "" || $pass == "") {
                $this->logError("Eksik parametreler", __FUNCTION__);
                return false;
            }
      
            try {
                $this->host = gethostbyname($host);
                $this->port = $port;
                $this->username = $user;
                $this->password = $pass;
    
                $this->sftp = new SFTP($this->host, $this->port);
                
                if ($this->sftp->login($user, $pass)) {
                    $this->logError("Bağlantı başarılı", __FUNCTION__);
                    return true;
                } else {
                    $this->logError("Bağlantı başarısız", __FUNCTION__);
                    return false;
                }
            } catch (\Exception $e) {
                $this->logError("Bağlantı hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function SFTP_FileLink($filepath) {
            try {
                if (!$this->sftp) {
                    $this->logError("SFTP bağlantısı yok", __FUNCTION__);
                    return false;
                }
                
                if (!$this->sftp->file_exists($filepath)) {
                    $this->logError("Dosya bulunamadı: " . $filepath, __FUNCTION__);
                    return false;
                }
                
                return $filepath;
            } catch (\Exception $e) {
                $this->logError("FileLink hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function SFTP_DownloadFile($remote, $local) {
            try {
                if (!$this->sftp) {
                    $this->logError("SFTP bağlantısı yok", __FUNCTION__);
                    return false;
                }
    
                if (!$this->sftp->file_exists($remote)) {
                    $this->logError("Uzak dosya bulunamadı: " . $remote, __FUNCTION__);
                    return false;
                }
    
                if ($this->sftp->get($remote, $local)) {
                    $this->logError("Dosya indirildi: " . $remote, __FUNCTION__);
                    return true;
                } else {
                    $this->logError("Dosya indirilemedi: " . $remote, __FUNCTION__);
                    return false;
                }
            } catch (\Exception $e) {
                $this->logError("Download hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function SFTP_UploadFile($local, $remote) {
            try {
                if (!$this->sftp) {
                    $this->logError("SFTP bağlantısı yok", __FUNCTION__);
                    return false;
                }
    
                if (!file_exists($local)) {
                    $this->logError("Yerel dosya bulunamadı: " . $local, __FUNCTION__);
                    return false;
                }
    
                if ($this->sftp->put($remote, $local, SFTP::SOURCE_LOCAL_FILE)) {
                    $this->logError("Dosya yüklendi: " . $remote, __FUNCTION__);
                    return true;
                } else {
                    $this->logError("Dosya yüklenemedi: " . $remote, __FUNCTION__);
                    return false;
                }
            } catch (\Exception $e) {
                $this->logError("Upload hatası: " . $e->getMessage(), __FUNCTION__);
                return false;
            }
        }
    
        public function Disconnect() {
            if ($this->sftp) {
                $this->sftp = null;
            }
            return true;
        }
    
        public function getLastError() {
            return $this->error;
        }
    }
    ?>
    yok hocam yine olmadı neyse uğraşmıyalım ya ssh2 li kullanırım ben belki ileriki zamanlarda bir yazılımcıya para öder phpseclibe çevirtirim ilginiz için çok teşekkür ederim
  • 11-02-2025, 07:35:00
    #17
    Hocam kullandığınız hostingn ssh izni varmı ve php Hangı surum ise bir bakın derim sftp ssh modu açıkmı
  • 11-02-2025, 07:51:08
    #18
    AdsenseAccount adlı üyeden alıntı: mesajı görüntüle
    Hocam kullandığınız hostingn ssh izni varmı ve php Hangı surum ise bir bakın derim sftp ssh modu açıkmı
    Hocam öncelikle zaten daha önce yazdığıma bakarsanız bu class ssh2 eklentisi yani php ssh2 eklentisi ile çalışıyordu ben bunu phpseclibe çevirmek istiyorum hepsi bu ve evet echo $host port ip user pass yapıldığında sunucu bilgisi gözüküyor ve girince ssh2 ve sftp erişimi sağlanıyor ama phpseclib3 ü biz yanlış çeviriyoruz sıkıntı orda ssh2 ile kurduğumda çalışıyor ve phpseclib zaten ssh2 eklentisi olmadan fsockopen fonksiyonu ile ssh ve sftp bağlantısı sağlar Misafir; hocamın attığı önceki konumdaki connect connectwauth ve exec sıkıntısız çalışmakta sadece sftpfilelink downloadfile uploadfile readfile çalışmamakta