Files
AtomicOld/simpla/ajax/save_style.php

36 lines
943 B
PHP
Raw Normal View History

2026-02-14 19:34:54 +03:00
<?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');
$style = $simpla->request->post('style');
$theme = $simpla->request->post('theme', 'string');
if(pathinfo($style, PATHINFO_EXTENSION) != 'css')
exit();
$file = $simpla->config->root_dir.'design/'.$theme.'/css/'.$style;
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;