| Current Path : /home/w/u/e/wuectly/www/03cbe/ |
| Current File : /home/w/u/e/wuectly/www/03cbe/com_media.zip |
PK qq!](\� � media.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2005 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$input = JFactory::getApplication()->input;
$user = JFactory::getUser();
$asset = $input->get('asset');
$author = $input->get('author');
// Access check.
if (!$user->authorise('core.manage', 'com_media') && (!$asset || (!$user->authorise('core.edit', $asset)
&& !$user->authorise('core.create', $asset)
&& count($user->getAuthorisedCategories($asset, 'core.create')) == 0)
&& !($user->id == $author && $user->authorise('core.edit.own', $asset))))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$params = JComponentHelper::getParams('com_media');
// Load the helper class
JLoader::register('MediaHelper', JPATH_ADMINISTRATOR . '/components/com_media/helpers/media.php');
// Set the path definitions
$popup_upload = $input->get('pop_up', null);
$path = 'file_path';
$view = $input->get('view');
if (substr(strtolower($view), 0, 6) == 'images' || $popup_upload == 1)
{
$path = 'image_path';
}
$mediaBaseDir = JPATH_ROOT . '/' . $params->get($path, 'images');
if (!is_dir($mediaBaseDir))
{
throw new \InvalidArgumentException(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 500);
}
define('COM_MEDIA_BASE', $mediaBaseDir);
define('COM_MEDIA_BASEURL', JUri::root() . $params->get($path, 'images'));
$controller = JControllerLegacy::getInstance('Media', array('base_path' => JPATH_COMPONENT_ADMINISTRATOR));
$controller->execute($input->get('task'));
$controller->redirect();
PK �}!]��b b medialist/thumbs_folders.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<?php foreach ($this->folders as $i => $folder) : ?>
<li class="imgOutline thumbnail height-80 width-80 center">
<?php if ($this->canDelete):?>
<a class="close delete-item" target="_top" href="index.php?option=com_media&task=folder.delete&tmpl=index&<?php echo JSession::getFormToken(); ?>=1&folder=<?php echo rawurlencode($this->state->folder); ?>&rm[]=<?php echo $this->escape($folder->name); ?>" rel="<?php echo $this->escape($folder->name); ?> :: <?php echo $this->escape($folder->files) + $this->escape($folder->folders); ?>" title="<?php echo JText::_('JACTION_DELETE');?>">×</a>
<div class="pull-left">
<?php echo JHtml::_('grid.id', $i, $this->escape($folder->name), false, 'rm', 'cb-folder'); ?>
</div>
<div class="clearfix"></div>
<?php endif;?>
<div class="height-50">
<a href="index.php?option=com_media&view=mediaList&tmpl=component&folder=<?php echo rawurlencode($folder->path_relative); ?>" target="folderframe">
<span class="icon-folder-2"></span>
</a>
</div>
<div class="small">
<a href="index.php?option=com_media&view=mediaList&tmpl=component&folder=<?php echo rawurlencode($folder->path_relative); ?>" target="folderframe">
<?php echo JHtml::_('string.truncate', $this->escape($folder->name), 10, false); ?>
</a>
</div>
</li>
<?php endforeach; ?>
PK �}!]<�r medialist/thumbs_imgs.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
$params = new Registry;
$dispatcher = JEventDispatcher::getInstance();
?>
<?php foreach ($this->images as $i => $img) : ?>
<?php $dispatcher->trigger('onContentBeforeDisplay', array('com_media.file', &$img, &$params, 0)); ?>
<li class="imgOutline thumbnail center">
<?php if ($this->canDelete):?>
<div class="imgDelete">
<a class="close delete-item" target="_top"
href="index.php?option=com_media&task=file.delete&tmpl=index&<?php echo JSession::getFormToken(); ?>=1&folder=<?php echo rawurlencode($this->state->folder); ?>&rm[]=<?php echo $this->escape($img->name); ?>"
rel="<?php echo $this->escape($img->name); ?>" title="<?php echo JText::_('JACTION_DELETE'); ?>"><span class="icon-delete"> </span></a>
</div>
<?php endif; ?>
<div class="imgThumb imgInput">
<?php if ($this->canDelete):?>
<?php echo JHtml::_('grid.id', $i, $this->escape($img->name), false, 'rm', 'cb-image'); ?>
<?php endif; ?>
<label for="cb-image<?php echo $i ?>">
<?php echo JHtml::_('image', COM_MEDIA_BASEURL . '/' . $this->escape($img->path_relative), JText::sprintf('COM_MEDIA_IMAGE_TITLE', $this->escape($img->title), JHtml::_('number.bytes', $img->size)), array('width' => $img->width_60, 'height' => $img->height_60)); ?>
</label>
</div>
<div class="imgPreview nowrap small">
<a href="<?php echo COM_MEDIA_BASEURL . '/' . str_replace('%2F', '/', rawurlencode($img->path_relative)); ?>" title="<?php echo $this->escape($img->name); ?>" class="preview truncate">
<span class="icon-search" aria-hidden="true"></span><?php echo $this->escape($img->name); ?>
</a>
</div>
</li>
<?php $dispatcher->trigger('onContentAfterDisplay', array('com_media.file', &$img, &$params, 0)); ?>
<?php endforeach; ?>
PK �}!]G��W W imageslist/default_folder.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$input = JFactory::getApplication()->input;
?>
<li class="imgOutline thumbnail height-80 width-80 center">
<a href="index.php?option=com_media&view=imagesList&tmpl=component&folder=<?php echo rawurlencode($this->_tmp_folder->path_relative); ?>&asset=<?php echo $input->getCmd('asset');?>&author=<?php echo $input->getCmd('author');?>" target="imageframe">
<div class="imgFolder">
<span class="icon-folder-2"></span>
</div>
<div class="small">
<?php echo JHtml::_('string.truncate', $this->escape($this->_tmp_folder->name), 10, false); ?>
</div>
</a>
</li>
PK �}!].��k k imageslist/default_image.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2016 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\Registry\Registry;
$params = new Registry;
$dispatcher = JEventDispatcher::getInstance();
$dispatcher->trigger('onContentBeforeDisplay', array('com_media.file', &$this->_tmp_img, &$params, 0));
?>
<li class="imgOutline thumbnail height-80 width-80 center">
<a class="img-preview" href="javascript:ImageManager.populateFields('<?php echo $this->escape($this->_tmp_img->path_relative); ?>')" title="<?php echo $this->escape($this->_tmp_img->name); ?>" >
<div class="imgThumb">
<div class="imgThumbInside">
<?php echo JHtml::_('image', $this->baseURL . '/' . $this->escape($this->_tmp_img->path_relative), JText::sprintf('COM_MEDIA_IMAGE_TITLE', $this->escape($this->_tmp_img->title), JHtml::_('number.bytes', $this->_tmp_img->size)), array('width' => $this->_tmp_img->width_60, 'height' => $this->_tmp_img->height_60)); ?>
</div>
</div>
<div class="imgDetails small">
<?php echo JHtml::_('string.truncate', $this->escape($this->_tmp_img->name), 10, false); ?>
</div>
</a>
</li>
<?php
$dispatcher->trigger('onContentAfterDisplay', array('com_media.file', &$this->_tmp_img, &$params, 0));
PK [�!]��b�h h
access.xmlnu &1i� <?xml version="1.0" encoding="utf-8" ?>
<access component="com_media">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.options" title="JACTION_OPTIONS" description="JACTION_OPTIONS_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
</section>
</access>
PK [�!]�gH�?
?
config.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset
name="component"
label="COM_MEDIA_FIELDSET_OPTIONS_LABEL">
<field
name="upload_extensions"
type="text"
label="COM_MEDIA_FIELD_LEGAL_EXTENSIONS_LABEL"
description="COM_MEDIA_FIELD_LEGAL_EXTENSIONS_DESC"
size="50"
default="bmp,csv,doc,gif,ico,jpg,jpeg,odg,odp,ods,odt,pdf,png,ppt,txt,xcf,xls,BMP,CSV,DOC,GIF,ICO,JPG,JPEG,ODG,ODP,ODS,ODT,PDF,PNG,PPT,TXT,XCF,XLS"
/>
<field
name="upload_maxsize"
type="number"
label="COM_MEDIA_FIELD_MAXIMUM_SIZE_LABEL"
description="COM_MEDIA_FIELD_MAXIMUM_SIZE_DESC"
validate="number"
min="0"
size="50"
default="10"
/>
<field
name="spacer1"
type="spacer"
label="COM_MEDIA_FOLDERS_PATH_LABEL"
class="text"
/>
<field
name="file_path"
type="text"
label="COM_MEDIA_FIELD_PATH_FILE_FOLDER_LABEL"
description="COM_MEDIA_FIELD_PATH_FILE_FOLDER_DESC"
size="50"
default="images"
validate="filePath"
exclude="administrator|api|bin|cache|cli|components|includes|language|layouts|libraries|media|modules|plugins|templates|tmp"
/>
<field
name="image_path"
type="text"
label="COM_MEDIA_FIELD_PATH_IMAGE_FOLDER_LABEL"
description="COM_MEDIA_FIELD_PATH_IMAGE_FOLDER_DESC"
size="50"
default="images"
validate="filePath"
exclude="administrator|api|bin|cache|cli|components|includes|language|layouts|libraries|modules|plugins|templates|tmp"
/>
<field
name="restrict_uploads"
type="radio"
label="COM_MEDIA_FIELD_RESTRICT_UPLOADS_LABEL"
description="COM_MEDIA_FIELD_RESTRICT_UPLOADS_DESC"
class="btn-group btn-group-yesno"
default="1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="check_mime"
type="radio"
label="COM_MEDIA_FIELD_CHECK_MIME_LABEL"
description="COM_MEDIA_FIELD_CHECK_MIME_DESC"
class="btn-group btn-group-yesno"
default="1"
showon="restrict_uploads:1"
>
<option value="1">JYES</option>
<option value="0">JNO</option>
</field>
<field
name="image_extensions"
type="text"
label="COM_MEDIA_FIELD_LEGAL_IMAGE_EXTENSIONS_LABEL"
description="COM_MEDIA_FIELD_LEGAL_IMAGE_EXTENSIONS_DESC"
size="50"
default="bmp,gif,jpg,png"
showon="restrict_uploads:1"
/>
<field
name="ignore_extensions"
type="text"
label="COM_MEDIA_FIELD_IGNORED_EXTENSIONS_LABEL"
description="COM_MEDIA_FIELD_IGNORED_EXTENSIONS_DESC"
size="50"
/>
<field
name="upload_mime"
type="text"
label="COM_MEDIA_FIELD_LEGAL_MIME_TYPES_LABEL"
description="COM_MEDIA_FIELD_LEGAL_MIME_TYPES_DESC"
size="50"
default="image/jpeg,image/gif,image/png,image/bmp,application/msword,application/excel,application/pdf,application/powerpoint,text/plain,application/x-zip"
showon="restrict_uploads:1"
/>
<field
name="upload_mime_illegal"
type="text"
label="COM_MEDIA_FIELD_ILLEGAL_MIME_TYPES_LABEL"
description="COM_MEDIA_FIELD_ILLEGAL_MIME_TYPES_DESC"
size="50"
default="text/html"
showon="restrict_uploads:1"
/>
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
filter="rules"
validate="rules"
component="com_media"
section="component"
/>
</fieldset>
</config>
PK [�!]�z�k models/manager.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Media Component Manager Model
*
* @since 1.5
*/
class MediaModelManager extends JModelLegacy
{
/**
* Method to get model state variables
*
* @param string $property Optional parameter name
* @param mixed $default Optional default value
*
* @return object The property where specified, the state object where omitted
*
* @since 1.5
*/
public function getState($property = null, $default = null)
{
static $set;
if (!$set)
{
$input = JFactory::getApplication()->input;
$folder = $input->get('folder', '', 'path');
$this->setState('folder', $folder);
$fieldid = $input->get('fieldid', '');
$this->setState('field.id', $fieldid);
$parent = str_replace("\\", '/', dirname($folder));
$parent = ($parent == '.') ? null : $parent;
$this->setState('parent', $parent);
$set = true;
}
return parent::getState($property, $default);
}
/**
* Get a select field with a list of available folders
*
* @param string $base The image directory to display
*
* @return html
*
* @since 1.5
*/
public function getFolderList($base = null)
{
// Get some paths from the request
if (empty($base))
{
$base = COM_MEDIA_BASE;
}
// Corrections for windows paths
$base = str_replace(DIRECTORY_SEPARATOR, '/', $base);
$com_media_base_uni = str_replace(DIRECTORY_SEPARATOR, '/', COM_MEDIA_BASE);
// Get the list of folders
jimport('joomla.filesystem.folder');
$folders = JFolder::folders($base, '.', true, true);
$document = JFactory::getDocument();
$document->setTitle(JText::_('COM_MEDIA_INSERT_IMAGE'));
// Build the array of select options for the folder list
$options[] = JHtml::_('select.option', '', '/');
foreach ($folders as $folder)
{
$folder = str_replace($com_media_base_uni, '', str_replace(DIRECTORY_SEPARATOR, '/', $folder));
$value = substr($folder, 1);
$text = str_replace(DIRECTORY_SEPARATOR, '/', $folder);
$options[] = JHtml::_('select.option', $value, $text);
}
// Sort the folder list array
if (is_array($options))
{
sort($options);
}
// Get asset and author id (use integer filter)
$input = JFactory::getApplication()->input;
$asset = $input->get('asset', 0, 'integer');
// For new items the asset is a string. JAccess always checks type first
// so both string and integer are supported.
if ($asset == 0)
{
$asset = htmlspecialchars(json_encode(trim($input->get('asset', 0, 'cmd'))), ENT_COMPAT, 'UTF-8');
}
$author = $input->get('author', 0, 'integer');
// Create the dropdown folder select list
$attribs = 'size="1" onchange="ImageManager.setFolder(this.options[this.selectedIndex].value, ' . $asset . ', ' . $author . ')" ';
$list = JHtml::_('select.genericlist', $options, 'folderlist', $attribs, 'value', 'text', $base);
return $list;
}
/**
* Get the folder tree
*
* @param mixed $base Base folder | null for using base media folder
*
* @return array
*
* @since 1.5
*/
public function getFolderTree($base = null)
{
// Get some paths from the request
if (empty($base))
{
$base = COM_MEDIA_BASE;
}
$mediaBase = str_replace(DIRECTORY_SEPARATOR, '/', COM_MEDIA_BASE . '/');
// Get the list of folders
jimport('joomla.filesystem.folder');
$folders = JFolder::folders($base, '.', true, true);
$tree = array();
foreach ($folders as $folder)
{
$folder = str_replace(DIRECTORY_SEPARATOR, '/', $folder);
$name = substr($folder, strrpos($folder, '/') + 1);
$relative = str_replace($mediaBase, '', $folder);
$absolute = $folder;
$path = explode('/', $relative);
$node = (object) array('name' => $name, 'relative' => $relative, 'absolute' => $absolute);
$tmp = &$tree;
for ($i = 0, $n = count($path); $i < $n; $i++)
{
if (!isset($tmp['children']))
{
$tmp['children'] = array();
}
if ($i == $n - 1)
{
// We need to place the node
$tmp['children'][$relative] = array('data' => $node, 'children' => array());
break;
}
if (array_key_exists($key = implode('/', array_slice($path, 0, $i + 1)), $tmp['children']))
{
$tmp = &$tmp['children'][$key];
}
}
}
$tree['data'] = (object) array('name' => JText::_('COM_MEDIA_MEDIA'), 'relative' => '', 'absolute' => $base);
return $tree;
}
}
PK [�!]��� � � models/list.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
/**
* Media Component List Model
*
* @since 1.5
*/
class MediaModelList extends JModelLegacy
{
/**
* Method to get model state variables
*
* @param string $property Optional parameter name
* @param mixed $default Optional default value
*
* @return object The property where specified, the state object where omitted
*
* @since 1.5
*/
public function getState($property = null, $default = null)
{
static $set;
if (!$set)
{
$input = JFactory::getApplication()->input;
$folder = $input->get('folder', '', 'path');
$this->setState('folder', $folder);
$parent = str_replace("\\", '/', dirname($folder));
$parent = ($parent == '.') ? null : $parent;
$this->setState('parent', $parent);
$set = true;
}
return parent::getState($property, $default);
}
/**
* Get the images on the current folder
*
* @return array
*
* @since 1.5
*/
public function getImages()
{
$list = $this->getList();
return $list['images'];
}
/**
* Get the folders on the current folder
*
* @return array
*
* @since 1.5
*/
public function getFolders()
{
$list = $this->getList();
return $list['folders'];
}
/**
* Get the documents on the current folder
*
* @return array
*
* @since 1.5
*/
public function getDocuments()
{
$list = $this->getList();
return $list['docs'];
}
/**
* Build imagelist
*
* @return array
*
* @since 1.5
*/
public function getList()
{
static $list;
// Only process the list once per request
if (is_array($list))
{
return $list;
}
// Get current path from request
$current = (string) $this->getState('folder');
$basePath = COM_MEDIA_BASE . ((strlen($current) > 0) ? '/' . $current : '');
$mediaBase = str_replace(DIRECTORY_SEPARATOR, '/', COM_MEDIA_BASE . '/');
// Reset base path
if (strpos(realpath($basePath), JPath::clean(realpath(COM_MEDIA_BASE))) !== 0)
{
$basePath = COM_MEDIA_BASE;
}
$images = array ();
$folders = array ();
$docs = array ();
$videos = array ();
$fileList = false;
$folderList = false;
if (file_exists($basePath))
{
// Get the list of files and folders from the given folder
$fileList = JFolder::files($basePath);
$folderList = JFolder::folders($basePath);
}
// Iterate over the files if they exist
if ($fileList !== false)
{
$tmpBaseObject = new JObject;
foreach ($fileList as $file)
{
if (is_file($basePath . '/' . $file) && substr($file, 0, 1) != '.' && strtolower($file) !== 'index.html')
{
$tmp = clone $tmpBaseObject;
$tmp->name = $file;
$tmp->title = $file;
$tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $file));
$tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
$tmp->size = filesize($tmp->path);
$ext = strtolower(JFile::getExt($file));
switch ($ext)
{
// Image
case 'jpg':
case 'png':
case 'gif':
case 'xcf':
case 'odg':
case 'bmp':
case 'jpeg':
case 'ico':
$info = @getimagesize($tmp->path);
$tmp->width = @$info[0];
$tmp->height = @$info[1];
$tmp->type = @$info[2];
$tmp->mime = @$info['mime'];
if (($info[0] > 60) || ($info[1] > 60))
{
$dimensions = MediaHelper::imageResize($info[0], $info[1], 60);
$tmp->width_60 = $dimensions[0];
$tmp->height_60 = $dimensions[1];
}
else
{
$tmp->width_60 = $tmp->width;
$tmp->height_60 = $tmp->height;
}
if (($info[0] > 16) || ($info[1] > 16))
{
$dimensions = MediaHelper::imageResize($info[0], $info[1], 16);
$tmp->width_16 = $dimensions[0];
$tmp->height_16 = $dimensions[1];
}
else
{
$tmp->width_16 = $tmp->width;
$tmp->height_16 = $tmp->height;
}
$images[] = $tmp;
break;
// Video
case 'mp4':
$tmp->icon_32 = 'media/mime-icon-32/' . $ext . '.png';
$tmp->icon_16 = 'media/mime-icon-16/' . $ext . '.png';
$videos[] = $tmp;
break;
// Non-image document
default:
$tmp->icon_32 = 'media/mime-icon-32/' . $ext . '.png';
$tmp->icon_16 = 'media/mime-icon-16/' . $ext . '.png';
$docs[] = $tmp;
break;
}
}
}
}
// Iterate over the folders if they exist
if ($folderList !== false)
{
$tmpBaseObject = new JObject;
foreach ($folderList as $folder)
{
$tmp = clone $tmpBaseObject;
$tmp->name = basename($folder);
$tmp->path = str_replace(DIRECTORY_SEPARATOR, '/', JPath::clean($basePath . '/' . $folder));
$tmp->path_relative = str_replace($mediaBase, '', $tmp->path);
$count = MediaHelper::countFiles($tmp->path);
$tmp->files = $count[0];
$tmp->folders = $count[1];
$folders[] = $tmp;
}
}
$list = array('folders' => $folders, 'docs' => $docs, 'images' => $images, 'videos' => $videos);
return $list;
}
/**
* Get the videos on the current folder
*
* @return array
*
* @since 3.5
*/
public function getVideos()
{
$list = $this->getList();
return $list['videos'];
}
}
PK [�!]eϫ�� � layouts/toolbar/uploadmedia.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$title = JText::_('JTOOLBAR_UPLOAD');
?>
<button data-toggle="collapse" data-target="#collapseUpload" class="btn btn-small btn-success">
<span class="icon-plus icon-white" title="<?php echo $title; ?>"></span> <?php echo $title; ?>
</button>
PK [�!]���� � layouts/toolbar/newfolder.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$title = JText::_('COM_MEDIA_CREATE_NEW_FOLDER');
?>
<button data-toggle="collapse" data-target="#collapseFolder" class="btn btn-small">
<span class="icon-folder" title="<?php echo $title; ?>"></span> <?php echo $title; ?>
</button>
PK [�!]h+M� � layouts/toolbar/deletemedia.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2013 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$title = JText::_('JTOOLBAR_DELETE');
JText::script('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST');
?>
<script type="text/javascript">
(function($){
// if any media is selected then only allow to submit otherwise show message
deleteMedia = function(){
if ( $('#folderframe').contents().find('input:checked[name="rm[]"]').length == 0){
alert(Joomla.JText._('JLIB_HTML_PLEASE_MAKE_A_SELECTION_FROM_THE_LIST'));
return false;
}
MediaManager.submit('folder.delete');
};
})(jQuery);
</script>
<button onclick="deleteMedia()" class="btn btn-small">
<span class="icon-remove" title="<?php echo $title; ?>"></span> <?php echo $title; ?>
</button>
PK [�!]+�4c� � media.xmlnu &1i� <?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade">
<name>com_media</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<copyright>(C) 2006 Open Source Matters, Inc.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>COM_MEDIA_XML_DESCRIPTION</description>
<files folder="site">
<filename>controller.php</filename>
<filename>media.php</filename>
<folder>helpers</folder>
</files>
<languages folder="site">
<language tag="en-GB">language/en-GB.com_media.ini</language>
</languages>
<administration>
<files folder="admin">
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>media.php</filename>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>layouts</folder>
<folder>models</folder>
<folder>views</folder>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB.com_media.ini</language>
<language tag="en-GB">language/en-GB.com_media.sys.ini</language>
</languages>
</administration>
</extension>
PK [�!]�s�1� � helpers/media.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
use Joomla\CMS\Object\CMSObject;
/**
* Media helper class.
*
* @since 1.6
* @deprecated 4.0 Use JHelperMedia instead
*/
abstract class MediaHelper
{
/**
* Checks if the file is an image
*
* @param string $fileName The filename
*
* @return boolean
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::isImage instead
*/
public static function isImage($fileName)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::isImage() instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->isImage($fileName);
}
/**
* Gets the file extension for the purpose of using an icon.
*
* @param string $fileName The filename
*
* @return string File extension
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::getTypeIcon instead
*/
public static function getTypeIcon($fileName)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::getTypeIcon() instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->getTypeIcon($fileName);
}
/**
* Checks if the file can be uploaded
*
* @param array $file File information
* @param string $error An error message to be returned
*
* @return boolean
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::canUpload instead
*/
public static function canUpload($file, $error = '')
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::canUpload() instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->canUpload($file, 'com_media');
}
/**
* Method to parse a file size
*
* @param integer $size The file size in bytes
*
* @return string The converted file size
*
* @since 1.6
* @deprecated 4.0 Use JHtml::_('number.bytes') instead
*/
public static function parseSize($size)
{
try
{
JLog::add(
sprintf("%s() is deprecated. Use JHtml::_('number.bytes') instead.", __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
return JHtml::_('number.bytes', $size);
}
/**
* Calculate the size of a resized image
*
* @param integer $width Image width
* @param integer $height Image height
* @param integer $target Target size
*
* @return array The new width and height
*
* @since 3.2
* @deprecated 4.0 Use JHelperMedia::imageResize instead
*/
public static function imageResize($width, $height, $target)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::imageResize() instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->imageResize($width, $height, $target);
}
/**
* Counts the files and directories in a directory that are not php or html files.
*
* @param string $dir Directory name
*
* @return array The number of files and directories in the given directory
*
* @since 1.5
* @deprecated 4.0 Use JHelperMedia::countFiles instead
*/
public static function countFiles($dir)
{
try
{
JLog::add(
sprintf('%s() is deprecated. Use JHelperMedia::countFiles() instead.', __METHOD__),
JLog::WARNING,
'deprecated'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$mediaHelper = new JHelperMedia;
return $mediaHelper->countFiles($dir);
}
/**
* Generates the URL to the object in the action logs component
*
* @param string $contentType The content type
* @param integer $id The integer id
* @param CMSObject $mediaObject The media object being uploaded
*
* @return string The link for the action log
*
* @since 3.9.27
*/
public static function getContentTypeLink($contentType, $id, CMSObject $mediaObject)
{
if ($contentType === 'com_media.file')
{
return '';
}
$link = 'index.php?option=com_media&view=media';
$uploadedPath = substr($mediaObject->get('filepath'), strlen(COM_MEDIA_BASE) + 1);
// Now remove the filename
$uploadedBasePath = substr_replace(
$uploadedPath,
'',
(strlen(DIRECTORY_SEPARATOR . $mediaObject->get('name')) * -1)
);
if (!empty($uploadedBasePath))
{
$link = $link . '&folder=' . $uploadedBasePath;
}
return $link;
}
}
PK [�!]g\�p p controller.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Media Manager Component Controller
*
* @since 1.5
*/
class MediaController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean $cachable If true, the view output will be cached
* @param array $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
*
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
JPluginHelper::importPlugin('content');
$vType = JFactory::getDocument()->getType();
$vName = $this->input->get('view', 'media');
switch ($vName)
{
case 'images':
$vLayout = $this->input->get('layout', 'default', 'string');
$mName = 'manager';
break;
case 'imagesList':
$mName = 'list';
$vLayout = $this->input->get('layout', 'default', 'string');
break;
case 'mediaList':
$app = JFactory::getApplication();
$mName = 'list';
$vLayout = $app->getUserStateFromRequest('media.list.layout', 'layout', 'thumbs', 'word');
break;
case 'media':
default:
$vName = 'media';
$vLayout = $this->input->get('layout', 'default', 'string');
$mName = 'manager';
break;
}
// Get/Create the view
$view = $this->getView($vName, $vType, '', array('base_path' => JPATH_COMPONENT_ADMINISTRATOR));
// Get/Create the model
if ($model = $this->getModel($mName))
{
// Push the model into the view (as default)
$view->setModel($model, true);
}
// Set the layout
$view->setLayout($vLayout);
// Display the view
$view->display();
return $this;
}
/**
* Validate FTP credentials
*
* @return void
*
* @since 1.5
*/
public function ftpValidate()
{
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
}
}
PK [�!]"��Kg g controllers/file.json.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* File Media Controller
*
* @since 1.6
*/
class MediaControllerFile extends JControllerLegacy
{
/**
* Upload a file
*
* @return void
*
* @since 1.5
*/
public function upload()
{
$params = JComponentHelper::getParams('com_media');
// Check for request forgeries
if (!JSession::checkToken('request'))
{
$response = array(
'status' => '0',
'message' => JText::_('JINVALID_TOKEN'),
'error' => JText::_('JINVALID_TOKEN')
);
echo json_encode($response);
return;
}
// Get the user
$user = JFactory::getUser();
JLog::addLogger(array('text_file' => 'upload.error.php'), JLog::ALL, array('upload'));
// Get some data from the request
$file = $this->input->files->get('Filedata', '', 'array');
$folder = $this->input->get('folder', '', 'path');
// Instantiate the media helper
$mediaHelper = new JHelperMedia;
if ($_SERVER['CONTENT_LENGTH'] > ($params->get('upload_maxsize', 0) * 1024 * 1024)
|| $_SERVER['CONTENT_LENGTH'] > $mediaHelper->toBytes(ini_get('upload_max_filesize'))
|| $_SERVER['CONTENT_LENGTH'] > $mediaHelper->toBytes(ini_get('post_max_size'))
|| $_SERVER['CONTENT_LENGTH'] > $mediaHelper->toBytes(ini_get('memory_limit')))
{
$response = array(
'status' => '0',
'message' => JText::_('COM_MEDIA_ERROR_WARNFILETOOLARGE'),
'error' => JText::_('COM_MEDIA_ERROR_WARNFILETOOLARGE')
);
echo json_encode($response);
return;
}
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
if (isset($file['name']))
{
// Make the filename safe
$file['name'] = JFile::makeSafe($file['name']);
// We need a URL safe name
$fileparts = pathinfo(COM_MEDIA_BASE . '/' . $folder . '/' . $file['name']);
// Transform filename to punycode
$fileparts['filename'] = JStringPunycode::toPunycode($fileparts['filename']);
$tempExt = !empty($fileparts['extension']) ? strtolower($fileparts['extension']) : '';
// Transform filename to punycode, then neglect other than non-alphanumeric characters & underscores. Also transform extension to lowercase
$safeFileName = preg_replace(array("/[\\s]/", '/[^a-zA-Z0-9_\-]/'), array('_', ''), $fileparts['filename']) . '.' . $tempExt;
// Create filepath with safe-filename
$files['final'] = $fileparts['dirname'] . DIRECTORY_SEPARATOR . $safeFileName;
$file['name'] = $safeFileName;
$filepath = JPath::clean($files['final']);
if (!$mediaHelper->canUpload($file, 'com_media')
|| strpos(realpath($fileparts['dirname']), JPath::clean(realpath(COM_MEDIA_BASE))) !== 0)
{
try
{
JLog::add('Invalid: ' . $filepath, JLog::INFO, 'upload');
}
catch (RuntimeException $exception)
{
// Informational log only
}
$response = array(
'status' => '0',
'message' => JText::_('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE'),
'error' => JText::_('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE')
);
echo json_encode($response);
return;
}
// Trigger the onContentBeforeSave event.
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$object_file = new JObject($file);
$object_file->filepath = $filepath;
$result = $dispatcher->trigger('onContentBeforeSave', array('com_media.file', &$object_file, true));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
try
{
JLog::add(
'Errors before save: ' . $object_file->filepath . ' : ' . implode(', ', $object_file->getErrors()),
JLog::INFO,
'upload'
);
}
catch (RuntimeException $exception)
{
// Informational log only
}
$response = array(
'status' => '0',
'message' => JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)),
'error' => JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors))
);
echo json_encode($response);
return;
}
if (JFile::exists($object_file->filepath))
{
// File exists
try
{
JLog::add('File exists: ' . $object_file->filepath . ' by user_id ' . $user->id, JLog::INFO, 'upload');
}
catch (RuntimeException $exception)
{
// Informational log only
}
$response = array(
'status' => '0',
'message' => JText::_('COM_MEDIA_ERROR_FILE_EXISTS'),
'error' => JText::_('COM_MEDIA_ERROR_FILE_EXISTS'),
'location' => str_replace(JPATH_ROOT, '', $filepath)
);
echo json_encode($response);
return;
}
elseif (!$user->authorise('core.create', 'com_media'))
{
// File does not exist and user is not authorised to create
try
{
JLog::add('Create not permitted: ' . $object_file->filepath . ' by user_id ' . $user->id, JLog::INFO, 'upload');
}
catch (RuntimeException $exception)
{
// Informational log only
}
$response = array(
'status' => '0',
'error' => JText::_('COM_MEDIA_ERROR_CREATE_NOT_PERMITTED'),
'message' => JText::_('COM_MEDIA_ERROR_CREATE_NOT_PERMITTED')
);
echo json_encode($response);
return;
}
if (!JFile::upload($object_file->tmp_name, $object_file->filepath))
{
// Error in upload
try
{
JLog::add('Error on upload: ' . $object_file->filepath, JLog::INFO, 'upload');
}
catch (RuntimeException $exception)
{
// Informational log only
}
$response = array(
'status' => '0',
'message' => JText::_('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE'),
'error' => JText::_('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE')
);
echo json_encode($response);
return;
}
else
{
// Trigger the onContentAfterSave event.
$dispatcher->trigger('onContentAfterSave', array('com_media.file', &$object_file, true));
try
{
JLog::add($folder, JLog::INFO, 'upload');
}
catch (RuntimeException $exception)
{
// Informational log only
}
$returnUrl = str_replace(JPATH_ROOT, '', $object_file->filepath);
$response = array(
'status' => '1',
'message' => JText::sprintf('COM_MEDIA_UPLOAD_COMPLETE', $returnUrl),
'error' => JText::sprintf('COM_MEDIA_UPLOAD_COMPLETE', $returnUrl),
'location' => str_replace('\\', '/', $returnUrl)
);
echo json_encode($response);
return;
}
}
else
{
$response = array(
'status' => '0',
'error' => JText::_('COM_MEDIA_ERROR_BAD_REQUEST'),
'message' => JText::_('COM_MEDIA_ERROR_BAD_REQUEST')
);
echo json_encode($response);
return;
}
}
}
PK [�!]���) ) controllers/file.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* Media File Controller
*
* @since 1.5
*/
class MediaControllerFile extends JControllerLegacy
{
/**
* The folder we are uploading into
*
* @var string
*/
protected $folder = '';
/**
* Upload one or more files
*
* @return boolean
*
* @since 1.5
*/
public function upload()
{
// Check for request forgeries
$this->checkToken('request');
$params = JComponentHelper::getParams('com_media');
// Get some data from the request
$files = $this->input->files->get('Filedata', array(), 'array');
$return = JFactory::getSession()->get('com_media.return_url');
$this->folder = $this->input->get('folder', '', 'path');
// Instantiate the media helper
$mediaHelper = new JHelperMedia;
// Don't redirect to an external URL.
if (!JUri::isInternal($return))
{
$return = '';
}
// Set the redirect
if ($return)
{
$this->setRedirect($return . '&folder=' . $this->folder);
}
else
{
$this->setRedirect('index.php?option=com_media&folder=' . $this->folder);
}
// First check against unfiltered input.
if (!$this->input->files->get('Filedata', null, 'RAW'))
{
// Total length of post back data in bytes.
$contentLength = $this->input->server->get('CONTENT_LENGTH', 0, 'INT');
// Maximum allowed size of post back data in MB.
$postMaxSize = $mediaHelper->toBytes(ini_get('post_max_size'));
// Maximum allowed size of script execution in MB.
$memoryLimit = $mediaHelper->toBytes(ini_get('memory_limit'));
// Check for the total size of post back data.
if (($postMaxSize > 0 && $contentLength > $postMaxSize)
|| ($memoryLimit != -1 && $contentLength > $memoryLimit))
{
// Files are too large.
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_WARNUPLOADTOOLARGE'));
return false;
}
// No files were provided.
$this->setMessage(JText::_('COM_MEDIA_ERROR_UPLOAD_INPUT'), 'warning');
return false;
}
if (!$files)
{
// Files were provided but are unsafe to upload.
$this->setMessage(JText::_('COM_MEDIA_ERROR_WARNFILENOTSAFE'), 'error');
return false;
}
// Authorize the user
if (!$this->authoriseUser('create'))
{
return false;
}
$uploadMaxSize = $params->get('upload_maxsize', 0) * 1024 * 1024;
$uploadMaxFileSize = $mediaHelper->toBytes(ini_get('upload_max_filesize'));
// Perform basic checks on file info before attempting anything
foreach ($files as &$file)
{
// Make the filename safe
$file['name'] = JFile::makeSafe($file['name']);
// We need a url safe name
$fileparts = pathinfo(COM_MEDIA_BASE . '/' . $this->folder . '/' . $file['name']);
if (strpos(realpath($fileparts['dirname']), JPath::clean(realpath(COM_MEDIA_BASE))) !== 0)
{
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_WARNINVALID_FOLDER'));
return false;
}
// Transform filename to punycode, check extension and transform it to lowercase
$fileparts['filename'] = JStringPunycode::toPunycode($fileparts['filename']);
$tempExt = !empty($fileparts['extension']) ? strtolower($fileparts['extension']) : '';
// Neglect other than non-alphanumeric characters, hyphens & underscores.
$safeFileName = preg_replace(array("/[\\s]/", '/[^a-zA-Z0-9_\-]/'), array('_', ''), $fileparts['filename']) . '.' . $tempExt;
$file['name'] = $safeFileName;
$file['filepath'] = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $this->folder, $file['name'])));
if (($file['error'] == 1)
|| ($uploadMaxSize > 0 && $file['size'] > $uploadMaxSize)
|| ($uploadMaxFileSize > 0 && $file['size'] > $uploadMaxFileSize))
{
// File size exceed either 'upload_max_filesize' or 'upload_maxsize'.
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_WARNFILETOOLARGE'));
return false;
}
if (JFile::exists($file['filepath']))
{
// A file with this name already exists
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_FILE_EXISTS'));
return false;
}
if (!isset($file['name']))
{
// No filename (after the name was cleaned by JFile::makeSafe)
$this->setRedirect('index.php', JText::_('COM_MEDIA_INVALID_REQUEST'), 'error');
return false;
}
}
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
foreach ($files as &$file)
{
// The request is valid
$err = null;
if (!MediaHelper::canUpload($file, $err))
{
// The file can't be uploaded
return false;
}
// Trigger the onContentBeforeSave event.
$object_file = new JObject($file);
$result = $dispatcher->trigger('onContentBeforeSave', array('com_media.file', &$object_file, true));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
return false;
}
if (!JFile::upload($object_file->tmp_name, $object_file->filepath))
{
// Error in upload
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_UNABLE_TO_UPLOAD_FILE'));
return false;
}
// Trigger the onContentAfterSave event.
$dispatcher->trigger('onContentAfterSave', array('com_media.file', &$object_file, true));
$this->setMessage(JText::sprintf('COM_MEDIA_UPLOAD_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}
return true;
}
/**
* Check that the user is authorized to perform this action
*
* @param string $action - the action to be performed (create or delete)
*
* @return boolean
*
* @since 1.6
*/
protected function authoriseUser($action)
{
if (!JFactory::getUser()->authorise('core.' . strtolower($action), 'com_media'))
{
// User is not authorised
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_' . strtoupper($action) . '_NOT_PERMITTED'));
return false;
}
return true;
}
/**
* Deletes paths from the current path
*
* @return boolean
*
* @since 1.5
*/
public function delete()
{
$this->checkToken('request');
$user = JFactory::getUser();
// Get some data from the request
$tmpl = $this->input->get('tmpl');
$paths = $this->input->get('rm', array(), 'array');
$folder = $this->input->get('folder', '', 'path');
$redirect = 'index.php?option=com_media&folder=' . $folder;
if ($tmpl == 'component')
{
// We are inside the iframe
$redirect .= '&view=mediaList&tmpl=component';
}
$this->setRedirect($redirect);
// Just return if there's nothing to do
if (empty($paths))
{
$this->setMessage(JText::_('JERROR_NO_ITEMS_SELECTED'), 'error');
return true;
}
if (!$user->authorise('core.delete', 'com_media'))
{
// User is not authorised to delete
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
return false;
}
// Need this to enqueue messages.
$app = JFactory::getApplication();
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$ret = true;
$safePaths = array_intersect($paths, array_map(array('JFile', 'makeSafe'), $paths));
foreach ($safePaths as $key => $path)
{
$fullPath = implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path));
if (strpos(realpath($fullPath), JPath::clean(realpath(COM_MEDIA_BASE))) !== 0)
{
unset($safePaths[$key]);
}
}
$unsafePaths = array_diff($paths, $safePaths);
foreach ($unsafePaths as $path)
{
$path = JPath::clean(implode(DIRECTORY_SEPARATOR, array($folder, $path)));
$path = htmlspecialchars($path, ENT_COMPAT, 'UTF-8');
$app->enqueueMessage(JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', $path), 'error');
}
foreach ($safePaths as $path)
{
$fullPath = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path)));
$object_file = new JObject(array('filepath' => $fullPath));
if (is_file($object_file->filepath))
{
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.file', &$object_file));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
$errors = $object_file->getErrors();
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('<br />', $errors)));
continue;
}
$ret &= JFile::delete($object_file->filepath);
// Trigger the onContentAfterDelete event.
$dispatcher->trigger('onContentAfterDelete', array('com_media.file', &$object_file));
$app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}
elseif (is_dir($object_file->filepath))
{
$contents = JFolder::files($object_file->filepath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'));
if (!empty($contents))
{
// This makes no sense...
$folderPath = substr($object_file->filepath, strlen(COM_MEDIA_BASE));
JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', $folderPath));
continue;
}
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.folder', &$object_file));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
$errors = $object_file->getErrors();
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('<br />', $errors)));
continue;
}
$ret &= !JFolder::delete($object_file->filepath);
// Trigger the onContentAfterDelete event.
$dispatcher->trigger('onContentAfterDelete', array('com_media.folder', &$object_file));
$app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}
}
return $ret;
}
}
PK [�!]��N� � controllers/folder.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
/**
* Folder Media Controller
*
* @since 1.5
*/
class MediaControllerFolder extends JControllerLegacy
{
/**
* Deletes paths from the current path
*
* @return boolean
*
* @since 1.5
*/
public function delete()
{
$this->checkToken('request');
$user = JFactory::getUser();
// Get some data from the request
$tmpl = $this->input->get('tmpl');
$paths = $this->input->get('rm', array(), 'array');
$folder = $this->input->get('folder', '', 'path');
$redirect = 'index.php?option=com_media&folder=' . $folder;
if ($tmpl == 'component')
{
// We are inside the iframe
$redirect .= '&view=mediaList&tmpl=component';
}
$this->setRedirect($redirect);
// Just return if there's nothing to do
if (empty($paths))
{
$this->setMessage(JText::_('JERROR_NO_ITEMS_SELECTED'), 'error');
return true;
}
if (!$user->authorise('core.delete', 'com_media'))
{
// User is not authorised to delete
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED'));
return false;
}
// Need this to enqueue messages.
$app = JFactory::getApplication();
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$ret = true;
$safePaths = array_intersect($paths, array_map(array('JFile', 'makeSafe'), $paths));
$unsafePaths = array_diff($paths, $safePaths);
foreach ($unsafePaths as $path)
{
$path = JPath::clean(implode(DIRECTORY_SEPARATOR, array($folder, $path)));
$path = htmlspecialchars($path, ENT_COMPAT, 'UTF-8');
$app->enqueueMessage(JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FILE_WARNFILENAME', $path), 'error');
}
foreach ($safePaths as $path)
{
$fullPath = JPath::clean(implode(DIRECTORY_SEPARATOR, array(COM_MEDIA_BASE, $folder, $path)));
if (strpos(realpath($fullPath), JPath::clean(realpath(COM_MEDIA_BASE))) !== 0)
{
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_WARNINVALID_FOLDER'));
continue;
}
$object_file = new JObject(array('filepath' => $fullPath));
if (is_file($object_file->filepath))
{
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.file', &$object_file));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
$errors = $object_file->getErrors();
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('<br />', $errors)));
continue;
}
$ret &= JFile::delete($object_file->filepath);
// Trigger the onContentAfterDelete event.
$dispatcher->trigger('onContentAfterDelete', array('com_media.file', &$object_file));
$app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}
elseif (is_dir($object_file->filepath))
{
$contents = JFolder::files($object_file->filepath, '.', true, false, array('.svn', 'CVS', '.DS_Store', '__MACOSX', 'index.html'));
if (!empty($contents))
{
// This makes no sense...
$folderPath = substr($object_file->filepath, strlen(COM_MEDIA_BASE));
JError::raiseWarning(100, JText::sprintf('COM_MEDIA_ERROR_UNABLE_TO_DELETE_FOLDER_NOT_EMPTY', $folderPath));
continue;
}
// Trigger the onContentBeforeDelete event.
$result = $dispatcher->trigger('onContentBeforeDelete', array('com_media.folder', &$object_file));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
$errors = $object_file->getErrors();
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_DELETE', count($errors), implode('<br />', $errors)));
continue;
}
$ret &= !JFolder::delete($object_file->filepath);
// Trigger the onContentAfterDelete event.
$dispatcher->trigger('onContentAfterDelete', array('com_media.folder', &$object_file));
$app->enqueueMessage(JText::sprintf('COM_MEDIA_DELETE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}
}
return $ret;
}
/**
* Create a folder
*
* @return boolean
*
* @since 1.5
*/
public function create()
{
// Check for request forgeries
$this->checkToken();
$user = JFactory::getUser();
$folder = $this->input->get('foldername', '');
$folderCheck = (string) $this->input->get('foldername', null, 'raw');
$parent = $this->input->get('folderbase', '', 'path');
$this->setRedirect('index.php?option=com_media&folder=' . $parent . '&tmpl=' . $this->input->get('tmpl', 'index'));
if (strlen($folder) > 0)
{
if (!$user->authorise('core.create', 'com_media'))
{
// User is not authorised to create
JError::raiseWarning(403, JText::_('COM_MEDIA_ERROR_CREATE_NOT_PERMITTED'));
return false;
}
// Set FTP credentials, if given
JClientHelper::setCredentialsFromRequest('ftp');
$this->input->set('folder', $parent);
if (($folderCheck !== null) && ($folder !== $folderCheck))
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('COM_MEDIA_ERROR_UNABLE_TO_CREATE_FOLDER_WARNDIRNAME'), 'warning');
return false;
}
$path = JPath::clean(COM_MEDIA_BASE . '/' . $parent . '/' . $folder);
if (strpos(realpath(COM_MEDIA_BASE . '/' . $parent), JPath::clean(realpath(COM_MEDIA_BASE))) !== 0)
{
$app = JFactory::getApplication();
$app->enqueueMessage(JText::_('COM_MEDIA_ERROR_WARNINVALID_FOLDER'), 'error');
return false;
}
if (!is_dir($path) && !is_file($path))
{
// Trigger the onContentBeforeSave event.
$object_file = new JObject(array('filepath' => $path));
JPluginHelper::importPlugin('content');
$dispatcher = JEventDispatcher::getInstance();
$result = $dispatcher->trigger('onContentBeforeSave', array('com_media.folder', &$object_file, true));
if (in_array(false, $result, true))
{
// There are some errors in the plugins
JError::raiseWarning(100, JText::plural('COM_MEDIA_ERROR_BEFORE_SAVE', count($errors = $object_file->getErrors()), implode('<br />', $errors)));
return false;
}
if (JFolder::create($object_file->filepath))
{
$data = "<html>\n<body bgcolor=\"#FFFFFF\">\n</body>\n</html>";
JFile::write($object_file->filepath . '/index.html', $data);
// Trigger the onContentAfterSave event.
$dispatcher->trigger('onContentAfterSave', array('com_media.folder', &$object_file, true));
$this->setMessage(JText::sprintf('COM_MEDIA_CREATE_COMPLETE', substr($object_file->filepath, strlen(COM_MEDIA_BASE))));
}
}
$this->input->set('folder', ($parent) ? $parent . '/' . $folder : $folder);
}
else
{
// File name is of zero length (null).
JError::raiseWarning(100, JText::_('COM_MEDIA_ERROR_UNABLE_TO_CREATE_FOLDER_WARNDIRNAME'));
return false;
}
return true;
}
}
PK [�!]��{ { views/imageslist/view.html.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* HTML View class for the Media component
*
* @since 1.0
*/
class MediaViewImagesList extends JViewLegacy
{
/**
* Execute and display a template script.
*
* @param string $tpl The name of the template file to parse; automatically searches through the template paths.
*
* @return mixed A string if successful, otherwise an Error object.
*
* @since 1.0
*/
public function display($tpl = null)
{
// Do not allow cache
JFactory::getApplication()->allowCache(false);
$images = $this->get('images');
$folders = $this->get('folders');
$state = $this->get('state');
$this->baseURL = COM_MEDIA_BASEURL;
$this->images = &$images;
$this->folders = &$folders;
$this->state = &$state;
parent::display($tpl);
}
/**
* Set the active folder
*
* @param integer $index Folder position
*
* @return void
*
* @since 1.0
*/
public function setFolder($index = 0)
{
if (isset($this->folders[$index]))
{
$this->_tmp_folder = &$this->folders[$index];
}
else
{
$this->_tmp_folder = new JObject;
}
}
/**
* Set the active image
*
* @param integer $index Image position
*
* @return void
*
* @since 1.0
*/
public function setImage($index = 0)
{
if (isset($this->images[$index]))
{
$this->_tmp_img = &$this->images[$index];
}
else
{
$this->_tmp_img = new JObject;
}
}
}
PK [�!] ��IY Y ( views/imageslist/tmpl/default_folder.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$input = JFactory::getApplication()->input;
?>
<li class="imgOutline thumbnail height-80 width-80 center">
<a href="index.php?option=com_media&view=imagesList&tmpl=component&folder=<?php echo rawurlencode($this->_tmp_folder->path_relative); ?>&asset=<?php echo $input->getCmd('asset'); ?>&author=<?php echo $input->getCmd('author'); ?>" target="imageframe">
<div class="height-50">
<span class="icon-folder-2"></span>
</div>
<div class="small">
<?php echo JHtml::_('string.truncate', $this->escape($this->_tmp_folder->name), 10, false); ?>
</div>
</a>
</li>
PK [�!]���w0 0 ! views/imageslist/tmpl/default.phpnu &1i� <?php
/**
* @package Joomla.Administrator
* @subpackage com_media
*
* @copyright (C) 2007 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
$lang = JFactory::getLanguage();
JHtml::_('stylesheet', 'media/popup-imagelist.css', array('version' => 'auto', 'relative' => true));
if ($lang->isRtl())
{
JHtml::_('stylesheet', 'media/popup-imagelist_rtl.css', array('version' => 'auto', 'relative' => true));
}
JFactory::getDocument()->addScriptDeclaration('var ImageManager = window.parent.ImageManager;');
if ($lang->isRtl())
{
JFactory::getDocument()->addStyleDeclaration(
'
@media (max-width: 767px) {
li.imgOutline.thumbnail.height-80.width-80.center {
float: right;
}
}
'
);
}
else
{
JFactory::getDocument()->addStyleDeclaration(
'
@media (max-width: 767px) {
li.imgOutline.thumbnail.height-80.width-80.center {
float: left;
}
}
'
);
}
?>
<?php if (count($this->images) > 0 || count($this->folders) > 0) : ?>
<ul class="manager thumbnails thumbnails-media">
<?php for ($i = 0, $n = count($this->folders); $i < $n; $i++) :
$this->setFolder($i);
echo $this->loadTemplate('folder');
endfor; ?>
<?php for ($i = 0, $n = count($this->images); $i < $n; $i++) :
$this->setImage($i);
echo $this->loadTemplate('image');
endfor; ?>
</ul>
<?php else : ?>
<div id="media-noimages">
<div class="alert alert-info"><?php echo JText::_('COM_MEDIA_NO_IMAGES_FOUND'); ?></div>
</div>
<?php endif; ?>
PK [�!]��]?7 7 '