<?php
include_once("../includes/global.php");
$script_tmp = explode('/', $_SERVER['SCRIPT_NAME']);
$sctiptName = array_pop($script_tmp);

@include_once("auth.php");
//=========================================
$type='home';
if(!empty($_POST['submit'])&&$_POST["submit"]==lang_show('submit'))
{
	unset($_POST['submit']);
	foreach($_POST as $pname=>$pvalue)
	{
		$sql="select * from ".CONFIG." where `index`='$pname' and type='$type'";
		$db->query($sql);
		if($db->num_rows())
		  $sql1=" update ".CONFIG." SET value='$pvalue' where `index`='$pname' and type='$type'";
		else
		   $sql1="insert into ".CONFIG." (`index`,value,type) values ('$pname','$pvalue','$type')";
		$db->query($sql1);
	}
	/****更新缓存文件*********/
	$write_config_con_array=read_config($type);//从库里取出数据生成数组
	$write_config_con_str=serialize($write_config_con_array);//将数组序列化后生成字符串
	$write_config_con_str=str_replace("'","\'",$write_config_con_str);
	$write_config_con_str='<?php $'.$type.'_config = unserialize(\''.$write_config_con_str.'\');?>';//生成要写的内容
	$fp=fopen('../config/'.$type.'_config.php','w');
	fwrite($fp,$write_config_con_str,strlen($write_config_con_str));//将内容写入文件．
	fclose($fp);
	/*********************/
	admin_msg($type."_config.php",lang_show('executed'));
	exit;
}
//===读库函数，生成config形式的数组====
function read_config($type)
{
	global $db;
	$sql="select * from ".CONFIG." where type='$type'";
	$db->query($sql);
	$re=$db->getRows();
	foreach($re as $v)
	{
		$index=$v['index'];
		$value=$v['value'];
		$configs[$index]=$value;
	}
	return $configs;
}
$reg_config=read_config($type);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<TITLE><?php echo lang_show('admin_system');?></TITLE>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<link href="main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div class="bigbox">
	<div class="bigboxhead"><?php echo lang_show('home_config');?></div>
	<div class="bigboxbody">
	<form name="sysconfig" action="" method="post" style="margin-top:0px;">
	<table width="100%" cellspacing="0">
		        <tr>
		          <td colspan="2"  align="left" ><?php echo lang_show('reg_0');?></td>
        </tr>
		        <tr>
          <td width="16%"  align="left" ><?php echo lang_show('search_word');?></td>
          <td width="84%" align="left" >
            <input name="hot_num" type="text" id="hot_num" value="<?php echo $reg_config['hot_num'];?>" size="10"></td>
        </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_offer_num');?></td>
                  <td align="left" ><input name="offer_num" type="text" id="offer_num" size="10" value="<?php echo $reg_config['offer_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_recoffer_num');?></td>
                  <td align="left" ><input name="pro_pic_num" type="text" id="pro_pic_num" size="10" value="<?php echo $reg_config['pro_pic_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_recoffer_numtext');?></td>
                  <td align="left" ><input name="pro_text_num" type="text" id="pro_text_num" size="10" value="<?php echo $reg_config['pro_text_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_offcat_num1');?></td>
                  <td align="left" ><input name="pro_cat_num" type="text" id="pro_cat_num" size="10" value="<?php echo $reg_config['pro_cat_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_offcat_num2');?></td>
                  <td align="left" ><input name="pro_cat1_num" type="text" id="pro_cat1_num" size="10" value="<?php echo $reg_config['pro_cat1_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_offcat_tag');?></td>
                  <td align="left" ><input name="cat_index" type="text" id="cat_index" size="10" value="<?php echo $reg_config['cat_index'];?>">
                  <?php echo lang_show('int_10');?></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_market');?></td>
                  <td align="left" ><input name="today_info" type="text" id="today_info" size="10" value="<?php echo $reg_config['today_info'];?>">
                  <?php echo lang_show('int_10');?></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_reccom');?></td>
                  <td align="left" ><input name="rec_user_num" type="text" id="rec_user_num" size="10" value="<?php echo $reg_config['rec_user_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_newcom');?></td>
                  <td align="left" ><input name="new_user_num" type="text" id="new_user_num" size="10" value="<?php echo $reg_config['new_user_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_exp');?></td>
                  <td align="left" ><input name="exp_num" type="text" id="exp_num" size="10" value="<?php echo $reg_config['exp_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_zp');?></td>
                  <td align="left" ><input name="job_num" type="text" id="job_num" size="10" value="<?php echo $reg_config['job_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_job');?></td>
                  <td align="left" ><input name="resume_num" type="text" id="resume_num" size="10" value="<?php echo $reg_config['resume_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_ask');?></td>
                  <td align="left" ><input name="ask_num" type="text" id="ask_num" size="10" value="<?php echo $reg_config['ask_num'];?>"></td>
                </tr>
                <tr>
                  <td height="40" align="left"><?php echo lang_show('home_vote');?></td>
                  <td align="left" ><input name="post_num" type="text" id="post_num" size="10" value="<?php echo $reg_config['post_num'];?>"></td>
                </tr>
        <tr>
          <td width="16%" height="40" align="right">&nbsp;</td>
          <td width="84%" align="left" ><input  class="btn" type="submit" name="submit" value="<?php echo lang_show('submit');?>"></td>
        </tr>
      </table>
	</form>
	</div>
</div>
</body>
</HTML>