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


PHP ssh2_sftp_unlink函数代码示例

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


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

示例1: get_files

 protected function get_files()
 {
     $server = $this->config->config_data['common']['host'];
     $user = $this->config->config_data['common']['user'];
     $password = $this->config->config_data['common']['password'];
     $directory_remote = rtrim($this->config->config_data['import']['remote_basedir'], '/');
     $directory_local = rtrim($this->config->config_data['import']['local_path'], '/');
     $port = 22;
     if (!function_exists("ssh2_connect")) {
         die("function ssh2_connect doesn't exist");
     }
     if (!($connection = ssh2_connect($server, $port))) {
         echo "fail: unable to establish connection\n";
     } else {
         // try to authenticate with username root, password secretpassword
         if (!ssh2_auth_password($connection, $user, $password)) {
             echo "fail: unable to authenticate\n";
         } else {
             // allright, we're in!
             echo "okay: logged in...<br/>";
             // Enter "sftp" mode
             $sftp = @ssh2_sftp($connection);
             // Scan directory
             $files = array();
             echo "Scanning {$directory_remote}<br/>";
             $dir = "ssh2.sftp://{$sftp}{$directory_remote}";
             $handle = opendir($dir);
             while (false !== ($file = readdir($handle))) {
                 if (is_dir($file)) {
                     echo "Directory: {$file}<br/>";
                     continue;
                 }
                 /*						if ($this->debug)
                 						{
                 							$size = filesize("ssh2.sftp://$sftp$directory_remote/$file");
                 							echo "File $file Size: $size<br/>";
                 
                 							$stream = @fopen("ssh2.sftp://$sftp$directory_remote/$file", 'r');
                 							$contents = fread($stream, filesize("ssh2.sftp://$sftp$directory_remote/$file"));
                 							@fclose($stream);
                 							echo "CONTENTS: $contents<br/><br/>";
                 						}
                 */
                 $files[] = $file;
             }
             if ($this->debug) {
                 _debug_array($files);
             } else {
                 foreach ($files as $file_name) {
                     if (stripos($file_name, 'Px205') === 0) {
                         //		_debug_array($file_name);
                         $file_remote = "{$directory_remote}/{$file_name}";
                         $file_local = "{$directory_local}/{$file_name}";
                         $stream = fopen("ssh2.sftp://{$sftp}{$file_remote}", 'r');
                         $contents = fread($stream, filesize("ssh2.sftp://{$sftp}{$file_remote}"));
                         fclose($stream);
                         $fp = fopen($file_local, "wb");
                         fwrite($fp, $contents);
                         if (fclose($fp)) {
                             echo "File remote: {$file_remote} was copied to local: {$file_local}<br/>";
                             if (ssh2_sftp_unlink($sftp, "{$directory_remote}/archive/{$file_name}")) {
                                 echo "Deleted duplicate File remote: {$directory_remote}/archive/{$file_name}<br/>";
                             }
                             if (ssh2_sftp_rename($sftp, $file_remote, "{$directory_remote}/archive/{$file_name}")) {
                                 echo "File remote: {$file_remote} was moved to remote: {$directory_remote}/archive/{$file_name}<br/>";
                             } else {
                                 echo "ERROR! File remote: {$file_remote} failed to move to remote: {$directory_remote}/archive/{$file_name}<br/>";
                                 if (unlink($file_local)) {
                                     echo "Lokal file was deleted: {$file_local}<br/>";
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
 }
开发者ID:HaakonME,项目名称:porticoestate,代码行数:78,代码来源:Import_fra_agresso_X205.php

示例2: delete

 /**
  * @param $filename
  */
 public function delete($filename)
 {
     if ($this->isDir($filename)) {
         ssh2_sftp_rmdir($this->getSftpResource(), $filename);
     } else {
         ssh2_sftp_unlink($this->getSftpResource(), $filename);
     }
 }
开发者ID:brabijan,项目名称:ssh,代码行数:11,代码来源:RemoteFilesystem.php

示例3: delete

 public function delete($filename)
 {
     $sftpResult = @ssh2_sftp_unlink($this->sftpResource, $this->getRemotePath($filename));
     if ($sftpResult) {
         return $this;
     } else {
         throw new ConnectionException('Unable to delete file');
     }
 }
开发者ID:mazhuravlev,项目名称:file-transfer,代码行数:9,代码来源:SFTPConnection.php

示例4: getSFTPPath

 /**
  * Find XE installed path on sftp
  */
 function getSFTPPath()
 {
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = "127.0.0.1";
     }
     if (!$ftp_info->ftp_port || !is_numeric($ftp_info->ftp_port)) {
         $ftp_info->ftp_port = '22';
     }
     $connection = ssh2_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
     if (!ssh2_auth_password($connection, $ftp_info->ftp_user, $ftp_info->ftp_password)) {
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $sftp = ssh2_sftp($connection);
     // create temp file
     $pin = $_SERVER['REQUEST_TIME'];
     FileHandler::writeFile('./files/cache/ftp_check', $pin);
     // create path candidate
     $xe_path = _XE_PATH_;
     $path_info = array_reverse(explode('/', _XE_PATH_));
     array_pop($path_info);
     // remove last '/'
     $path_candidate = array();
     $temp = '';
     foreach ($path_info as $path) {
         $temp = '/' . $path . $temp;
         $path_candidate[] = $temp;
     }
     // try
     foreach ($path_candidate as $path) {
         // upload check file
         if (!@ssh2_scp_send($connection, FileHandler::getRealPath('./files/cache/ftp_check'), $path . 'ftp_check.html')) {
             continue;
         }
         // get check file
         $result = FileHandler::getRemoteResource(getNotencodedFullUrl() . 'ftp_check.html');
         // delete temp check file
         @ssh2_sftp_unlink($sftp, $path . 'ftp_check.html');
         // found
         if ($result == $pin) {
             $found_path = $path;
             break;
         }
     }
     FileHandler::removeFile('./files/cache/ftp_check', $pin);
     if ($found_path) {
         $this->add('found_path', $found_path);
     }
 }
开发者ID:conory,项目名称:rhymix,代码行数:52,代码来源:admin.admin.model.php

示例5: run_script_on_server

function run_script_on_server($script, $server, $user, $public_key_file, $private_key_file)
{
    $con = ssh2_connect($server);
    if ($con === false) {
        return array(false, false);
    }
    $result = ssh2_auth_pubkey_file($con, $user, $public_key_file, $private_key_file);
    if (!$result) {
        return array(false, false);
    }
    $remote_script = basename($script);
    $result = ssh2_scp_send($con, $script, $remote_script, 0700);
    if (!$result) {
        return array(false, false);
    }
    $io_stream = ssh2_exec($con, "( ./{$remote_script} ) 2>&1; echo \$?");
    if ($io_stream) {
        stream_set_blocking($io_stream, true);
        $output = '';
        while (true) {
            $line = fgets($io_stream);
            if ($line === false) {
                break;
            }
            $output .= $line;
        }
        fclose($io_stream);
        $output = rtrim($output);
        $last_newline_index = strrpos($output, "\n");
        $status_code = intval(substr($output, $last_newline_index + 1));
        $output = substr($output, 0, $last_newline_index);
    } else {
        $output = false;
        $status_code = false;
    }
    $sftp_con = ssh2_sftp($con);
    if ($sftp_con) {
        ssh2_sftp_unlink($sftp_con, $remote_script);
    }
    return array($output, $status_code);
}
开发者ID:cleberps,项目名称:linux-learn-map,代码行数:41,代码来源:check.php

示例6: delete

 /**
  * @see Filesystem::delete
  */
 public function delete($path, $recursive = false)
 {
     if ($this->isFile($path)) {
         return ssh2_sftp_unlink($this->sftp_link, $path);
     }
     if (!$recursive) {
         return ssh2_sftp_rmdir($this->sftp_link, $path);
     }
     $filelist = $this->listDir($path);
     if (is_array($filelist)) {
         foreach ($filelist as $filename => $fileinf) {
             $this->delete($path . '/' . $filename, $recursive);
         }
     }
     return ssh2_sftp_rmdir($this->sftpConnection, $path);
 }
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:19,代码来源:Ssh2Filesystem.php

示例7: unlink

 public function unlink($path)
 {
     $path = $this->path($path);
     $return = @ssh2_sftp_unlink($this->getSftpResource(), $path);
     if (!$return) {
         throw new Engine_Vfs_Adapter_Exception(sprintf('Unable to unlink "%s"', $path));
     }
     return true;
 }
开发者ID:febryantosulistyo,项目名称:ClassicSocial,代码行数:9,代码来源:Ssh.php

示例8: delete

 /**
  * @param string $identifier
  * @param bool $recursive
  * @return bool
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function delete($identifier, $recursive)
 {
     if (is_dir($this->sftpWrapper . $identifier)) {
         return ssh2_sftp_rmdir($this->sftp, $identifier);
     } elseif (is_file($this->sftpWrapper . $identifier)) {
         return ssh2_sftp_unlink($this->sftp, $identifier);
     } else {
         return false;
     }
 }
开发者ID:vertexvaar,项目名称:falsftp,代码行数:16,代码来源:PhpSshAdapter.php

示例9: date

 $line_loop1 = 0;
 $line_loop2 = 0;
 //先取回10.10.1.102台鐵資料
 $SFtp_host = '10.10.1.102';
 $SFtp_user = "settlement";
 $SFtp_pass = "allpay10047";
 $File_Name = "Train_Out_" . date("Ymd") . ".txt";
 $File_Name_path = $DirUrlTxt . "/" . $File_Name;
 $connection = ssh2_connect($SFtp_host, 22);
 $login = ssh2_auth_password($connection, $SFtp_user, $SFtp_pass);
 if ($login) {
     $sftp = ssh2_sftp($connection);
     $data = file_get_contents("ssh2.sftp://{$sftp}/{$File_Name}", true);
     $sFTPok = file_put_contents($File_Name_path, $data);
     if ($sFTPok) {
         ssh2_sftp_unlink($sftp, $File_Name);
     } else {
         $FTPechoTO = "由SFTP 10.10.1.102 取回台鐵檔案失敗";
     }
 } else {
     $FTPechoTO = "SFTP 10.10.1.102 連線失敗";
 }
 if (!filesize($File_Name_path)) {
     $msg = $subject . ", " . $FTPechoTO . " 未取得台鐵 " . date("Ymd") . " 關帳檔. 很重要請檢查! by g_Close_china";
     exec_line(1, $msg, 'g_Close_china');
     die($subject . "-" . $FTPechoTO . " \r\n");
 }
 //檔案解密
 FileEncrypt($File_Name_path, 'decrypt');
 //中信新33一般 cup_us!='2'銀聯不處理
 //帳單名稱以 mid_tctb.webname 為主, 除了 GID = 907739 (統宣) 721730 (公司測試店)
开发者ID:sac071213,项目名称:allpay_web,代码行数:31,代码来源:g_Close_china.php

示例10: _removeFile

 /**
  * Remove file
  *
  * @param string $path Path to remove
  * @return Object
  */
 function _removeFile($path)
 {
     if (substr($path, 0, 2) == "./") {
         $path = substr($path, 2);
     }
     $target_path = $this->ftp_info->ftp_root_path . $path;
     if (!@ssh2_sftp_unlink($this->sftp, $target_path)) {
         return new Object(-1, sprintf(Context::getLang('msg_delete_file_failed'), $path));
     }
     return new Object();
 }
开发者ID:Gunmania,项目名称:xe-core,代码行数:17,代码来源:autoinstall.lib.php

示例11: deleteFile

 public function deleteFile(string $path) : bool
 {
     if (@ssh2_sftp_unlink($this->connect, $path)) {
         return true;
     } else {
         throw new FileNotFoundException($path);
     }
 }
开发者ID:znframework,项目名称:znframework,代码行数:8,代码来源:InternalSSH.php

示例12: rm

 /**
  * Delete a file from remote server
  */
 public function rm($remoteFile)
 {
     $file = $this->_getFilename($remoteFile);
     if (!ssh2_sftp_unlink($this->_getSftp(), $file)) {
         throw new \Exception("Could not remove file '{$file}'");
     }
 }
开发者ID:banago,项目名称:bridge,代码行数:10,代码来源:Ssh2.php

示例13: moveFile

 /**
  * Move a file (cut) instead of copy it
  * @return SplFileInfo the file downloaded
  */
 public function moveFile($file, $local)
 {
     $result = $this->downloadFile($file, $local);
     ssh2_sftp_unlink($this->resource, $file);
     return $result;
 }
开发者ID:ducks-project,项目名称:remote-protocol,代码行数:10,代码来源:Sftp.php

示例14: delete

 /**
  * Deletes a remote file.
  *
  * @param string  $remote_path
  * @param boolean $recursive
  *
  * @return boolean Returns TRUE on success or FALSE on error
  *
  * @throws \BackBee\Util\Transport\Exception\TransportException Occures if SSH connection is invalid
  */
 public function delete($remote_path, $recursive = false)
 {
     if (null === $this->_sftp_resource) {
         throw new TransportException(sprintf('None SSH connection available.'));
     }
     if (true === $recursive) {
         // @todo
         throw new TransportException(sprintf('REcursive option not implemented yet.'));
     }
     $remote_path = $this->_getAbsoluteRemotePath($remote_path);
     if (false === @ssh2_sftp_stat($this->_sftp_resource, $remote_path)) {
         return $this->_trigger_error(sprintf('Remote file to delete does not exist: %s.', $remote_path));
     }
     if (false === ssh2_sftp_unlink($this->_sftp_resource, $remote_path)) {
         return ssh2_sftp_rmdir($this->_sftp_resource, $remote_path);
     }
     return true;
 }
开发者ID:mickaelsteinberg,项目名称:BackBee,代码行数:28,代码来源:SFTP.php

示例15: delete

 /**
  * Delete a file (remove it from the disk)
  *
  * @param   string  $fileName  The full path to the file
  *
  * @return  boolean  True on success
  */
 public function delete($fileName)
 {
     $targetFile = $this->translatePath($fileName);
     try {
         $ret = @ssh2_sftp_unlink($this->sftpHandle, $targetFile);
     } catch (\Exception $e) {
         $ret = false;
     }
     return $ret;
 }
开发者ID:edrdesigner,项目名称:awf,代码行数:17,代码来源:Sftp.php


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