AVE.CMS v3.28
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

894 lines
24 KiB

7 years ago
<?php
/**
7 years ago
* AVE.cms
*
* @package AVE.cms
* @version 3.x
* @filesource
* @copyright © 2007-2014 AVE.cms, http://www.ave-cms.ru
7 years ago
*
*/
/**
7 years ago
* Класс управления настройками системы
7 years ago
*/
7 years ago
class AVE_Settings
7 years ago
{
7 years ago
/**
* СВОЙСТВА
*/
/**
* Количество стран на странице
*
* @public int
*/
public $_limit = 15;
7 years ago
/**
7 years ago
* ВНЕШНИЕ МЕТОДЫ
7 years ago
*/
7 years ago
/**
* Метод отображения настроек
*
*/
function settingsShow()
7 years ago
{
7 years ago
global $AVE_Template;
$date_formats = array(
'%d.%m.%Y',
'%d %B %Y',
'%A, %d.%m.%Y',
'%A, %d %B %Y'
);
$time_formats = array(
'%d.%m.%Y, %H:%M',
'%d %B %Y, %H:%M',
'%A, %d.%m.%Y (%H:%M)',
'%A, %d %B %Y (%H:%M)'
);
$AVE_Template->assign('date_formats', $date_formats);
$AVE_Template->assign('time_formats', $time_formats);
$AVE_Template->assign('row', get_settings());
$AVE_Template->assign('available_countries', get_country_list(1));
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_main.tpl'));
}
/**
* Метод отображения дополнительных настроек
*
*/
function settingsCase()
{
global $AVE_Template;
7 years ago
7 years ago
// Сохраняем настройки
if (isset($_REQUEST['more']))
7 years ago
{
7 years ago
$set = '<?php' . "\r\n\r\n";
7 years ago
foreach($_REQUEST['GLOB'] as $key => $type)
7 years ago
{
7 years ago
foreach($type as $k => $v)
7 years ago
{
7 years ago
switch ($GLOBALS['CMS_CONFIG'][$key][$k]['TYPE'])
{
case 'bool' :
$v = $v ? 'true' : 'false';
break;
case 'integer' :
$v = intval($v);
break;
case 'string' :
$v = "'" . add_slashes($v) . "'";
break;
case 'dropdown' :
$v = "'" . add_slashes($v) . "'";
break;
default :
$v = "'" . add_slashes($v) . "'";
break;
}
$set .= "\t" . "// " . $GLOBALS['CMS_CONFIG'][$key][$k]['DESCR'] . "\r\n";
$set .= "\t" . "define('" . $k . "', " . $v . ");\r\n\r\n";
7 years ago
}
7 years ago
}
7 years ago
7 years ago
$set .= '?>';
7 years ago
7 years ago
$result = file_put_contents(BASE_DIR . '/config/config.inc.php', $set);
7 years ago
7 years ago
if ($result > 0)
{
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED');
$header = $AVE_Template->get_config_vars('SETTINGS_SUCCESS');
$theme = 'accept';
reportLog($AVE_Template->get_config_vars('SETTINGS_SAVE_DOP'));
}
else
{
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED_ERR');
$header = $AVE_Template->get_config_vars('SETTINGS_ERROR');
$theme = 'error';
}
if (isAjax())
{
echo json_encode(array(
'message' => $message,
'header' => $header,
'theme' => $theme)
);
}
else
{
$AVE_Template->assign('message', $message);
header('Location:index.php?do=settings&sub=case&cp=' . SESSION);
}
7 years ago
7 years ago
exit;
// Выводим настройки
}
else
{
$AVE_Template->assign('CMS_CONFIG', $GLOBALS['CMS_CONFIG']);
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_case.tpl'));
}
}
/**
* Метод записи настроек
*
*/
function settingsSave()
{
global $AVE_DB, $AVE_Template;
$muname = ($_REQUEST['mail_smtp_login']) ? "mail_smtp_login = '" . $_REQUEST['mail_smtp_login'] . "'," : '';
$mpass = ($_REQUEST['mail_smtp_pass']) ? "mail_smtp_pass = '" . $_REQUEST['mail_smtp_pass'] . "'," : '';
$msmp = ($_REQUEST['mail_sendmail_path']) ? "mail_sendmail_path = '" . $_REQUEST['mail_sendmail_path'] . "'," : '';
$mn = ($_REQUEST['mail_from_name']) ? "mail_from_name = '" . $_REQUEST['mail_from_name'] . "'," : '';
$ma = ($_REQUEST['mail_from']) ? "mail_from = '" . $_REQUEST['mail_from'] . "'," : '';
$ep = ($_REQUEST['page_not_found_id']) ? "page_not_found_id = '" . $_REQUEST['page_not_found_id'] . "'," : '';
$sn = ($_REQUEST['site_name']) ? "site_name = '" . $_REQUEST['site_name'] . "'," : '';
$mp = ($_REQUEST['mail_port']) ? "mail_port = '" . $_REQUEST['mail_port'] . "'," : '';
$mh = ($_REQUEST['mail_host']) ? "mail_host = '" . $_REQUEST['mail_host'] . "'," : '';
$sql = $AVE_DB->Query("
UPDATE
" . PREFIX . "_settings
SET
" . $muname . "
" . $mpass . "
mail_smtp_encrypt = '" . $_REQUEST['mail_smtp_encrypt'] . "',
" . $msmp . "
" . $ma . "
" . $mn . "
" . $ep . "
" . $sn . "
" . $mp . "
" . $mh . "
default_country = '" . $_REQUEST['default_country'] . "',
mail_type = '" . $_REQUEST['mail_type'] . "',
mail_content_type = '" . $_REQUEST['mail_content_type'] . "',
mail_word_wrap = '" . (int)$_REQUEST['mail_word_wrap'] . "',
mail_new_user = '" . $_REQUEST['mail_new_user'] . "',
mail_signature = '" . $_REQUEST['mail_signature'] . "',
message_forbidden = '" . $_REQUEST['message_forbidden'] . "',
hidden_text = '" . $_REQUEST['hidden_text'] . "',
navi_box = '" . $_REQUEST['navi_box'] . "',
start_label = '" . $_REQUEST['start_label'] . "',
end_label = '" . $_REQUEST['end_label'] . "',
separator_label = '" . $_REQUEST['separator_label'] . "',
next_label = '" . $_REQUEST['next_label'] . "',
prev_label = '" . $_REQUEST['prev_label'] . "',
total_label = '" . $_REQUEST['total_label'] . "',
link_box = '" . $_REQUEST['link_box'] . "',
total_box = '" . $_REQUEST['total_box'] . "',
active_box = '" . $_REQUEST['active_box'] . "',
separator_box = '" . $_REQUEST['separator_box'] . "',
bread_box = '" . $_REQUEST['bread_box'] . "',
bread_show_main = '" . ($_REQUEST['bread_show_main'] != 0 ? 1 : 0) . "',
bread_show_host = '" . ($_REQUEST['bread_show_host'] != 0 ? 1 : 0) . "',
bread_sepparator = '" . $_REQUEST['bread_sepparator'] . "',
bread_sepparator_use = '" . ($_REQUEST['bread_sepparator_use'] != 0 ? 1 : 0) . "',
bread_link_box = '" . $_REQUEST['bread_link_box'] . "',
bread_link_template = '" . $_REQUEST['bread_link_template'] . "',
bread_self_box = '" . $_REQUEST['bread_self_box'] . "',
bread_link_box_last = '" . ($_REQUEST['bread_link_box_last'] != 0 ? 1 : 0) . "',
date_format = '" . $_REQUEST['date_format'] . "',
time_format = '" . $_REQUEST['time_format'] . "',
7 years ago
use_doctime = '" . intval($_REQUEST['use_doctime']) . "'
7 years ago
WHERE
Id = 1
");
if ($sql->_result === false)
7 years ago
{
7 years ago
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED_ERR');
$header = $AVE_Template->get_config_vars('SETTINGS_ERROR');
$theme = 'error';
7 years ago
}
7 years ago
else
{
7 years ago
$this->clearSettingsCache();
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED');
$header = $AVE_Template->get_config_vars('SETTINGS_SUCCESS');
$theme = 'accept';
reportLog($AVE_Template->get_config_vars('SETTINGS_SAVE_MAIN'));
7 years ago
}
7 years ago
7 years ago
if (isset($_REQUEST['ajax']) && $_REQUEST['ajax'] = '1')
7 years ago
{
7 years ago
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
7 years ago
}
7 years ago
else
{
$AVE_Template->assign('message', $message);
7 years ago
header('Location:index.php?do=settings&cp=' . SESSION);
7 years ago
}
7 years ago
exit;
}
7 years ago
7 years ago
/**
* Метод отображения списка стран
*
*/
function settingsCountriesList()
7 years ago
{
7 years ago
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
$sql = $AVE_DB->Query("
SELECT SQL_CALC_FOUND_ROWS *
FROM
" . PREFIX . "_countries
ORDER BY country_status ASC, country_name ASC
LIMIT " . (get_current_page() * $this->_limit - $this->_limit) . "," . $this->_limit
);
7 years ago
7 years ago
$countries = array();
7 years ago
7 years ago
while ($row = $sql->FetchAssocArray())
array_push($countries, $row);
7 years ago
7 years ago
$num = $AVE_DB->Query("SELECT FOUND_ROWS()")->GetCell();
7 years ago
7 years ago
if ($num > $this->_limit)
{
$page_nav = "<a href=\"index.php?do=settings&sub=countries&page={s}&cp=" . SESSION . "\">{t}</a>";
$page_nav = get_pagination(ceil($num / $this->_limit), 'page', $page_nav);
$AVE_Template->assign('page_nav', $page_nav);
}
7 years ago
7 years ago
$AVE_Template->assign('countries', $countries);
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_countries.tpl'));
7 years ago
}
7 years ago
/**
* Метод записи параметров стран
*
*/
function settingsCountriesSave()
7 years ago
{
7 years ago
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
foreach ($_POST['country_name'] as $id => $country_name)
{
$AVE_DB->Query("
UPDATE " . PREFIX . "_countries
SET
country_name = '" . $country_name . "',
country_status = '" . $_POST['country_status'][$id] . "',
country_eu = '" . $_POST['country_eu'][$id] . "'
WHERE
Id = '" . $id . "'
");
}
7 years ago
7 years ago
reportLog($AVE_Template->get_config_vars('SETTINGS_SAVE_COUNTRY'));
}
7 years ago
7 years ago
/**
* Метод отображения списка языков
*
*/
function settingsLanguageList()
7 years ago
{
7 years ago
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
$sql = $AVE_DB->Query("
SELECT
*
FROM
" . PREFIX . "_settings_lang
ORDER BY lang_default DESC, lang_status ASC, lang_key ASC
");
7 years ago
7 years ago
$language = array();
7 years ago
7 years ago
while ($row = $sql->FetchAssocArray())
array_push($language, $row);
7 years ago
7 years ago
$AVE_Template->assign('language', $language);
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_lang.tpl'));
7 years ago
}
7 years ago
7 years ago
/**
* Метод Редактирования параметров языков
*
*/
function settingsLanguageEdit()
7 years ago
{
7 years ago
global $AVE_DB, $AVE_Template;
if (isset($_REQUEST["Id"]))
{
$items = $AVE_DB->Query("
SELECT
*
FROM
" . PREFIX . "_settings_lang
WHERE
Id = '" . $_REQUEST["Id"] . "'
")->FetchRow();
$AVE_Template->assign('items', $items);
}
7 years ago
7 years ago
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_lang_edit.tpl'));
7 years ago
}
7 years ago
function settingsLanguageEditSave()
{
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
if (! empty($_REQUEST["Id"]))
{
$AVE_DB->Query("
UPDATE
" . PREFIX . "_settings_lang
SET
lang_key = '" .$_REQUEST['lang_key']. "',
lang_alias_pref = '" .$_REQUEST['lang_alias_pref']. "',
lang_name = '" .$_REQUEST['lang_name']. "'
WHERE
Id = '" . $_REQUEST["Id"] . "'
");
}
else
{
$AVE_DB->Query("
INSERT INTO
" . PREFIX . "_settings_lang
SET
lang_key = '" .$_REQUEST['lang_key']. "',
lang_name = '" .$_REQUEST['lang_name']. "',
lang_alias_pref = '" .$_REQUEST['lang_alias_pref']. "',
lang_default = '0',
lang_status = '0'
");
7 years ago
7 years ago
}
7 years ago
7 years ago
$AVE_DB->clearCache('langs');
7 years ago
7 years ago
echo "<script>window.opener.location.reload(); window.close();</script>";
}
7 years ago
7 years ago
function settingsPaginationsList()
{
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
$sql = "
SELECT
id,
pagination_name
FROM
" . PREFIX . "_paginations
";
7 years ago
7 years ago
$query = $AVE_DB->Query($sql);
7 years ago
7 years ago
$items = array();
7 years ago
7 years ago
while ($row = $query->FetchRow())
array_push($items, $row);
7 years ago
7 years ago
$AVE_Template->assign('items', $items);
7 years ago
7 years ago
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_pagination.tpl'));
}
7 years ago
7 years ago
function settingsPaginationsNew()
{
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
$pagination = new stdClass();
7 years ago
7 years ago
$AVE_Template->assign('pagination', $pagination);
$AVE_Template->assign('content', $AVE_Template->fetch('settings/pagination_edit.tpl'));
}
7 years ago
7 years ago
function settingsPaginationsEdit()
7 years ago
{
7 years ago
global $AVE_DB, $AVE_Template;
7 years ago
$sql = "
7 years ago
SELECT
*
FROM
7 years ago
" . PREFIX . "_paginations
WHERE
id = '" . $_REQUEST['id'] . "'
";
7 years ago
$pagination = $AVE_DB->Query($sql)->FetchRow();
7 years ago
7 years ago
$AVE_Template->assign('pagination', $pagination);
$AVE_Template->assign('content', $AVE_Template->fetch('settings/pagination_edit.tpl'));
}
7 years ago
7 years ago
function settingsPaginationsSave()
{
global $AVE_DB, $AVE_Template;
// Если пришел ID
if (isset($_REQUEST['id']) && $_REQUEST['id'] > 0)
7 years ago
{
$sql = "
7 years ago
UPDATE
7 years ago
" . PREFIX . "_paginations
SET
pagination_name = '" . $_REQUEST['pagination_name'] . "',
pagination_box = '" . $_REQUEST['pagination_box'] . "',
pagination_start_label = '" . $_REQUEST['pagination_start_label'] . "',
pagination_end_label = '" . $_REQUEST['pagination_end_label'] . "',
pagination_separator_box = '" . $_REQUEST['pagination_separator_box'] . "',
pagination_separator_label = '" . $_REQUEST['pagination_separator_label'] . "',
pagination_next_label = '" . $_REQUEST['pagination_next_label'] . "',
pagination_prev_label = '" . $_REQUEST['pagination_prev_label'] . "',
pagination_link_box = '" . $_REQUEST['pagination_link_box'] . "',
pagination_active_link_box = '" . $_REQUEST['pagination_active_link_box'] . "',
pagination_link_template = '" . $_REQUEST['pagination_link_template'] . "',
pagination_link_active_template = '" . $_REQUEST['pagination_link_active_template'] . "'
7 years ago
WHERE
id = '" . $_REQUEST['id'] . "'
7 years ago
";
7 years ago
$query = $AVE_DB->Query($sql);
7 years ago
7 years ago
if ($query === false)
{
$message = $AVE_Template->get_config_vars('PAGINATION_SAVED_ERR');
$header = $AVE_Template->get_config_vars('PAGINATION_ERROR');
$theme = 'error';
}
else
{
AVE_Paginations::clearCache();
7 years ago
7 years ago
$message = $AVE_Template->get_config_vars('PAGINATION_SAVED');
$header = $AVE_Template->get_config_vars('PAGINATION_SUCCESS');
$theme = 'accept';
}
7 years ago
7 years ago
if (isAjax())
{
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
}
else
{
header('Location:index.php?do=settings&action=paginations&cp=' . SESSION);
}
7 years ago
7 years ago
exit;
}
// Если не пришел ID
else
{
$sql = "
INSERT INTO
" . PREFIX . "_paginations
SET
pagination_name = '" . $_REQUEST['pagination_name'] . "',
pagination_box = '" . $_REQUEST['pagination_box'] . "',
pagination_start_label = '" . $_REQUEST['pagination_start_label'] . "',
pagination_end_label = '" . $_REQUEST['pagination_end_label'] . "',
pagination_separator_box = '" . $_REQUEST['pagination_separator_box'] . "',
pagination_separator_label = '" . $_REQUEST['pagination_separator_label'] . "',
pagination_next_label = '" . $_REQUEST['pagination_next_label'] . "',
pagination_prev_label = '" . $_REQUEST['pagination_prev_label'] . "',
pagination_link_box = '" . $_REQUEST['pagination_link_box'] . "',
pagination_active_link_box = '" . $_REQUEST['pagination_active_link_box'] . "',
pagination_link_template = '" . $_REQUEST['pagination_link_template'] . "',
pagination_link_active_template = '" . $_REQUEST['pagination_link_active_template'] . "'
";
}
7 years ago
7 years ago
$query = $AVE_DB->Query($sql);
header('Location:index.php?do=settings&action=paginations&cp=' . SESSION);
exit;
7 years ago
}
7 years ago
function settingsPaginationsDel()
{
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
if (isset($_REQUEST['id']) && $_REQUEST['id'] > 1)
{
$sql = "
DELETE
FROM
" . PREFIX . "_paginations
WHERE
id = '" . $_REQUEST['id'] . "'
";
7 years ago
7 years ago
$AVE_DB->Query($sql);
AVE_Paginations::clearCache();
}
header('Location:index.php?do=settings&action=paginations&cp=' . SESSION);
exit;
}
/**
* Функция делает рекурсивный обход вложенных папок, и добавляет их в архив
*
* @param string $src_dir папка которую хотим заархивировать
* @param string $zip Куда кладем и как называем файл архива
* @return ZIP
*/
function ZipDirectory($src_dir, $zip, $dir_in_archive = '')
7 years ago
{
7 years ago
$dirHandle = opendir($src_dir);
while (false !== ($file = readdir($dirHandle)))
7 years ago
{
7 years ago
if (($file != '.') && ($file != '..'))
7 years ago
{
7 years ago
if (! is_dir($src_dir . $file))
7 years ago
{
7 years ago
$zip->addFile($src_dir . $file, $dir_in_archive.$file);
7 years ago
}
7 years ago
else
{
$zip->addEmptyDir($dir_in_archive.$file);
$zip = ZipDirectory($src_dir . $file . DIRECTORY_SEPARATOR, $zip, $dir_in_archive . $file . DIRECTORY_SEPARATOR);
}
}
7 years ago
}
7 years ago
return $zip;
}
7 years ago
7 years ago
/**
* Функция проверяет, возможно ли создать zip-архив, запускает
* ZipDirectory и закрывает файл при завершении обхода папок.
*
* @param string $src_dir папка которую хотим заархивировать
* @param string $archive_path Куда кладем и как называем файл архива
* @return bool true|false
*/
function ZipFull($src_dir, $archive_path)
7 years ago
{
7 years ago
$zip = new ZipArchive();
7 years ago
7 years ago
if ($zip->open($archive_path, ZIPARCHIVE::CREATE) !== true)
{
return false;
}
7 years ago
7 years ago
$zip = ZipDirectory($src_dir,$zip);
7 years ago
7 years ago
$zip->close();
7 years ago
7 years ago
return true;
}
7 years ago
7 years ago
/**
* Функция очищает кеш системных настроек
*
*/
function clearSettingsCache()
{
$cache_dir = BASE_DIR . '/tmp/cache/sql/settings/';
7 years ago
7 years ago
return rrmdir($cache_dir);
}
7 years ago
7 years ago
/**
* Функция редактирования robots.txt
*
*/
function editRobots()
{
global $AVE_DB, $AVE_Template;
7 years ago
7 years ago
$file_name = 'robots.txt';
7 years ago
7 years ago
$_REQUEST['sub'] = (! isset($_REQUEST['sub']))
? ''
: $_REQUEST['sub'];
7 years ago
7 years ago
switch ($_REQUEST['sub'])
{
case 'save':
$file = BASE_DIR . '/' . $file_name;
7 years ago
7 years ago
$template = stripcslashes($_REQUEST['code_text']);
7 years ago
7 years ago
$result = file_put_contents($file, trim($template));
if ($result === false)
7 years ago
{
7 years ago
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED_ERR_FILE');
$header = $AVE_Template->get_config_vars('SETTINGS_ERROR');
$theme = 'error';
7 years ago
}
7 years ago
else
{
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED_FILE');
$header = $AVE_Template->get_config_vars('SETTINGS_SUCCESS');
$theme = 'accept';
}
if (isAjax())
7 years ago
{
7 years ago
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
7 years ago
}
7 years ago
else
{
$AVE_Template->assign('message', $message);
header('Location:index.php?do=settings&cp=' . SESSION);
}
exit;
7 years ago
7 years ago
default:
$file = BASE_DIR . '/' . $file_name;
7 years ago
7 years ago
$template = file_get_contents($file);
7 years ago
7 years ago
$formaction = "index.php?do=settings&action=robots&sub=save&cp=" . SESSION;
7 years ago
7 years ago
$AVE_Template->assign('file_name', $file_name);
$AVE_Template->assign('formaction', $formaction);
$AVE_Template->assign('template', $template);
break;
}
7 years ago
7 years ago
$AVE_Template->assign('content', $AVE_Template->fetch('settings/edit_file.tpl'));
}
7 years ago
7 years ago
/**
* Функция редактирования func.custom.php
*
*/
function editCustom()
{
5 years ago
global $AVE_Template;
7 years ago
7 years ago
$file_name = 'func.custom.php';
7 years ago
7 years ago
$_REQUEST['sub'] = (! isset($_REQUEST['sub']))
? ''
: $_REQUEST['sub'];
7 years ago
7 years ago
switch ($_REQUEST['sub'])
{
case 'save':
$file = BASE_DIR . '/functions/' . $file_name;
7 years ago
7 years ago
$template = stripcslashes($_REQUEST['code_text']);
7 years ago
7 years ago
$result = file_put_contents($file, trim($template));
7 years ago
7 years ago
if ($result === false)
7 years ago
{
7 years ago
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED_ERR_FILE');
$header = $AVE_Template->get_config_vars('SETTINGS_ERROR');
$theme = 'error';
7 years ago
}
7 years ago
else
{
$message = $AVE_Template->get_config_vars('SETTINGS_SAVED_FILE');
$header = $AVE_Template->get_config_vars('SETTINGS_SUCCESS');
$theme = 'accept';
}
if (isAjax())
7 years ago
{
7 years ago
echo json_encode(array('message' => $message, 'header' => $header, 'theme' => $theme));
7 years ago
}
7 years ago
else
{
$AVE_Template->assign('message', $message);
header('Location:index.php?do=settings&cp=' . SESSION);
}
exit;
7 years ago
7 years ago
default:
$file = BASE_DIR . '/functions/' . $file_name;
7 years ago
7 years ago
$template = file_get_contents($file);
7 years ago
7 years ago
$formaction = "index.php?do=settings&action=custom&sub=save&cp=" . SESSION;
7 years ago
7 years ago
$AVE_Template->assign('file_name', $file_name);
$AVE_Template->assign('formaction', $formaction);
$AVE_Template->assign('template', $template);
break;
}
7 years ago
7 years ago
$AVE_Template->assign('content', $AVE_Template->fetch('settings/edit_file.tpl'));
}
5 years ago
function showCache ()
{
global $AVE_Template;
$AVE_Template->assign('content', $AVE_Template->fetch('settings/settings_cache.tpl'));
}
function showCacheSize ()
{
4 years ago
global $AVE_Template;
5 years ago
switch ($_REQUEST['source'])
{
case 'smarty':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/smarty'));
break;
4 years ago
case 'block':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/block'));
break;
5 years ago
case 'documents':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/documents'));
break;
case 'langs':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/langs'));
break;
case 'modules':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/modules'));
break;
case 'navigations':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/navigations'));
break;
case 'paginations':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/paginations'));
break;
case 'requests':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/requests'));
break;
case 'rubrics':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/rubrics'));
break;
case 'sessions':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/session'));
break;
4 years ago
case 'sysblocks':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/sysblocks'));
break;
5 years ago
case 'settings':
$size = format_size(get_dir_size(BASE_DIR . '/tmp/cache/sql/settings'));
break;
}
$return = [
'size' => $size,
4 years ago
'message' => $AVE_Template->get_config_vars('SETTINGS_SUCCESS'),
5 years ago
'theme' => 'accept'
];
_json($return, true);
}
function clearCache ()
{
global $AVE_Template;
switch ($_REQUEST['source'])
{
case 'smarty':
$cache_dir = BASE_DIR . '/tmp/cache/smarty';
break;
4 years ago
case 'block':
$cache_dir = BASE_DIR . '/tmp/cache/sql/block';
4 years ago
break;
5 years ago
case 'documents':
$cache_dir = BASE_DIR . '/tmp/cache/sql/documents';
break;
case 'langs':
$cache_dir = BASE_DIR . '/tmp/cache/sql/langs';
break;
case 'modules':
$cache_dir = BASE_DIR . '/tmp/cache/sql/modules';
break;
case 'navigations':
$cache_dir = BASE_DIR . '/tmp/cache/sql/navigations';
break;
case 'paginations':
$cache_dir = BASE_DIR . '/tmp/cache/sql/paginations';
break;
case 'requests':
$cache_dir = BASE_DIR . '/tmp/cache/sql/requests';
break;
case 'rubrics':
$cache_dir = BASE_DIR . '/tmp/cache/sql/rubrics';
break;
4 years ago
case 'sysblocks':
4 years ago
$cache_dir = BASE_DIR . '/tmp/cache/sql/sysblocks';
4 years ago
break;
5 years ago
case 'sessions':
$cache_dir = BASE_DIR . '/tmp/session';
break;
case 'settings':
$cache_dir = BASE_DIR . '/tmp/cache/sql/settings';
break;
}
$remove = rrmdir($cache_dir);
$return = [
'size' => format_size(get_dir_size($cache_dir)),
4 years ago
'header' => $remove ? $AVE_Template->get_config_vars('SETTINGS_CACHE_SUCCESS') : $AVE_Template->get_config_vars('SETTINGS_CACHE_ERROR'),
'message' => $remove ? $AVE_Template->get_config_vars('SETTINGS_CACHE_SUCCESS_T') : $AVE_Template->get_config_vars('SETTINGS_CACHE_ERROR_T'),
5 years ago
'theme' => $remove ? 'accept' : 'error'
];
_json($return, true);
}
7 years ago
}
7 years ago
?>