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


PHP Net_SFTP::pwd方法代码示例

本文整理汇总了PHP中Net_SFTP::pwd方法的典型用法代码示例。如果您正苦于以下问题:PHP Net_SFTP::pwd方法的具体用法?PHP Net_SFTP::pwd怎么用?PHP Net_SFTP::pwd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Net_SFTP的用法示例。


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

示例1: _getCurrentDirectory

 /**
  * Return the current directory
  *
  * @return String
  * @throws CMbException
  */
 private function _getCurrentDirectory()
 {
     if (!$this->connexion) {
         throw new CMbException("CSourceSFTP-connexion-failed", $this->hostname);
     }
     if (!($pwd = $this->connexion->pwd())) {
         throw new CMbException("CSourceSFTP-pwd-failed", $this->hostname);
     }
     return $pwd;
 }
开发者ID:fbone,项目名称:mediboard4,代码行数:16,代码来源:CSFTP.class.php

示例2: pwd

 /**
  * Returns the current directory path
  *
  * @return string
  */
 public function pwd()
 {
     switch ($this->_connType) {
         case SftpHelper::TYPE_SFTP:
         default:
             $res = $this->_connection->pwd();
             break;
         case SftpHelper::TYPE_FTP:
             $res = ftp_pwd($this->_connection);
             break;
     }
     return $res;
 }
开发者ID:giovdk21,项目名称:deployii,代码行数:18,代码来源:SftpHelper.php

示例3: connect

 /**
  * @param \Cogeco\Build\Entity\Host $host
  * @return \Net_SFTP
  * @throws \Cogeco\Build\Exception
  */
 public static function connect(Host $host)
 {
     // Throw an exception if no host is provided
     if (empty($host)) {
         throw new Exception(__METHOD__ . "() No host specified");
     }
     // If the connection doesn't already exist, create it
     if (empty(self::$handles[$host->hostname])) {
         self::log("- Starting an SSH session on {$host->hostname} for user {$host->account->username}\n\n");
         self::$handles[$host->hostname] = $handle = new \Net_SFTP($host->hostname);
         if (!$handle->login($host->account->username, $host->account->password)) {
             throw new Exception(__METHOD__ . '() SSH connection failed');
         }
         // Set the home folder, if it isn't explicitly set already
         $homeDirPath = $handle->pwd();
         if (empty($host->homeDirPath) && !empty($homeDirPath)) {
             $host->homeDirPath = $homeDirPath;
         }
     }
     return self::$handles[$host->hostname];
 }
开发者ID:primat,项目名称:deployer-org,代码行数:26,代码来源:SshTask.php

示例4: cwd

 public function cwd()
 {
     $ret = $this->ftp->pwd();
     $ret = rtrim($ret, "/\\");
     return $ret;
 }
开发者ID:grlf,项目名称:eyedock,代码行数:6,代码来源:AdminUpgradeController.php

示例5: uploadToFulfillment

 public function uploadToFulfillment()
 {
     //test
     //return true;
     if (!$this->filePath) {
         return false;
     }
     $fType = $this->fulfillment_zip ? '.zip' : '.csv';
     if ($this->ssl) {
         $sftp = new Net_SFTP($this->server);
         if (!$sftp->login($this->username, $this->password)) {
             echo 'Login Failed';
             return false;
         }
         if (!$sftp->put($sftp->pwd() . $this->upload_path . $this->csvFileName . $fType, $this->filePath, NET_SFTP_LOCAL_FILE)) {
             // Download error
             echo 'error';
             return false;
         }
     } else {
         $ftp = ftp_connect($this->server, $this->port, 20);
         if ($this->username && $this->password) {
             ftp_login($ftp, $this->username, $this->password);
         }
         ftp_pasv($ftp, true);
         // Passive mode
         if (!ftp_put($ftp, $this->upload_path . $this->csvFileName . $fType, $this->filePath, FTP_BINARY)) {
             // Download error
             echo 'error';
             return false;
         }
         ftp_close($ftp);
     }
     return true;
 }
开发者ID:,项目名称:,代码行数:35,代码来源:

示例6: pwd

 /**
  * Get current working directory
  *
  */
 public function pwd()
 {
     return $this->_connection->pwd();
 }
开发者ID:Airmal,项目名称:Magento-Em,代码行数:8,代码来源:Sftp.php

示例7: stream_open

 /**
  * This method is called immediately after the wrapper is initialized
  *
  * Connects to an SFTP server
  *
  * NOTE: This method is not get called by default for the following functions:
  * dir_opendir(), mkdir(), rename(), rmdir(), stream_metadata(), unlink() and url_stat()
  * So I implemented a call to stream_open() at the beginning of the functions and stream_close() at the end
  *
  * The wrapper will also reuse open connections
  *
  * @param String $path
  * @param String $mode
  * @param Integer $options
  * @param String &$opened_path
  * @return bool
  * @access public
  */
 public function stream_open($path, $mode, $options, &$opened_path)
 {
     $url = parse_url($path);
     $host = $url["host"];
     $port = $url["port"];
     $user = $url["user"];
     $pass = $url["pass"];
     $this->path = $url["path"];
     $connection_uuid = md5($host . $port . $user);
     // Generate a unique ID for the current connection
     if (isset(self::$instances[$connection_uuid])) {
         // Get previously established connection
         $this->sftp = self::$instances[$connection_uuid];
     } else {
         //$context = stream_context_get_options($this->context);
         if (!isset($user) || !isset($pass)) {
             return FALSE;
         }
         // Connection
         $sftp = new Net_SFTP($host, isset($port) ? $port : 22);
         if (!$sftp->login($user, $pass)) {
             return FALSE;
         }
         // Store connection instance
         self::$instances[$connection_uuid] = $sftp;
         // Get current connection
         $this->sftp = $sftp;
     }
     $filesize = $this->sftp->size($this->path);
     if (isset($mode)) {
         $this->mode = preg_replace('#[bt]$#', '', $mode);
     } else {
         $this->mode = 'r';
     }
     switch ($this->mode[0]) {
         case 'r':
             $this->position = 0;
             break;
         case 'w':
             $this->position = 0;
             if ($filesize === FALSE) {
                 $this->sftp->touch($this->path);
             } else {
                 $this->sftp->truncate($this->path, 0);
             }
             break;
         case 'a':
             if ($filesize === FALSE) {
                 $this->position = 0;
                 $this->sftp->touch($this->path);
             } else {
                 $this->position = $filesize;
             }
             break;
         case 'c':
             $this->position = 0;
             if ($filesize === FALSE) {
                 $this->sftp->touch($this->path);
             }
             break;
         default:
             return FALSE;
     }
     if ($options == STREAM_USE_PATH) {
         $opened_path = $this->sftp->pwd();
     }
     return TRUE;
 }
开发者ID:floffel03,项目名称:pydio-core,代码行数:86,代码来源:SFTPPSL_StreamWrapper.php

示例8: pwd

 protected function pwd()
 {
     return $this->conn->pwd();
 }
开发者ID:fanqimeng,项目名称:4tweb,代码行数:4,代码来源:PwSftpSave.php

示例9: substr

    if (strlen($order['expiry_date']) == 4) {
        $expiry_date[] = substr($order['expiry_date'], 0, 2);
        $expiry_date[] = '20' . substr($order['expiry_date'], 2, 2);
    } elseif (strlen($order['expiry_date']) == 3) {
        $expiry_date[] = '0' . substr($order['expiry_date'], 0, 1);
        $expiry_date[] = '20' . substr($order['expiry_date'], 1, 2);
    } else {
        $expiry_date[] = '00';
        $expiry_date[] = '0000';
    }
    $expiryDate = implode('/', $expiry_date);
    $csv[] = array($order['order_id'], date("d/m/Y"), 'HHCRBM', $order['product_name'], '', '', $order['fname'], $order['lname'], $order['address1'], $order['address2'], $order['city'], $order['country_name'], $order['zip'], $order['phone'], '', $order['email'], sprintf("%02d", substr($order['created'], 8, 2)) . '/' . sprintf("%02d", substr($order['created'], 5, 2)) . '/' . sprintf("%02d", substr($order['created'], 0, 4)), 'Credit', $arrayNote1['ccn'], $expiryDate, '', '', $arrayNote1['ccc'], 'rocket', '1');
}
$name = 'lj3out_rocket_' . date('Ymdhis');
$path = array('files', 'csv', 'rockets');
$filePath = Csv::saveCsv($csv, $name, $path);
$fileZipPath = AF::path($name, $path, 'zip');
$phpFilePath = AF::path('zip', $path);
system('/usr/bin/php ' . $phpFilePath . ' name=' . $name . ' > /dev/null 2>&1 &');
$sftp = new Net_SFTP($option['server']);
if (!$sftp->login($option['username'], $option['password'])) {
    exit('Login Failed');
}
if (!$sftp->put($sftp->pwd() . $option['uploadPath'] . $name . '.zip', $fileZipPath, NET_SFTP_LOCAL_FILE)) {
    echo 'error';
    die;
}
$sql = "UPDATE `orders` SET `rocket` = 2\n        WHERE `order_id` IN (?a)";
$msql->query($sql, $orderIDs);
unlink($fileZipPath);
unlink($filePath);
开发者ID:,项目名称:,代码行数:31,代码来源:

示例10: sftp_printer

<?php

if (isset($_GET['tID'])) {
    //echo sftp_printer($_GET['tID'].'.xml');
    if (strrpos(get_include_path(), "phpseclib0.3.0") === false) {
        set_include_path(get_include_path() . PATH_SEPARATOR . './phpseclib0.3.0');
        // Staging requires the ../ to be ./
    }
    include 'Net/SFTP.php';
    $sftp = new Net_SFTP('ftp.tginc.com', 2222);
    if (!$sftp->login('flatterbox', 'T&!Fl@!!er')) {
        echo 'Login Failed';
    }
    echo $sftp->pwd();
    //$response = http_get("http://www.whatismyip.com/", array("timeout"=>1), $info);
    $externalContent = file_get_contents('http://checkip.dyndns.com/');
    preg_match('/Current IP Address: \\[?([:.0-9a-fA-F]+)\\]?/', $externalContent, $m);
    $externalIp = $m[1];
    echo '<br/>' . $externalIp;
    //print_r($sftp);
} else {
    echo 'The ring... it is gone...';
}
/* SFTP TO PRINTER */
function sftp_printer($xml_file)
{
    if (strrpos(get_include_path(), "phpseclib0.3.0") === false) {
        set_include_path(get_include_path() . PATH_SEPARATOR . './phpseclib0.3.0');
        // Staging requires the ../ to be ./
    }
    include 'Net/SFTP.php';
开发者ID:avijitdeb,项目名称:flatterbox.com,代码行数:31,代码来源:tmp1234.php

示例11: getConnection

 /**
  * @return \Net_SFTP
  * @throws \Exception
  */
 protected function getConnection()
 {
     if (!$this->connection) {
         $host = $this->config->get(FilesystemConfig::HOST);
         $port = $this->config->get(FilesystemConfig::PORT, 22);
         $username = $this->config->get(FilesystemConfig::USERNAME);
         $password = $this->config->get(FilesystemConfig::PASSWORD, '');
         $key = $this->config->get(self::CONFIG_KEY);
         $keyFile = $this->config->get(self::CONFIG_KEY_FILE);
         $basepath = Util::normalizePath('/' . $this->config->get(FilesystemConfig::BASEPATH, ''));
         if ($keyFile) {
             $key = file_get_contents($keyFile);
         }
         if ($key) {
             $key = new \Crypt_RSA();
             if ($password) {
                 $key->setPassword($password);
             }
             $key->loadKey($key);
             $password = $key;
         }
         $connection = new \Net_SFTP($host, $port);
         if (!$connection->login($username, $password)) {
             throw new \Exception(sprintf('Could not login to %s', $host));
         }
         if ($basepath != '/') {
             $connection->chdir($basepath);
         }
         $this->connection = $connection;
         $this->basepath = $connection->pwd() . '/';
     }
     return $this->connection;
 }
开发者ID:filicious,项目名称:sftp,代码行数:37,代码来源:SFTPAdapter.php

示例12: update_firmware

function update_firmware()
{
    $ssh = new Net_SSH2('192.168.88.1');
    $current_firwmare_version = '';
    if ($ssh->login('admin', '')) {
        $routerboard = $ssh->exec('system resource print');
        preg_match_all('/([^:]*?):([^\\r\\n]*)\\r\\n?/', $routerboard, $matches);
        $output = array_combine(preg_replace('/\\s/', '', $matches[1]), $matches[2]);
        $current_firmware_version = preg_replace("/[^0-9.]/", "", $output['version']);
        logthis('current firmware version: ' . $current_firmware_version);
        $routerboard = $ssh->exec('system routerboard print');
        preg_match_all('/([^:]*?):([^\\r\\n]*)\\r\\n?/', $routerboard, $matches);
        $output = array_combine(preg_replace('/\\s/', '', $matches[1]), $matches[2]);
        $model = 'RB' . preg_replace("/[^0-9]/", "", $output['model']);
        $ssh->disconnect();
        $files = scandir($GLOBALS['firmware_directory']);
        $sftp = new Net_SFTP('192.168.88.1');
        if (!$sftp->login('admin', '')) {
            exit('Login Failed');
        }
        $routeros_file_found = 0;
        foreach ($files as $file) {
            if (strstr($file, 'routeros-' . $GLOBALS['architecture_types'][$model] . '-')) {
                $routeros_file_found = 1;
                $newfw = preg_replace("/.npk/", "", $file);
                $newfw = preg_replace("/[^0-9.]/", "", $newfw);
                if ($current_firmware_version != $newfw) {
                    if ($current_firmware_version > $newfw) {
                        logthis('current firmware is newer than ' . $newfw);
                    } else {
                        logthis('new firmware version: ' . $newfw);
                    }
                } else {
                    logthis('firmware already up to date');
                }
            }
        }
        if ($routeros_file_found == 0) {
            die('no routeros for ' . $GLOBALS['architecture_types'][$model] . ' found.');
        }
        $sftp->pwd();
        foreach ($files as $file) {
            if ($file != '.' && $file != '..') {
                if (strstr($file, $GLOBALS['architecture_types'][$model]) || strstr($file, $model)) {
                    if (!strstr($file, $current_firmware_version . '-') && !strstr($file, $current_firmware_version . '.npk')) {
                        //append a '-' here also check for npk...
                        logthis('sftping file (not using a password): ' . $file);
                        $sftp->put("{$file}", file_get_contents($GLOBALS['firmware_directory'] . $file));
                        $ssh->exec(':beep frequency=137 length=2ms;');
                    }
                }
                if (strstr($file, $model)) {
                    $configfile = $file;
                }
            }
        }
        if (!$configfile) {
            die('no backup for ' . $model . ' found.');
        }
        $ssh = new Net_SSH2('192.168.88.1');
        if ($ssh->login('admin', '')) {
            $todo = $ssh->exec('system reboot');
            logthis($todo);
            $ssh->disconnect();
            logthis('updated firmware (not using a password)');
        }
        return $configfile;
    }
    if ($ssh->login('admin', $GLOBALS['admin_password'])) {
        $routerboard = $ssh->exec('system resource print');
        preg_match_all('/([^:]*?):([^\\r\\n]*)\\r\\n?/', $routerboard, $matches);
        $output = array_combine(preg_replace('/\\s/', '', $matches[1]), $matches[2]);
        $current_firmware_version = preg_replace("/[^0-9.]/", "", $output['version']);
        logthis('current firmware version: ' . $current_firmware_version);
        $routerboard = $ssh->exec('system routerboard print');
        preg_match_all('/([^:]*?):([^\\r\\n]*)\\r\\n?/', $routerboard, $matches);
        $output = array_combine(preg_replace('/\\s/', '', $matches[1]), $matches[2]);
        $model = 'RB' . preg_replace("/[^0-9]/", "", $output['model']);
        $ssh->disconnect();
        $files = scandir($GLOBALS['firmware_directory']);
        $sftp = new Net_SFTP('192.168.88.1');
        if (!$sftp->login('admin', $GLOBALS['admin_password'])) {
            exit('Login Failed');
        }
        foreach ($files as $file) {
            if (strstr($file, 'routeros-' . $GLOBALS['architecture_types'][$model] . '-')) {
                $routeros_file_found = 1;
                $newfw = preg_replace("/.npk/", "", $file);
                $newfw = preg_replace("/[^0-9.]/", "", $newfw);
                if ($current_firmware_version != $newfw) {
                    if ($current_firmware_version > $newfw) {
                        logthis('current firmware is newer than ' . $newfw);
                    } else {
                        logthis('new firmware version: ' . $newfw);
                    }
                } else {
                    logthis('firmware already up to date');
                }
            }
        }
//.........这里部分代码省略.........
开发者ID:jamenlang,项目名称:mikrotik-php,代码行数:101,代码来源:cookiecutter.php


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