File: /home/temp/yarusvl.ru/adminx/ajax/save_script.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');
$script = $mgc->request->post('script');
$theme = $mgc->request->post('theme', 'string');
if(pathinfo($script, PATHINFO_EXTENSION) != 'js') {
exit();
}
/*Сохранение скриптов из админки*/
$file = $mgc->config->root_dir.'tpls/'.$theme.'/js/'.$script;
if(is_file($file) && is_writable($file) && !is_file($mgc->config->root_dir.'tpls/'.$theme.'/locked')) {
file_put_contents($file, $content);
$js_version = ltrim($mgc->settings->js_version, '0');
if (!$js_version) {
$js_version = 0;
}
$mgc->settings->js_version = str_pad(++$js_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;