<?php
	include_once("admin/include/config.php");
	define("THIS_PAGE","ly");
	if(!$hm_arr = get_seo(2)){
		$hm_title = $hm_key = $hm_des = hmcss_default_config(1);
	}
	else{
		$hm_title = $hm_arr[0][2];
		$hm_key = $hm_arr[0][3];
		$hm_des = $hm_arr[0][4];
	}
	$action = trim($_GET["action"]);
	if($action == "reply"){
		check_site_url();
		array_pop($_POST);//表单提交上来的数据都存入$_POST数组中，现在弹出最后一个数组值，因为最后一个是按纽
		extract($_POST);//把数组名作为变量名，数组值作为变量值
		$ly_user = trim($ly_user);
		(strlen($ly_user) <2 || check_bad_str($ly_user)) ? show_err("请输入留言名，您的输入中有非法字符") : $ly_user = addslashes($ly_user);
		$ly_contact = trim($ly_contact);
		check_bad_str($ly_contact) ? show_err("您输入的联系人中含有非法字符") : $ly_contact = addslashes($ly_contact);
		//产品介绍
		strlen($ly_content) < 9 ? show_err("请输入至少10个英文字符或5个中文字的留言信息") : $ly_content = addslashes($ly_content);
		mysql_query("insert into hmcss_ly_main (ly_user,ly_contact,ly_content,ly_time) values ('$ly_user','$ly_contact','$ly_content','" . date("Y-m-d H:i:s",time()) . "')")
			or show_err("添留言出错，请联系管理员");
		show_err("您已留言成功","online_ly_new.php");
	}
?>
<!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><?php echo $hm_title; ?></title>
<meta name="description" content="<?php echo $hm_des; ?>" />
<meta name="keywords" content="<?php echo $hm_key; ?>" />
<script language = "javascript" src="admin/include/jquery.min.js" type="text/javascript"></script>
<script language="javascript">
function del(id)
{
	if(confirm('确定要删除该留言吗？'))
		location.href='admin/DEL.php?type=ly&id=' + id; 
	else
		return;
}
</script>
<link rel="stylesheet" type="text/css" href="style.css" />
<style type="text/css">
#out{width:1000px; overflow:hidden; min-height:600px; height:auto; background-image:url(pics/bg/left_bg.gif); background-repeat:repeat-y;}
#right{width:800px; height:auto!important; height:auto; float:left; text-indent:2em; padding:10px 0px; line-height:20px;}
.ly_out{width:798px; border:1px #73d1e9 solid; min-height:100px; height:auto; overflow:hidden; margin:10px auto;}
.ly_top{width:798px; height:30px; line-height:30px; background-color:#eafcff; border-bottom:1px #73d1e9 solid;}
	.ly_top ul{list-style:none; margin:0px; padding:0px;}
	.ly_top li{list-style:none; margin:0px; padding:0px; text-align:center; float:left; color:#09F; height:30px; line-height:30px; text-indent:0px;}
.ly_con{height:auto!important; height:auto; width:788px; margin:5px; float:left;}
.admin_div{margin:0px; padding:0px; float:right; height:30px; width:200px; text-align:center; text-indent:0px;}
.do_style{display:inline-block; width:60px; height:25px; line-height:25px; text-align:center; cursor:pointer; margin-top:3px; text-indent:0px;}
.do_style:hover{background-color:#337ABB; color:#eef7fd;  cursor:pointer;}
.admin_span a{color:#06F; font-size:12px; text-decoration:none;}
.admin_span a:hover{color:#F30; font-size:12px; text-decoration:underline;}
</style>
</head>

<body>
<?php require_once("top.php"); ?>
<div class="now_position"><span class="position_str">当前位置：<a href="index.php">首页</a>-><a href="online_ly.php">在线留言</a>->留言查看</span><span class="im_notice">
<marquee direction="left" scrolldelay="100" onmouseout="this.start()" onmouseover="this.stop()" style="width:400px;">
<?php hmcss_notice(); ?>
</marquee></span></div>
<div id="out">
<div id="left">
	<div class="left_menu">
    	<span class="left_arr_over"></span><span class="left_menu_con"><a href="online_ly.php">留言查看</a></span>
    </div>
    <div class="left_menu">
    	<span class="left_arr_normal"></span><span class="left_menu_con"><a href="online_ly_new.php">我要留言</a></span>
    </div>
    <div class="left_menu">
    	<span class="left_arr_normal"></span><span class="left_menu_con"><a href="javascript:" onclick="alert('请登陆后台管理后，刷新本页');">留言管理</a></span>
    </div>
</div>
<div id="right">
<?php
	$page = trim($_GET["page"]);
	$page = is_numeric($page) ? $page : 1;
	$max_per_page = 5;
	if(!$hm_arr  = get_ly())
		show_err("系统中暂无留言，请签写新留言","online_ly_new.php");
	//计算总页数
	$all_page = ceil(count($hm_arr)/$max_per_page);
	if($page > $all_page)
		$page = $all_page;
	$start = $page ? (($page - 1) * $max_per_page) : 0;
	$filter_arr[0] = array("1","$start,$max_per_page",false);
	$hm_arr  = get_ly($filter_arr);
	$show_admin = $_COOKIE["user_name"] ? true : false;
	foreach($hm_arr as $key => $val){
		echo "	<div class=\"ly_out\">\r";
		echo "		<div class=\"ly_top\">\r";
		echo "        	<ul>";
		echo "            	<li style=\"width:50px; background:url(pics/ly_user.gif) right no-repeat\"></li>\r";
		echo "                <li style=\"width:60px; overflow:hidden;\">$val[1]</li>\r";
		echo "            <li style=\"width:50px; background:url(pics/ly_time.gif) right no-repeat\"></li>\r";
		echo "                <li style=\"width:180px;\">$val[5]</li>\r";
		echo "                <li style=\"width:50px; background:url(pics/ly_contact.gif) right no-repeat\"></li>\r";
		echo "                <li style=\"width:400px; word-wrap:break-word; overflow:hidden; text-align:left;\">$val[2]</li>\r";
		echo "            </ul>";
		echo "        </div>";
		echo "        <div class=\"ly_con\" id=\"ly_$val[0]\" style=\"word-wrap:break-word; overflow:hidden; line-height:20px; padding-bottom:20px;\">\r";
		echo "$val[3]</div>\r";
		if($val[4]){
			echo "<div style=\"float:left; font-weight:bold; color:#666; font-size:14px; border-top:1px #DDD solid; width:100%;\">回复内容：</div>";
			echo "        <div class=\"ly_con\" id=\"ly_$val[0]\" style=\"word-wrap:break-word; overflow:hidden; line-height:20px;\">\r";
			echo "$val[4]</div>\r";
		}
		if($show_admin)
			echo "<div class=\"admin_div\"><span class=\"admin_span\" style=\"display:inline-block; background:url(pics/reply.gif) left no-repeat; width:70px;\"><a href=\"online_ly_reply.php?ly_id=$val[0]\">回复</a></span><span class=\"admin_span\" style=\"display:inline-block; background:url(pics/delete.gif) left no-repeat; width:70px;\"><a href=javascript:del($val[0])>删除</a></span></div>";
		echo "</div>\r";
	}
	if($all_page > 1){
		echo "<div id=\"page\" style=\"width:798px;\">\r\n";
		for($i = 1;$i <= $all_page;$i++)
			echo $i - $page == 0 ? "<a class=\"now_page\">$i</a>" : "<a class=\"page_span\" href=\"online_ly.php?page=$i\">$i</a>";
		echo "</div>\r\n";
	}
?>
</div>
</div>
<div id="foot"><?php unset($hm_arr,$filter,$hm_arr_news,$config_arr); hmcss_foot(); ?></div>
</body>
</html>