File: /home/temp/yarusvl.ru/adminx/ajax/save_template.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');
$template = $mgc->request->post('template');
$theme = $mgc->request->post('theme', 'string');
if(pathinfo($template, PATHINFO_EXTENSION) != 'tpl') {
exit();
}
/*Сохранение файлов шаблона из админки*/
$file = $mgc->config->root_dir.'tpls/'.$theme.'/html/'.$template;
if(is_file($file) && is_writable($file) && !is_file($mgc->config->root_dir.'tpls/'.$theme.'/locked')) {
file_put_contents($file, $content);
}
$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;