Source for file template.php
Documentation is available at template.php
* @package Joomla.Administrator
* @subpackage com_templates
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla.Administrator
* @subpackage com_templates
* Checks if the file is an image
* @param string $fileName The filename
* Checks if the file can be uploaded
* @param array $file File information
* @param string $err An error message to be returned
public static function canUpload($file, $err =
'')
if (empty($file['name']))
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_UPLOAD_INPUT'), 'error');
// Media file names should never have executable extensions buried in them.
'exe', 'phtml','java', 'perl', 'py', 'asp','dll', 'go', 'jar',
'ade', 'adp', 'bat', 'chm', 'cmd', 'com', 'cpl', 'hta', 'ins', 'isp',
'jse', 'lib', 'mde', 'msc', 'msp', 'mst', 'pif', 'scr', 'sct', 'shb',
'sys', 'vb', 'vbe', 'vbs', 'vxd', 'wsc', 'wsf', 'wsh'
$explodedFileName =
explode('.', $file['name']);
if (count($explodedFileName >
2))
foreach ($executable as $extensionName)
if (in_array($extensionName, $explodedFileName))
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_EXECUTABLE'), 'error');
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNFILENAME'), 'error');
$imageTypes =
explode(',', $params->get('image_formats'));
$sourceTypes =
explode(',', $params->get('source_formats'));
$fontTypes =
explode(',', $params->get('font_formats'));
$archiveTypes =
explode(',', $params->get('compressed_formats'));
$allowable =
array_merge($imageTypes, $sourceTypes, $fontTypes, $archiveTypes);
if ($format ==
'' ||
$format ==
false ||
(!in_array($format, $allowable)))
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNFILETYPE'), 'error');
if ($zip->open($file['tmp_name']) ===
true)
for ($i =
0; $i <
$zip->numFiles; $i++
)
$entry =
$zip->getNameIndex($i);
$endString =
substr($entry, -
1);
if ($endString !=
DIRECTORY_SEPARATOR)
$explodeArray =
explode('.', $entry);
$ext =
end($explodeArray);
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_UNSUPPORTED_ARCHIVE'), 'error');
$app->enqueueMessage(JText::_('COM_TEMPLATES_FILE_ARCHIVE_OPEN_FAIL'), 'error');
// Max upload size set to 2 MB for Template Manager
$maxSize = (int)
($params->get('upload_limit') *
1024 *
1024);
if ($maxSize >
0 && (int)
$file['size'] >
$maxSize)
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNFILETOOLARGE'), 'error');
'abbr', 'acronym', 'address', 'applet', 'area', 'audioscope', 'base', 'basefont', 'bdo', 'bgsound', 'big', 'blackface', 'blink', 'blockquote',
'body', 'bq', 'br', 'button', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'comment', 'custom', 'dd', 'del', 'dfn', 'dir', 'div',
'dl', 'dt', 'em', 'embed', 'fieldset', 'fn', 'font', 'form', 'frame', 'frameset', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'hr', 'html',
'iframe', 'ilayer', 'img', 'input', 'ins', 'isindex', 'keygen', 'kbd', 'label', 'layer', 'legend', 'li', 'limittext', 'link', 'listing',
'map', 'marquee', 'menu', 'meta', 'multicol', 'nobr', 'noembed', 'noframes', 'noscript', 'nosmartquotes', 'object', 'ol', 'optgroup', 'option',
'param', 'plaintext', 'pre', 'rt', 'ruby', 's', 'samp', 'script', 'select', 'server', 'shadow', 'sidebar', 'small', 'spacer', 'span', 'strike',
'strong', 'style', 'sub', 'sup', 'table', 'tbody', 'td', 'textarea', 'tfoot', 'th', 'thead', 'title', 'tr', 'tt', 'ul', 'var', 'wbr', 'xml',
foreach ($html_tags as $tag)
// A tag is '<tagname ', so we need to add < and a space or '<tagname>'
if (stristr($xss_check, '<' .
$tag .
' ') ||
stristr($xss_check, '<' .
$tag .
'>'))
$app->enqueueMessage(JText::_('COM_TEMPLATES_ERROR_WARNIEXSS'), 'error');
Documentation generated on Tue, 19 Nov 2013 15:15:36 +0100 by phpDocumentor 1.4.3