• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

PHP ftp_raw函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中ftp_raw函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_raw函数的具体用法?PHP ftp_raw怎么用?PHP ftp_raw使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了ftp_raw函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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], '');
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:13,代码来源:SynologyFtp.php


示例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;
 }
开发者ID:bloveing,项目名称:openulteo,代码行数:23,代码来源:class.ftpAccessDriver.php


示例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;
 }
开发者ID:nao-pon,项目名称:xelfinder,代码行数:47,代码来源:xelFinderVolumeFTP.class.php


示例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;
 }
开发者ID:nsbawden,项目名称:dac-atom,代码行数:40,代码来源:shiftedit-proxy.php


示例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;
     }
//.........这里部分代码省略.........
开发者ID:Jumpscale,项目名称:jumpscale_portal8,代码行数:101,代码来源:elFinderVolumeFTP.class.php


示例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;
 }
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:27,代码来源:class.ftpAccessWrapper.php


示例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;
 }
开发者ID:komaspieler,项目名称:yii2-gftp,代码行数:16,代码来源:FtpDriver.php


示例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;
 }
开发者ID:phateio,项目名称:php-radio-kernel,代码行数:58,代码来源:db_ftp.class.php


示例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&#160;&hellip;', '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);
//.........这里部分代码省略.........
开发者ID:skinnard,项目名称:FTL-2,代码行数:101,代码来源:class-destination-ftp.php


示例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);
     }
 }
开发者ID:bergi9,项目名称:2Moons,代码行数:12,代码来源:ftp.class.php


示例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;
开发者ID:helloworld-digital,项目名称:katemorgan,代码行数:67,代码来源:cron.php


示例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');
开发者ID:hscale,项目名称:webento,代码行数:31,代码来源:header_backwpupbackups.php


示例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);
	}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:12,代码来源:class.FTPClientExtension.php


示例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;
}
开发者ID:hscale,项目名称:webento,代码行数:101,代码来源:func_backwpupbackups.php


示例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);
 }
开发者ID:robik,项目名称:cFTP,代码行数:11,代码来源:Session.php


示例16: ftp_connect

<?php

require 'server.inc';
$ftp = ftp_connect('127.0.0.1', $port);
if (!$ftp) {
    die("Couldn't connect to the server");
}
var_dump(ftp_login($ftp, 'user', 'pass'));
var_dump(ftp_raw($ftp, 'HELP'));
var_dump(ftp_raw($ftp, 'HELP HELP'));
var_dump(ftp_close($ftp));
开发者ID:badlamer,项目名称:hhvm,代码行数:11,代码来源:001.php


示例17: login

 /**
  * FTP Login
  */
 function login()
 {
     if ($this->ftps) {
         $result = array_pop(ftp_raw($this->conn_id, 'USER ' . $this->username));
         if (preg_match('/^331/', $result)) {
             $result = array_pop(ftp_raw($this->conn_id, 'PASS ' . $this->password));
             return preg_match('/^230/', $result);
         } else {
             $result = $this->conn_id = @ftp_ssl_connect($this->hostname, $this->port);
             if (FALSE === $result) {
                 if ($this->debug == TRUE) {
                     $this->_error('ftp_unable_to_connect');
                 }
                 $this->errmsg = '指定されたFTPサーバーに、接続できません。FTPサーバー名をご確認下さい。<br />もしくは、FTP接続の制限が考えられます。';
                 $this->errmsg .= '<br />また、FTPS のアクセスができない可能性もありますので、チェックを外してみてください。';
                 return FALSE;
             }
             $this->isConnectable = true;
             return @ftp_login($this->conn_id, $this->username, $this->password);
         }
     } else {
         echo '<!-- ftp:';
         var_dump($this->conn_id, $this->username, $this->password);
         echo ' -->';
         return @ftp_login($this->conn_id, $this->username, $this->password);
     }
 }
开发者ID:hokuken,项目名称:QHM-Quick-Installer,代码行数:30,代码来源:install2.php


示例18: gs_hylafax_authfile_put

function gs_hylafax_authfile_put($authfile)
{
    # connect to fax server
    #
    $con_id = @ftp_connect(gs_get_conf('GS_FAX_HYLAFAX_HOST'), gs_get_conf('GS_FAX_HYLAFAX_PORT'), gs_get_conf('GS_FAX_HYLAFAX_TIMEOUT', 20));
    if (!$con_id) {
        return new GsError('Failed to connect to HylaFax server.');
    }
    # log in as admin user
    #
    if (!@ftp_login($con_id, gs_get_conf('GS_FAX_HYLAFAX_ADMIN'), gs_get_conf('GS_FAX_HYLAFAX_PASS'))) {
        return new GsError('Failed to log in at HylaFax server.');
    }
    # go into admin mode
    #
    if (!@ftp_raw($con_id, 'admin ' . gs_get_conf('GS_FAX_HYLAFAX_PASS'))) {
        return new GsError('Failed to switch to admin mode at HylaFax server.');
    }
    # put the local authfile to fax server
    #
    # HylaFax convention: absolute path, relative to Hylafax dir (/var/spool/hylafax/)
    if (!@ftp_put($con_id, '/etc/hosts.hfaxd', $authfile, FTP_BINARY)) {
        return new GsError('Failed to push authfile to HylaFax server.');
    }
    # close connection
    #
    if (@ftp_close($con_id)) {
        return true;
    } else {
        return new GsError('Error.');
    }
}
开发者ID:rkania,项目名称:GS3,代码行数:32,代码来源:gs_hylafax_authfile.php


示例19: isFTPConnected

 private function isFTPConnected()
 {
     if ($this->link_id) {
         if (ftp_raw($this->link_id, 'NOOP')) {
             return true;
         }
     }
     return false;
 }
开发者ID:BGCX067,项目名称:faculaframework-svn-to-git,代码行数:9,代码来源:api.upload.php


示例20: connect

 /**
  * Opens the adapter's ftp connection.
  *
  * @throws RuntimeException if could not connect
  */
 private function connect()
 {
     // open ftp connection
     if (!$this->ssl) {
         $this->connection = ftp_connect($this->host, $this->port);
     } else {
         if (function_exists('ftp_ssl_connect')) {
             $this->connection = ftp_ssl_connect($this->host, $this->port);
         } else {
             throw new \RuntimeException('This Server Has No SSL-FTP Available.');
         }
     }
     if (!$this->connection) {
         throw new \RuntimeException(sprintf('Could not connect to \'%s\' (port: %s).', $this->host, $this->port));
     }
     $username = $this->username ?: 'anonymous';
     $password = $this->password ?: '';
     // login ftp user
     if (!@ftp_login($this->connection, $username, $password)) {
         $this->close();
         throw new \RuntimeException(sprintf('Could not login as %s.', $username));
     }
     // switch to passive mode if needed
     if ($this->passive && !ftp_pasv($this->connection, true)) {
         $this->close();
         throw new \RuntimeException('Could not turn passive mode on.');
     }
     // enable utf8 mode if configured
     if ($this->utf8 == true) {
         ftp_raw($this->connection, "OPTS UTF8 ON");
     }
     // ensure the adapter's directory exists
     if ('/' !== $this->directory) {
         try {
             $this->ensureDirectoryExists($this->directory, $this->create);
         } catch (\RuntimeException $e) {
             $this->close();
             throw $e;
         }
         // change the current directory for the adapter's directory
         if (!ftp_chdir($this->connection, $this->directory)) {
             $this->close();
             throw new \RuntimeException(sprintf('Could not change current directory for the \'%s\' directory.', $this->directory));
         }
     }
 }
开发者ID:knplabs,项目名称:gaufrette,代码行数:51,代码来源:Ftp.php



注:本文中的ftp_raw函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ftp_rawlist函数代码示例发布时间:2022-05-15
下一篇:
PHP ftp_quit函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap