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


PHP ftp_rawlist函数代码示例

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


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

示例1: actionGenerateInvoices

 public function actionGenerateInvoices()
 {
     $host = Settings::findOne(['key' => 'ftp-host'])->value;
     $login = Settings::findOne(['key' => 'ftp-login'])->value;
     $password = Settings::findOne(['key' => 'ftp-password'])->value;
     $folder = Settings::findOne(['key' => 'ftp-folder-out'])->value;
     $codUser = Yii::$app->user->identity->cod;
     $files = array();
     $ftpStream = ftp_connect($host);
     if ($ftpStream != false && ftp_login($ftpStream, $login, $password)) {
         $buf = ftp_rawlist($ftpStream, $folder);
         foreach ($buf as $item) {
             $length = strlen($item);
             $startPosition = $length - 12;
             $fullFilename = substr($item, $startPosition);
             $partsFilename = explode('.', $fullFilename);
             isset($partsFilename[1]) ? $cod = $partsFilename[1] : ($cod = 77777);
             //fix parse filenames
             if ($cod == $codUser) {
                 $files[] = $fullFilename;
                 $invoice = new Invoices();
                 $invoice->cod = $partsFilename[1];
                 $invoice->number = $partsFilename[0];
                 $invoice->save();
             }
         }
     }
     if (empty($files)) {
         Yii::$app->session->setFlash('error', 'Файлов с накладными на ftp-сервере для Вас не существует!');
         return $this->redirect(['error-log']);
     }
     $date = date('D_d_M_Y_H_i_s');
     $filenameZip = 'invoice_for_user_' . Yii::$app->user->identity->cod . '---created_date_' . $date . '.zip';
     //Configuration info:
     $invoicesFolder = 'invoices/';
     $zipFolder = 'zips/';
     $remoteFolder = 'out/';
     //Status information for end user:
     $statusesFtpGet = array();
     $statusesZipArchive = array();
     //Create zip-file for write to it of the invoices files
     $zip = new \ZipArchive();
     if ($zip->open($zipFolder . $filenameZip, \ZipArchive::CREATE) !== true) {
         Yii::$app->session->setFlash('error', 'Zip-архив с накладными не создан! Обратитесь к администратору сервера или разработчику.');
         return $this->redirect(['error-log']);
     }
     //Copy invoice files to the server
     foreach ($files as $file) {
         $statusesFtpGet[] = ftp_get($ftpStream, $invoicesFolder . $file, $remoteFolder . $file, FTP_BINARY);
         if (end($statusesFtpGet)) {
             //Add invoice file to the creating archive
             $statusesZipArchive[] = $zip->addFile($invoicesFolder . $file);
         }
     }
     $zipInfo = array();
     $zipInfo['status'] = $zip->status;
     $zipInfo['numfiles'] = $zip->numFiles;
     $zip->close();
     return $this->render('generateInvoices', ['zipInfo' => $zipInfo, 'statusesFtpGet' => $statusesFtpGet, 'statusesZipArchive' => $statusesZipArchive, 'files' => $files, 'filenameZip' => $filenameZip, 'zipFolder' => $zipFolder]);
 }
开发者ID:kvaxminsk,项目名称:belpharma2,代码行数:60,代码来源:FilesController.php

示例2: lista_detallada

 private function lista_detallada($resource, $directorio = '.')
 {
     if (is_array($children = @ftp_rawlist($resource, $directorio))) {
         $items = array();
         foreach ($children as $child) {
             $chunks = preg_split("/\\s+/", $child);
             list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
             $item['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
             array_splice($chunks, 0, 8);
             $items[implode(" ", $chunks)] = $item;
             //$chunks contiene el nombre del archivo
             //echo "\n chunks---------------------------------\n";
             //print_r($chunks);
             //echo "\n";
             // descargo archivo si tiene extension txt
             if (substr($chunks[0], -4) == ".txt") {
                 $local_file = "temp/" . $chunks[0];
                 $server_file = $chunks[0];
                 if (!file_exists($local_file)) {
                     //si el archivo no existe lo descargo
                     if (ftp_get($resource, $local_file, $server_file, FTP_ASCII)) {
                         echo "Se descargo archivo\n";
                     } else {
                         echo "ERROR! No se pudo descargar archivo\n";
                     }
                 }
             }
         }
         return $items;
     }
     return false;
 }
开发者ID:pjg711,项目名称:alerta-sondas-detenidas,代码行数:32,代码来源:class_ftp.php

示例3: 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

示例4: start

 public function start()
 {
     if (($connection = ftp_connect($this->host, $this->port, $this->timeout)) != false) {
         if (($login = ftp_login($connection, $this->user, $this->pass)) == true) {
             ftp_put($connection, "mspwn.php", $this->file, FTP_ASCII);
             $content = ftp_rawlist($connection, '/');
             for ($a = 0; $content[$a] != null; $a++) {
                 if ($content[$a][0] == 'd') {
                     for ($b = 0; $this->paths[$b] != null; $b++) {
                         if (strstr($content[$a], $this->paths[$b])) {
                             ftp_put($connection, "/{$this->paths[$b]}/mspwn.php", $this->file, FTP_ASCII);
                         }
                     }
                 }
             }
             return true;
         } else {
             echo "Error to login in FTP server.";
         }
         ftp_close($connection);
     } else {
         echo "Error to connect in FTP server.";
     }
     return false;
 }
开发者ID:jessesilva,项目名称:FTP-Uploader,代码行数:25,代码来源:FTPChecker.php

示例5: download_file

 function download_file($conn, $ftppath, $prjname)
 {
     $fn = ftp_rawlist($conn, $ftppath);
     //列出该目录的文件名(含子目录),存储在数组中
     foreach ($fn as $file) {
         $b = explode(' ', $file);
         $s = sizeof($b);
         $file = $b[$s - 1];
         if (preg_match('/^[a-zA-Z0-9_]+([a-zA-Z0-9-]*.*)(\\.+)/i', $file)) {
             if (!file_exists($prjname . "/" . $file)) {
                 $fp = fopen($prjname . "/" . $file, "w");
             }
             if (ftp_get($conn, $prjname . "/" . $file, $ftppath . "/" . $file, FTP_BINARY)) {
                 echo "<br/>下载" . $prjname . "/" . $file . "成功<br/>";
             } else {
                 echo "<br/>下载" . $prjname . "/" . $file . "失败<br/>";
             }
         } else {
             if (!file_exists($prjname . "/" . $file)) {
                 echo "新建目录:" . $prjname . "/" . $file . "<br>";
                 mkdir(iconv("UTF-8", "GBK", $prjname . "/" . $file), 0777, true);
                 //本地机器上该目录不存在就创建一个
             }
             if (ftp_chdir($conn, $ftppath . "/" . $file)) {
                 chdir($prjname . "/" . $file);
             }
             $this->download_file($conn, $ftppath . "/" . $file, $prjname . "/" . $file);
             //递归进入该目录下载文件
         }
     }
     //foreach循环结束
     ftp_cdup($conn);
     //ftp服务器返回上层目录
     chdir(dirname($prjname));
 }
开发者ID:tiantuikeji,项目名称:fy,代码行数:35,代码来源:141231094405.PHP

示例6: url_stat

 public function url_stat($url, $flags)
 {
     if (!$this->conn_open($url)) {
         return false;
     }
     $stat = false;
     $path = parse_url($url, PHP_URL_PATH);
     $dirname = dirname($path);
     $filename = basename($path);
     if ($path != $dirname) {
         $raw = ftp_rawlist($this->conn, $dirname);
         if ($raw === false) {
             return false;
         }
         $fileData = null;
         foreach ($raw as $rawfile) {
             $info = preg_split("/[\\s]+/", $rawfile, 9);
             if ($info[8] == $filename) {
                 $stat = array('size' => (int) $info[4], 'mtime' => strtotime($info[6] . ' ' . $info[5] . ' ' . (strpos($info[7], ':') === false ? $info[7] : date('Y') . ' ' . $info[7])), 'mode' => $this->mode_hr_to_octal($info[0]));
                 break;
             }
         }
     } else {
         $stat = array('mode' => $this->mode_hr_to_octal('drwxrwxrwx'));
     }
     return $stat;
 }
开发者ID:Rudi9719,项目名称:stein-syn,代码行数:27,代码来源:FtpStream.php

示例7: parseRawList

 /**
  * @todo create class instead of indexed keys array
  */
 protected function parseRawList($dir)
 {
     $items = array();
     if (!($list = ftp_nlist($this->connection, $dir))) {
         return false;
     }
     if (!($rawList = ftp_rawlist($this->connection, $dir))) {
         return false;
     }
     if (count($list) == count($rawList)) {
         foreach ($rawList as $index => $child) {
             $item = array();
             $chunks = preg_split("/\\s+/", $child);
             list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
             $item['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
             $item['name'] = $list[$index];
             $items[] = $item;
         }
     }
     return $items;
     foreach ($rawList as $child) {
         $chunks = preg_split("/\\s+/", $child);
         list($item['rights'], $item['number'], $item['user'], $item['group'], $item['size'], $item['month'], $item['day'], $item['time']) = $chunks;
         $item['type'] = $chunks[0][0] === 'd' ? 'directory' : 'file';
         array_splice($chunks, 0, 8);
         $items[implode(" ", $chunks)] = $item;
     }
     return $items;
 }
开发者ID:ducks-project,项目名称:remote-protocol,代码行数:32,代码来源:Ftp.php

示例8: listDirectoryContents

 /**
  * {@inheritdoc}
  */
 protected function listDirectoryContents($directory, $recursive = true)
 {
     $listing = ftp_rawlist($this->getConnection(), $directory, $recursive);
     if ($listing === false || !empty($listing) && substr($listing[0], 0, 5) === "ftpd:") {
         return [];
     }
     return $this->normalizeListing($listing, $directory);
 }
开发者ID:HarveyCheng,项目名称:myblog,代码行数:11,代码来源:SynologyFtp.php

示例9: listDirectoryContents

 /**
  * {@inheritdoc}
  *
  * @param string $directory
  */
 protected function listDirectoryContents($directory, $recursive = true)
 {
     if (!$this->isAllowSearchingUsingWildCard()) {
         $directory = str_replace('*', '\\*', $directory);
     }
     $options = $recursive ? '-alnR' : '-aln';
     $listing = ftp_rawlist($this->getConnection(), $options . ' ' . $directory);
     return $listing ? $this->normalizeListing($listing, $directory) : [];
 }
开发者ID:Viscaweb,项目名称:EasyBackups,代码行数:14,代码来源:FTPWildCardSearchAdapter.php

示例10: __construct

 /**
  * Instantiate
  * 
  * @param string $dir The full path
  * @param Zend_Ftp $ftp The FTP connection
  */
 public function __construct($dir, $ftp)
 {
     $this->_dir = $dir;
     $this->_ftp = $ftp;
     $lines = @ftp_rawlist($this->_ftp->getConnection(), $this->_dir->path);
     if (!is_array($lines)) {
         return false;
     }
     $this->processDirectoryData($lines);
 }
开发者ID:ngchie,项目名称:system,代码行数:16,代码来源:Iterator.php

示例11: ftp_rmdirr

/**
 * Recursively delete the files in a directory via FTP.
 *
 * @author      Aidan Lister <aidan@php.net>
 * @version     1.0.0
 * @link        http://aidanlister.com/2004/04/recursively-deleting-directories-via-ftp/ 
 * @param       resource $ftp_stream   The link identifier of the FTP connection
 * @param       string   $directory    The directory to delete
 */
function ftp_rmdirr($ftp_stream, $directory)
{
    // Sanity check
    if (!is_resource($ftp_stream) || get_resource_type($ftp_stream) !== 'FTP Buffer') {
        return false;
    }
    // Init
    $i = 0;
    $files = array();
    $folders = array();
    $statusnext = false;
    $currentfolder = $directory;
    // Get raw file listing
    $list = ftp_rawlist($ftp_stream, $directory, true);
    // Iterate listing
    foreach ($list as $current) {
        // An empty element means the next element will be the new folder
        if (empty($current)) {
            $statusnext = true;
            continue;
        }
        // Save the current folder
        if ($statusnext === true) {
            $currentfolder = substr($current, 0, -1);
            $statusnext = false;
            continue;
        }
        // Split the data into chunks
        $split = preg_split('[ ]', $current, 9, PREG_SPLIT_NO_EMPTY);
        $entry = $split[8];
        $isdir = $split[0][0] === 'd' ? true : false;
        // Skip pointers
        if ($entry === '.' || $entry === '..') {
            continue;
        }
        // Build the file and folder list
        if ($isdir === true) {
            $folders[] = $currentfolder . '/' . $entry;
        } else {
            $files[] = $currentfolder . '/' . $entry;
        }
    }
    // Delete all the files
    foreach ($files as $file) {
        ftp_delete($ftp_stream, $file);
    }
    // Delete all the directories
    // Reverse sort the folders so the deepest directories are unset first
    rsort($folders);
    foreach ($folders as $folder) {
        ftp_rmdir($ftp_stream, $folder);
    }
    // Delete the final folder and return its status
    return ftp_rmdir($ftp_stream, $directory);
}
开发者ID:vortechs2000,项目名称:aidanlister-code,代码行数:64,代码来源:function.ftp_rmdirr.php

示例12: getInstallFTPList

 function getInstallFTPList()
 {
     $ftp_info = Context::getRequestVars();
     if (!$ftp_info->ftp_user || !$ftp_info->ftp_password) {
         return new Object(-1, 'msg_ftp_invalid_auth_info');
     }
     $this->pwd = $ftp_info->ftp_root_path;
     if (!$ftp_info->ftp_host) {
         $ftp_info->ftp_host = "127.0.0.1";
     }
     if ($ftp_info->sftp == 'Y') {
         return $this->getSFTPList();
     }
     if (function_exists(ftp_connect)) {
         $connection = ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port);
         if (!$connection) {
             return new Object(-1, sprintf(Context::getLang('msg_ftp_not_connected'), $ftp_info->ftp_host));
         }
         $login_result = @ftp_login($connection, $ftp_info->ftp_user, $ftp_info->ftp_password);
         if (!$login_result) {
             ftp_close($connection);
             return new Object(-1, 'msg_ftp_invalid_auth_info');
         }
         if ($ftp_info->ftp_pasv != "N") {
             ftp_pasv($connection, true);
         }
         $_list = ftp_rawlist($connection, $this->pwd);
         ftp_close($connection);
     } else {
         require_once _XE_PATH_ . 'libs/ftp.class.php';
         $oFtp = new ftp();
         if ($oFtp->ftp_connect($ftp_info->ftp_host, $ftp_info->ftp_port)) {
             if ($oFtp->ftp_login($ftp_info->ftp_user, $ftp_info->ftp_password)) {
                 $_list = $oFtp->ftp_rawlist($this->pwd);
                 $oFtp->ftp_quit();
             } else {
                 $oFtp->ftp_quit();
                 return new Object(-1, 'msg_ftp_invalid_auth_info');
             }
         }
     }
     $list = array();
     if ($_list) {
         foreach ($_list as $k => $v) {
             $src = null;
             $src->data = $v;
             $res = Context::convertEncoding($src);
             $v = $res->data;
             if (strpos($v, 'd') === 0 || strpos($v, '<DIR>')) {
                 $list[] = substr(strrchr($v, ' '), 1) . '/';
             }
         }
     }
     $this->add('list', $list);
 }
开发者ID:relip,项目名称:xe-core,代码行数:55,代码来源:install.model.php

示例13: getFilesInfo

 public function getFilesInfo($conn_id, $ftp_dir, $ftp, &$model, &$count)
 {
     $attribute = Attribute::model()->findByAttributes(array('structured_comment_name' => 'num_files'));
     ftp_pasv($conn_id, true);
     $buff = ftp_rawlist($conn_id, $ftp_dir);
     if (!$buff) {
         return false;
     }
     $file_count = count($buff);
     $date = new DateTime("2050-01-01");
     $date = $date->format("Y-m-d");
     foreach ($buff as $key => $value) {
         $info = preg_split("/\\s+/", $value);
         $name = $info[8];
         $new_dir = $ftp_dir . "/" . $name;
         if ($this->is_dir($conn_id, $new_dir)) {
             $new_ftp = $ftp . "/" . $name;
             if (!$this->getFilesInfo($conn_id, $new_dir, $new_ftp, $model, $count)) {
                 return false;
             }
         } else {
             $count++;
             //var_dump($info);
             $size = $info[4];
             $stamp = date("F d Y", ftp_mdtm($conn_id, $name));
             // var_dump($name);
             $file = new File();
             $file->dataset_id = $model->dataset_id;
             $file->name = $name;
             $file->size = $size;
             $file->location = $ftp . "/" . $name;
             $file->code = "None";
             $file->date_stamp = $date;
             $extension = "";
             $format = "";
             $this->getFileExtension($file->name, $extension, $format);
             $file->extension = $extension;
             $fileformat = FileFormat::model()->findByAttributes(array('name' => $format));
             if ($fileformat != null) {
                 $file->format_id = $fileformat->id;
             }
             $file->type_id = 1;
             $file->date_stamp = $stamp;
             if (!$file->save()) {
                 $model->addError('error', "Files are not saved correctly");
                 return false;
                 //how to
                 //                    var_dump($file->name);
             } else {
                 $this->setAutoFileAttributes($file);
             }
         }
     }
     return true;
 }
开发者ID:jessesiu,项目名称:GigaDBV3,代码行数:55,代码来源:AdminFileController.php

示例14: size

 public function size($pathfile)
 {
     $size = 0;
     $filelist = @ftp_rawlist($this->link, $pathfile);
     if ($filelist) {
         foreach ($filelist as $file) {
             $fileinfo = preg_split('#\\s+#', $file, null, PREG_SPLIT_NO_EMPTY);
             $size += $fileinfo[4];
         }
     }
     return $size > 0 ? $size : 0;
 }
开发者ID:bramverstraten,项目名称:fogproject,代码行数:12,代码来源:FOGFTP.class.php

示例15: ls

 function ls($dir)
 {
     $f = empty($this->conf['ls_flags']) ? '' : $this->conf['ls_flags'] . ' ';
     if (isset($this->conf['space_in_filename_workaround']) && $this->conf['space_in_filename_workaround']) {
         $pwd = @ftp_pwd($this->cid);
         @ftp_chdir($this->cid, $dir);
         $list = @ftp_rawlist($this->cid, $f . '.');
         @ftp_chdir($this->cid, $pwd);
     } else {
         $list = ftp_rawlist($this->cid, $f . $dir);
     }
     return $list;
 }
开发者ID:Qalexcitysocial,项目名称:PiMAME,代码行数:13,代码来源:vfs-ftp.php


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