本文整理汇总了PHP中ftp_raw函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_raw函数的具体用法?PHP ftp_raw怎么用?PHP ftp_raw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_raw函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getMetadata
/**
* {@inheritdoc}
*/
public function getMetadata($path)
{
if (empty($path) || !($object = ftp_raw($this->getConnection(), 'STAT ' . $path)) || count($object) < 3) {
return false;
}
if (substr($object[1], 0, 5) === "ftpd:") {
return false;
}
return $this->normalizeObject($object[1], '');
}
示例2: features
/** This method retrieves the FTP server features as described in RFC2389
A decent FTP server support MLST command to list file using UTF-8 encoding
@return an array of features (see code) */
function getServerFeatures()
{
$features = @ftp_raw($this->connect, "FEAT");
// Check the answer code
if (!$this->checkCode($features)) {
return array("list" => "LIST", "charset" => $this->repository->getOption("CHARSET"));
}
$retArray = array("list" => "LIST", "charset" => $this->repository->getOption("CHARSET"));
// Ok, find out the encoding used
foreach ($features as $feature) {
if (strstr($feature, "UTF8") !== FALSE) {
// See http://wiki.filezilla-project.org/Character_Set for an explaination
@ftp_raw($this->connect, "OPTS UTF-8 ON");
$retArray['charset'] = "UTF-8";
return $retArray;
}
}
// In the future version, we should also use MLST as it standardize the listing format
return $retArray;
}
示例3: connect
/**
* Connect to ftp server
*
* @return bool
* @author Dmitry (dio) Levashov
* @author Naoki Sawada
**/
protected function connect()
{
if (!($this->connect = ftp_connect($this->options['host'], $this->options['port'], $this->options['timeout']))) {
return $this->setError('Unable to connect to FTP server ' . $this->options['host']);
}
if (!ftp_login($this->connect, $this->options['user'], $this->options['pass'])) {
$this->umount();
return $this->setError('Unable to login into ' . $this->options['host']);
}
// try switch utf8 mode
if ($this->encoding) {
@ftp_exec($this->connect, 'OPTS UTF8 OFF');
} else {
@ftp_exec($this->connect, 'OPTS UTF8 ON');
}
// switch off extended passive mode - may be usefull for some servers
@ftp_exec($this->connect, 'epsv4 off');
// enter passive mode if required
ftp_pasv($this->connect, $this->options['mode'] == 'passive');
// enter root folder
if (!@ftp_chdir($this->connect, $this->root) || $this->root != ftp_pwd($this->connect)) {
if (empty($this->options['is_local']) || !$this->setLocalRoot()) {
$this->umount();
return $this->setError('Unable to open root folder.');
}
}
// check for MLST support
$features = ftp_raw($this->connect, 'FEAT');
if (!is_array($features)) {
$this->umount();
return $this->setError('Server does not support command FEAT.');
}
foreach ($features as $feat) {
if (strpos(trim($feat), 'MLST') === 0) {
$this->MLSTsupprt = true;
break;
}
}
return true;
}
示例4: put
function put($file, $content, $resume_pos = 0)
{
$mode = FTP_BINARY;
if (!$file) {
return false;
}
$path = $this->dir . $file;
$tmp = tmpfile();
if (fwrite($tmp, $content) === false) {
$this->ftp_log[] = 'can\'t write to filesystem';
return false;
}
rewind($tmp);
$this->chdir(dirname($path));
if ($resume_pos) {
ftp_raw($this->conn_id, "REST " . $resume_pos);
}
$result = ftp_fput($this->conn_id, basename_safe($path), $tmp, $mode);
//try deleting first
if ($result === false) {
$items = $this->parse_raw_list(dirname($file));
$perms = 0;
foreach ($items as $v) {
if ($v['name'] == basename($file)) {
$perms = $v['permsn'];
}
}
//delete before save otherwise save does not work on some servers
$this->delete($file);
if ($perms) {
$this->chmod(intval($perms, 8), $file);
}
if ($resume_pos) {
ftp_raw($this->conn_id, "REST " . $resume_pos);
}
$result = ftp_fput($this->conn_id, basename_safe($path), $tmp, $mode);
}
fclose($tmp);
return $result;
}
示例5: _stat
/**
* Return stat for given path.
* Stat contains following fields:
* - (int) size file size in b. required
* - (int) ts file modification time in unix time. required
* - (string) mime mimetype. required for folders, others - optionally
* - (bool) read read permissions. required
* - (bool) write write permissions. required
* - (bool) locked is object locked. optionally
* - (bool) hidden is object hidden. optionally
* - (string) alias for symlinks - link target path relative to root path. optionally
* - (string) target for symlinks - link target path. optionally
*
* If file does not exists - returns empty array or false.
*
* @param string $path file path
* @return array|false
* @author Dmitry (dio) Levashov
**/
protected function _stat($path)
{
$raw = ftp_raw($this->connect, 'MLST ' . $path);
if (is_array($raw) && count($raw) > 1 && substr(trim($raw[0]), 0, 1) == 2) {
$parts = explode(';', trim($raw[1]));
array_pop($parts);
$parts = array_map('strtolower', $parts);
$stat = array();
// debug($parts);
foreach ($parts as $part) {
list($key, $val) = explode('=', $part);
switch ($key) {
case 'type':
$stat['mime'] = strpos($val, 'dir') !== false ? 'directory' : $this->mimetype($path);
break;
case 'size':
$stat['size'] = $val;
break;
case 'modify':
$ts = mktime(intval(substr($val, 8, 2)), intval(substr($val, 10, 2)), intval(substr($val, 12, 2)), intval(substr($val, 4, 2)), intval(substr($val, 6, 2)), substr($val, 0, 4));
$stat['ts'] = $ts;
// $stat['date'] = $this->formatDate($ts);
break;
case 'unix.mode':
$stat['chmod'] = $val;
break;
case 'perm':
$val = strtolower($val);
$stat['read'] = (int) preg_match('/e|l|r/', $val);
$stat['write'] = (int) preg_match('/w|m|c/', $val);
if (!preg_match('/f|d/', $val)) {
$stat['locked'] = 1;
}
break;
}
}
if (empty($stat['mime'])) {
return array();
}
if ($stat['mime'] == 'directory') {
$stat['size'] = 0;
}
if (isset($stat['chmod'])) {
$stat['perm'] = '';
if ($stat['chmod'][0] == 0) {
$stat['chmod'] = substr($stat['chmod'], 1);
}
for ($i = 0; $i <= 2; $i++) {
$perm[$i] = array(false, false, false);
$n = isset($stat['chmod'][$i]) ? $stat['chmod'][$i] : 0;
if ($n - 4 >= 0) {
$perm[$i][0] = true;
$n = $n - 4;
$stat['perm'] .= 'r';
} else {
$stat['perm'] .= '-';
}
if ($n - 2 >= 0) {
$perm[$i][1] = true;
$n = $n - 2;
$stat['perm'] .= 'w';
} else {
$stat['perm'] .= '-';
}
if ($n - 1 == 0) {
$perm[$i][2] = true;
$stat['perm'] .= 'x';
} else {
$stat['perm'] .= '-';
}
$stat['perm'] .= ' ';
}
$stat['perm'] = trim($stat['perm']);
$owner = $this->options['owner'];
$read = $owner && $perm[0][0] || $perm[1][0] || $perm[2][0];
$stat['read'] = $stat['mime'] == 'directory' ? $read && ($owner && $perm[0][2] || $perm[1][2] || $perm[2][2]) : $read;
$stat['write'] = $owner && $perm[0][1] || $perm[1][1] || $perm[2][1];
unset($stat['chmod']);
}
return $stat;
}
//.........这里部分代码省略.........
示例6: getServerFeatures
/** This method retrieves the FTP server features as described in RFC2389
* A decent FTP server support MLST command to list file using UTF-8 encoding
* @return an array of features (see code)
*/
protected function getServerFeatures()
{
$link = $this->createFTPLink();
$features = @ftp_raw($link, "FEAT");
// Check the answer code
if (isset($features[0]) && $features[0][0] != "2") {
//ftp_close($link);
return array("list" => "LIST", "charset" => $this->repoCharset);
}
$retArray = array("list" => "LIST", "charset" => $this->repoCharset);
// Ok, find out the encoding used
foreach ($features as $feature) {
if (strstr($feature, "UTF8") !== FALSE) {
// See http://wiki.filezilla-project.org/Character_Set for an explaination
@ftp_raw($link, "OPTS UTF-8 ON");
$retArray['charset'] = "UTF-8";
//ftp_close($link);
return $retArray;
}
}
// In the future version, we should also use MLST as it standardize the listing format
return $retArray;
}
示例7: raw
/**
* Sends an arbitrary command to the FTP server.
*
* @param string $command FTP command to execute.
*
* @return string[] The server's response as an array of strings. No parsing is performed on the response string and not determine if the command succeeded.
*
* @throws FtpException If command execution fails.
*/
public function raw($command)
{
$this->connectIfNeeded();
$this->param = $command;
$res = ftp_raw($this->handle, $command);
return $res;
}
示例8: ftp_mlsd
function ftp_mlsd($directory)
{
require SYSTEM_ROOT . '/config.remote.php';
if (!self::islogin()) {
if (!self::login()) {
return false;
}
}
if (!@ftp_chdir(self::$cid, $directory)) {
return false;
}
$ret = ftp_raw(self::$cid, 'PASV');
if (!count($ret)) {
return false;
}
if (!preg_match('/^227.*\\(([0-9]+,[0-9]+,[0-9]+,[0-9]+),([0-9]+),([0-9]+)\\)$/', $ret[0], $matches)) {
return false;
}
$conn_IP = str_replace(',', '.', $matches[1]);
$conn_Port = intval($matches[2]) * 256 + intval($matches[3]);
$socket = @fsockopen($conn_IP, $conn_Port, $errno, $errstr, $ftp_timeout);
if (!$socket) {
return false;
}
stream_set_timeout($socket, $ftp_timeout);
ftp_raw(self::$cid, 'MLSD');
$s = '';
while (!feof($socket)) {
$s .= fread($socket, 1024);
$stream_meta_data = stream_get_meta_data($socket);
if ($stream_meta_data['timed_out']) {
fclose($socket);
return false;
}
}
fclose($socket);
$files = array();
foreach (explode("\n", $s) as $line) {
if (!$line) {
continue;
}
$file = array();
$elements = explode(';', $line, 8);
$cnt = count($elements);
if ($cnt > 0) {
$cnt--;
$file['filename'] = trim($elements[$cnt]);
for ($i = 0; $i < $cnt; $i++) {
if ($i < $cnt) {
$attribute = explode('=', $elements[$i]);
$file[$attribute[0]] = $attribute[1];
}
}
}
$files[] = $file;
}
return $files;
}
示例9: job_run_archive
/**
* @param $job_object
* @return bool
*/
public function job_run_archive(BackWPup_Job $job_object)
{
$job_object->substeps_todo = 2 + $job_object->backup_filesize;
if ($job_object->steps_data[$job_object->step_working]['SAVE_STEP_TRY'] != $job_object->steps_data[$job_object->step_working]['STEP_TRY']) {
$job_object->log(sprintf(__('%d. Try to send backup file to an FTP server …', 'backwpup'), $job_object->steps_data[$job_object->step_working]['STEP_TRY']), E_USER_NOTICE);
}
if (!empty($job_object->job['ftpssl'])) {
//make SSL FTP connection
if (function_exists('ftp_ssl_connect')) {
$ftp_conn_id = ftp_ssl_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
if ($ftp_conn_id) {
$job_object->log(sprintf(__('Connected via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('Cannot connect via explicit SSL-FTP to server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
return FALSE;
}
} else {
$job_object->log(__('PHP function to connect with explicit SSL-FTP to server does not exist!', 'backwpup'), E_USER_ERROR);
return TRUE;
}
} else {
//make normal FTP connection if SSL not work
$ftp_conn_id = ftp_connect($job_object->job['ftphost'], $job_object->job['ftphostport'], $job_object->job['ftptimeout']);
if ($ftp_conn_id) {
$job_object->log(sprintf(__('Connected to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('Cannot connect to FTP server: %s', 'backwpup'), $job_object->job['ftphost'] . ':' . $job_object->job['ftphostport']), E_USER_ERROR);
return FALSE;
}
}
//FTP Login
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'USER ' . $job_object->job['ftpuser']), E_USER_NOTICE);
if ($loginok = @ftp_login($ftp_conn_id, $job_object->job['ftpuser'], BackWPup_Encryption::decrypt($job_object->job['ftppass']))) {
$job_object->log(sprintf(__('FTP server response: %s', 'backwpup'), 'User ' . $job_object->job['ftpuser'] . ' logged in.'), E_USER_NOTICE);
} else {
//if PHP ftp login don't work use raw login
$return = ftp_raw($ftp_conn_id, 'USER ' . $job_object->job['ftpuser']);
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
if (substr(trim($return[0]), 0, 3) <= 400) {
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'PASS *******'), E_USER_NOTICE);
$return = ftp_raw($ftp_conn_id, 'PASS ' . BackWPup_Encryption::decrypt($job_object->job['ftppass']));
if (substr(trim($return[0]), 0, 3) <= 400) {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_NOTICE);
$loginok = TRUE;
} else {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $return[0]), E_USER_ERROR);
}
}
}
if (!$loginok) {
return FALSE;
}
//SYSTYPE
$job_object->log(sprintf(__('FTP client command: %s', 'backwpup'), 'SYST'), E_USER_NOTICE);
$systype = ftp_systype($ftp_conn_id);
if ($systype) {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), $systype), E_USER_NOTICE);
} else {
$job_object->log(sprintf(__('FTP server reply: %s', 'backwpup'), __('Error getting SYSTYPE', 'backwpup')), E_USER_ERROR);
}
//set actual ftp dir to ftp dir
if (empty($job_object->job['ftpdir'])) {
$job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id));
}
// prepend actual ftp dir if relative dir
if (substr($job_object->job['ftpdir'], 0, 1) != '/') {
$job_object->job['ftpdir'] = trailingslashit(ftp_pwd($ftp_conn_id)) . $job_object->job['ftpdir'];
}
//test ftp dir and create it if not exists
if ($job_object->job['ftpdir'] != '/') {
@ftp_chdir($ftp_conn_id, '/');
//go to root
$ftpdirs = explode('/', trim($job_object->job['ftpdir'], '/'));
foreach ($ftpdirs as $ftpdir) {
if (empty($ftpdir)) {
continue;
}
if (!@ftp_chdir($ftp_conn_id, $ftpdir)) {
if (@ftp_mkdir($ftp_conn_id, $ftpdir)) {
$job_object->log(sprintf(__('FTP Folder "%s" created!', 'backwpup'), $ftpdir), E_USER_NOTICE);
ftp_chdir($ftp_conn_id, $ftpdir);
} else {
$job_object->log(sprintf(__('FTP Folder "%s" cannot be created!', 'backwpup'), $ftpdir), E_USER_ERROR);
return FALSE;
}
}
}
}
// Get the current working directory
$current_ftp_dir = trailingslashit(ftp_pwd($ftp_conn_id));
if ($job_object->substeps_done == 0) {
$job_object->log(sprintf(__('FTP current folder is: %s', 'backwpup'), $current_ftp_dir), E_USER_NOTICE);
}
//get file size to resume upload
@clearstatcache();
$job_object->substeps_done = @ftp_size($ftp_conn_id, $job_object->job['ftpdir'] . $job_object->backup_file);
//.........这里部分代码省略.........
示例10: executeRawCommand
/**
* Sends an arbitrary command to a FTP server
*
* @param string $command The command that is send to the server.
* @return mixed The server response as string or array
*/
public function executeRawCommand($command)
{
if (is_resource($this->cid)) {
return ftp_raw($this->cid, $command);
}
}
示例11: woo_ce_cron_export
//.........这里部分代码省略.........
$user = woo_ce_get_option( 'auto_ftp_method_user', '' );
$pass = woo_ce_get_option( 'auto_ftp_method_pass', '' );
$path = woo_ce_get_option( 'auto_ftp_method_path', '' );
$filename = woo_ce_get_option( 'auto_ftp_method_filename', '' );
// Switch to fixed export filename if provided
if( !empty( $filename ) )
$export->filename = woo_ce_generate_filename( $export->type, $filename ) . '.' . $file_extension;
// Check what protocol are we using; FTP or SFTP?
$protocol = woo_ce_get_option( 'auto_ftp_method_protocol', 'ftp' );
switch( $protocol ) {
case 'ftp':
default:
// Check if ftp_connect() is available
if( function_exists( 'ftp_connect' ) ) {
$passive = woo_ce_get_option( 'auto_ftp_method_passive', '' );
$timeout = woo_ce_get_option( 'auto_ftp_method_timeout', '' );
if( $connection = @ftp_connect( $host, $port ) ) {
// Update the FTP timeout if available and if a timeout was provided at export
$remote_timeout = ftp_get_option( $connection, FTP_TIMEOUT_SEC );
$timeout = absint( $timeout );
if( $remote_timeout !== false && !empty( $timeout ) ) {
// Compare the server timeout and the timeout provided at export
if( $remote_timeout <> $timeout ) {
if( ftp_set_option( $connection, FTP_TIMEOUT_SEC, $timeout ) == false )
error_log( sprintf( '[store-exporter-deluxe] %s: Warning: %s', $export->filename, sprintf( __( 'Could not change the FTP server timeout on %s', 'woo_ce' ), $host ) ) );
}
}
unset( $remote_timeout );
if( ftp_login( $connection, $user, $pass ) ) {
// Check if Transfer Mode is set to Auto/Pasive and if passive mode is available
if( in_array( $passive, array( 'auto', 'passive' ) ) ) {
$features = ftp_raw( $connection, 'FEAT' );
if( !empty( $features ) ) {
if( in_array( 'PASV', $features ) ) {
if( ftp_pasv( $connection, true ) == false )
error_log( sprintf( '[store-exporter-deluxe] %s: Warning: %s', 'woo_ce', $export->filename, sprintf( __( 'Could not switch to FTP passive mode on %s', 'woo_ce' ), $host ) ) );
}
}
}
// Change directory if neccesary
if( !empty( $directory ) ) {
$current_directory = ftp_pwd( $connection );
if( $current_directory !== false && @ftp_chdir( $connection, $path ) )
ftp_chdir( $connection, $path );
}
if( ftp_put( $connection, sprintf( '%s/%s', $path, $export->filename ), $upload['file'], FTP_ASCII ) ) {
error_log( sprintf( '[store-exporter-deluxe] %s: Success: %s', $export->filename, sprintf( __( 'Scheduled export of %s to %s via FTP uploaded', 'woo_ce' ), $export->filename, $path ) ) );
} else {
$export->error = sprintf( __( 'There was a problem uploading %s to %s via FTP, response: %s', 'woo_ce' ), $export->filename, $path, woo_ce_error_get_last_message() );
error_log( sprintf( '[store-exporter-deluxe] %s: Error: %s', $export->filename, $export->error ) );
}
} else {
$export->error = sprintf( __( 'Login incorrect for user %s on FTP server at %s, response: %s', 'woo_ce' ), $user, $host, woo_ce_error_get_last_message() );
error_log( sprintf( '[store-exporter-deluxe] %s: Error: %s', $export->filename, $export->error ) );
}
} else {
$export->error = sprintf( __( 'There was a problem connecting to %s via FTP', 'woo_ce' ), $host );
error_log( sprintf( '[store-exporter-deluxe] %s: Error: %s', $export->filename, $export->error ) );
}
} else {
$export->error = __( 'The function ftp_connect() is disabled within your WordPress site, cannot upload to FTP server', 'woo_ce' );
error_log( __( '[store-exporter-deluxe] %s: Error: %s', 'woo_ce' ), $export->filename, $export->error );
}
break;
示例12: ftp_ssl_connect
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) {
//make SSL FTP connection
$ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'], $jobvalue['ftphostport'], 10);
} elseif (!$jobvalue['ftpssl']) {
//make normal FTP conection if SSL not work
$ftp_conn_id = ftp_connect($jobvalue['ftphost'], $jobvalue['ftphostport'], 10);
}
$loginok = false;
if ($ftp_conn_id) {
//FTP Login
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], backwpup_base64($jobvalue['ftppass']))) {
$loginok = true;
} else {
//if PHP ftp login don't work use raw login
ftp_raw($ftp_conn_id, 'USER ' . $jobvalue['ftpuser']);
$return = ftp_raw($ftp_conn_id, 'PASS ' . backwpup_base64($jobvalue['ftppass']));
if (substr(trim($return[0]), 0, 3) <= 400) {
$loginok = true;
}
}
}
if ($loginok) {
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
ftp_delete($ftp_conn_id, $backupfile);
} else {
$backwpup_message .= 'FTP: ' . __('Login failure!', 'backwpup') . '<br />';
}
}
}
}
delete_transient('backwpup_backups_chache');
示例13: _exec
protected function _exec($cmd, $function = "_exec") {
if(!$this->ready) {
$this->pushError($function, 'Connect first');
return false;
}
if($this->LocalEcho) {
echo "PUT > ".$cmd.self::CRLF;
}
$this->ftp_data_sock = ftp_raw($this->ftp_control_sock, $cmd);
$this->lastaction = time();
return $this->_readMsg($function);
}
示例14: backwpup_get_backup_files
//.........这里部分代码省略.........
$blobs = $storageClient->listBlobs($jobvalue['msazureContainer'], $jobvalue['msazuredir']);
if (is_array($blobs)) {
foreach ($blobs as $blob) {
$files[$filecounter]['JOBID'] = $jobid;
$files[$filecounter]['DEST'] = $dest;
$files[$filecounter]['folder'] = "https://" . $jobvalue['msazureAccName'] . '.' . $jobvalue['msazureHost'] . "/" . $jobvalue['msazureContainer'] . "/" . dirname($blob->Name) . "/";
$files[$filecounter]['file'] = $blob->Name;
$files[$filecounter]['filename'] = basename($blob->Name);
$files[$filecounter]['downloadurl'] = backwpup_admin_url('admin.php') . '?page=backwpupbackups&action=downloadmsazure&file=' . $blob->Name . '&jobid=' . $jobid;
$files[$filecounter]['filesize'] = $blob->size;
$files[$filecounter]['time'] = strtotime($blob->lastmodified);
$filecounter++;
}
}
} catch (Exception $e) {
$backwpup_message .= 'MSAZURE: ' . $e->getMessage() . '<br />';
}
}
}
//Get files/filinfo from RSC
if ($dest == 'RSC' and !empty($jobvalue['rscUsername']) and !empty($jobvalue['rscAPIKey']) and !empty($jobvalue['rscContainer'])) {
if (!class_exists('CF_Authentication')) {
require_once dirname(__FILE__) . '/../libs/rackspace/cloudfiles.php';
}
if (class_exists('CF_Authentication')) {
try {
$auth = new CF_Authentication($jobvalue['rscUsername'], $jobvalue['rscAPIKey']);
$auth->ssl_use_cabundle();
if ($auth->authenticate()) {
$conn = new CF_Connection($auth);
$conn->ssl_use_cabundle();
$backwpupcontainer = $conn->get_container($jobvalue['rscContainer']);
$contents = $backwpupcontainer->get_objects(0, NULL, NULL, $jobvalue['rscdir']);
foreach ($contents as $object) {
$files[$filecounter]['JOBID'] = $jobid;
$files[$filecounter]['DEST'] = $dest;
$files[$filecounter]['folder'] = "RSC://" . $jobvalue['rscContainer'] . "/" . dirname($object->name) . "/";
$files[$filecounter]['file'] = $object->name;
$files[$filecounter]['filename'] = basename($object->name);
$files[$filecounter]['downloadurl'] = backwpup_admin_url('admin.php') . '?page=backwpupbackups&action=downloadrsc&file=' . $object->name . '&jobid=' . $jobid;
$files[$filecounter]['filesize'] = $object->content_length;
$files[$filecounter]['time'] = strtotime($object->last_modified);
$filecounter++;
}
}
} catch (Exception $e) {
$backwpup_message .= 'RSC: ' . $e->getMessage() . '<br />';
}
}
}
//Get files/filinfo from FTP
if ($dest == 'FTP' and !empty($jobvalue['ftphost']) and function_exists('ftp_connect') and !empty($jobvalue['ftpuser']) and !empty($jobvalue['ftppass'])) {
if (function_exists('ftp_ssl_connect') and $jobvalue['ftpssl']) {
//make SSL FTP connection
$ftp_conn_id = ftp_ssl_connect($jobvalue['ftphost'], $jobvalue['ftphostport'], 10);
} elseif (!$jobvalue['ftpssl']) {
//make normal FTP conection if SSL not work
$ftp_conn_id = ftp_connect($jobvalue['ftphost'], $jobvalue['ftphostport'], 10);
}
$loginok = false;
if ($ftp_conn_id) {
//FTP Login
if (@ftp_login($ftp_conn_id, $jobvalue['ftpuser'], backwpup_base64($jobvalue['ftppass']))) {
$loginok = true;
} else {
//if PHP ftp login don't work use raw login
ftp_raw($ftp_conn_id, 'USER ' . $jobvalue['ftpuser']);
$return = ftp_raw($ftp_conn_id, 'PASS ' . backwpup_base64($jobvalue['ftppass']));
if (substr(trim($return[0]), 0, 3) <= 400) {
$loginok = true;
}
}
}
if ($loginok) {
ftp_chdir($ftp_conn_id, $jobvalue['ftpdir']);
$currentftpdir = rtrim(ftp_pwd($ftp_conn_id), '/') . '/';
ftp_pasv($ftp_conn_id, $jobvalue['ftppasv']);
if ($ftpfilelist = ftp_nlist($ftp_conn_id, $currentftpdir)) {
foreach ($ftpfilelist as $ftpfiles) {
if (substr(basename($ftpfiles), 0, 1) == '.') {
continue;
}
$files[$filecounter]['JOBID'] = $jobid;
$files[$filecounter]['DEST'] = $dest;
$files[$filecounter]['folder'] = "ftp://" . $jobvalue['ftphost'] . ':' . $jobvalue['ftphostport'] . dirname($ftpfiles) . "/";
$files[$filecounter]['file'] = $ftpfiles;
$files[$filecounter]['filename'] = basename($ftpfiles);
$files[$filecounter]['downloadurl'] = "ftp://" . rawurlencode($jobvalue['ftpuser']) . ":" . rawurlencode(backwpup_base64($jobvalue['ftppass'])) . "@" . $jobvalue['ftphost'] . ':' . $jobvalue['ftphostport'] . $ftpfiles;
$files[$filecounter]['filesize'] = ftp_size($ftp_conn_id, $ftpfiles);
$files[$filecounter]['time'] = ftp_mdtm($ftp_conn_id, $ftpfiles);
$filecounter++;
}
}
} else {
$backwpup_message .= 'FTP: ' . __('Login failure!', 'backwpup') . '<br />';
}
$donefolders[] = $jobvalue['ftphost'] . '|' . $jobvalue['ftpuser'] . '|' . $jobvalue['ftpdir'];
}
return $files;
}
示例15: doCommand
/**
* Sends an arbitrary command to the FTP server
*
* @param string $command Command to execute
*
* @return array Response
*/
public function doCommand($command)
{
return @ftp_raw($this->handle, $command);
}