<?php
require("session_check.php");	
require("../foundation/module_lang.php");
	//语言包引入
	$f_langpackage=new foundationlp;
	$lp_f_amend_suc=$f_langpackage->f_amend_suc;
	
	//数据表定义
	$t_config=$tablePreStr."config";
	
	//数据库连接
	$dbo=new dbex;
	dbtarget('w',$dbServs);
	
	if(get_argp('action')){
		
		//变量区
		$s_web_title=short_check(get_argp('web_title'));
		$s_web_URL=short_check(get_argp('web_URL'));
		$s_web_key_word=short_check(get_argp('web_key_word'));
		$s_web_description=short_check(get_argp('web_description'));
		$s_web_author=short_check(get_argp('web_author'));
		$s_domain_remark=short_check(get_argp('domain_remark'));
		$s_web_site_domain=short_check(get_argp('web_site_domain'));
		$s_web_report=short_check(get_argp('web_report'));
		$s_admin_email=short_check(get_argp('admin_email'));
		$s_filtrate=str_replace(array("&quot;","|","，","|"),array("",",",",",","),short_check(get_argp('filtrate')));
		$s_copyright=short_check(get_argp('copyright'));
		$s_ctrl_f=short_check(get_argp('ctrl_f'));
		$s_offline=short_check(get_argp('offline'));
		$s_index_affair_num=short_check(get_argp('index_affair_num'));
		$s_home_affair_num=short_check(get_argp('home_affair_num'));
		$s_ctrl_cache=short_check(get_argp('ctrl_cache'));
		$s_update_cache_time=short_check(get_argp('update_cache_time'));
		$s_perpage_num=short_check(get_argp('perpage_num'));
		$s_min_birth_year=short_check(get_argp('min_birth_year'));
		$s_max_birth_year=short_check(get_argp('max_birth_year'));
		$s_reg_info=long_check(get_argp('reg_info'));
		$s_off_info=short_check(get_argp('off_info'));
		$s_action_time=short_check(get_argp('action_time'));
		$s_relay_time=short_check(get_argp('relay_time'));
		$s_g_manager_limit=short_check(get_argp('g_manager_limit'));
		$s_u_creat_limit=short_check(get_argp('u_creat_limit'));
		$s_lib_path=short_check(get_argp('lib_path'));
		$s_change_lp=short_check(get_argp('change_lp'));
		$f_str=str_replace(array("|","，","|"),",",$filtrate_str);
		$s_session_prefix=short_check(get_argp('sess_prefix'));
		$s_skin=short_check(get_argp('skin'));
		
		$config_array=array(
			"title" => $s_web_title,
			"site_URL" => $s_web_URL,
			"key_words" => $s_web_key_word,
			"desc" => $s_web_description,
			"author" => $s_web_author,
			"error_report" => $s_web_report,
			"domain_remark" => $s_domain_remark,
			"site_domain" => $s_web_site_domain,
			"admin_email"=> $s_admin_email,
			"filtrate"=> $s_filtrate,
			"copyright"=> $s_copyright,
			"offline"=> $s_offline,
			"off_info"=> $s_off_info,
			"index_affair_num"=> $s_index_affair_num,
			"home_affair_num"=> $s_home_affair_num,
			"ctrl_cache"=> $s_ctrl_cache,
			"ctrl_filt"=> $s_ctrl_f,
			"perpage_num"=> $s_perpage_num,
			"update_cache_time"=> $s_update_cache_time,
			"min_year"=> $s_min_birth_year,
			"max_year"=> $s_max_birth_year,
			"reg_info"=> $s_reg_info,
			"allow_refresh_time "=> $s_action_time,
			"delay_time "=> $s_relay_time,
			"manager_num "=> $s_g_manager_limit,
			"creat_group_limit"=> $s_u_creat_limit,
			"lib_path"=> $s_lib_path,
			"lp_settiing"=> $s_change_lp,
			"sess_prefix"=> $s_session_prefix,
			"skin"=> $s_skin,
			);
			
		//方法定义
		function update_config($dbo,$t_config,$config_array){
			global $lp_f_amend_suc;
			foreach($config_array as $k => $v ){
				$sql="update $t_config set v = '$v' where k = '$k' ";
				$dbo->exeUpdate($sql);
			}
			echo "<script type='text/javascript'>alert('".$lp_f_amend_suc."');window.location.href='basic_set.php';</script>";
		}

$guest_time=spell_array($limit_guest_time);
$action_time=spell_array($limit_action_time);
$ip_limit=spell_array($limit_ip_list);

		//配置文件静态化
		$config_re=fopen("../configuration.php","w+");
		$insert_config_data='<?php
//语言包参数，目前参数值zh,en
$langPackagePara="'.$s_change_lp.'";

//配置信息
$webRoot=str_replace("\\\","/",dirname(__FILE__))."/";
$metaDesc = "'.$s_web_description.'";
$metaKeys = "'.$s_web_key_word.'";
$siteName="'.$s_web_title.'";
$copyright="'.$s_copyright.'";
$domain_remark="'.$s_domain_remark.'";
$offline='.$s_offline.';
$adminEmail="'.$s_admin_email.'";
$siteDomain="'.$s_web_site_domain.'";
$skinUrl="'.$s_skin.'";

//时区设置
date_default_timezone_set ("Asia/Shanghai");

//支持库配置
$baseLibsPath="'.$s_lib_path.'";

//防刷新时间设置,只限制insert动作.单位:秒
$allowRefreshTime='.intval($s_action_time).';

//超限系统延时设置,单位:秒
$delayTime='.intval($s_relay_time).';

//缓存更新延时设置,单位为秒
$cache_update_delay_time='.intval($s_update_cache_time).';

//出生年份范围
$set_min_year='.intval($s_min_birth_year).';
$set_max_year='.intval($s_max_birth_year).';

//站点调试信息设置
ini_set("display_errors",'.$s_web_report.');

//站点关闭提示信息
$offline_message="'.$s_off_info.'";

//分页数据量
$set_page_data_num='.intval($s_perpage_num).';

//限制访问的时间段
$limit_guest_time='.$guest_time.';

//限制交互时间段
$limit_action_time='.$action_time.';

//限制访问的ip列表
$limit_ip_list='.$ip_limit.';

//群组管理员限制数量
$set_manager_num='.intval($s_g_manager_limit).';

//每人限制创建群组数量
$set_creat_group_limit='.intval($s_u_creat_limit).';

//主页显示动态条数
$home_affair_num='.intval($s_home_affair_num).';

//首页显示动态条数
$index_affair_num='.intval($s_index_affair_num).';

//是否开启过滤
$is_filt='.$s_ctrl_f.';

//敏感词过滤
$filtrate_str="'.$s_filtrate.'";

//session前缀
global $session_prefix;
$session_prefix="'.$s_session_prefix.'";
?>
';

			fwrite($config_re,trim($insert_config_data));
			fclose($config_re);
			
			if(isset($_COOKIE['lp_name'])){
				$_COOKIE['lp_name']='';
			}
			update_config($dbo,$t_config,$config_array);
		
		}else{
			$configs_rs=array();
			
			$sql="select sql_cache * from $t_config";
			
			$configs_rs=$dbo->getRs($sql);
			
			foreach($configs_rs as $rs){
				$key[] = $rs['k'];
				$value[] = $rs['v'];
				$config=array_combine($key,$value);
			}
				
				//站点开关控制
				$o_open="selected";
				$o_close="";
				if($config['offline']==1){
					$o_open="";
					$o_close="selected";
				}
					
				//开启缓存控制
				$c_open="";
				$c_close="selected";
				if($config['ctrl_cache']==0){
					$c_open="selected";
					$c_close="";
				}
					
				//错误报告控制
				$open_report="";
				$close_report="selected";
				if($config['error_report']==1){
					$open_report="selected";
					$close_report="";					
				}
				
				//过滤控制
				$c_fopen="";
				$c_fclose="selected";
				if($config['ctrl_filt']==1){
					$c_fopen="selected";
					$c_fclose="";					
				}
					
		}

?>
<html>
<head>
<title><?php echo $f_langpackage->f_site_set?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="css/right.css">
<script type='text/javascript'>
function create_xmlhttp(){
if(window.ActiveXObject){
	xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}else{
		xmlhttp=new XMLHttpRequest();
	}
}

function GET_TOP_URL(){
	var location_site="http://"+location.host+location.pathname+location.search;
	var no_file_url=location_site.replace(/.[^\/]*$/g,"/");
	var no_dir_url=no_file_url.replace(/\/sysadmin\//,"/");
	return no_dir_url;
}

function show_domain(){
	var domain_url=GET_TOP_URL();
	document.getElementById('domain_url').innerHTML=domain_url;
	var costom_url=document.getElementById("web_site_domain").value;
	if(costom_url!=domain_url){
		document.getElementById("web_site_domain").style.color='red';
		document.getElementById('domain_url').style.color='red';
	}
	
}

function check_domain(){
	var domain_url=GET_TOP_URL();
	var costom_url=document.getElementById("web_site_domain").value;
	if(domain_url!=costom_url){
		show_domain();
		return confirm('<?php echo $f_langpackage->f_tip_domain;?>');
	}
}

function set_domain(){
	var domain_url=GET_TOP_URL();
	document.getElementById("web_site_domain").value=domain_url;
	document.getElementById("web_site_domain").style.color='';
	document.getElementById('domain_url').style.color='';
}

</script>
</head>


<body onload='show_domain()'>

<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_site_set?></div>
</div>

<form action='' method='POST' onsubmit='return check_domain()'>
	<input type='hidden' name='skin' value='<?php echo $config['skin'];?>' />
	<input type='hidden' name='tpl_compile_type' value='<?php echo $config['tpl_compile_type'];?>' />
	<table class='main main_left'>
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_site_name?>：	</td>
			<td width=80%> <input type='text' size='30' value='<?php echo $config['title'];?>' name='web_title' /> <?php echo $f_langpackage->f_site_name_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_domain?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['site_domain'];?>' name='web_site_domain' id='web_site_domain' /> （<?php echo $f_langpackage->f_check_domain?><a href='javascript:set_domain();' title='<?php echo $f_langpackage->f_click_set?>'><span id='domain_url'></span></a>） </td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_keyword?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['key_words'];?>' name='web_key_word' /> <?php echo $f_langpackage->f_keyword_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_description?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['desc'];?>' name='web_description' /> <?php echo $f_langpackage->f_description_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_author?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['author'];?>' name='web_author' /> <?php echo $f_langpackage->f_author_annotations?></td>
		</tr>					
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td> <?php echo $f_langpackage->f_mail?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['admin_email'];?>' name='admin_email' /> <?php echo $f_langpackage->f_mail_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_copyright_inf?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['copyright'];?>' name='copyright' /> <?php echo $f_langpackage->f_copyright_inf_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td> <?php echo $f_langpackage->f_record?>：	</td>
			<td> <input type='text' size='30' value='<?php echo $config['domain_remark'];?>' name='domain_remark' /> <?php echo $f_langpackage->f_record_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_close_say?>：	</td>
			<td>
				<textarea cols="20" rows="4" name='off_info'><?php echo $config['off_info'];?></textarea> <?php echo $f_langpackage->f_close_say_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
				
		<tr>
			<td> <?php echo $f_langpackage->f_open_err?>：	</td>
			<td>
				<select name='web_report'>
					<option value="0" <?php echo $close_report;?>><?php echo $f_langpackage->f_close?></option>
					<option value="1" <?php echo $open_report;?>><?php echo $f_langpackage->f_open?></option>
				</select>
				<?php echo $f_langpackage->f_open_err_annotations?>
			</td>
		</tr>		
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_close_control?>：	</td>
			<td> 
				<select name='offline'>
					<option value='0' <?php echo $o_open;?>><?php echo $f_langpackage->f_open?></option>
					<option value='1' <?php echo $o_close;?>><?php echo $f_langpackage->f_close?></option>
				</select>
				<?php echo $f_langpackage->f_close_annotations?>
			</td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

	</table>	
	
<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_display_set?></div>
</div>

	<table class='main main_left'>
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_main_dynamic_num?>：	</td>
			<td width=80%> <input type='text' size='2' value='<?php echo $config['index_affair_num'];?>' name='index_affair_num' /> 条<?php echo $f_langpackage->f_main_dynamic_num_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td width=20%> <?php echo $f_langpackage->f_home_dynamic_num?>：	</td>
			<td width=80%> <input type='text' size='2' value='<?php echo $config['home_affair_num'];?>' name='home_affair_num' /> 条 <?php echo $f_langpackage->f_home_dynamic_num_annotations?></td>
		</tr>				
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
	
		<tr>
			<td> <?php echo $f_langpackage->f_cache?>：	</td>
			<td> 
				<select name='ctrl_cache'>
					<option value='0' <?php echo $c_open;?>><?php echo $f_langpackage->f_open?></option>
					<option value='1' <?php echo $c_close;?>><?php echo $f_langpackage->f_close?></option>
				</select>
				<?php echo $f_langpackage->f_cache_annotations?>
			</td>
		</tr>		
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_cache_update?>：	</td>
			<td> <input type='text' size='2' value='<?php echo $config['update_cache_time'];?>' name='update_cache_time' /> 秒<?php echo $f_langpackage->f_cache_update_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_page_num?>：	</td>
			<td> <input type='text' size='2' name='perpage_num' value='<?php echo $config['perpage_num'];?>' /> 条<?php echo $f_langpackage->f_page_num_annotations?></td> 
		</tr>	
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
		<tr>
			<td> <?php echo $f_langpackage->f_birthday?>：	</td>
			<td> 
				<input type='text' size='4' name='min_birth_year' value='<?php echo $config['min_year'];?>' />~<input type='text' size='4' name='max_birth_year' value='<?php echo $config['max_year'];?>' /><?php echo $f_langpackage->f_birthday_annotations?>
			</td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td> <?php echo $f_langpackage->f_article?>：	</td>
			<td> <textarea cols="70" rows="9" name='reg_info' ><?php echo $config['reg_info'];?></textarea>	<br /><?php echo $f_langpackage->f_article_annotations?></td>
		</tr>		
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
	</table>
		
<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_watering_set?></div>
</div>

	<table class='main main_left'>
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_alternation_time?>：	</td>
			<td width=80%> <input type='text' size='2' name='action_time' value='<?php echo $config['allow_refresh_time'];?>' />秒 <?php echo $f_langpackage->f_alternation_time_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td> <?php echo $f_langpackage->f_defer_time?>：	</td>
			<td> <input type='text' size='2' name='relay_time' value='<?php echo $config['delay_time'];?>' />秒 <?php echo $f_langpackage->f_defer_time_annotations?></td>
		</tr>				
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
	</table>		
	
<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_filter_set?></div>
</div>

	<table class='main main_left'>
		
		<tr>
			<td> <?php echo $f_langpackage->f_open_filter?>：	</td>
			<td> 
				<select name='ctrl_f'>
					<option value='1' <?php echo $c_fopen;?>><?php echo $f_langpackage->f_open?></option>
					<option value='0' <?php echo $c_fclose;?>><?php echo $f_langpackage->f_close?></option>
				</select>
				<?php echo $f_langpackage->f_open_filter_annotations?>
			</td>
		</tr>		
		
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_filter_content?>：	</td>
			<td width=80%> <textarea cols="20" rows="4" name='filtrate' ><?php echo $config['filtrate'];?></textarea> <?php echo $f_langpackage->f_filter_content_annotations?> </td>
		</tr>
		
	</table>
	
	
<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_module_parameter?></div>
</div>		

	<table class='main main_left'>
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_group_admin?>：	</td>
			<td width=80%> <input type='text' size='2' name='g_manager_limit' value='<?php echo $config['manager_num'];?>' />名<?php echo $f_langpackage->f_group_admin_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td> <?php echo $f_langpackage->f_my_group_num?>：	</td>
			<td> <input type='text' size='2' name='u_creat_limit' value='<?php echo $config['creat_group_limit'];?>' />个<?php echo $f_langpackage->f_my_group_num_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>
		
	</table>	
	
<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_sess_pre?></div>
</div>	

	<table class='main main_left'>
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_sess_pre?>：	</td>
			<td width=80%> <input type='text' size='30' name='sess_prefix' value='<?php echo $config['sess_prefix'];?>' /> <?php echo $f_langpackage->f_sess_pre_inf?></td>
		</tr>
	</table>	
	
<div class="container">
	<div class="rs_head"><?php echo $f_langpackage->f_high_set?></div>
</div>

	<table class='main main_left'>
		<tr>
			<td width=20%> <?php echo $f_langpackage->f_support_library?>：	</td>
			<td width=80%> <input type='text' size='30' name='lib_path' value='<?php echo $config['lib_path'];?>' /> <?php echo $f_langpackage->f_support_library_annotations?></td>
		</tr>
		
		<tr><td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td></tr>

		<tr>
			<td> <?php echo $f_langpackage->f_language_pack?>：	</td>
			<td>
				<?php echo show_back_lp($config['lp_settiing']);?>
				<?php echo $f_langpackage->f_language_pack_annotations?>
			</td>
		</tr>
		<tr>
			<td class="dotted_line" colspan="10" style="line-height:100%;">&nbsp</td>
		</tr>		
		<tr>
			<td><input type=submit value='<?php echo $f_langpackage->f_refer?>' name='action' class='top_button' /></td>	
		</tr>
		
	</table>
	

	
</form>
</body>
</html>