本文整理汇总了PHP中ftp_nlist函数的典型用法代码示例。如果您正苦于以下问题:PHP ftp_nlist函数的具体用法?PHP ftp_nlist怎么用?PHP ftp_nlist使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ftp_nlist函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: clean
/**
* @param string $file
*/
private function clean($file)
{
if (ftp_size($this->connection, $file) == -1) {
$result = ftp_nlist($this->connection, $file);
foreach ($result as $childFile) {
$this->clean($childFile);
}
ftp_rmdir($this->connection, $file);
} else {
ftp_delete($this->connection, $file);
}
}
开发者ID:LibraryOfLawrence,项目名称:pagekit,代码行数:15,代码来源:FtpTestCase.php
示例2: getDirListing
function getDirListing($directory = '.', $parameters = '-a')
{
// get contents of the current directory
//$contentsArray = ftp_nlist($this->connectionId, $parameters . ' ' . $directory);
$contentsArray = ftp_nlist($this->connectionId, $directory);
return $contentsArray;
}
开发者ID:rrbaker,项目名称:Ushahidi_IVR_API_Plugin,代码行数:7,代码来源:ftp_class.php
示例3: 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
示例4: GetFTPRoot
static function GetFTPRoot($conn_id, $testDir)
{
$ftp_root = false;
//attempt to find the ftp_root
$testDir = $testDir . '/';
$array = ftp_nlist($conn_id, '.');
if (!$array) {
return false;
}
$possible = array();
foreach ($array as $file) {
if ($file[0] == '.') {
continue;
}
//is the $file within the $testDir.. not the best test..
$pos = strpos($testDir, '/' . $file . '/');
if ($pos === false) {
continue;
}
$possible[] = substr($testDir, $pos);
}
$possible[] = '/';
//test this too
foreach ($possible as $file) {
if (gpftp::TestFTPDir($conn_id, $file, $testDir)) {
$ftp_root = $file;
break;
}
}
return $ftp_root;
}
开发者ID:VTAMAGNO,项目名称:gpEasy-CMS,代码行数:31,代码来源:ftp.php
示例5: ftp_sync
function ftp_sync($dir)
{
global $conn_id;
if ($dir != ".") {
if (ftp_chdir($conn_id, $dir) == false) {
echo "Change Dir Failed: {$dir}<BR>\r\n";
return;
}
if (!is_dir($dir)) {
mkdir($dir);
}
chdir($dir);
}
$contents = ftp_nlist($conn_id, ".");
foreach ($contents as $file) {
if ($file == '.' || $file == '..') {
continue;
}
if (@ftp_chdir($conn_id, $file)) {
ftp_chdir($conn_id, "..");
ftp_sync($file);
} else {
ftp_get($conn_id, $file, $file, FTP_BINARY);
}
}
ftp_chdir($conn_id, "..");
chdir("..");
}
开发者ID:mrj0909,项目名称:sf,代码行数:28,代码来源:ftp_transfer.php
示例6: files
public function files(string $path, string $extension = NULL) : array
{
$list = ftp_nlist($this->connect, $path);
if (!empty($list)) {
foreach ($list as $file) {
if ($file !== '.' && $file !== '..') {
if (!empty($extension) && $extension !== 'dir') {
if (extension($file) === $extension) {
$files[] = $file;
}
} else {
if ($extension === 'dir') {
$extens = extension($file);
if (empty($extens)) {
$files[] = $file;
}
} else {
$files[] = $file;
}
}
}
}
}
if (!empty($files)) {
return $files;
} else {
return [];
}
}
开发者ID:znframework,项目名称:znframework,代码行数:29,代码来源:Info.php
示例7: getFromFTP
public function getFromFTP($ftp, $user, $pass, $dir)
{
$connect = ftp_connect($ftp);
$login_result = ftp_login($connect, $user, $pass);
$contents = ftp_nlist($connect, $dir);
return $contents;
}
开发者ID:anzasolutions,项目名称:radioldn,代码行数:7,代码来源:index.php
示例8: fetchFile
/**
* Fetch data file from Itella FTP server
* @param $type Data file type (PCF = localities, BAF = street addresses, POM = zip code changes)
* @returns Temp file name
*/
public function fetchFile($type)
{
//Connect to FTP server
$ftp = ftp_connect($this->host);
if ($ftp === false) {
throw new Exception("Could not connect to '{$this->host}'");
}
if (!ftp_login($ftp, $this->user, $this->password)) {
throw new Exception("Login to '{$this->host}' as '{$this->user}' failed");
}
//Find filename to download
ftp_pasv($ftp, true);
$list = ftp_nlist($ftp, '.');
$file = null;
foreach ($list as $item) {
$parts = explode('_', $item);
if (isset($parts[0]) && strtoupper($parts[0]) == strtoupper($type)) {
$file = $item;
}
}
if ($file == null) {
throw new Exception("'{$type}' file not found");
}
//Download requested data file
$tmpFile = tempnam(sys_get_temp_dir(), 'FinZip_' . $type . '_') . '.zip';
$this->tmpFiles[] = $tmpFile;
$tmp = fopen($tmpFile, 'w');
ftp_pasv($ftp, true);
ftp_fget($ftp, $tmp, $file, FTP_BINARY);
ftp_close($ftp);
fclose($tmp);
//Return the filename of the temporary file
return $tmpFile;
}
开发者ID:tangervu,项目名称:finzip,代码行数:39,代码来源:FinZip.php
示例9: get_file
/**
* Function that retrieves a file from FTP library and compress it if necessary
*
* @param string $file File name to be retrieved from FTP library
* @return boolean
*/
public function get_file($file, $dir = '')
{
if (!defined("LOCATION") || !defined("CODE") || !defined("LIBRARY") || !defined("CACHE_PATH")) {
$this->container->__error("Imposible recuperar el archivo remoto: falta alguna constante por definir");
return false;
}
$cnn = ftp_connect(LOCATION);
$rs = ftp_login($cnn, LIBRARY, CODE);
if ($rs === false) {
$this->container->__error("Imposible conectar a la libreria de funciones!");
}
$dir = $dir == '' ? '' : $dir . DIRECTORY_SEPARATOR;
ftp_chdir($cnn, LIBRARY . DIRECTORY_SEPARATOR . $dir);
if (@ftp_chdir($cnn, $file) !== false) {
if ($this->container->__debug()) {
@mkdir(CACHE_PATH . $dir . $file);
chmod(CACHE_PATH . $dir . $file, 0777);
$dir = $dir == '' ? $file : $dir . $file;
} else {
@mkdir(CACHE_PATH . $dir . md5($file));
chmod(CACHE_PATH . $dir . md5($file), 0777);
$dir = $dir == '' ? $file : $dir . $file;
}
$files = ftp_nlist($cnn, ".");
foreach ($files as $filea) {
$this->get_file($filea, $dir);
}
return true;
} else {
if ($file == '.' || $file == '..') {
return;
}
if ($this->container->__debug()) {
$aux = ftp_get($cnn, CACHE_PATH . $dir . $file, $file, FTP_BINARY);
} else {
$temp = explode(DIRECTORY_SEPARATOR, $dir);
array_walk($temp, function (&$element, $index) {
$element = md5($element);
});
array_pop($temp);
$temp = implode(DIRECTORY_SEPARATOR, $temp) . DIRECTORY_SEPARATOR;
$aux = ftp_get($cnn, CACHE_PATH . $temp . md5($file), $file, FTP_BINARY);
}
if (!$aux) {
ftp_close($cnn);
$this->container->__error("Imposible obtener el archivo para cache: " . $file);
return false;
} else {
ftp_close($cnn);
if ($this->container->__debug()) {
chmod(CACHE_PATH . $dir . $file, 0777);
$this->compress_cache_file($dir . $file);
} else {
chmod(CACHE_PATH . $temp . md5($file), 0777);
$this->compress_cache_file($temp . md5($file));
}
return true;
}
}
}
开发者ID:fran-diaz,项目名称:ite,代码行数:66,代码来源:cache.php
示例10: getlist
/**
* 获取FTP指定目录列表
*
* @access public
* @param mixed $dir 文件夹
* @return array 返回数组, 内分 [dir] 跟 [file]
*/
public function getlist($dir = '')
{
$dir = !$dir ? $this->dirlink : $dir;
$list = ftp_nlist($this->link, $dir);
if (!$list) {
$this->errormsg = "Can't list this dir";
return FALSE;
} else {
$dirarray = array();
foreach ($list as $value) {
$v = strrchr($value, '/');
if ($v) {
$temp = substr(strrchr($value, '/'), '1');
$path = pathinfo($temp);
if (isset($path['extension']) && $path['extension']) {
$dirarray['file'][] = $temp;
} else {
$dirarray['dir'][] = $temp;
}
} else {
$path = pathinfo($value);
if (isset($path['extension']) && $path['extension']) {
$dirarray['file'][] = $value;
} else {
$dirarray['dir'][] = $value;
}
}
}
}
return $dirarray;
}
开发者ID:knowsee,项目名称:uoke_framework,代码行数:38,代码来源:ftp.class.php
示例11: build_content
function build_content($ftp, $dir)
{
$content_array = array();
$dirs_array = array();
$files_array = array();
$files = ftp_nlist($ftp, $dir);
foreach ($files as $filename) {
$filename = explode('/', $filename);
$filename = $filename[count($filename) - 1];
if ($filename == '.' || $filename == '..') {
continue;
}
$fullname = $filename;
if ($dir != '') {
$fullname = $dir . '/' . $fullname;
}
$filename = utf8_encode($filename);
if (ftp_size($ftp, $fullname) == -1) {
$fullname = utf8_encode($fullname);
$dirs_array[] = array('name' => $filename, 'file' => $fullname, 'is_folder' => 'true');
} else {
$fullname = utf8_encode($fullname);
$files_array[] = array('name' => $filename, 'file' => $fullname, 'icon' => get_icon($filename));
}
}
usort($dirs_array, 'cmp');
usort($files_array, 'cmp');
$content_array = array_merge($dirs_array, $files_array);
return $content_array;
}
开发者ID:hoksi,项目名称:mangolight-editor,代码行数:30,代码来源:list.php
示例12: actionSynchronization
public function actionSynchronization()
{
if (date('w', time()) == 0 || date('w', time()) == 6) {
return;
}
$transfer_src = ftp_connect('91.197.79.112');
$login_result = ftp_login($transfer_src, 'transfer', 'dnUtd74n');
if (!$login_result) {
return false;
}
ftp_pasv($transfer_src, TRUE);
$files = ftp_nlist($transfer_src, ".");
foreach ($files as $file) {
if (!is_file(Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file)) {
$transfer_dst = ftp_connect('37.46.85.148');
$login_result = ftp_login($transfer_dst, 'carakas', 'hokwEw21');
if (!$login_result) {
return false;
}
ftp_pasv($transfer_dst, TRUE);
ftp_get($transfer_src, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, $file, FTP_ASCII);
ftp_put($transfer_dst, $file, Yii::getAlias('@backend/web/') . $this->upload_dir . '/' . $file, FTP_BINARY);
ftp_close($transfer_dst);
}
}
ftp_close($transfer_src);
}
开发者ID:mark38,项目名称:yii2-site-mng,代码行数:27,代码来源:DefaultController.php
示例13: getFileList
public function getFileList($dirname)
{
if (($fileList = ftp_nlist($this->ftpStream, Gpf_Paths::INSTALL_DIR)) == false) {
throw new Gpf_Exception($this->_('Directory %s does not exist', Gpf_Paths::INSTALL_DIR));
}
Gpf_Log::debug('Getting files list: ' . print_r($fileList, true));
return $fileList;
}
开发者ID:AmineCherrai,项目名称:rostanvo,代码行数:8,代码来源:Ftp.class.php
示例14: getFiles
protected function getFiles($remoteDirectory)
{
$files = ftp_nlist($this->connection, $remoteDirectory);
if ($files === false) {
throw new \Exception('Could not get files from directory ' . $remoteDirectory);
}
return $files;
}
开发者ID:henrytrager,项目名称:BackupTask,代码行数:8,代码来源:FtpUpload.php
示例15: getDirNames
public function getDirNames($dir)
{
$direcotryContent = array_map('basename', ftp_nlist($this->conn_id, './Filme/' . $dir));
$direcotoryFolders = array_filter($direcotryContent, function ($var) {
return strpos($var, '.') === false;
});
return $direcotoryFolders;
}
开发者ID:meneman,项目名称:mediathek,代码行数:8,代码来源:FTPFilesystem.php
示例16: exists
function exists($path){
$nlist = ftp_nlist($this->ftp, $path);
if (!is_array($nlist)){
return false;
}
return true;
}
开发者ID:kaspernj,项目名称:knjphpfw,代码行数:9,代码来源:ftp.php
示例17: listFiles
/**
* Get the directories / files list on the current working directory
*
* @throws \Exception If files cannot be listed
*
* @return array|\string[] The list of directories / files contained in the current working directory
*/
public function listFiles() : array
{
ftp_pasv($this->resource, true);
$list = @ftp_nlist($this->resource, ".");
if ($list === false) {
throw new \Exception('Cannot list files from "' . ftp_pwd($this->resource) . '"');
}
return $list;
}
开发者ID:ZiperRom1,项目名称:awesomeChatRoom,代码行数:16,代码来源:ftpFileManager.php
示例18: CheckDir
public static function CheckDir($dirname, $conn)
{
$origin = ftp_pwd($conn);
if (@ftp_chdir($conn, $dirname)) {
ftp_chdir($conn, $origin);
return ftp_nlist($conn, $dirname);
}
return false;
}
开发者ID:KaPJICoH,项目名称:Filesystem,代码行数:9,代码来源:CheckFTP.php
示例19: Ftp_recursivo_descarga_listado_archivos
public function Ftp_recursivo_descarga_listado_archivos($ftpConnection, $path)
{
$contents = ftp_nlist($ftpConnection, $path);
foreach ($contents as $currentFile) {
$archivos = ftp_nlist($ftpConnection, $currentFile);
foreach ($archivos as $archivo) {
$this->descargar_archivos($archivo, $ftpConnection);
}
}
}
开发者ID:bcgarcia,项目名称:WGNOV14,代码行数:10,代码来源:Ftp.php
示例20: ftpFileList
protected function ftpFileList($path)
{
$result;
$conn_id = ftp_connect(FTP_SERVER);
$login_result = ftp_login($conn_id, FTP_USER_NAME, FTP_USER_PASS);
$result = ftp_nlist($conn_id, $path);
// 接続を閉じる
ftp_close($conn_id);
return $result;
}
开发者ID:TaikiFnit,项目名称:CMS-on-PHP-v2,代码行数:10,代码来源:appModel.php
注:本文中的ftp_nlist函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论