Init
This commit is contained in:
36
simpla/ajax/save_template.php
Normal file
36
simpla/ajax/save_template.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
session_start();
|
||||
|
||||
chdir('../..');
|
||||
require_once('api/Simpla.php');
|
||||
|
||||
$simpla = new Simpla();
|
||||
|
||||
if(!$simpla->managers->access('design'))
|
||||
return false;
|
||||
|
||||
// Проверка сессии для защиты от xss
|
||||
if(!$simpla->request->check_session())
|
||||
{
|
||||
trigger_error('Session expired', E_USER_WARNING);
|
||||
exit();
|
||||
}
|
||||
$content = $simpla->request->post('content');
|
||||
$template = $simpla->request->post('template');
|
||||
$theme = $simpla->request->post('theme', 'string');
|
||||
|
||||
if(pathinfo($template, PATHINFO_EXTENSION) != 'tpl')
|
||||
exit();
|
||||
|
||||
$file = $simpla->config->root_dir.'design/'.$theme.'/html/'.$template;
|
||||
if(is_file($file) && is_writable($file) && !is_file($simpla->config->root_dir.'design/'.$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;
|
||||
Reference in New Issue
Block a user