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

📄 file.php

📁 Joomla15 - 最新开源CMS
💻 PHP
字号:
<?php/** * @version		$Id: weblink.php 7873 2007-07-05 22:44:21Z friesengeist $ * @package		Joomla * @subpackage	Content * @copyright	Copyright (C) 2005 - 2007 Open Source Matters. All rights reserved. * @license		GNU/GPL, see LICENSE.php * Joomla! is free software. This version may have been modified pursuant to the * GNU General Public License, and as distributed it includes or is derivative * of works licensed under the GNU General Public License or other free or open * source software licenses. See COPYRIGHT.php for copyright notices and * details. */// Check to ensure this file is included in Joomla!defined('_JEXEC') or die();jimport('joomla.filesystem.file');jimport('joomla.filesystem.folder');/** * Weblinks Weblink Controller * * @package		Joomla * @subpackage	Weblinks * @since 1.5 */class MediaControllerFile extends MediaController{	/**	 * Upload a file	 *	 * @since 1.5	 */	function upload()	{		global $mainframe;		$file 		= JRequest::getVar( 'Filedata', '', 'files', 'array' );		$folder		= JRequest::getVar( 'folder', '', '', 'path' );		$format		= JRequest::getVar( 'format', 'html', '', 'cmd');		$return		= JRequest::getVar( 'return-url', null, 'post', 'base64' );		$err		= null;		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		if (isset($file['name'])) {			$filepath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.strtolower($file['name']));			if (!MediaHelper::canUpload( $file, $err )) {				if ($format == 'json') {					jimport('joomla.utilities.log');					$log = &JLog::getInstance('upload.error.php');					$log->addEntry(array('comment' => 'Invalid: '.$filepath.': '.$err));					header('HTTP/1.0 415 Unsupported Media Type');					die('Error. Unsupported Media Type');				} else {					JError::raiseNotice(100, JText::_($err));					// REDIRECT					if ($return) {						$mainframe->redirect(base64_decode($return).'&folder='.$folder);					}					return;				}			}			if (JFile::exists($filepath)) {				if ($format == 'json') {					jimport('joomla.utilities.log');					$log = &JLog::getInstance('upload.error.php');					$log->addEntry(array('comment' => 'File already exists: '.$filepath));					header('HTTP/1.0 409 Conflict');					die('Error. File already exists');				} else {					JError::raiseNotice(100, JText::_('Error. File already exists'));					// REDIRECT					if ($return) {						$mainframe->redirect(base64_decode($return).'&folder='.$folder);					}					return;				}			}			if (!JFile::upload($file['tmp_name'], $filepath)) {				if ($format == 'json') {					jimport('joomla.utilities.log');					$log = &JLog::getInstance('upload.error.php');					$log->addEntry(array('comment' => 'Cannot upload: '.$filepath));					header('HTTP/1.0 400 Bad Request');					die('Error. Unable to upload file');				} else {					JError::raiseWarning(100, JText::_('Error. Unable to upload file'));					// REDIRECT					if ($return) {						$mainframe->redirect(base64_decode($return).'&folder='.$folder);					}					return;				}			} else {				if ($format == 'json') {					jimport('joomla.utilities.log');					$log = &JLog::getInstance();					$log->addEntry(array('comment' => $folder));					die('Upload complete');				} else {					$mainframe->enqueueMessage(JText::_('Upload complete'));					// REDIRECT					if ($return) {						$mainframe->redirect(base64_decode($return).'&folder='.$folder);					}					return;				}			}		} else {			$mainframe->redirect('index.php', 'Invalid Request', 'error');		}	}	/**	 * Deletes paths from the current path	 *	 * @param string $listFolder The image directory to delete a file from	 * @since 1.5	 */	function delete()	{		global $mainframe;		// Set FTP credentials, if given		jimport('joomla.client.helper');		JClientHelper::setCredentialsFromRequest('ftp');		// Get some data from the request		$tmpl	= JRequest::getCmd( 'tmpl' );		$paths	= JRequest::getVar( 'rm', array(), '', 'array' );		$folder = JRequest::getVar( 'folder', '', '', 'path');		// Initialize variables		$msg = array();		$ret = true;		if (count($paths)) {			foreach ($paths as $path)			{				if ($path !== JFilterInput::clean($path, 'path')) {					JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path).' '.JText::_('WARNFILENAME'));					continue;				}				$fullPath = JPath::clean(COM_MEDIA_BASE.DS.$folder.DS.$path);				if (is_file($fullPath)) {					$ret |= !JFile::delete($fullPath);				} else if (is_dir($fullPath)) {					$files = JFolder::files($fullPath, '.', true);					$canDelete = true;					foreach ($files as $file) {						if ($file != 'index.html') {							$canDelete = false;						}					}					if ($canDelete) {						$ret |= !JFolder::delete($fullPath);					} else {						JError::raiseWarning(100, JText::_('Unable to delete:').$fullPath.' '.JText::_('Not Empty!'));					}				}			}		}		if ($tmpl == 'component') {			// We are inside the iframe			$mainframe->redirect('index.php?option=com_media&view=mediaList&folder='.$folder.'&tmpl=component');		} else {			$mainframe->redirect('index.php?option=com_media&folder='.$folder);		}	}}

⌨️ 快捷键说明

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