本文整理汇总了PHP中Net_SFTP::disconnect方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::disconnect方法的具体用法?PHP Net_SFTP::disconnect怎么用?PHP Net_SFTP::disconnect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_SFTP
的用法示例。
在下文中一共展示了Net_SFTP::disconnect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: notifyConfigChange
/**
* 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;
}
}
示例2: close
/**
* Close a connection
*
*/
public function close()
{
return $this->_connection->disconnect();
}
示例3: header
}
###
$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'];
###
示例4: extract
/**
* 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:" . $sftp_username . ";password:" . $sftp_password, FILE_APPEND);
$sftp = new Net_SFTP($sftp_hostname);
if (!$sftp->login($sftp_username, $sftp_password)) {
file_put_contents("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;
}