* @license http://www.contenido.org/license/LIZENZ.txt
* @link http://www.4fb.de
* @link http://www.contenido.org
* @since file available since contenido release <= 4.6
*
* {@internal
* created 2002-03-02
* modified 2008-06-27, Frederic Schneider, add security fix
*
* $Id$:
* }}
*
*/
if (!defined('CON_FRAMEWORK')) {
die('Illegal call');
}
cInclude("includes", "functions.file.php");
$tpl->reset();
if (!(int) $client > 0) {
#if there is no client selected, display empty page
$oPage = new cPage;
$oPage->render();
return;
}
$path = $cfgClient[$client]["css"]["path"];
$sFileType = "css";
$sSession = $sess->id;
$sArea = 'style';
$sActionDelete = 'style_delete';
$sActionEdit = 'style_edit';
$sScriptTemplate = '
';
$tpl->set('s', 'JAVASCRIPT', $sScriptTemplate);
# delete file
if ($action == $sActionDelete) {
if (!strrchr($_REQUEST['delfile'], "/")) {
if (file_exists($path . $_REQUEST['delfile'])) {
unlink($path . $_REQUEST['delfile']);
removeFileInformation($client, $_REQUEST['delfile'], 'css', $db);
}
}
}
// show folders
function scanAllDir($dir, $sFileType = null, $bShowEmptyDir = false) {
$result = [];
foreach (scandir($dir) as $filename) {
if ($filename[0] === '.')
continue;
$filePath = $dir . DIRECTORY_SEPARATOR . $filename;
if (is_dir($filePath)) {
$tmp = [];
foreach (scanAllDir($filePath, $sFileType) as $childFilename) {
if (is_null($sFileType) || pathinfo($filePath . DIRECTORY_SEPARATOR . $childFilename, PATHINFO_EXTENSION) == $sFileType) {
$tmp[] = $childFilename;
}
}
if ($bShowEmptyDir || !empty($tmp)) {
$result[] = array(
'folder' => $filename,
'files' => $tmp
);
}
unset($tmp);
} else {
if (is_null($sFileType) || pathinfo($filePath, PATHINFO_EXTENSION) == $sFileType) {
$result[] = $filename;
}
}
}
return $result;
}
if ($handle = opendir($path)) {
$aFiles = array();
while ($file = readdir($handle)) {
if (substr($file, (strlen($file) - (strlen($sFileType) + 1)), (strlen($sFileType) + 1)) == ".$sFileType" AND is_readable($path . $file)) {
$aFiles[] = $file;
} elseif (substr($file, (strlen($file) - (strlen($sFileType) + 1)), (strlen($sFileType) + 1)) == ".$sFileType" AND!is_readable($path . $file)) {
$notification->displayNotification("error", $file . " " . i18n("is not readable!"));
}
}
closedir($handle);
// display files
if (is_array($aFiles)) {
sort($aFiles);
foreach ($aFiles as $filename) {
$bgcolor = ( is_int($tpl->dyn_cnt / 2) ) ? $cfg["color"]["table_light"] : $cfg["color"]["table_dark"];
$tpl->set('d', 'BGCOLOR', $bgcolor);
$tmp_mstr = '%s';
$html_filename = sprintf($tmp_mstr, 'right_top',
$sess->url("main.php?area=$area&frame=3&file=$filename"),
'right_bottom',
$sess->url("main.php?area=$area&frame=4&action=$sActionEdit&file=$filename&tmp_file=$filename"),
$filename, $filename, clHtmlSpecialChars($filename));
$tpl->set('d', 'FILENAME', $html_filename);
$delTitle = i18n("Delete File");
$delDescr = sprintf(i18n("Do you really want to delete the following file:
%s
"), $filename);
if ($perm->have_perm_area_action('style', $sActionDelete)) {
$tpl->set('d', 'DELETE', '');
} else {
$tpl->set('d', 'DELETE', '');
}
if (stripslashes($_REQUEST['file']) == $filename) {
$tpl->set('d', 'ID', 'id="marked"');
} else {
$tpl->set('d', 'ID', '');
}
$tpl->next();
}
}
} else {
if ((int) $client > 0) {
$notification->displayNotification("error", i18n("Directory is not existing or readable!") . "
$path");
}
}
$tpl->generate($cfg['path']['templates'] . $cfg['templates']['files_overview']);
?>