当前位置: 首页>>代码示例>>PHP>>正文


PHP ftp_set_option函数代码示例

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


在下文中一共展示了ftp_set_option函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 = 'gemeinschaft@gemeinschaft.local';
     }
     $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


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