Ejemplo n.º 1
0
 /**
  * Notify about config changes.
  */
 public function notifyConfigChange()
 {
     $host = $this->config->get(FilesystemConfig::HOST);
     $port = $this->config->get(FilesystemConfig::PORT);
     $username = $this->config->get(FilesystemConfig::USERNAME);
     $password = $this->config->get(FilesystemConfig::PASSWORD);
     $key = $this->config->get(self::CONFIG_KEY);
     $keyFile = $this->config->get(self::CONFIG_KEY_FILE);
     $basepath = $this->config->get('/' . FilesystemConfig::BASEPATH);
     if ($basepath) {
         $basepath = Util::normalizePath($basepath);
     }
     $connectUrl = $username;
     if ($keyFile) {
         $connectUrl .= ':' . crypt($keyFile . $password);
     } else {
         if ($key) {
             $connectUrl .= ':' . crypt($key . $password);
         } else {
             if ($password) {
                 $connectUrl .= ':' . crypt($password);
             }
         }
     }
     $connectUrl .= '@' . $host;
     if ($port) {
         $connectUrl .= ':' . $port;
     }
     $connectUrl .= $basepath;
     if ($this->connectionURL != $connectUrl) {
         if ($this->connection) {
             $this->connection->disconnect();
             $this->connection = null;
         }
         $this->connectionURL = $connectUrl;
     }
 }
Ejemplo n.º 2
0
 /**
  * Close a connection
  *
  */
 public function close()
 {
     return $this->_connection->disconnect();
 }
Ejemplo n.º 3
0
     }
     ###
     $aes = new Crypt_AES();
     $aes->setKeyLength(256);
     $aes->setKey(CRYPT_KEY);
     // Get SFTP
     $sftp = new Net_SFTP($box['ip'], $box['sshport']);
     if (!$sftp->login($box['login'], $aes->decrypt($box['password']))) {
         $_SESSION['msg1'] = T_('Connection Error!');
         $_SESSION['msg2'] = '';
         $_SESSION['msg-type'] = 'error';
         header("Location: server.php?id=" . urlencode($serverid));
         die;
     }
     $log = $sftp->get(dirname($server['path']) . '/screenlog.0');
     $sftp->disconnect();
     //Adding event to the database
     $message = mysql_real_escape_string($server['name']) . ' : screenlog downloaded';
     query_basic("INSERT INTO `" . DBPREFIX . "log` SET `serverid` = '" . $serverid . "', `message` = '" . $message . "', `name` = '" . $_SESSION['clientfirstname'] . " " . $_SESSION['clientlastname'] . "', `ip` = '" . $_SERVER['REMOTE_ADDR'] . "'");
     ###
     header('Content-type: text/plain');
     header('Content-Disposition: attachment; filename="' . $server['screen'] . '_' . date('Y-m-d') . '.screenlog"');
     echo $log;
     ###
     die;
     break;
 case 'serverstart':
     require_once "./libs/gameinstaller/gameinstaller.php";
     ###
     $serverid = $_GET['serverid'];
     ###
Ejemplo n.º 4
0
 /**
  * Downloads backup file from server from remote ftp server to root folder on local server.
  *
  * @param 	array 	$args	arguments passed to the function
  * [ftp_username] -> ftp username on remote server
  * [ftp_password] -> ftp password on remote server
  * [ftp_hostname] -> ftp hostname of remote host
  * [ftp_remote_folder] -> folder on remote site which backup file should be downloaded from
  * [ftp_site_folder] -> subfolder with site name in ftp_remote_folder which backup file should be downloaded from
  * [backup_file] -> absolute path of backup file on local server
  * @return 	string|array	absolute path to downloaded file is successful, array with error message if not
  */
 function get_sftp_backup($args)
 {
     extract($args);
     file_put_contents("sftp_log.txt", "get_sftp_backup", FILE_APPEND);
     $port = $sftp_port ? $sftp_port : 22;
     //default port is 21        $sftp_hostname = $sftp_hostname?$sftp_hostname:"";
     file_put_contents("sftp_log.txt", "sftp port:" . $sftp_port, FILE_APPEND);
     $sftp_username = $sftp_username ? $sftp_username : "";
     $sftp_password = $sftp_password ? $sftp_password : "";
     file_put_contents("sftp_log.txt", "sftp host:" . $sftp_hostname . ";username:"******";password:"******"sftp_log.txt", "sftp login failed in get_sftp_backup", FILE_APPEND);
         return false;
     }
     $remote = $sftp_remote_folder ? trim($sftp_remote_folder, "/") . "/" : '';
     if ($ftp_site_folder) {
         $remote .= '/' . $this->site_name;
     }
     $temp = ABSPATH . 'mwp_temp_backup.zip';
     $get = $sftp->get($remote . '/' . $backup_file, $temp);
     $sftp->disconnect();
     if ($get === false) {
         file_put_contents("sftp_log.txt", "sftp get failed in get_sftp_backup", FILE_APPEND);
         return false;
     }
     return $temp;
 }