本文整理汇总了PHP中ftp_get_option函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_get_option函数的具体用法?PHP ftp_get_option怎么用?PHP ftp_get_option使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_get_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: connect
function connect()
{
if (!$this->options['hostname'] || !$this->options['username'] || !$this->options['password']) {
if (!defined('SUPPORT_URL')) {
define('SUPPORT_URL', getOption('supportURL'));
}
appUpdateMsg('<a href="' . SUPPORT_URL . 'solution/articles/195233-asking-for-ftp-sftp-details-during-update/" target="_blank">See how to add the FTP details</a>.');
return false;
}
if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect')) {
$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
} else {
$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
}
if (!$this->link) {
//$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
appUpdateMsg(sprintf('Failed to connect to the FTP server "%1$s:%2$s"', $this->options['hostname'], $this->options['port']));
return false;
}
if (!@ftp_login($this->link, $this->options['username'], $this->options['password'])) {
//$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
appUpdateMsg(sprintf('FTP username or password incorrect for "%s"', $this->options['username']));
return false;
}
//Set the Connection to use Passive FTP
if ($this->options['passive']) {
@ftp_pasv($this->link, true);
}
if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT) {
@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
}
return true;
}
示例2: connect
public function connect($host, $login, $password)
{
if (!parent::connect($host, $login, $password)) {
return false;
}
if (empty($this->port)) {
$this->port = 21;
}
$this->handle = $this->ssl && function_exists('ftp_ssl_connect') ? @ftp_ssl_connect($this->host, $this->port, $this->timeout) : @ftp_connect($this->host, $this->port, $this->timeout);
if ($this->handle && @ftp_login($this->handle, $this->login, $this->password)) {
@ftp_pasv($this->handle, true);
if (@ftp_get_option($this->handle, FTP_TIMEOUT_SEC) < $this->timeout) {
@ftp_set_option($this->handle, FTP_TIMEOUT_SEC, $this->timeout);
}
$this->connected = true;
return true;
}
return false;
}
示例3: connect
public function connect()
{
if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect')) {
$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
} else {
$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], FS_CONNECT_TIMEOUT);
}
if (!$this->link) {
$this->errors->add('connect', sprintf(__('Failed to connect to FTP Server %1$s:%2$s'), $this->options['hostname'], $this->options['port']));
return false;
}
if (!@ftp_login($this->link, $this->options['username'], $this->options['password'])) {
$this->errors->add('auth', sprintf(__('Username/Password incorrect for %s'), $this->options['username']));
return false;
}
// Set the Connection to use Passive FTP
@ftp_pasv($this->link, true);
if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < FS_TIMEOUT) {
@ftp_set_option($this->link, FTP_TIMEOUT_SEC, FS_TIMEOUT);
}
return true;
}
示例4: connect
function connect()
{
if (isset($this->options['ssl']) && $this->options['ssl'] && function_exists('ftp_ssl_connect')) {
$this->link = @ftp_ssl_connect($this->options['hostname'], $this->options['port'], $this->options['connect_timeout']);
} else {
$this->link = @ftp_connect($this->options['hostname'], $this->options['port'], $this->options['connect_timeout']);
}
if (!$this->link) {
$this->errors->add('connect', sprintf('Could not connect to FTP server %s:%s', $this->options['hostname'], $this->options['port']));
return false;
}
if (!@ftp_login($this->link, $this->options['username'], $this->options['password'])) {
$this->errors->add('auth', 'The username and/or password is incorrect.');
return false;
}
//Set the Connection to use Passive FTP
@ftp_pasv($this->link, true);
if (@ftp_get_option($this->link, FTP_TIMEOUT_SEC) < $this->options['connection_timeout']) {
@ftp_set_option($this->link, FTP_TIMEOUT_SEC, $this->options['connection_timeout']);
}
return true;
}
示例5: getOption
/**
*
* 返回当前 FTP 连接的各种不同的选项设置
*
* @param int $option
* @return mixed
*/
public static function getOption($option)
{
return ftp_get_option(self::$resource, $option);
}
示例6: getAutoseek
/**
* Determine if autoseek is enabled.
* Autoseek is used by the unobtrusive Upload/Download methods to automatically find the resume position.
*
* @return bool
*/
public function getAutoseek()
{
if (is_resource($this->cid)) {
return @ftp_get_option($this->cid, FTP_AUTOSEEK);
}
}
示例7: evaluate
//.........这里部分代码省略.........
$keyLen = $encoding && $encoding !== 'ASCII' ? static::strLen($key) . '; ' . $encoding : static::strLen($key);
$keyInfo = "{$keyInfo}({$keyLen})";
} else {
$keyLen = strlen($key);
}
$this->fmt->startRow();
$this->fmt->text('key', $key, "Key: {$keyInfo}");
$this->fmt->colDiv($max - $keyLen);
$this->fmt->sep('=>');
$this->fmt->colDiv();
$this->evaluate($value, $specialStr);
$this->fmt->endRow();
}
unset($subject[static::MARKER_KEY]);
$this->fmt->endGroup();
return;
// resource
// resource
case 'resource':
$meta = array();
$resType = get_resource_type($subject);
$this->fmt->text('resource', strval($subject));
if (!static::$config['showResourceInfo']) {
return $this->fmt->emptyGroup($resType);
}
// @see: http://php.net/manual/en/resource.php
// need to add more...
switch ($resType) {
// curl extension resource
case 'curl':
$meta = curl_getinfo($subject);
break;
case 'FTP Buffer':
$meta = array('time_out' => ftp_get_option($subject, FTP_TIMEOUT_SEC), 'auto_seek' => ftp_get_option($subject, FTP_AUTOSEEK));
break;
// gd image extension resource
// gd image extension resource
case 'gd':
$meta = array('size' => sprintf('%d x %d', imagesx($subject), imagesy($subject)), 'true_color' => imageistruecolor($subject));
break;
case 'ldap link':
$constants = get_defined_constants();
array_walk($constants, function ($value, $key) use(&$constants) {
if (strpos($key, 'LDAP_OPT_') !== 0) {
unset($constants[$key]);
}
});
// this seems to fail on my setup :(
unset($constants['LDAP_OPT_NETWORK_TIMEOUT']);
foreach (array_slice($constants, 3) as $key => $value) {
if (ldap_get_option($subject, (int) $value, $ret)) {
$meta[strtolower(substr($key, 9))] = $ret;
}
}
break;
// mysql connection (mysql extension is deprecated from php 5.4/5.5)
// mysql connection (mysql extension is deprecated from php 5.4/5.5)
case 'mysql link':
case 'mysql link persistent':
$dbs = array();
$query = @mysql_list_dbs($subject);
while ($row = @mysql_fetch_array($query)) {
$dbs[] = $row['Database'];
}
$meta = array('host' => ltrim(@mysql_get_host_info($subject), 'MySQL host info: '), 'server_version' => @mysql_get_server_info($subject), 'protocol_version' => @mysql_get_proto_info($subject), 'databases' => $dbs);
break;
示例8: getTimeout
/**
* Get the currently set timeout.
* Returns the actual timeout set.
*
* @access public
* @return int The actual timeout
*/
function getTimeout()
{
return ftp_get_option($this->_handle, FTP_TIMEOUT_SEC);
}
示例9: getRemoteFile
/**
* Lance le téléchargement du fichier par FTP sur le serveur
* @param $directory_file
* @param $server_file
* @return bool
*/
public function getRemoteFile($directory_file, $server_file)
{
$timeout = ftp_get_option($this->ftpConnect(), FTP_TIMEOUT_SEC);
// try to download server_file and save to local_file
if (ftp_get($this->ftpConnect(), $directory_file, $server_file, FTP_BINARY)) {
return true;
} else {
return false;
}
ftp_close($this->ftpConnect());
}
示例10: getOption
/**
* Retrieves various runtime behaviour of the current stream
* @link http://php.net/ftp_get_option
*
* @param integer $option Runtime option. (FTPWrapper::TIMEOUT_SEC, FTPWrapper::AUTOSEEK)
* @return mixed Value on success, FALSE on error
*/
public function getOption($option)
{
return ftp_get_option($this->connection->getStream(), $option);
}
示例11: woo_ce_cron_export
//.........这里部分代码省略.........
// Delete the export file regardless of whether e-mail was successful or not
wp_delete_attachment( $post_ID, true );
error_log( sprintf( '[store-exporter-deluxe] %s: Success: %s', $export->filename, sprintf( __( 'Scheduled export e-mail of %s sent to %s', 'woo_ce' ), $export->filename, $export->to ) ) );
}
if( $gui == 'ftp' ) {
// Load up our FTP/SFTP resources
$host = woo_ce_get_option( 'auto_ftp_method_host', '' );
if( !empty( $host ) )
$host = woo_ce_format_ftp_host( $host );
$port = woo_ce_get_option( 'auto_ftp_method_port', '' );
$port = ( !empty( $port ) ? absint( $port ) : false );
$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 ) );
}
示例12: setOptionValue
/**
* Sets FTP option value
*
* @param int $option Option id. Supported are: <code>FTP_TIMEOUT_SEC</code>, <code>FTP_AUTOSEEK</code>
* @param type $value Value to set
* @throws cFTP_Exception
*
* @return cFTP_Session This
*/
public function setOptionValue( $option, $value )
{
$success = @ftp_get_option($this->handle, $option, $value);
if( $success === false )
throw new cFTP_Exception( "Could not set option value", 10 );
return $this;
}
示例13: getOption
/**
* Retrieves various runtime behaviours of the current FTP stream
* TIMEOUT_SEC | AUTOSEEK
*
* @param mixed $option
*
* @return mixed
*/
public function getOption($option)
{
switch ($option) {
case FTPClient::TIMEOUT_SEC:
case FTPClient::AUTOSEEK:
$result = @ftp_get_option($this->connection, $option);
return $result;
break;
default:
throw new Exception('Unsupported option');
break;
}
}
示例14: var_dump
<?php
$ftp = null;
var_dump(ftp_connect(array()));
var_dump(ftp_connect('127.0.0.1', 0, -3));
var_dump(ftp_raw($ftp));
var_dump(ftp_mkdir($ftp));
var_dump(ftp_rmdir($ftp));
var_dump(ftp_nlist($ftp));
var_dump(ftp_rawlist($ftp));
var_dump(ftp_fget($ftp));
var_dump(ftp_nb_fget($ftp));
var_dump(ftp_nb_get($ftp));
var_dump(ftp_pasv($ftp));
var_dump(ftp_nb_continue());
var_dump(ftp_fput());
var_dump(ftp_nb_fput($ftp));
var_dump(ftp_put($ftp));
var_dump(ftp_nb_put($ftp));
var_dump(ftp_size($ftp));
var_dump(ftp_mdtm($ftp));
var_dump(ftp_rename($ftp));
var_dump(ftp_site($ftp));
var_dump(ftp_set_option($ftp));
var_dump(ftp_get_option($ftp));
示例15: get_option
/**
* 获取FTP选项
*
* @author Garbin
* @param string $option
* @return mixed
*/
function get_option($option)
{
return ftp_get_option($this->_connection, $option);
}