Пример #1
0
function load_css2_file($filename, $styledir)
{
    $data = '';
    $lines = file($filename);
    //
    foreach ($lines as $line) {
        if (preg_match_all("/@import( |\t)+('|\")(.*)(|\")( |\t)*;/U", $line, $importfiles, PREG_SET_ORDER)) {
            foreach ($importfiles as $file) {
                $import = $styledir . '/' . $file[3];
                $data .= load_css2_file($import, substr($import, 0, strrpos($import, "/")));
                $line = str_replace($file[0], "", $line);
            }
        }
        // TODO: Does it matter what $line may contain smth before '@import'? :)
        $data .= $line;
    }
    return $data;
}
Пример #2
0
}
if (!isset($_REQUEST["sub"])) {
    $_REQUEST["sub"] = '';
}
if (!isset($_REQUEST["try"])) {
    $_REQUEST["try"] = '';
}
$editstyle = preg_replace("/[^-_a-z\\d]/i", "", $_REQUEST["editstyle"]);
$styledir = "styles";
if (isset($_REQUEST["edit"]) and $_REQUEST["edit"]) {
    $action = 'edit';
    //	$data = implode("",file("$styledir/$editstyle.css"));
    if ($tikidomain and is_file("{$styledir}/{$tikidomain}/{$editstyle}.css")) {
        $data = load_css2_file("{$styledir}/{$tikidomain}/{$editstyle}.css", $styledir);
    } else {
        $data = load_css2_file("{$styledir}/{$editstyle}.css", $styledir);
    }
} elseif (isset($_REQUEST["save"]) and $_REQUEST["save"]) {
    check_ticket('edit-css');
    $action = 'display';
    $data = '';
    if ($tikidomain and is_dir("{$styledir}/{$tikidomain}")) {
        $fp = fopen("{$styledir}/{$tikidomain}/{$editstyle}.css", "w");
    } else {
        $fp = fopen("{$styledir}/{$editstyle}.css", "w");
    }
    if (!$fp) {
        $smarty->assign('errortype', 401);
        $smarty->assign('msg', tra("You do not have permission to write the style sheet"));
        $smarty->display("error.tpl");
        die;