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

PHP ftp_connect函数代码示例

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

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



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

示例1: conexion

 /**
  * Establece la conceccion al servidor de FTP
  *
  * @param $servidor_ftp=host  $user=usuario $pass=password $modo=de conexxion por defecto en true
  * @return $id_con identificador de la conexion FTP
  */
 function conexion($servidor_ftp, $user, $pass, $modo = true, $puerto = 21, $tiempoEspera = 360)
 {
     // configurar una conexion o abortar
     // el arroba es para evitar los warning que salgan por pantalla
     if (empty($tiempoEspera)) {
         $tiempoEspera = 90;
     }
     @($id_con = ftp_connect($servidor_ftp, $puerto, $tiempoEspera));
     if (!$id_con || !isset($id_con)) {
         return false;
         //return false conexion no establecida
     } else {
         // Abrir la session con usuario y contraseña
         // el arroba es para evitar los warning que salgan por pantalla
         @($login_result = ftp_login($id_con, $user, $pass));
         if (!$login_result || !isset($login_result)) {
             return false;
             //return false el logueo no fue establecida
         }
     }
     // Habilita o deshabilita el modo pasivo. En modo pasivo, las conexiones de datos son
     // iniciadas por el cliente, en lugar del servidor. Puede requerirse si el cliente se
     // encuentra detrás de un firewall. ftp_pasv() únicamente puede llamarse después de
     // un inicio de sesión exitoso, de otra forma fallará.
     ftp_pasv($id_con, $modo);
     // Verifico que type UNIX (tambien lo toman como valor la mayoria de los servidores windows)
     $res = ftp_systype($id_con);
     //if($res != "UNIX") return false;
     // Se conect OK
     return $id_con;
 }
开发者ID:Nilphy,项目名称:moteguardian,代码行数:37,代码来源:clase.FTPDriver.php


示例2: getListing

 public function getListing()
 {
     $dir = $this->directory;
     // Parse directory to parts
     $parsed_dir = trim($dir, '/');
     $this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
     // Find the path to the parent directory
     if (!empty($parts)) {
         $copy_of_parts = $parts;
         array_pop($copy_of_parts);
         if (!empty($copy_of_parts)) {
             $this->parent_directory = '/' . implode('/', $copy_of_parts);
         } else {
             $this->parent_directory = '/';
         }
     } else {
         $this->parent_directory = '';
     }
     // Connect to the server
     if ($this->ssl) {
         $con = @ftp_ssl_connect($this->host, $this->port);
     } else {
         $con = @ftp_connect($this->host, $this->port);
     }
     if ($con === false) {
         $this->setError(JText::_('FTPBROWSER_ERROR_HOSTNAME'));
         return false;
     }
     // Login
     $result = @ftp_login($con, $this->username, $this->password);
     if ($result === false) {
         $this->setError(JText::_('FTPBROWSER_ERROR_USERPASS'));
         return false;
     }
     // Set the passive mode -- don't care if it fails, though!
     @ftp_pasv($con, $this->passive);
     // Try to chdir to the specified directory
     if (!empty($dir)) {
         $result = @ftp_chdir($con, $dir);
         if ($result === false) {
             $this->setError(JText::_('FTPBROWSER_ERROR_NOACCESS'));
             return false;
         }
     } else {
         $this->directory = @ftp_pwd($con);
         $parsed_dir = trim($this->directory, '/');
         $this->parts = empty($parsed_dir) ? array() : explode('/', $parsed_dir);
         $this->parent_directory = $this->directory;
     }
     // Get a raw directory listing (hoping it's a UNIX server!)
     $list = @ftp_rawlist($con, '.');
     ftp_close($con);
     if ($list === false) {
         $this->setError(JText::_('FTPBROWSER_ERROR_UNSUPPORTED'));
         return false;
     }
     // Parse the raw listing into an array
     $folders = $this->parse_rawlist($list);
     return $folders;
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:60,代码来源:ftpbrowsers.php


示例3: ftp_put_file

function ftp_put_file($remote, $local)
{
    $ftp_host = 'xungeng.vpaas.net';
    $ftp_user = 'root';
    $ftp_pass = 'zehin@123';
    $code = 0;
    $conn_id = ftp_connect($ftp_host);
    if ($conn_id) {
        // try to login
        $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
        if ($login_result) {
            $source_file = $local;
            //源地址
            $destination_file = $remote;
            //目标地址
            $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
            if ($upload) {
                $msg = "success";
                $code = 1;
            } else {
                $msg = "FTP upload has failed!";
            }
        } else {
            $msg = "FTP connection has failed!" . "Attempted to connect to {$ftp_host} for user {$ftp_user}";
        }
    } else {
        $msg = "无法连接到{$ftp_host}";
    }
    ftp_close($conn_id);
    return array('code' => $code, 'msg' => $msg);
}
开发者ID:xinyflove,项目名称:MyPHPFunction,代码行数:31,代码来源:ftp_put_file.php


示例4: connect

 /**
  * Connect to ftp server
  *
  * @return bool
  **/
 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']);
     }
     // switch off extended passive mode - may be usefull for some servers
     //@ftp_exec($this->connect, 'epsv4 off' );
     // enter passive mode if required
     $this->options['mode'] = 'active';
     ftp_pasv($this->connect, $this->options['mode'] == 'passive');
     // enter root folder
     if (!ftp_chdir($this->connect, $this->root)) {
         $this->umount();
         return $this->setError('Unable to open root folder.');
     }
     $stat = array();
     $stat['name'] = $this->root;
     $stat['mime'] = 'directory';
     $this->filesCache[$this->root] = $stat;
     $this->cacheDir($this->root);
     return true;
 }
开发者ID:scorpionx,项目名称:vtt-bundle,代码行数:31,代码来源:elFinderVolumeFTPIIS.php


示例5: isValid

 public function isValid($postData)
 {
     if (!extension_loaded('FTP')) {
         throw new \Exception("No PHP FTP extension found");
     }
     foreach ($this->required as $requiredField) {
         if (empty($postData[$requiredField])) {
             throw new \Exception("Missing Required Fields");
         }
     }
     foreach ($postData as $key => $value) {
         if (empty($postData[$key])) {
             unset($postData[$key]);
         }
     }
     $postData = array_replace_recursive($this->defaults, $postData);
     $connect = ftp_connect($postData['host'], $postData['port']);
     if (!$connect) {
         throw new \Exception("Unable to make connection to host");
     }
     $login = @ftp_login($connect, $postData['user'], $postData['password']);
     if (!$login) {
         throw new \Exception("Unable to login.  Please check the username and password");
     }
     if (!is_writable($postData['tmb_path'])) {
         throw new \Exception("Unable to write to thumbnail directory: " . $postData['tmb_path']);
     }
     return true;
 }
开发者ID:reliv,项目名称:rcm-install,代码行数:29,代码来源:Ftp.php


示例6: connect

 /**
  * 连接FTP服务器
  * @param string $host       服务器地址
  * @param string $username   用户名
  * @param string $password   密码
  * @param integer $port       服务器端口,默认值为21
  * @param boolean $pasv        是否开启被动模式
  * @param boolean $ssl      是否使用SSL连接
  * @param integer $timeout     超时时间 
  */
 public function connect($host, $username = '', $password = '', $port = '21', $pasv = false, $ssl = false, $timeout = 30)
 {
     $start = time();
     if ($ssl) {
         if (!($this->link = @ftp_ssl_connect($host, $port, $timeout))) {
             $this->err_code = 1;
             return false;
         }
     } else {
         if (!($this->link = ftp_connect($host, $port, $timeout))) {
             $this->err_code = 1;
             return false;
         }
     }
     if (ftp_login($this->link, $username, $password)) {
         if ($pasv) {
             ftp_pasv($this->link, true);
         }
         $this->link_time = time() - $start;
         return true;
     } else {
         $this->err_code = 1;
         return false;
     }
     register_shutdown_function(array(&$this, 'close'));
 }
开发者ID:HUST-CA,项目名称:Hustca-Ncre,代码行数:36,代码来源:ftp.cls.php


示例7: __construct

 /**
  * 构造函数,自动连接
  * @access public
  * @param array $config FTP选项
  */
 public function __construct($config)
 {
     if (!function_exists('ftp_connect')) {
         throw new SYException('Ext "FTP" is required', '10023');
     }
     if (!isset($config['port'])) {
         $config['port'] = 21;
     }
     //默认为被动模式
     if (!isset($config['pasv'])) {
         $config['pasv'] = TRUE;
     }
     if (FALSE === ($this->link = ftp_connect($config['host'], $config['port']))) {
         throw new SYException('Can not connect to FTP Server', '10040');
     }
     //登录
     if (isset($config['user'])) {
         if (!ftp_login($this->link, $config['user'], $config['password'])) {
             throw new SYException('Can not login to FTP Server', '10041');
         }
     } else {
         if (!ftp_login($this->link, 'anonymous', '')) {
             throw new SYException('Can not login to FTP Server as anonymous', '10041');
         }
     }
     if ($config['pasv']) {
         ftp_pasv($this->link, TRUE);
     }
     $this->config = $config;
 }
开发者ID:sm115,项目名称:SYFramework,代码行数:35,代码来源:YFtp.php


示例8: __construct

 /**
  * 方法:FTP连接
  * @FTP_HOST -- FTP主机
  * @FTP_PORT -- 端口
  * @FTP_USER -- 用户名
  * @FTP_PASS -- 密码
  */
 function __construct($FTP_HOST, $FTP_PORT, $FTP_USER, $FTP_PASS)
 {
     $this->conn_id = @ftp_connect($FTP_HOST, $FTP_PORT) or die("FTP服务器连接失败");
     @ftp_login($this->conn_id, $FTP_USER, $FTP_PASS) or die("FTP服务器登陆失败");
     @ftp_pasv($this->conn_id, 0);
     // 打开被动模拟
 }
开发者ID:nick198205,项目名称:yiqixiu,代码行数:14,代码来源:Ftp.class.php


示例9: ftp

 public function ftp($host = '', $user = '', $password = '', $rootdir = './', $port = 21)
 {
     if (defined('C_FTP_METHOD')) {
         $this->_method = C_FTP_METHOD;
     }
     if ($this->_method == 'PHP') {
         //echo 'PHPMODE: ';
         $rootdir = LITO_ROOT_PATH;
         if (!is_dir($rootdir)) {
             return false;
         }
         $this->rootdir = preg_replace('!\\/$!', '', $rootdir);
         $this->connected = true;
         $this->lito_root = true;
         //echo 'Useing PHP as a workaround!';
     } else {
         $this->_host = $host;
         $this->_port = $port;
         $this->_user = $user;
         $this->_password = $password;
         if (!@($this->_connection = ftp_connect($this->_host, $this->_port))) {
             return false;
         }
         if (!@ftp_login($this->_connection, $this->_user, $this->_password)) {
             return false;
         }
         $this->connected = true;
         ftp_chdir($this->_connection, $rootdir);
         //if ($this->exists('litotex.php'))
         $this->lito_root = true;
     }
 }
开发者ID:Wehmeyer,项目名称:Litotex-0.7,代码行数:32,代码来源:ftp_class.php


示例10: ftpBackupFile

function ftpBackupFile($source_file, $ftpserver, $ftpuser, $ftppassword)
{
    global $log;
    $FTPOK = 0;
    $NOCONNECTION = 1;
    $NOLOGIN = 2;
    $NOUPLOAD = 3;
    $log->debug("Entering ftpBackupFile(" . $source_file . ", " . $ftpserver . ", " . $ftpuser . ", " . $ftppassword . ") method ...");
    // set up basic connection
    $conn_id = @ftp_connect($ftpserver);
    if (!$conn_id) {
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOCONNECTION;
    }
    // login with username and password
    $login_result = @ftp_login($conn_id, $ftpuser, $ftppassword);
    if (!$login_result) {
        ftp_close($conn_id);
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOLOGIN;
    }
    // upload the file
    $destination_file = basename($source_file);
    $upload = ftp_put($conn_id, $destination_file, $source_file, FTP_BINARY);
    // check upload status
    if (!$upload) {
        ftp_close($conn_id);
        $log->debug("Exiting ftpBackupFile method ...");
        return $NOUPLOAD;
    }
    // close the FTP stream
    ftp_close($conn_id);
    $log->debug("Exiting ftpBackupFile method ...");
    return $FTPOK;
}
开发者ID:casati-dolibarr,项目名称:corebos,代码行数:35,代码来源:ftp.php


示例11: _connect

 /**
  * Connects to FTP server
  *
  * @param string $error
  * @return boolean
  */
 function _connect(&$error)
 {
     if (empty($this->_config['host'])) {
         $error = 'Empty host.';
         return false;
     }
     if (!isset($this->_config['port'])) {
         $this->_config['port'] = 21;
     }
     $this->_ftp = @ftp_connect($this->_config['host'], $this->_config['port'], W3_CDN_FTP_CONNECT_TIMEOUT);
     if (!$this->_ftp) {
         $error = sprintf('Unable to connect to %s:%d.', $this->_config['host'], $this->_config['port']);
         return false;
     }
     if (!@ftp_login($this->_ftp, $this->_config['user'], $this->_config['pass'])) {
         $this->_disconnect();
         $error = 'Incorrect login or password.';
         return false;
     }
     if (isset($this->_config['pasv']) && !@ftp_pasv($this->_ftp, $this->_config['pasv'])) {
         $this->_disconnect();
         $error = 'Unable to change mode to passive.';
         return false;
     }
     if (!empty($this->_config['path']) && !@ftp_chdir($this->_ftp, $this->_config['path'])) {
         $this->_disconnect();
         $error = sprintf('Unable to change directory to: %s.', $this->_config['path']);
         return false;
     }
     return true;
 }
开发者ID:alx,项目名称:SBek-Arak,代码行数:37,代码来源:Ftp.php


示例12: __construct

 /**
  * Connect to FTP server and authenticate via password
  *
  * @since 3.0
  * @throws Exception
  * @return \WC_Customer_Order_CSV_Export_Method_FTP
  */
 public function __construct()
 {
     parent::__construct();
     // Handle errors from ftp_* functions that throw warnings for things like invalid username / password, failed directory changes, and failed data connections
     set_error_handler(array($this, 'handle_errors'));
     // setup connection
     $this->link = null;
     if ('ftps' == $this->security && function_exists('ftp_ssl_connect')) {
         $this->link = ftp_ssl_connect($this->server, $this->port, $this->timeout);
     } elseif ('ftps' !== $this->security) {
         $this->link = ftp_connect($this->server, $this->port, $this->timeout);
     }
     // check for successful connection
     if (!$this->link) {
         throw new Exception(__("Could not connect via FTP to {$this->server} on port {$this->port}, check server address and port.", WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
     }
     // attempt to login, note that incorrect credentials throws an E_WARNING PHP error
     if (!ftp_login($this->link, $this->username, $this->password)) {
         throw new Exception(__("Could not authenticate via FTP with username {$this->username} and password <hidden>. Check username and password.", WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
     }
     // set passive mode if enabled
     if ($this->passive_mode) {
         // check for success
         if (!ftp_pasv($this->link, true)) {
             throw new Exception(__('Could not set passive mode', WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
         }
     }
     // change directories if initial path is populated, note that failing to change directory throws an E_WARNING PHP error
     if ($this->path) {
         // check for success
         if (!ftp_chdir($this->link, '/' . $this->path)) {
             throw new Exception(__("Could not change directory to {$this->path} - check path exists.", WC_Customer_Order_CSV_Export::TEXT_DOMAIN));
         }
     }
 }
开发者ID:daanbakker1995,项目名称:vanteun,代码行数:42,代码来源:class-wc-customer-order-csv-export-method-ftp.php


示例13: downloadFile

 public function downloadFile()
 {
     $requestURL = trim(Mage::getStoreConfig('pulliver/western_power/base_url'), ' /');
     $username = Mage::getStoreConfig('pulliver/western_power/username');
     $password = Mage::getStoreConfig('pulliver/western_power/password');
     $connection = ftp_connect($requestURL);
     if (!$connection) {
         Vikont_Pulliver_Helper_Data::inform(sprintf('Could not connect to %s', $requestURL));
     }
     if (!@ftp_login($connection, $username, $password)) {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('Error logging to FTP %s as %s', $requestURL, $username));
     }
     $remoteFileName = Mage::getStoreConfig('pulliver/western_power/remote_filename');
     $localFileName = $this->getLocalFileName($remoteFileName, 'downloaded/');
     if (file_exists($localFileName)) {
         @unlink($localFileName);
     } else {
         if (!file_exists($dirName = dirname($localFileName))) {
             mkdir($dirName, 0777, true);
         }
     }
     Vikont_Pulliver_Helper_Data::type("Downloading {$requestURL}/{$remoteFileName}...");
     $startedAt = time();
     if (!ftp_get($connection, $localFileName, $remoteFileName, FTP_BINARY)) {
         Vikont_Pulliver_Helper_Data::throwException(sprintf('Error downloading from FTP %s/%s to %s', $requestURL, $remoteFileName, $localFileName));
     }
     ftp_close($connection);
     $timeTaken = time() - $startedAt;
     Vikont_Pulliver_Helper_Data::inform(sprintf('Inventory successfully downloaded from %s/%s to %s, size=%dbytes, time=%ds', $requestURL, $remoteFileName, $localFileName, filesize($localFileName), $timeTaken));
     return $localFileName;
 }
开发者ID:rcclaudrey,项目名称:dev,代码行数:31,代码来源:WesternPower.php


示例14: subida_script

function subida_script($ftp_server, $ftp_user, $ftp_pass)
{
    // set up basic connection
    $conn_id = ftp_connect($ftp_server);
    if (!$conn_id) {
        echo "<div class='alert alert-warning' style='width:300px;margin:auto'>Connection established</div>";
    }
    // login with username and password
    $login_result = ftp_login($conn_id, $ftp_user, $ftp_pass);
    if ($login_result) {
        echo "<div class='alert alert-success' style='width:300px;margin:auto'>Connection established</div>";
    }
    ftp_chdir($conn_id, 'public_html');
    ftp_mkdir($conn_id, 'search');
    ftp_chdir($conn_id, 'search');
    ftp_mkdir($conn_id, 'css');
    ftp_chdir($conn_id, 'css');
    echo ftp_pwd($conn_id);
    ftp_chdir($conn_id, '../../autotienda/search');
    echo ftp_pwd($conn_id);
    //Uploading files...
    //to be uploaded
    $file = "search/.htaccess";
    $fp = fopen($file, 'r');
    ftp_fput($conn_id, $file, $fp, FTP_ASCII);
    echo ftp_pwd($conn_id);
    // close the connection
    ftp_close($conn_id);
    fclose($fp);
}
开发者ID:nuwem,项目名称:fitness,代码行数:30,代码来源:libconfig.php


示例15: upload

 public function upload($filePath, $fileName)
 {
     $details = $this->get_details();
     $this->setServer($details['server']);
     $this->setUsername($details['username']);
     $this->setPassword($details['password']);
     $this->setPort($details['port']);
     $conn_id = ftp_connect($this->server, $this->port);
     $login = ftp_login($conn_id, $this->username, $this->password);
     if ($login) {
         $dir = SNS_FTP_BACKUPS_FOLDER;
         if (!$this->ftp_is_dir($conn_id, $dir)) {
             if (ftp_mkdir($conn_id, $dir) === false) {
                 throw new Sns_Exception_Unavailable_Operation('Cannot create folder ' . $dir . 'on FTP server');
             }
         }
         if (ftp_put($conn_id, $dir . '/' . $fileName, $filePath, FTP_BINARY) === false) {
             throw new Sns_Exception_Unavailable_Operation('Cannot upload file ' . $filePath . 'to FTP server');
         }
     } else {
         throw new Sns_Exception_Unavailable_Operation('Cannot connect to FTP server.');
     }
     if (ftp_close($conn_id) === false) {
         throw new Sns_Exception_Unavailable_Operation('Cannot close connection to FTP server.');
     }
 }
开发者ID:eugenehiggins,项目名称:wordpress-intermediate,代码行数:26,代码来源:Sns_Ftp.php


示例16: open

 /**
  * Connect to FTP Server. Use ssl + passive mode by default.
  *
  * @throws 
  * @see __construct
  * @param string $host
  * @param string $user
  * @param string $pass
  */
 public function open($host, $user, $pass)
 {
     $this->setConf(['host' => $host, 'login' => $user, 'password' => $pass]);
     $required = ['host', 'login', 'password', 'port', 'timeout'];
     foreach ($required as $key) {
         if (empty($this->conf[$key])) {
             throw new Exception('empty conf parameter', $key);
         }
     }
     if ($this->conf['ssl']) {
         $this->ftp = @ftp_ssl_connect($this->conf['host'], $this->conf['port'], $this->conf['timeout']);
     } else {
         $this->ftp = @ftp_connect($this->conf['host'], $this->conf['port'], $this->conf['timeout']);
     }
     if ($this->ftp === false) {
         throw new Exception('FTP connect failed', 'host=' . $this->conf['host'] . ' port=' . $this->conf['port']);
     }
     if (!@ftp_login($this->ftp, $this->conf['login'], $this->conf['password'])) {
         $ssl_msg = $this->conf['ssl'] ? ' - try without ssl' : ' - try with ssl';
         throw new Exception('FTP login failed' . $ssl_msg, 'login=' . $this->conf['login'] . ' password=' . mb_substr($this->conf['password'], 0, 2) . '***');
     }
     if ($this->conf['passive'] && !@ftp_pasv($this->ftp, true)) {
         throw new Exception('Failed to switch to passive FTP mode');
     }
     $this->_log('FTP connected to ' . $this->conf['host']);
 }
开发者ID:RolandKujundzic,项目名称:rkphplib,代码行数:35,代码来源:FTP.class.php


示例17: JSX_PHP_FTP_Directory_List_Get

function JSX_PHP_FTP_Directory_List_Get($p_aConnData, $p_aPathData)
{
    // Connection settings.
    $hostname = $p_aConnData['hostname'];
    $username = $p_aConnData['username'];
    $password = $p_aConnData['password'];
    // Directory settings.
    $startdir = $p_aPathData['startdir'];
    // absolute path
    $suffix = $p_aPathData['suffix'];
    // suffixes to list
    $g_levello = $p_aPathData['levello'];
    // Livello di "nested directory".
    // Data array.
    $files = array();
    // Ftp connection.
    $conn_id = ftp_connect($hostname);
    $login = ftp_login($conn_id, $username, $password);
    if (!$conn_id) {
        echo 'Wrong server!';
        exit;
    } else {
        if (!$login) {
            echo 'Wrong username/password!';
            exit;
        } else {
            // Get data through FTP.
            $files = JSX_PHP_FTP_raw_list($conn_id, $p_aConnData, $p_aPathData, $files);
        }
    }
    // Close FTP connection.
    ftp_close($conn_id);
    // Return value.
    return $files;
}
开发者ID:XrosaXasorX,项目名称:PHP_FTP_FileSystem_RecursiveScan,代码行数:35,代码来源:jsx_include_php.php


示例18: __construct

 /**
  * Opens a new ftp connection to given host.
  * 
  * @param 	string		$host
  * @param 	string		$port
  * @param 	integer		$timeout
  */
 public function __construct($host = 'localhost', $port = 21, $timeout = 30)
 {
     $this->resource = ftp_connect($host, $port, $timeout);
     if ($this->resource === false) {
         throw new SystemException('Can not connect to ' . $host, 11008);
     }
 }
开发者ID:CaribeSoy,项目名称:contest-wcf,代码行数:14,代码来源:FTP.class.php


示例19: connect

 public function connect()
 {
     $this->printLog("Connect");
     if ($this->conn_id = ftp_connect($this->host, $this->port, $this->timeout)) {
         if (ftp_login($this->conn_id, $this->user, $this->pass)) {
             $this->updateState(PR_FTP_STATE_LOGGED_IN);
             if ($status = ftp_chdir($this->conn_id, $this->cur_path)) {
                 $this->updateState(PR_FTP_STATE_TARGETED);
                 $this->updateStatus(PR_FTP_STATUS_READY);
                 $this->systype = ftp_systype($this->conn_id);
                 // TODO: make specific OS dependednt things
                 $this->printLog("OS: " . $this->systype . " " . ftp_pwd($this->conn_id));
                 // TODO: pass the mode into the module
                 ftp_pasv($this->conn_id, true);
                 unset($this->listing_cache);
                 $this->listing_cache = array();
             } else {
                 $this->updateState(PR_FTP_STATE_ERROR);
             }
         } else {
             $this->updateState(PR_FTP_STATE_DISCONNECTED);
             $this->updateStatus(PR_FTP_STATUS_NOT_READY);
         }
     } else {
         $this->updateState(PR_FTP_STATE_DISCONNECTED);
         $this->updateStatus(PR_FTP_STATUS_NOT_READY);
     }
 }
开发者ID:revsm,项目名称:procureor,代码行数:28,代码来源:ftpclient.php


示例20: _getConnexion

 protected function _getConnexion($data)
 {
     if (!empty($this->conn)) {
         return $this->conn;
     }
     if (!array_key_exists('host', $data) || empty($data['host'])) {
         throw new InvalidArgumentException('Veuillez sp&eacute;cifier l\'adresse du serveur FTP');
     }
     if (!array_key_exists('port', $data) || empty($data['port'])) {
         throw new InvalidArgumentException('Veuillez sp&eacute;cifier le port de connexion au serveur FTP');
     }
     if (!array_key_exists('user', $data) || empty($data['host'])) {
         throw new InvalidArgumentException('Veuillez sp&eacute;cifier le nom d\'utilisateur du serveur FTP');
     }
     if (!array_key_exists('password', $data) || empty($data['password'])) {
         throw new InvalidArgumentException('Veuillez sp&eacute;cifier le mot de passe du serveur FTP');
     }
     $conn = @ftp_connect($data['host'], $data['port']);
     if ($conn === false) {
         throw new Exception('Impossible de se connecter au serveur FTP "' . $loginData['host'] . ':' . $loginData['port'] . '"');
     }
     if (@ftp_login($conn, $data['user'], $data['password'])) {
         $this->conn = $conn;
         return $conn;
     } else {
         throw new Exception('Impossible de se connecter au serveur FTP "' . $loginData['host'] . ':' . $loginData['port'] . '" en tant que "' . $loginData['user'] . '"');
     }
 }
开发者ID:Tiger66639,项目名称:symbiose-raspberrypi,代码行数:28,代码来源:FTPController.class.php



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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