Files
@ f43d1a4680a9
Branch filter:
Location: hot67beta/administrator/components/com_media/controllers/folder.php
f43d1a4680a9
3.7 KiB
text/x-php
menubar 0 to 10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | <?php
/**
* @version $Id: folder.php 10456 2008-06-26 17:24:13Z willebil $
* @package Joomla
* @subpackage Media
* @copyright Copyright (C) 2005 - 2008 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( 'Restricted access' );
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* Weblinks Weblink Controller
*
* @package Joomla
* @subpackage Media
* @since 1.5
*/
class MediaControllerFolder extends MediaController
{
/**
* 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 !== JFile::makeSafe($path)) {
JError::raiseWarning(100, JText::_('Unable to delete:').htmlspecialchars($path, ENT_COMPAT, 'UTF-8').' '.JText::_('WARNDIRNAME'));
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);
}
}
/**
* Create a folder
*
* @param string $path Path of the folder to create
* @since 1.5
*/
function create()
{
global $mainframe;
// Check for request forgeries
JRequest::checkToken() or jexit( 'Invalid Token' );
// Set FTP credentials, if given
jimport('joomla.client.helper');
JClientHelper::setCredentialsFromRequest('ftp');
$folder = JRequest::getCmd( 'foldername', '');
$folderCheck = JRequest::getVar( 'foldername', null, '', 'string', JREQUEST_ALLOWRAW);
$parent = JRequest::getVar( 'folderbase', '', '', 'path' );
JRequest::setVar('folder', $parent);
if (($folderCheck !== null) && ($folder !== $folderCheck)) {
$mainframe->redirect('index.php?option=com_media&folder='.$parent, JText::_('WARNDIRNAME'));
}
if (strlen($folder) > 0) {
$path = JPath::clean(COM_MEDIA_BASE.DS.$parent.DS.$folder);
if (!is_dir($path) && !is_file($path))
{
jimport('joomla.filesystem.*');
JFolder::create($path);
JFile::write($path.DS."index.html", "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>");
}
JRequest::setVar('folder', ($parent) ? $parent.'/'.$folder : $folder);
}
$mainframe->redirect('index.php?option=com_media&folder='.$parent);
}
}
|