<?php
//=============================================
if($action=="loginout"){
ob_start();
header("set-cookie:....");
setcookie("user", "", time()-14400,"/");
setcookie("password", "", time()-14400,"/");
ob_end_flush();
}
//============================================
require("config.php");
$con=0;
if(isset($user)&&isset($password)){
if($con==0){
@$link=mysql_connect($host,$dbuser,$pw) or die("太失望了,连接服务器失败!!");
@mysql_select_db($db,$link) or die("对不起,连接数据库失败!!");
$con=1;
}
$query="select * from xp_user
where user = '".$user."'
and password = '".$password."'";
@$result=mysql_query($query,$link) or die("2连接失败!!");
$row=mysql_num_rows($result);
if($row!=0){
$enter=1;
}
}
?>
<!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=gb2312" />
<title>橡皮泥留言板系统</title>
<style type="text/css">
<!--
body {
margin-left: 0px;
margin-top: 0px;
}
.STYLE1 {font-size: 12px}
.STYLE4 {font-size: 12px;
color: #999999;
}
-->
</style>
<script type="text/javascript" src="http://www.into123.cn/mysys/tongji.php?wz=<?php echo $_SERVER['SERVER_NAME']."&lei=liuyan1.0"; ?>">
</script></head>
<body>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="60"><iframe src="http://www.into123.cn/ad/liuyan.php" frameborder="0" width="600" height="60" align="middle" scrolling="no"></iframe></td>
</tr>
</table>
<?php
if($action=="add"){
if($name==""||$http==""||$text==""){
echo "<center style=\"font-size:12px;\">有项目为空,请重新发送。</center>";
}else if($yantext!=$yan){
echo "<span style=\"font-size:12px;\">验证码出错!</span>";
}else{
if($con==0){
@$link=mysql_connect($host,$dbuser,$pw) or die("太失望了,连接服务器失败!!");
@mysql_select_db($db,$link) or die("对不起,连接数据库失败!!");
$con=1;
}
$date=date("y-m-d h:i:s");
$query="insert into xp_liuyan
(name,http,text,date)
values
('".$name."','".$http."','".$text."','".$date."')";
@$result=mysql_query($query,$link) or die("1连接失败!!");
if(!$result){
echo "<center style=\"font-size:12px;\">留言添加失败,请重新发送。</center>";
}
}
}
//=============================================
if($action=="del"&&$enter==1){
if($con==0){
@$link=mysql_connect($host,$dbuser,$pw) or die("太失望了,连接服务器失败!!");
@mysql_select_db($db,$link) or die("对不起,连接数据库失败!!");
$con=1;
}
$query="delete from xp_liuyan
where id = '".$id."'";
@$result=mysql_query($query,$link) or die("3连接失败!!");
if($result){
echo "<center style=\"font-size:12px;\">删除成功!</center>";
}else{
echo "<center style=\"font-size:12px;\">删除失败</center>";
}
}
?>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="139" valign="top">
<?php
$pagesize=10;
if(!isset($totalpage)){
if($con==0){
@$link=mysql_connect($host,$dbuser,$pw) or die("太失望了,连接服务器失败!!");
@mysql_select_db($db,$link) or die("对不起,连接数据库失败!!");
$con=1;
}
$query="select * from xp_liuyan";
@$result=mysql_query($query,$link) or die("4连接失败!!");
$num_row=mysql_num_rows($result);
$totalpage=($num_row-1)/$pagesize+1;
$totalpage=(int)$totalpage;
}
$query="select * from xp_liuyan";
@$result=mysql_query($query,$link) or die("连接失败!!");
$totalnum_rows=mysql_num_rows($result);
echo "<table width='600' height='20' border='0' cellpadding='0' cellspacing='0' bgcolor='#FFB9A2' class='juzhong'><tr><td style=\"font-size:14px\" align='center'>";
echo "总共有".$totalnum_rows."条留言!!";
echo "</td></tr></table>";
if($num_row>0){
if(!isset($pagenum)){
$pagenum=1;
}
$start=($pagenum-1)*$pagesize;
$query="select * from xp_liuyan
order by id desc
limit ".$start.",".($pagesize+1);
@$result=mysql_query($query,$link) or die("连接失败!!");
$num_rows=mysql_num_rows($result);
$nextpage=0;
if($num_rows>$pagesize){
$num_rows=$pagesize;
$nextpage=1;
}
echo "<table width='600' style=\"line-height:20px;\" border=\"1\" bordercolor=\"#FFFF66\">";
for($i=0;$i<$num_rows;$i++){
$row=mysql_fetch_array($result);
echo "<tr>";
echo "<td bgcolor='#FFFF66' width='600' align='left' valign='top' style=\"font-size:12px;\">";
echo "留言".$row[id].":此留言发表于".$row[date]." ";
if($enter==1){
echo "<span style=\"font-size:12px;\"><a href=".$PHP_SELF."?action=del&id=".$row[id].">删除</a></span>";
}
echo "<br />留言者:<a href=".$row[http].">".$row[name]."</a></td></tr><tr><td width='600' height='50' align='left' valign='top' style=\"font-size:12px;\">";
echo "<span style=\"color:#FF0000;\"><strong>".$row[text]."</strong></span>";
echo "</td>";
echo "</tr>";
}
echo "</table>";
if($pagenum>1){
echo "<span style=\"font-size:12px;\"><a href=liuyan.php?pagenum=".($pagenum-1)."#foot>上一页</a></span> ";
}
if($nextpage==1){
echo "<span style=\"font-size:12px;\"><a href=liuyan.php?pagenum=".($pagenum+1)."#foot>下一页</a></span>";
}
}
else{
echo "<br />对不起,暂时没有留言。";
}
mysql_free_result($result);
?></td>
</tr>
</table>
<table width="600" height="192" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="192" align="center"><table width="320" height="96" border="0" cellpadding="0" cellspacing="0">
<form id="form1" name="form1" method="post" action="<?php echo $PHP_SELF."?action=add"; ?>">
<tr>
<td width="83" height="20" align="right"><span class="STYLE1">大名:</span></td>
<td width="237" align="left"><label>
<input name="name" type="text" id="name" />
</label></td>
</tr>
<tr>
<td height="20" align="right" class="STYLE1">地址:</td>
<td align="left"><label>
<input name="http" type="text" id="http" value="http://" />
</label></td>
</tr>
<tr>
<td height="20" align="right" class="STYLE1">内容:</td>
<td align="left"><label>
<textarea name="text" cols="30" rows="5" id="text"></textarea>
</label></td>
</tr>
<tr>
<td height="20" align="right" class="STYLE1">验证码:</td>
<td align="left"><label>
<input name="yantext" type="text" id="yantext" size="10" /><input name="yan" type="hidden" value="<?php
$yan=rand(1000,9999);
echo $yan;
?>" /><?php
echo "<span style=\"font-size:14px\"><strong>".$yan."</strong></span>";
?>
</label></td>
</tr>
<tr>
<td height="20" colspan="2" align="center"><label>
<input type="submit" name="Submit" value="提交" />
<input type="reset" name="Submit2" value="取消" />
</label></td>
</tr></form>
</table></td>
</tr>
</table>
<table width="600" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="20" align="center" class="STYLE1">
<?php
if($enter==1){
echo "<a href=".$PHP_SELF."?action=loginout>登出</a>";
}
?>
</td>
</tr>
</table>
<table width="366" height="22" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td align="center"><span class="STYLE4">program(php) <a href="http://mysys.into123.cn/">流星雨祝福墙</a> made by <a href="http://www.into123.cn/">into123.cn</a>, 2008</span></td>
</tr>
</table>
</body>
</html>