File: /home/temp/yarusvl.ru/adminx/ajax/save_style.php
<?php
if(!$mgc->managers->access('design')) {
exit();
}
// Проверка сессии для защиты от xss
if(!$mgc->request->check_session()) {
trigger_error('Session expired', E_USER_WARNING);
exit();
}
$content = $mgc->request->post('content');
$style = $mgc->request->post('style');
$theme = $mgc->request->post('theme', 'string');
if(pathinfo($style, PATHINFO_EXTENSION) != 'css') {
exit();
}
/*Сохранение стилей из админки*/
$file = $mgc->config->root_dir.'tpls/'.$theme.'/css/'.$style;
if(is_file($file) && is_writable($file) && !is_file($mgc->config->root_dir.'tpls/'.$theme.'/locked')) {
file_put_contents($file, $content);
$css_version = ltrim($mgc->settings->css_version, '0');
if (!$css_version) {
$css_version = 0;
}
$mgc->settings->css_version = str_pad(++$css_version, 6, 0, STR_PAD_LEFT);
}
$result = true;
header("Content-type: application/json; charset=UTF-8");
header("Cache-Control: must-revalidate");
header("Pragma: no-cache");
header("Expires: -1");
$json = json_encode($result);
print $json;