Файл: pages/settings.php
Строк: 91
<?php
include '../engine/includes/start.php';
//if (!$user_id)
//Core::stop();
Core::add_words('user.ini');
$set['title'] = __('Мои настройки');
$cache = new Cache(tmpDir . 'themes.swc');
if (!$cache->life())
{
$opendir = opendir(H.'style/themes/');
$themes = array();
while ($theme = readdir($opendir))
{
if ($theme == '.' || $theme == '..' || !is_dir(H.'style/themes/'.$theme))
continue;
$config = parse_ini_file(H.'style/themes/'.$theme.'/theme.ini');
$themes[$theme] = $config['name'];
}
closedir($opendir);
$cache->write(serialize($themes));
}
$themes = unserialize($cache->read());
$cache = new Cache(tmpDir . 'langs.swc');
if (!$cache->life())
{
$opendir = opendir(H.'engine/files/languages/');
while ($lang = readdir($opendir))
{
if ($lang == '.' || $lang == '..' || !is_dir(H.'engine/files/languages/'.$lang))
continue;
$config = parse_ini_file(H.'engine/files/languages/'.$lang.'/lang.ini');
$langs[$lang] = $config['name'];
}
closedir($opendir);
$cache->write(serialize($langs));
}
$langs = unserialize($cache->read());
if (isset($_POST['save']))
{
if (isset($_POST['theme']) && is_dir(H.'style/themes/'.$_POST['theme']))
{
$show_theme = $_COOKIE['set_theme'] = $user['set_them'] = Core::form('theme');
setcookie('set_theme', Core::form('theme') , ($time + 64800), '/');
}
if (Core::form('lang') && is_dir(H.'engine/files/languages/'.Core::form('lang')))
{
$_COOKIE['language'] = Core::$language = Core::form('lang');
Core::$lang_words = parse_ini_file(H . 'engine/files/languages/' . Core::$language . '/words.ini');
setcookie('language', Core::form('lang') , ($time + 64800), '/');
}
if ($user_id)
{
$user = Core::get_user($user_id, true);
$sql->query("UPDATE `user` SET `set_them` = '".$user['set_them']."' WHERE `id` = ".$user_id." LIMIT 1");
}
//Core::msg_show('Сохранение успешно', 'msg');
}
include incDir . 'head.php';
?>
<form method="post">
<?=__('Тема')?>:<br />
<select name='theme'>
<?php
foreach($themes as $theme => $name)
{
echo '<option value="'.$theme.'"'.($theme == $show_theme ? ' selected="selected"' : '').'>'.$name.'</option>';
}
?>
</select><hr />
<?=__('Язык сайта')?>:<br />
<?php
foreach($langs as $code => $lang)
{
echo ' <img src="/style/icons/flags/'.$code.'.png"/> <label><input type="radio" name="lang" value="'.$code.'"'.($code == Core::$language ? ' checked="checked"' : '').'/ > ' .$lang .'</label><br />';
}
?>
<br />
<input type='submit' name='save' value='<?=__('Сохранить')?>'/>
</form>
<div class='link'>
« <a href='menu.php'><?=$user_id ? __('Кабинет') : __('Вход')?></a><br />
</div>
<?php
include incDir . 'foot.php';