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

PHP ftp_set_option函数代码示例

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

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



在下文中一共展示了ftp_set_option函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: sftp_connect

function sftp_connect()
{
    global $_SGLOBAL;
    @set_time_limit(0);
    $func = $_SGLOBAL['setting']['ftpssl'] && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect';
    if ($func == 'ftp_connect' && !function_exists('ftp_connect')) {
        runlog('FTP', "FTP NOT SUPPORTED.", 0);
    }
    if ($ftpconnid = @$func($_SGLOBAL['setting']['ftphost'], intval($_SGLOBAL['setting']['ftpport']), 20)) {
        if ($_SGLOBAL['setting']['ftptimeout'] && function_exists('ftp_set_option')) {
            @ftp_set_option($ftpconnid, FTP_TIMEOUT_SEC, $_SGLOBAL['setting']['ftptimeout']);
        }
        if (sftp_login($ftpconnid, $_SGLOBAL['setting']['ftpuser'], $_SGLOBAL['setting']['ftppassword'])) {
            if ($_SGLOBAL['setting']['ftppasv']) {
                sftp_pasv($ftpconnid, TRUE);
            }
            if (sftp_chdir($ftpconnid, $_SGLOBAL['setting']['ftpdir'])) {
                return $ftpconnid;
            } else {
                runlog('FTP', "CHDIR '{$_SGLOBAL[setting][ftpdir]}' ERROR.", 0);
            }
        } else {
            runlog('FTP', '530 NOT LOGGED IN.', 0);
        }
    } else {
        runlog('FTP', "COULDN'T CONNECT TO {$_SGLOBAL[setting][ftphost]}:{$_SGLOBAL[setting][ftpport]}.", 0);
    }
    sftp_close($ftpconnid);
    return -1;
}
开发者ID:NaturalWill,项目名称:UCQA,代码行数:30,代码来源:function_ftp.php


示例2: mconnect

 function mconnect($fhost, $fuser, $fpassword, $fpath, $fport = 21, $fpasv = 0, $timeout = 0, $fssl = 0)
 {
     $func = $fssl && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect';
     if ($func == 'ftp_connect' && !function_exists('ftp_connect')) {
         $this->conn_id = 0;
         return -1;
     }
     if (!($this->conn_id = @$func($fhost, $fport, 20))) {
         $this->conn_id = 0;
         return -2;
     }
     if ($timeout && function_exists('ftp_set_option')) {
         @ftp_set_option($this->conn_id, FTP_TIMEOUT_SEC, $timeout);
     }
     if (@(!ftp_login($this->conn_id, $fuser, $fpassword))) {
         $this->conn_id = 0;
         return -3;
     }
     @ftp_pasv($this->conn_id, $fpasv ? true : false);
     if (!$this->mchdir($fpath)) {
         $this->conn_id = 0;
         return -4;
     }
     return $this->conn_id;
 }
开发者ID:polarlight1989,项目名称:08cms,代码行数:25,代码来源:ftp.fun.php


示例3: _settimeout

	protected function _settimeout($sock) {
		if(!ftp_set_option($sock, FTP_TIMEOUT_SEC, $this->timeout)) {
			$this->pushError('_settimeout', 'ftp set send timeout');
			$this->_quit();
			return false;
		}
		return true;
	}
开发者ID:BackupTheBerlios,项目名称:viscacha-svn,代码行数:8,代码来源:class.FTPClientExtension.php


示例4: connect

 private function connect()
 {
     //prepare connection
     $this->connection = ftp_connect($this->host, $this->port);
     //login to ftp server
     $loginResponse = ftp_login($this->connection, $this->user, $this->pass);
     if (!$this->connection || !$loginResponse) {
         return false;
     }
     ftp_pasv($this->connection, $this->passive);
     ftp_set_option($this->connection, FTP_TIMEOUT_SEC, 300);
 }
开发者ID:mukulmantosh,项目名称:maratus-php-backup,代码行数:12,代码来源:Ftp.php


示例5: dftp_connect

function dftp_connect($ftphost, $ftpuser, $ftppass, $ftppath, $ftpport = 21, $ftpssl = 0, $silent = 0)
{
    global $ftp;
    @set_time_limit(0);
    $ftphost = wipespecial($ftphost);
    $ftpport = intval($ftpport);
    $ftpssl = intval($ftpssl);
    $ftp['timeout'] = intval($ftp['timeout']);
    $func = $ftpssl && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect';
    if ($func == 'ftp_connect' && !function_exists('ftp_connect')) {
        if ($silent) {
            return -4;
        } else {
            errorlog('FTP', "FTP not supported.", 0);
        }
    }
    if ($ftp_conn_id = @$func($ftphost, $ftpport, 20)) {
        if ($ftp['timeout'] && function_exists('ftp_set_option')) {
            @ftp_set_option($ftp_conn_id, FTP_TIMEOUT_SEC, $ftp['timeout']);
        }
        if (dftp_login($ftp_conn_id, $ftpuser, $ftppass)) {
            if ($ftp['pasv']) {
                dftp_pasv($ftp_conn_id, TRUE);
            }
            if (dftp_chdir($ftp_conn_id, $ftppath)) {
                return $ftp_conn_id;
            } else {
                if ($silent) {
                    return -3;
                } else {
                    errorlog('FTP', "Chdir '{$ftppath}' error.", 0);
                }
            }
        } else {
            if ($silent) {
                return -2;
            } else {
                errorlog('FTP', '530 Not logged in.', 0);
            }
        }
    } else {
        if ($silent) {
            return -1;
        } else {
            errorlog('FTP', "Couldn't connect to {$ftphost}:{$ftpport}.", 0);
        }
    }
    dftp_close($ftp_conn_id);
    return -1;
}
开发者ID:BGCX067,项目名称:f2cont-svn-to-git,代码行数:50,代码来源:ftp.func.php


示例6: connect

 /**
  * Establish ftp connection
  *
  * @param $config
  * @return resource
  * @throws \Exception
  */
 public function connect($config)
 {
     if (!isset($config['port'])) {
         $config['port'] = 21;
     }
     $connectionId = ftp_connect($config['host'], $config['port']);
     $loginResponse = ftp_login($connectionId, $config['username'], $config['password']);
     ftp_pasv($connectionId, $config['passive']);
     ftp_set_option($connectionId, FTP_TIMEOUT_SEC, 300);
     if (!$connectionId || !$loginResponse) {
         throw new \Exception('FTP connection has failed!');
     }
     return $connectionId;
 }
开发者ID:LespiletteMaxime,项目名称:laravel-ftp,代码行数:21,代码来源:Ftp.php


示例7: connect

 /**
  * FTP-ftp连接
  *
  * @param array  $config 配置
  *
  * @return bool
  */
 public function connect(array $config)
 {
     $port = isset($config['port']) ? (int) $config['port'] : 21;
     //端口号
     $this->linkid = ftp_connect($config['service'], $port);
     if (!$this->linkid) {
         return false;
     }
     @ftp_set_option($this->linkid, FTP_TIMEOUT_SEC, $this->timeout);
     if (@(!ftp_login($this->linkid, $config['username'], $config['password']))) {
         return false;
     }
     return true;
 }
开发者ID:phpdn,项目名称:framework,代码行数:21,代码来源:Ftp.php


示例8: connect

 /**
  * Creates a new connection to an FTP server.
  *
  * @param array $config
  *
  * @throws \Exception
  *
  * @return resource
  */
 public function connect($config)
 {
     if (!isset($config['port'])) {
         $config['port'] = 21;
     }
     if (!isset($config['passive'])) {
         $config['passive'] = true;
     }
     $connection = ftp_connect($config['host'], $config['port']);
     $response = ftp_login($connection, $config['user'], $config['pass']);
     ftp_pasv($connection, $config['passive']);
     ftp_set_option($connection, FTP_TIMEOUT_SEC, 300);
     if (!$connection || !$response) {
         throw new Exception('FTP Connection Failed');
     }
     return $connection;
 }
开发者ID:bluebaytravel,项目名称:ftp,代码行数:26,代码来源:Ftp.php


示例9: 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;
 }
开发者ID:laiello,项目名称:litepublisher,代码行数:19,代码来源:remote.ftp.class.php


示例10: connect

 function connect($host, $port = null, $user = '', $pass = '')
 {
     $this->disconnect();
     $this->_host = $host;
     $this->_port = $port;
     if (in_array($user, array('', null, false), true)) {
         $user = 'anonymous';
         $pass = '[email protected]';
     }
     $this->_user = $user;
     $this->_pass = $pass;
     if (!extension_loaded('ftp')) {
         gs_log(GS_LOG_WARNING, 'ftp extension for PHP not available');
         $this->_conn_failed = true;
         return false;
     }
     if (!preg_match('/^[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}$/', $this->_host)) {
         $ips = getHostByNameL($this->_host);
         # for some strange reason this is a lot faster than to
         # leave the lookup up to ftp_connect()
         if (!is_array($ips) || count($ips) < 1) {
             gs_log(GS_LOG_WARNING, 'Failed to resolve "' . $this->_host . '"');
             $this->_conn_failed = true;
             return false;
         }
         $this->_host = $ips[0];
     }
     $this->_conn = ftp_connect($this->_host, $this->_port, 4);
     if (!$this->_conn) {
         gs_log(GS_LOG_NOTICE, 'Failed to connect to ftp://' . $this->_host);
         $this->_conn_failed = true;
         return false;
     }
     @ftp_set_option($this->_conn, FTP_TIMEOUT_SEC, 3);
     if (!@ftp_login($this->_conn, $this->_user, $this->_pass)) {
         gs_log(GS_LOG_NOTICE, 'Failed to log in at ftp://' . $this->_host);
         $this->_conn_failed = true;
         @ftp_close($this->_conn);
         return false;
     }
     $this->_connected = true;
     return true;
 }
开发者ID:rkania,项目名称:GS3,代码行数:43,代码来源:ftp-filesize.php


示例11: connect

 public function connect()
 {
     $this->conn_id = ftp_connect($this->host, $this->port, 30);
     if ($this->conn_id === false) {
         return false;
     }
     $result = ftp_login($this->conn_id, $this->username, $this->password);
     if ($result == true) {
         ftp_set_option($this->conn_id, FTP_TIMEOUT_SEC, $this->timeout);
         if ($this->passive == true) {
             ftp_pasv($this->conn_id, true);
         } else {
             ftp_pasv($this->conn_id, false);
         }
         $this->system_type = ftp_systype($this->conn_id);
         return true;
     } else {
         return false;
     }
 }
开发者ID:brandmobility,项目名称:kikbak,代码行数:20,代码来源:ftp.class.php


示例12: connect

 /**
  * 连接FTP
  * @param string $server 服务器名
  * @param integer $port 服务器端口
  * @param string $username 用户名
  * @param string $password 密码
  * @return boolean
  */
 public function connect($server, $username, $password, $port = 21)
 {
     //参数分析
     if (!$server || !$username || !$password) {
         return false;
     }
     $this->link = ftp_connect($server, $port);
     if (!$this->link) {
         $this->falseMessage = '不能连接到FTP!';
         return false;
     }
     @ftp_set_option($this->link, FTP_TIMEOUT_SEC, $this->timeout);
     if (@(!ftp_login($this->link, $username, $password))) {
         $this->falseMessage = '不能登录到FTP!请检查用户名和密码。';
         return false;
     }
     //打开被动模拟
     @ftp_pasv($this->link, 1);
     return true;
 }
开发者ID:chaoyanjie,项目名称:MonkeyPHP,代码行数:28,代码来源:FTPClient.php


示例13: fconnect

 function fconnect($ftphost, $ftpport, $ftpusername, $ftppassword, $ftppath, $ftpssl = 0, $pasv = 0, $tranmode = 0, $timeout = 0, $checkftp = 0)
 {
     $ftphost = $this->wipespecial($ftphost);
     $func = $ftpssl && function_exists('ftp_ssl_connect') ? 'ftp_ssl_connect' : 'ftp_connect';
     $this->ftpconnectid = @$func($ftphost, $ftpport, 20);
     if (!$this->ftpconnectid) {
         if ($checkftp == 1) {
             return 'HostFail';
         }
         echo "Fail to connect ftp host!";
         exit;
     }
     if ($timeout && function_exists('ftp_set_option')) {
         @ftp_set_option($this->ftpconnectid, FTP_TIMEOUT_SEC, $timeout);
     }
     $login = $this->fLogin($ftpusername, $ftppassword);
     if (!$login) {
         if ($checkftp == 1) {
             $this->fExit();
             return 'UserFail';
         }
         echo "The username/password for ftp is error!";
         $this->fExit();
         exit;
     }
     if ($pasv) {
         $this->fPasv(TRUE);
     }
     $ftppath = empty($ftppath) ? '/' : $ftppath;
     $chdir = $this->fChdir($ftppath);
     if (!$chdir) {
         if ($checkftp == 1) {
             $this->fExit();
             return 'PathFail';
         }
         echo "The path for ftp is error!";
         $this->fExit();
         exit;
     }
     $this->ftptranmode = $tranmode ? FTP_ASCII : FTP_BINARY;
 }
开发者ID:novnan,项目名称:meiju,代码行数:41,代码来源:ftp.php


示例14: login

 function login()
 {
     require SYSTEM_ROOT . '/config.remote.php';
     if (!(self::$cid = @ftp_connect($ftp_host, $ftp_port, $ftp_timeout))) {
         //self::halt("Can't connect to FTP server on '$ftp_host'");
         return false;
     }
     if (!@ftp_login(self::$cid, $ftp_user, $ftp_pass)) {
         //self::halt("Can't login to FTP server on '$ftp_host' with username '$ftp_user'");
         return false;
     }
     self::$root = $ftp_root;
     $ftp_host = $ftp_user = $ftp_pass = $ftp_root = $ftp_port = NULL;
     ftp_set_option(self::$cid, FTP_TIMEOUT_SEC, $ftp_timeout);
     ftp_pasv(self::$cid, true);
     if (self::islogin()) {
         return true;
     } else {
         //self::halt("Can't query from FTP server");
         return false;
     }
 }
开发者ID:phateio,项目名称:php-radio-kernel,代码行数:22,代码来源:db_ftp.class.php


示例15: 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;
 }
开发者ID:kuryerov,项目名称:portfolio,代码行数:22,代码来源:class-wp-filesystem-ftpext.php


示例16: 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;
 }
开发者ID:pcbrsites,项目名称:leeflets,代码行数:22,代码来源:ftpext.php


示例17: connect

 public function connect()
 {
     $time_start = time();
     $this->conn_id = ftp_connect($this->host, $this->port, 20);
     if ($this->conn_id) {
         $result = ftp_login($this->conn_id, $this->username, $this->password);
     }
     if (!empty($result)) {
         ftp_set_option($this->conn_id, FTP_TIMEOUT_SEC, $this->timeout);
         ftp_pasv($this->conn_id, $this->passive);
         $this->system_type = ftp_systype($this->conn_id);
         return true;
     } elseif (time() - $time_start > 19) {
         global $updraftplus_admin;
         if (isset($updraftplus_admin->logged) && is_array($updraftplus_admin->logged)) {
             $updraftplus_admin->logged[] = sprintf(__('The %s connection timed out; if you entered the server correctly, then this is usually caused by a firewall blocking the connection - you should check with your web hosting company.', 'updraftplus'), 'FTP');
         } else {
             global $updraftplus;
             $updraftplus->log(sprintf(__('The %s connection timed out; if you entered the server correctly, then this is usually caused by a firewall blocking the connection - you should check with your web hosting company.', 'updraftplus'), 'FTP'), 'error');
         }
     }
     return false;
 }
开发者ID:jeanpage,项目名称:ca_learn,代码行数:23,代码来源:ftp.class.php


示例18: ftp_connect

<?php

require 'server.inc';
$ftp = ftp_connect('127.0.0.1', $port);
ftp_login($ftp, 'user', 'pass');
if (!$ftp) {
    die("Couldn't connect to the server");
}
ftp_set_option($ftp, FTP_AUTOSEEK, false);
$local_file = dirname(__FILE__) . DIRECTORY_SEPARATOR . "ftp_fget_basic1.txt";
$handle = fopen($local_file, 'w');
var_dump(ftp_fget($ftp, $handle, 'fget.txt', FTP_ASCII, FTP_AUTORESUME));
var_dump(file_get_contents($local_file));
@unlink(dirname(__FILE__) . DIRECTORY_SEPARATOR . "ftp_fget_basic1.txt");
开发者ID:alphaxxl,项目名称:hhvm,代码行数:14,代码来源:ftp_fget_basic1.php


示例19: createFTPLink

 protected function createFTPLink()
 {
     // If connexion exist and is still connected
     if (is_array($_SESSION["FTP_CONNEXIONS"]) && array_key_exists($this->repositoryId, $_SESSION["FTP_CONNEXIONS"]) && @ftp_systype($_SESSION["FTP_CONNEXIONS"][$this->repositoryId])) {
         AJXP_Logger::debug("Using stored FTP Session");
         return $_SESSION["FTP_CONNEXIONS"][$this->repositoryId];
     }
     AJXP_Logger::debug("Creating new FTP Session");
     $link = FALSE;
     //Connects to the FTP.
     if ($this->secure) {
         $link = @ftp_ssl_connect($this->host, $this->port);
     } else {
         $link = @ftp_connect($this->host, $this->port);
     }
     if (!$link) {
         throw new AJXP_Exception("Cannot connect to FTP server!");
     }
     //register_shutdown_function('ftp_close', $link);
     @ftp_set_option($link, FTP_TIMEOUT_SEC, 10);
     if (!@ftp_login($link, $this->user, $this->password)) {
         throw new AJXP_Exception("Cannot login to FTP server with user {$this->user}");
     }
     if (!$this->ftpActive) {
         @ftp_pasv($link, true);
         global $_SESSION;
         $_SESSION["ftpPasv"] = "true";
     }
     if (!is_array($_SESSION["FTP_CONNEXIONS"])) {
         $_SESSION["FTP_CONNEXIONS"] = array();
     }
     $_SESSION["FTP_CONNEXIONS"][$this->repositoryId] = $link;
     return $link;
 }
开发者ID:BackupTheBerlios,项目名称:ascore,代码行数:34,代码来源:class.ftpAccessWrapper.php


示例20: connect

 /**
  * Method to connect to a FTP server
  *
  * @access public
  * @param string $host Host to connect to [Default: 127.0.0.1]
  * @param string $port Port to connect on [Default: port 21]
  * @return boolean True if successful
  */
 function connect($host = '127.0.0.1', $port = 21)
 {
     // Initialise variables.
     $errno = null;
     $err = null;
     // If already connected, return
     if (is_resource($this->_conn)) {
         return true;
     }
     // If native FTP support is enabled lets use it...
     if (FTP_NATIVE) {
         $this->_conn = @ftp_connect($host, $port, $this->_timeout);
         if ($this->_conn === false) {
             JError::raiseWarning('30', JText::sprintf('JLIB_CLIENT_ERROR_JFTP_NO_CONNECT', $host, $port));
             return false;
         }
         // Set the timeout for this connection
         ftp_set_option($this->_conn, FTP_TIMEOUT_SEC, $this->_timeout);
         return true;
     }
     // Connect to the FTP server.
     $this->_conn = @fsockopen($host, $port, $errno, $err, $this->_timeout);
     if (!$this->_conn) {
         JError::raiseWarning('30', JText::sprintf('JLIB_CLIENT_ERROR_JFTP_NO_CONNECT_SOCKET', $host, $port, $errno, $err));
         return false;
     }
     // Set the timeout for this connection
     socket_set_timeout($this->_conn, $this->_timeout);
     // Check for welcome response code
     if (!$this->_verifyResponse(220)) {
         JError::raiseWarning('35', JText::sprintf('JLIB_CLIENT_ERROR_JFTP_BAD_RESPONSE', $this->_response));
         return false;
     }
     return true;
 }
开发者ID:akksi,项目名称:jcg,代码行数:43,代码来源:ftp.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
PHP ftp_site函数代码示例发布时间:2022-05-15
下一篇:
PHP ftp_rmdir函数代码示例发布时间: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