<?
include_once '../sys/inc/start.php';
include_once '../sys/inc/compress.php';
include_once '../sys/inc/sess.php';
include_once '../sys/inc/home.php';
include_once '../sys/inc/settings.php';
$temp_set=$set;
include_once '../sys/inc/db_connect.php';
include_once '../sys/inc/ipua.php';
include_once '../sys/inc/fnc.php';
include_once '../sys/inc/user.php';
only_level(4);

if (!isset($access['settings_change'])){header("Location: index.php?".SID);exit;}
$set['title']='Настройки системы';
include_once '../sys/inc/thead.php';
title();
if (isset($_POST['save']))
{

$temp_set['title']=esc($_POST['title']);
$temp_set['mail_backup']=esc($_POST['mail_backup']);
$temp_set['p_str']=intval($_POST['p_str']);
mysql_query("ALTER TABLE `user` CHANGE `set_p_str` `set_p_str` INT( 11 ) DEFAULT '$temp_set[p_str]'");


if (!ereg('\.\.',$_POST['set_them']) && is_dir(H.'style/themes/'.$_POST['set_them']))
{
$temp_set['set_them']=$_POST['set_them'];
mysql_query("ALTER TABLE `user` CHANGE `set_them` `set_them` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '$temp_set[set_them]'");
}
if (!ereg('\.\.',$_POST['set_them2']) && is_dir(H.'style/themes/'.$_POST['set_them2']))
{
$temp_set['set_them2']=$_POST['set_them2'];
mysql_query("ALTER TABLE `user` CHANGE `set_them2` `set_them2` VARCHAR( 32 ) CHARACTER SET utf8 COLLATE utf8_general_ci DEFAULT '$temp_set[set_them2]'");
}
if ($_POST['set_show_icon']==2 || $_POST['set_show_icon']==1 || $_POST['set_show_icon']==0)
{
$temp_set['set_show_icon']=intval($_POST['set_show_icon']);
mysql_query("ALTER TABLE `user` CHANGE `set_show_icon` `set_show_icon` SET( '0', '1', '2' ) DEFAULT '$temp_set[set_show_icon]'");
}


$temp_set['meta_keywords']=esc(stripcslashes(htmlspecialchars($_POST['meta_keywords'])),1);
$temp_set['meta_description']=esc(stripcslashes(htmlspecialchars($_POST['meta_description'])),1);




if (save_settings($temp_set))
msg('Настройки успешно приняты');
else
$err='Нет прав для изменения файла настроек';
}
err();
aut();



echo "<form method=\"post\" action=\"?\">\n";

echo "Название сайта:<br />\n<input name=\"title\" value=\"$temp_set[title]\" type=\"text\" /><br />\n";
echo "Пунктов на страницу:<br />\n<input name=\"p_str\" value=\"$temp_set[p_str]\" type=\"text\" /><br />\n";


echo "Иконки:<br />\n<select name=\"set_show_icon\">\n";
if ($temp_set['set_show_icon']==2)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"2\"$sel>Большие</option>\n";
if ($temp_set['set_show_icon']==1)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"1\"$sel>Маленькие</option>\n";
if ($temp_set['set_show_icon']==0)$sel=' selected="selected"';else $sel=NULL;
echo "<option value=\"0\"$sel>Скрывать</option>\n";
echo "</select><br />\n";

echo "Тема (WAP):<br />\n<select name=\"set_them\">\n";
$opendirthem=opendir(H.'style/themes');
while ($themes=readdir($opendirthem)){
if (is_dir(H."style/themes/$themes") && $themes!='.' && $themes!='..')
{
if ($temp_set['set_them']==$themes)$check=' selected="selected"';else $check=NULL;
echo "<option$check value=\"$themes\">".trim(file_get_contents(H.'style/themes/'.$themes.'/them.name'))."</option>\n";
}
}
echo "</select><br />\n";

echo "Тема (WEB):<br />\n<select name=\"set_them2\">\n";
$opendirthem=opendir(H.'style/themes');
while ($themes=readdir($opendirthem)){
if (is_dir(H."style/themes/$themes") && $themes!='.' && $themes!='..')
{
if ($temp_set['set_them2']==$themes)$check=' selected="selected"';else $check=NULL;
echo "<option$check value=\"$themes\">".trim(file_get_contents(H.'style/themes/'.$themes.'/them.name'))."</option>\n";
}
}
echo "</select><br />\n";






$temp_set['meta_keywords']=(isset($temp_set['meta_keywords']))?$temp_set['meta_keywords']:null;
$temp_set['meta_description']=(isset($temp_set['meta_description']))?$temp_set['meta_description']:null;

echo "Ключевые слова (META):<br />\n";
echo "<textarea name='meta_keywords'>$temp_set[meta_keywords]</textarea><br />\n";
echo "Описание (META):<br />\n";
echo "<textarea name='meta_description'>$temp_set[meta_description]</textarea><br />\n";










echo "E-mail для BackUp:<br />\n<input type='text' name='mail_backup' value='$temp_set[mail_backup]'  /><br />\n";
echo "<input value=\"Изменить\" name='save' type=\"submit\" />\n";
echo "</form>\n";


echo "<div class='foot'>\n";
echo "&laquo;<a href='/adm_panel/'>В админку</a><br />\n";
echo "</div>\n";

include_once '../sys/inc/tfoot.php';
?>