<?php
	include_once("check_login.php");
	//查看网站配置相关信息
	include_once("include/config.php");
	$action = trim($_GET["action"]);
	if($action == "save"){
		check_site_url();
		array_pop($_POST);//表单提交上来的数据都存入$_POST数组中，现在弹出最后一个数组值，因为最后一个是按纽
		extract($_POST);//把数组名作为变量名，数组值作为变量值
		if(!check_is_numb($seo_id) || $seo_id <1 )
			show_err("提交的SEO数据出错,请联系管理员");
		//检查该SEO页是否存在
		if(!$hm_arr = get_seo($seo_id))
			show_err("该SEO优化页不存在");
		else{
			mysql_query("update hmcss_seo set seo_title = '" . addslashes($seo_title) . "',seo_key = '" . addslashes($seo_key) . "',seo_des = '" . addslashes($seo_des) . "' where seo_id = $seo_id")
				or show_err("更新SEO数据出错");
			show_err($hm_arr[0][1] . "的SEO优化配置已成功修改","set_site_seo.php?seo_id=$seo_id");
		}
	}
	else{
		$seo_id = trim($_GET["seo_id"]);
		$seo_title = "";
		$seo_key = "";
		$seo_des = "";
		if($hm_arr = get_seo()){
			$op_str = "";
			foreach ($hm_arr as $key => $val){
				if($seo_id == $val[0]){
					$op_str .= "<option value=\"$val[0]\" selected=\"selected\">$val[1]</option>\n\r";
					$seo_title = $val[2];
					$seo_key = $val[3];
					$seo_des = $val[4];
				}
				else
					$op_str .= "<option value=\"$val[0]\">$val[1]</option>\n\r";
			}
			!($seo_title) && $seo_title = $hm_arr[0][2];
			!($seo_key) && $seo_key = $hm_arr[0][3];
			!($seo_des) && $seo_des = $hm_arr[0][4];
		}
		else
			$op_str .= "<option value=\"0\">请先添加SEO数据</option>\n\r";
	}
?>
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>网站设置</title>
<script language = "javascript" src="include/jquery.min.js" type="text/javascript"></script>
<script language = "javaScript" src = "include/hmcss_ajax.js" type="text/javascript"></script>
<script language="javascript">
function go_seo()
{
	location.href = "set_site_seo.php?seo_id=" + $("#seo_id").val();
}
</script>
<style type="text/css"></style>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
<div class="head_menu"><a href="set_site_admin.php">密码修改</a><a href="set_site_info.php">网站配置</a><a href="set_site_intro.php">企业简介</a><a href="set_site_contact.php">联系方式</a><span class="head_menu_on"><a href="set_site_seo.php">网站SEO优化</a></span><a href="set_site_foot.php">网站页脚</a></div>
<div class="set_main_out">
	<form id="form1" name="form1" method="post" action="set_site_seo.php?action=save">
	<div class="set_main">
		<ul>
        	<li style="width:140px;">文件选择:</li>
          <li style="width:638px;"> <select name="seo_id" id="seo_id" onchange="go_seo()">
            <?php echo $op_str; ?>
          </select><span id="floading"></span>
            <span style="font-size: 12px; color: #999"> 请选择当前需要修改的页面</span>
          </li>
          <li style="width:140px; height:100px; line-height:100px;">网页标题(title):</li><li style="width:638px; height:100px; line-height:100px;">
              <textarea name="seo_title" cols="49" rows="5" id="seo_title"><?php echo $seo_title; ?></textarea>
              <span style="color:#999; font-size:12px;">请输入本页标题信息(200字)</span></li>
            <li style="width:140px; height:100px; line-height:100px;">网页关键字:</li><li style="width:638px; height:100px; line-height:100px;">
              <textarea name="seo_key" cols="49" rows="5" id="seo_key"><?php echo $seo_key; ?></textarea>
              <span style="color:#999; font-size:12px;">你需要优化的SEO关键字(200字)</span></li>
            <li style="width:140px; height:100px; line-height:100px;">网页描述:</li><li style="width:638px; height:100px; line-height:100px;">
              <textarea name="seo_des" cols="49" rows="5" id="seo_des"><?php echo $seo_des; ?></textarea>
              <span style="color:#999; font-size:12px; display:inline-block; width:200px; white-space:pre-wrap; line-height:20px;">网页的主要描述<br />(非常重要，内容只可与本页有关)</span></li>
            <li style="width:788px; text-indent:0px; text-align:center;">
              <input type="submit" name="button" id="button" value="  提 交  " />
            </li>
    	</ul>
	</div>
   </form>
</div>
</body>
</html>