⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 folder.php

📁 Joomla!是一套获得过多个奖项的内容管理系统(Content Management System, CMS)。Joomla!采用PHP+MySQL数据库开发
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		foreach ($folders as $folder) {			if (is_link($folder)) {				// Don't descend into linked directories, just delete the link.				jimport('joomla.filesystem.file');				if (JFile::delete($folder) !== true) {					// JFile::delete throws an error					return false;				}			} elseif (JFolder::delete($folder) !== true) {				// JFolder::delete throws an error				return false;			}		}		if ($ftpOptions['enabled'] == 1) {			// Connect the FTP client			jimport('joomla.client.ftp');			$ftp = &JFTP::getInstance(				$ftpOptions['host'], $ftpOptions['port'], null,				$ftpOptions['user'], $ftpOptions['pass']			);		}		// In case of restricted permissions we zap it one way or the other		// as long as the owner is either the webserver or the ftp		if (@rmdir($path)) {			$ret = true;		} elseif ($ftpOptions['enabled'] == 1) {			// Translate path and delete			$path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/');			// FTP connector throws an error			$ret = $ftp->delete($path);		} else {			JError::raiseWarning(				'SOME_ERROR_CODE',				'JFolder::delete: ' . JText::_('Could not delete folder'),				'Path: ' . $path			);			$ret = false;		}		return $ret;	}	/**	 * Moves a folder.	 *	 * @param string The path to the source folder.	 * @param string The path to the destination folder.	 * @param string An optional base path to prefix to the file names.	 * @return mixed Error message on false or boolean true on success.	 * @since 1.5	 */	function move($src, $dest, $path = '')	{		// Initialize variables		jimport('joomla.client.helper');		$ftpOptions = JClientHelper::getCredentials('ftp');		if ($path) {			$src = JPath::clean($path . DS . $src);			$dest = JPath::clean($path . DS . $dest);		}		if (!JFolder::exists($src) && !is_writable($src)) {			return JText::_('Cannot find source folder');		}		if (JFolder::exists($dest)) {			return JText::_('Folder already exists');		}		if ($ftpOptions['enabled'] == 1) {			// Connect the FTP client			jimport('joomla.client.ftp');			$ftp = &JFTP::getInstance(				$ftpOptions['host'], $ftpOptions['port'], null,				$ftpOptions['user'], $ftpOptions['pass']			);			//Translate path for the FTP account			$src = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $src), '/');			$dest = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dest), '/');			// Use FTP rename to simulate move			if (!$ftp->rename($src, $dest)) {				return JText::_('Rename failed');			}			$ret = true;		} else {			if (!@rename($src, $dest)) {				return JText::_('Rename failed');			}			$ret = true;		}		return $ret;	}	/**	 * Wrapper for the standard file_exists function	 *	 * @param string Folder name relative to installation dir	 * @return boolean True if path is a folder	 * @since 1.5	 */	function exists($path)	{		return is_dir(JPath::clean($path));	}	/**	 * Utility function to read the files in a folder.	 *	 * @param	string	The path of the folder to read.	 * @param	string	A filter for file names.	 * @param	mixed	True to recursively search into sub-folders, or an	 * integer to specify the maximum depth.	 * @param	boolean	True to return the full path to the file.	 * @param	array	Array with names of files which should not be shown in	 * the result.	 * @return	array	Files in the given folder.	 * @since 1.5	 */	function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS'))	{		// Initialize variables		$arr = array();		// Check to make sure the path valid and clean		$path = JPath::clean($path);		// Is the path a folder?		if (!is_dir($path)) {			JError::raiseWarning(21, 'JFolder::files: ' . JText::_('Path is not a folder'), 'Path: ' . $path);			return false;		}		// read the source directory		$handle = opendir($path);		while (($file = readdir($handle)) !== false)		{			if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {				$dir = $path . DS . $file;				$isDir = is_dir($dir);				if ($isDir) {					if ($recurse) {						if (is_integer($recurse)) {							$arr2 = JFolder::files($dir, $filter, $recurse - 1, $fullpath);						} else {							$arr2 = JFolder::files($dir, $filter, $recurse, $fullpath);						}												$arr = array_merge($arr, $arr2);					}				} else {					if (preg_match("/$filter/", $file)) {						if ($fullpath) {							$arr[] = $path . DS . $file;						} else {							$arr[] = $file;						}					}				}			}		}		closedir($handle);		asort($arr);		return $arr;	}	/**	 * Utility function to read the folders in a folder.	 *	 * @param	string	The path of the folder to read.	 * @param	string	A filter for folder names.	 * @param	mixed	True to recursively search into sub-folders, or an	 * integer to specify the maximum depth.	 * @param	boolean	True to return the full path to the folders.	 * @param	array	Array with names of folders which should not be shown in	 * the result.	 * @return	array	Folders in the given folder.	 * @since 1.5	 */	function folders($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS'))	{		// Initialize variables		$arr = array();		// Check to make sure the path valid and clean		$path = JPath::clean($path);		// Is the path a folder?		if (!is_dir($path)) {			JError::raiseWarning(21, 'JFolder::folder: ' . JText::_('Path is not a folder'), 'Path: ' . $path);			return false;		}		// read the source directory		$handle = opendir($path);		while (($file = readdir($handle)) !== false)		{			if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) {				$dir = $path . DS . $file;				$isDir = is_dir($dir);				if ($isDir) {					// Removes filtered directories					if (preg_match("/$filter/", $file)) {						if ($fullpath) {							$arr[] = $dir;						} else {							$arr[] = $file;						}					}					if ($recurse) {						if (is_integer($recurse)) {							$arr2 = JFolder::folders($dir, $filter, $recurse - 1, $fullpath);						} else {							$arr2 = JFolder::folders($dir, $filter, $recurse, $fullpath);						}												$arr = array_merge($arr, $arr2);					}				}			}		}		closedir($handle);		asort($arr);		return $arr;	}	/**	 * Lists folder in format suitable for tree display.	 *	 * @access	public	 * @param	string	The path of the folder to read.	 * @param	string	A filter for folder names.	 * @param	integer	The maximum number of levels to recursively read,	 * defaults to three.	 * @param	integer	The current level, optional.	 * @param	integer	Unique identifier of the parent folder, if any.	 * @return	array	Folders in the given folder.	 * @since	1.5	 */	function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0)	{		$dirs = array ();		if ($level == 0) {			$GLOBALS['_JFolder_folder_tree_index'] = 0;		}		if ($level < $maxLevel) {			$folders = JFolder::folders($path, $filter);			// first path, index foldernames			foreach ($folders as $name) {				$id = ++$GLOBALS['_JFolder_folder_tree_index'];				$fullName = JPath::clean($path . DS . $name);				$dirs[] = array(					'id' => $id,					'parent' => $parent,					'name' => $name,					'fullname' => $fullName,					'relname' => str_replace(JPATH_ROOT, '', $fullName)				);				$dirs2 = JFolder::listFolderTree($fullName, $filter, $maxLevel, $level + 1, $id);				$dirs = array_merge($dirs, $dirs2);			}		}		return $dirs;	}	/**	 * Makes path name safe to use.	 *	 * @access	public	 * @param	string The full path to sanitise.	 * @return	string The sanitised string.	 * @since	1.5	 */	function makeSafe($path)	{		$ds = (DS == '\\') ? '\\' . DS : DS;		$regex = array('#[^A-Za-z0-9:\_\-' . $ds . ' ]#');		return preg_replace($regex, '', $path);	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -