<?
define("ADMIN_AUTHORIZATION",1);
include("../../../includes/common.php");
/*PAGE TITLE*/
$page_title = "Настройки";
$header = "Настройки";
$table = "system_settings";
/* pager start */
/*
$params['tables'] = $table;
$params['nocheckfield']=true;
$params['s_prefix'] = $table;
$pager = GetPagerParams($params);
*/
/* pager end */
/*
function LocalCheck(){
global $_POST;
global $DOCUMENT_ROOT,$PROJECT_ROOT,$ADMIN_ROOT;
global $SITE_DOCUMENT_ROOT;
$error = "";
if(!ValidateEmail($_POST['admin_email'])){
$error .="Administrator's e-mail is not correct.<br>\n";
}
if(!(is_numeric($_POST['min_login_length'])&&$_POST['min_login_length']>0)){
$error .="Wrong min. login length.<br>\n";
}
if(!(is_numeric($_POST['max_login_length'])&&$_POST['max_login_length']>0)){
$error .="Wrong max. login length.<br>\n";
}
if($error==""){
if($_POST['max_login_length']<=$_POST['mir_login_length']){
$error .="Max. login length must be more than min. length.<br>\n";
}
}
if(!(is_numeric($_POST['min_password_length'])&&$_POST['min_password_length']>0)){
$error .="Wrong min. password length.<br>\n";
}
if(!(is_numeric($_POST['max_password_length'])&&$_POST['max_password_length']>0)){
$error .="Wrong max. password length.<br>\n";
}
if($error==""){
if($_POST['max_password_length']<=$_POST['min_password_length']){
$error .="Max. password length must be more than min. length.<br>\n";
}
}
if(!(is_numeric($_POST['client_logo_max_size'])&&$_POST['client_logo_max_size']>0)){
$error .="Wrong client's logo max. size.<br>\n";
}
if(!(is_numeric($_POST['max_client_logo_width'])&&$_POST['max_client_logo_width']>0)){
$error .="Wrong client's logo width.<br>\n";
}
if(!(is_numeric($_POST['max_client_logo_height'])&&$_POST['max_client_logo_height']>0)){
$error .="Wrong client's logo height.<br>\n";
}
if(!(is_numeric($_POST['client_remember_login_timeout'])&&$_POST['client_remember_login_timeout']>0)){
$error .="Wrong client's login remember timeout.<br>\n";
}
if(!is_dir($SITE_DOCUMENT_ROOT.$_POST['client_logo_dir'])){
$error .= "Client's logo path is not exists or isn't correct.<br>\n";
}
if(!(is_numeric($_POST['client_session_timeout'])&&$_POST['client_session_timeout']>0)){
$error .="Timeout of client session is not correct.<br>\n";
}
if(!(is_numeric($_POST['remember_login_timeout'])&&$_POST['remember_login_timeout']>0)){
$error .="Timeout of admin login remember is not correct.<br>\n";
}
if(!(is_numeric($_POST['partner_default_payout_perc'])&&$_POST['partner_default_payout_perc']>=0&&$_POST['partner_default_payout_perc']<=100)){
$error .="Default partner payout is not correct.<br>\n";
}
if(!(is_numeric($_POST['admin_items_per_page'])&&$_POST['admin_items_per_page']>0)){
$error .="Count of records on list pages is not correct.<br>\n";
}
if(!(is_numeric($_POST['admin_pages_per_block'])&&$_POST['admin_pages_per_block']>0)){
$error .="Pages in one block is not correct.<br>\n";
}
// echo $PROJECT_ROOT.$_POST['html_editor_path'];
if(!is_dir($ADMIN_ROOT.$_POST['html_editor_path'])){
$error .= "WYSIWYG editor path is not exists or isn't correct.<br>\n";
}
if(!(is_numeric($_POST['second_subscription_discount'])&&$_POST['second_subscription_discount']>=0)){
$error .="Wrong one more registration discount.<br>\n";
}
if(!(is_numeric($_POST['second_subscription_discount_expiration'])&&$_POST['second_subscription_discount_expiration']>=0)){
$error .="Wrong one more registration discount expiration.<br>\n";
}
if(!(is_numeric($_POST['second_subscription_vendor_id']))){
$error .="Second subscription vendor is invalid.<br>\n";
}
if(!(is_numeric($_POST['rss_preview_width'])&&$_POST['rss_preview_width']>0)){
$error .="Wrong rss image width.<br>\n";
}
if(!(is_numeric($_POST['rss_preview_height'])&&$_POST['rss_preview_height']>0)){
$error .="Wrong rss image height.<br>\n";
}
if(!is_dir($SITE_DOCUMENT_ROOT."/".$_POST['rss_path'])){
$error .= "Rss images path is not exists or isn't correct.<br>\n";
}
return $error;
}
*/
if(isset($_POST['submit'])){
reset ($_POST);
while (list($key, $value) = each ($_POST)) {
$$key = $value;
}
// print_r($_POST);
$error = "";
// $error = LocalCheck();
if($error==""){
$res_flag = true;
foreach($_POST as $key=>$value){
// $tmp_row = mysql_fetch_object(mysql_query("select * from system_settings where param_name='$key'"));
/*
if($tmp_row->param_name==""){
mysql_query("insert into system_settings (param_name,\"param_value\") values ('$key','".addslashes(trim($_POST[$key]))."');");
// echo "insert into system_settings (param_name,\"value\") values ('$key','".addslashes(trim($_POST[$key]))."');";
}
*/
if(!$tmp_res=mysql_query("update system_settings set param_value='".addslashes(trim($_POST[$key]))."' where param_name='$key'")){
// elseif(!$tmp_res=@UpdateRecord("system_settings",Array("value"=>addslashes(trim($_POST[$key]))),Array(param_name=>$key))){
// echo "<br />update system_settings set param_value='".addslashes(trim($_POST[$key]))."' where param_name='$key'"."<br>";
$res_flag = false;
break;
}
}
if($res_flag){
//$status = "Настройки успешно сохранены.<br>\n";
$_SESSION['STATUS_MSG'] = "Настройки успешно сохранены.";
header("Location: ./index.php?l_pager");
exit;
}
else{
//$error = "DATABASE error.<br>\n";
$_SESSION['ERROR_MSG'] = "Ошибка работы с базой данных.";
header("Location: ./index.php?l_pager");
exit;
}
}
}
else{
foreach($SETTINGS as $key=>$value){
$$key = $value;
}
}
foreach($SETTINGS as $key=>$value){
$smarty->assign($key,$$key);
}
/*$smarty->assign('admin_items_per_page',$admin_items_per_page);
$smarty->assign('admin_pages_per_block',$admin_pages_per_block);
$smarty->assign('admin_email',$admin_email);
$smarty->assign('html_editor_path',$html_editor_path);
$smarty->assign('min_login_length',$min_login_length);
$smarty->assign('max_login_length',$max_login_length);
$smarty->assign('min_password_length',$min_password_length);
$smarty->assign('max_password_length',$max_password_length);
$smarty->assign('invalid_request_msg',$invalid_request_msg);
$smarty->assign('client_session_timeout',$client_session_timeout);
$smarty->assign('cat_websites_per_page',$cat_websites_per_page);
$smarty->assign('remote_mng_script',$remote_mng_script);
$smarty->assign('client_items_per_page',$client_items_per_page);
$smarty->assign('internal_mail_max_filesize',$internal_mail_max_filesize);*/
/*
$disc_vendor_names = Array();
$disc_vendor_ids = Array();
$res = mysql_query("select * from promo_vendors order by name asc");
while($row = pg_fetch_object($res)){
array_push($disc_vendor_names,stripslashes($row->name));
array_push($disc_vendor_ids,stripslashes($row->id));
}
$smarty->assign('disc_vendor_names',$disc_vendor_names);
$smarty->assign('disc_vendor_ids',$disc_vendor_ids);
*/
$smarty->assign('user_ip_now', $_SERVER["REMOTE_ADDR"]);
$smarty->assign('page_title', $page_title);
$smarty->assign('error',$error);
$smarty->assign('status',$status);
$smarty->assign('top_menu_tpl',"admin_settings_menu.tpl");
$smarty->assign('main_tpl','admin_settings_index.tpl');
/* display content */
$smarty->display('admin_index.tpl');
?>