本文整理汇总了PHP中Net_SFTP::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::get方法的具体用法?PHP Net_SFTP::get怎么用?PHP Net_SFTP::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Net_SFTP
的用法示例。
在下文中一共展示了Net_SFTP::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readFromZiraatTxt
function readFromZiraatTxt($tesvikid)
{
$sftp = new Net_SFTP(ZIRAAT_FTP_HOST);
if ($sftp->login(ZIRAAT_FTP_USER, ZIRAAT_FTP_PASS)) {
//ilk önce doğru txt mi ??
$directory_temp = EK_FOLDER . "ziraat_eft/temp_bankadan_kuruma/";
if (!file_exists($directory_temp)) {
mkdir($directory_temp, 0777, true);
}
//$fileTo
$fileFrom = "/bankadan_kuruma/";
$filelist = $sftp->nlist($fileFrom);
$control = false;
$fileth = count($filelist) - 1;
do {
$file = $filelist[$fileth];
$fileTo = $directory_temp . $file;
$sftp->get($fileFrom . $file, $fileTo);
$control = $this->checkTxtFileForTesvik($tesvikid, $fileTo);
if ($control == false) {
unlink($fileTo);
$fileth--;
}
if ($fileth == 0) {
break;
}
} while ($control == false);
if ($control == true) {
$directory = EK_FOLDER . "ziraat_eft/bankadan_kuruma/" . date('Ymd');
if (!file_exists($directory)) {
mkdir($directory, 0777, true);
}
$files = explode('/', $fileTo);
rename($fileTo, $directory . '/' . end($files));
$return['FILE'] = date('Ymd') . '/' . end($files);
$return['STATUS'] = true;
$return['TEXT'] = "Dosya basariyla indirildi";
} else {
$return['STATUS'] = false;
$return['TEXT'] = "Dosya indirme hatasi";
}
} else {
$return['STATUS'] = false;
$return['TEXT'] = "ftp bağlanti hatasi";
}
return $return;
}
示例2: read
/**
* Read a file
*
*/
public function read($filename, $dest = null)
{
if (is_null($dest)) {
$dest = false;
}
return $this->_connection->get($filename, $dest);
}
示例3: _getFile
/**
* get a file
*
* @param String $source_file the target file to download
* @param bool $destination_file the save path
*
* @return String
* @throws CMbException
*/
private function _getFile($source_file, $destination_file = false)
{
if (!$this->connexion) {
throw new CMbException("CSourceSFTP-connexion-failed", $this->hostname);
}
// Download the file
if (!($data = $this->connexion->get($source_file, $destination_file))) {
throw new CMbException("CSourceSFTP-download-file-failed", $source_file, $destination_file);
}
return $data;
}
示例4: scpRemoteLocal
/**
* copy a file from the remote server to the local install
* @param $source string
* @param $destination string
* @return bool
*/
public function scpRemoteLocal($source, $destination)
{
$sftp = new \Net_SFTP(Setting::getSetting('remote:host'));
$key = new Crypt_RSA();
$key->loadKey(file_get_contents(Setting::getSetting('ssh:priv_key')));
if (!$sftp->login(Setting::getSetting('remote:user'), $key)) {
$cli = new CLImate();
$cli->error("Could not connect to server");
return false;
}
$sftp->get($source, $destination);
}
示例5: get
/**
* @param string $remotePath
* @param string $destFile
* @param int $resumePos
*
* @return bool
*/
public function get($remotePath, $destFile, $resumePos = 0)
{
switch ($this->_connType) {
case SftpHelper::TYPE_SFTP:
default:
$res = $this->_connection->get($remotePath, $destFile, $resumePos);
break;
case SftpHelper::TYPE_FTP:
$res = @ftp_get($this->_connection, $destFile, $remotePath, FTP_BINARY, $resumePos);
break;
}
return $res;
}
示例6: exit
if (!$mail->Send()) {
echo "Mailer Error: " . $mail->ErrorInfo;
} else {
echo "Message sent!";
}
//unlink('/tmp/kontakti.txt');
$sftp = new Net_SFTP('podrska.bbtrade.rs');
if (!$sftp->login('root', 'bbsb100$')) {
echo "Login Failed";
exit('Login Failed');
}
// outputs the contents of filename.remote to the screen
//echo $sftp->get('/tmp/kontakti.txt');
// copies filename.remote to filename.local from the SFTP server
//$sftp->get('/tmp/kontakti.txt', '\\C$\Users\%username%\Desktop\kontakti.txt');
$sftp->get('/tmp/izvestaj_op.csv', 'C:/storno/izvestaj.txt');
if ($sftp->delete('/tmp/izvestaj_op.csv')) {
// doesn't delete directories
echo "File /tmp/izvestaj_op.csv je obrisan!";
} else {
echo "File /tmp/izvestaj_op.csv nije obrisan!";
}
echo '<br />';
/*echo "Izvrsen je sledeci upit:";
echo '<br />';
echo $sql;*/
echo '<br />';
echo "Ako ste upisali ispravnu email adresu, fajl ce Vam biti isporucen putem email-a.";
} else {
//Besmisleno je jer bi ovako bio prevelik fajl
/*
示例7:
<?php
session_start();
include 'header.php';
include 'Net/SFTP.php';
$fileToGet = $_GET['file'];
$localFile = 'uploads/' . $fileToGet;
$sftp = new Net_SFTP(SSH_HOST);
if ($sftp->login($_SESSION['id'], $_SESSION['passwd'])) {
$sftp->get('/scratch/' . $_SESSION['id'] . '/meshslicer/' . $fileToGet, $localFile);
$reply = json_encode(array('Error' => '0', 'Message' => ""));
//unlink($localFile);
} else {
$reply = json_encode(array('Error' => '1', 'Message' => "Astral problem. Please try again."));
}
echo $reply;
示例8: downloadJob
private function downloadJob($result, $silverpop, $type, $listId = array())
{
if (empty($result['JOB_ID'])) {
$this->logMessage("WARNING: Last job was not successfully created. Check the source in Silverpop.");
return;
}
$file = str_replace('/download/', '', $result['FILE_PATH']);
// Wait till its done
$counter = 0;
do {
sleep(2);
$status = $silverpop->getJobStatus($result['JOB_ID']);
$counter++;
} while (!in_array($status['JOB_STATUS'], array('COMPLETE', 'CANCELLED', 'ERROR')) && $counter < 3600);
// Check if everything happend OK
if ($status['JOB_STATUS'] != 'COMPLETE') {
throw new SilverpopException('An error occured while creating report in Silverpop. Last job status: ' . $status['JOB_STATUS'] . '. Last job status response: ' . json_encode($status));
}
$this->logMessage('Job finished for ID ' . $result['JOB_ID']);
// ================== Download data from SFTP ==================
$sftp = new Net_SFTP('transfer' . $this->config['engage_server'] . '.silverpop.com');
if (!$sftp->login($this->config['username'], $this->config['#password'])) {
exit('Login Failed');
}
$sftp->get("{$this->remoteDir}{$file}", $this->localDir . $file);
if ($type == 'contact_lists') {
$this->loadFile($this->localDir . $file, $this->config['bucket'], $type, false, array('LIST_NAME', 'LIST_ID'), $listId);
} else {
if ($type == 'events') {
$this->extractAndLoad($this->localDir . $file, $this->config['bucket'], array('Raw Recipient Data Export' => 'events'), array('LIST_NAME', 'LIST_ID'), $listId);
} else {
$this->extractAndLoad($this->localDir . $file, $this->config['bucket']);
}
}
$this->logMessage('Data downloaded for job ' . $result['JOB_ID']);
}
示例9: getcwd
$sslpassword = $query_row['sslpassword'];
}
$path = getcwd();
chdir('..');
chdir('..');
$path = getcwd();
chdir('php/pear');
$path = getcwd();
set_include_path($path);
set_include_path(get_include_path() . '/' . 'phpsec');
include 'Net/SSH2.php';
include 'File/ANSI.php';
include '/Net/SFTP.php';
$sftp = new Net_SFTP(@$hostname);
if (@$sftp->login(@$sslusername, @$sslpassword)) {
$data = $sftp->get('/proc/stat');
$data = explode("\n", $data);
$cores = array();
foreach ($data as $line) {
if (preg_match('/^cpu[0-9]/', $line)) {
$info = explode(' ', $line);
$cores[] = array('user' => round($info[1] / ($info[1] + $info[2] + $info[3] + $info[4] + $info[5] + $info[6] + $info[7] + $info[8] + $info[9]) * 100, 2) . '%', 'sys' => round($info[3] / ($info[1] + $info[2] + $info[3] + $info[4] + $info[5] + $info[6] + $info[7] + $info[8] + $info[9]) * 100, 2) . '%', 'idle' => round($info[4] / ($info[1] + $info[2] + $info[3] + $info[4] + $info[5] + $info[6] + $info[7] + $info[8] + $info[9]) * 100, 2) . '%');
}
}
echo json_encode($cores);
} else {
echo "[]";
}
} else {
echo "[]";
}
示例10: poll_hl7_results
/**
* Poll all eligible labs for new results and store them in the database.
*
* @param array &$messages Receives messages of interest.
* @return string Error text, or empty if no errors.
*/
function poll_hl7_results(&$messages)
{
global $srcdir;
$messages = array();
$filecount = 0;
$badcount = 0;
$ppres = sqlStatement("SELECT * FROM procedure_providers ORDER BY name");
while ($pprow = sqlFetchArray($ppres)) {
$protocol = $pprow['protocol'];
$remote_host = $pprow['remote_host'];
$hl7 = '';
if ($protocol == 'SFTP') {
ini_set('include_path', ini_get('include_path') . PATH_SEPARATOR . "{$srcdir}/phpseclib");
require_once "{$srcdir}/phpseclib/Net/SFTP.php";
// Compute the target path name.
$pathname = '.';
if ($pprow['results_path']) {
$pathname = $pprow['results_path'] . '/' . $pathname;
}
// Connect to the server and enumerate files to process.
$sftp = new Net_SFTP($remote_host);
if (!$sftp->login($pprow['login'], $pprow['password'])) {
return xl('Login to remote host') . " '{$remote_host}' " . xl('failed');
}
$files = $sftp->nlist($pathname);
foreach ($files as $file) {
if (substr($file, 0, 1) == '.') {
continue;
}
++$filecount;
$hl7 = $sftp->get("{$pathname}/{$file}");
// Archive the results file.
$prpath = $GLOBALS['OE_SITE_DIR'] . "/procedure_results";
if (!file_exists($prpath)) {
mkdir($prpath);
}
$prpath .= '/' . $pprow['ppid'];
if (!file_exists($prpath)) {
mkdir($prpath);
}
$fh = fopen("{$prpath}/{$file}", 'w');
if ($fh) {
fwrite($fh, $hl7);
fclose($fh);
} else {
$messages[] = xl('File') . " '{$file}' " . xl('cannot be archived, ignored');
++$badcount;
continue;
}
// Now delete it from its ftp directory.
if (!$sftp->delete("{$pathname}/{$file}")) {
$messages[] = xl('File') . " '{$file}' " . xl('cannot be deleted, ignored');
++$badcount;
continue;
}
// Parse and process its contents.
$msg = receive_hl7_results($hl7);
if ($msg) {
$messages[] = xl('Error processing file') . " '{$file}':" . $msg;
++$badcount;
continue;
}
$messages[] = xl('New file') . " '{$file}' " . xl('processed successfully');
}
}
// TBD: Insert "else if ($protocol == '???') {...}" to support other protocols.
}
if ($badcount) {
return "{$badcount} " . xl('error(s) encountered from new results');
}
return '';
}
示例11: getcwd
$sslusername = $query_row['sslusername'];
$sslpassword = $query_row['sslpassword'];
}
$path = getcwd();
chdir('..');
chdir('..');
$path = getcwd();
chdir('php/pear');
$path = getcwd();
set_include_path($path);
set_include_path(get_include_path() . '/' . 'phpsec');
include 'Net/SSH2.php';
include 'File/ANSI.php';
include '/Net/SFTP.php';
$sftp = new Net_SFTP(@$hostname);
if (@$sftp->login(@$sslusername, @$sslpassword)) {
$contents = $sftp->get('/proc/meminfo');
$data = explode("\n", $contents);
$meminfo = array();
foreach ($data as $line) {
@(list($key, $val) = explode(":", $line));
$meminfo[$key] = trim($val);
}
$json[] = $meminfo;
echo json_encode($json);
} else {
echo "[]";
}
} else {
echo "[]";
}
示例12: tsdns
function tsdns($action, $sship, $sshport, $sshuser, $keyuse, $sshkey, $sshpw, $notified, $path, $bitversion, $tsip, $tsport, $tsdns, $reseller_id, $maxnotified = 2)
{
global $sql;
$sshSftpObject = new Net_SFTP($sship, $sshport);
if ($keyuse != 'N') {
$privateKey = EASYWIDIR . '/keys/' . removePub($sshkey);
$sshpw = new Crypt_RSA();
if ($keyuse == 'B') {
$sshpw->setPassword($sshpw);
}
$keyContent = @file_get_contents($privateKey);
if ($keyContent) {
$sshpw->loadKey($keyContent);
}
}
if ($sshSftpObject->login($sshuser, $sshpw)) {
$split_config = preg_split('/\\//', $path, -1, PREG_SPLIT_NO_EMPTY);
$folderfilecount = count($split_config) - 1;
$i = 0;
$folders = substr($path, 0, 1) == '/' ? '/' : '';
$lastFolder = '';
while ($i <= $folderfilecount) {
$folders .= $split_config[$i] . '/';
$lastFolder = $split_config[$i];
$i++;
}
if ($lastFolder != 'tsdns' or substr($path, 0, 1) != '/') {
$folders .= 'tsdns/';
}
if ($action == 'md' or $action == 'dl') {
$newip = $tsip[0];
$oldip = isset($tsip[1]) ? $tsip[1] : '';
$newport = $tsport[0];
$oldport = isset($tsport[1]) ? $tsport[1] : '';
$newdns = $tsdns[0];
$olddns = isset($tsdns[1]) ? $tsdns[1] : '';
} else {
$dnsarray = array();
}
$file = substr($path, 0, 1) == '/' ? $folders . 'tsdns_settings.ini' : '/home/' . $sshuser . '/' . $folders . 'tsdns_settings.ini';
if ($action != 'rs') {
$data = $sshSftpObject->get($file);
$data = str_replace(array("", "\\b", "\r", "\\Z"), '', $data);
}
if ($action != 'rs' and $action != 'mw') {
$edited = false;
$ca = array();
foreach (preg_split('/\\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) {
if ($action != 'li' and $configLine != $olddns . '=' . $oldip . ':' . $oldport and $configLine != $newdns . '=' . $newip . ':' . $newport) {
$ca[] = $configLine . "\r\n";
} else {
if ($action == 'md' and $edited == false and ($configLine == $olddns . '=' . $oldip . ':' . $oldport or $configLine == $newdns . '=' . $newip . ':' . $newport)) {
$edited = true;
$ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
}
}
if ($action == 'li' and $configLine != '' and !preg_match('/^#(|\\s+)(.*)$/', $configLine)) {
$dnsconfig = explode('=', $configLine);
if (isset($dnsconfig[1])) {
$linedns = $dnsconfig[0];
$lineserver = $dnsconfig[1];
$dnsarray[$lineserver] = $linedns;
}
}
}
if ($action == 'md' and $edited == false) {
$ca[] = $newdns . '=' . $newip . ':' . $newport . "\r\n";
}
if ($action != 'li') {
$ca = array_unique($ca);
sort($ca);
$newcfg = '';
foreach ($ca as $line) {
$newcfg .= $line;
}
if ($newcfg == '') {
$newcfg = '# No TSDNS data entered';
}
$sshSftpObject->put($file, $newcfg);
}
}
if ($action == 'mw' and isset($data)) {
$usedIPs = array();
foreach (preg_split('/\\n/', $data, -1, PREG_SPLIT_NO_EMPTY) as $configLine) {
if ($configLine != '' and !preg_match('/^#(|\\s+)(.*)$/', $configLine)) {
$splittedLine = preg_split('/\\=/', $configLine, -1, PREG_SPLIT_NO_EMPTY);
$usedIPs[] = isset($splittedLine[1]) ? array('dns' => $splittedLine[0], 'address' => $splittedLine[1]) : $configLine;
} else {
$usedIPs[] = $configLine;
}
}
foreach ($tsip as $newLine) {
$splittedLine = preg_split('/\\=/', strtolower($newLine), -1, PREG_SPLIT_NO_EMPTY);
if (isset($splittedLine[1]) and !array_key_exists($splittedLine[1], $usedIPs)) {
$usedIPs[] = array('dns' => $splittedLine[0], 'address' => $splittedLine[1]);
}
}
function array_multi_dimensional_unique($multi)
{
$unique = array();
//.........这里部分代码省略.........
示例13: download
public function download($localfile, $remotefile = '', $mode = 'A')
{
return $this->conn->get($remotefile, $localfile);
}
示例14: array
}
$sftp->chdir('out');
$files = $sftp->nlist();
$wr1 = array();
foreach ($files as $filename) {
if (substr($filename, 0, 4) == '7760' && substr($filename, -4) == '.wr1') {
$wr1[] = $filename;
}
}
sort($wr1);
foreach ($wr1 as $filename) {
echo $filename . '<br />';
$sql = "SELECT * FROM `wr1` WHERE `filename` = ?s";
$result = $msql->query($sql, substr($filename, 0, 8));
if (!$result->num_rows) {
$wr1File = $sftp->get($filename);
if (strlen($wr1File) != 802) {
preg_match_all('/^.{3}7760.{43}LJ(\\d+).*$/m', $wr1File, $matches);
$orderIDs = array_unique($matches[1]);
sort($orderIDs);
$ordersArr = array();
foreach ($orderIDs as $order) {
$ordersArr[] = '(' . (int) $order . ')';
}
unset($orderIDs);
$sql = "INSERT IGNORE INTO `wr1_orders` (`order_id`) VALUES " . implode(',', $ordersArr);
$msql->query($sql);
}
$sql = "INSERT IGNORE INTO `wr1` (`filename`) VALUES (?s)";
$msql->query($sql, substr($filename, 0, 8));
}
示例15: 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;
}