标签:doctype select sof round div meta null recordset 资料
error_reporting(0);
$conn = new com("adodb.connection");
$conn->open("driver={microsoft access driver (*.mdb)}; dbq=" . realpath("db.mdb "));
$rs=new com("adodb.recordset");
$abc = $_get["abc"]; $webn = $_post["webn"]; $name = $_post["name"]; $pws = $_post["pws"]; $newpws = $_post["newpws"];
$rs->open("select * from [web]",$conn,1,1);
$adminname = $rs->fields(1)->value;
$adminpws = $rs->fields(2)->value;
$ll = $rs->fields(3)->value;
$webname = $rs->fields(4)->value;
$rs->close();
$admincookie = $adminname;
$conn->execute("update [web] set [ll] = ‘$ll‘+1"); //$rs->close();
?>
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title><? echo $webname ?></title>
<style type="text/css教程">
<!--
body {font-size:14px; line-height:25px; margin:10px auto; padding:10px; width:680px; border:solid #8aa 1px;}
a {color:#008; text-decoration:none;}
a:hover {color:#f00; text-decoration:underline;}
hr {color:#8aa; height:1px;}
-->
</style>
</head>
<body>
<?
if ($abc=="admin"){
if ($name==$adminname && $pws==$adminpws){
setcookie("admin", $admincookie, time()+3600); header("location:./");
}else{echo "<script>alert(‘用户名或密码错误!‘);history.back();</script>";}
}
if ($abc=="exit"){
setcookie("admin", "", time()-3600); header("location:./");
}
if ($abc=="editadmin"){
if (!$webname || !$name || !$pws){
echo "<script>alert(‘留言本、用户名、原密码不能为空!‘);history.back();</script>";
}
if ($pws!=$adminpws){
echo "<script>alert(‘愿密码错误!‘);history.back();</script>";
}
if($newpws!=""){
$conn->execute("update [web] set [webname] = ‘$webname‘ , [name] = ‘$name‘ , [pws] = ‘$newpws‘");
$conn->close(); //$conn=null;
echo "<script>alert(‘修改成功,请重新登录!‘);location=‘?abc=exit‘;</script>";
}else{
$conn->execute("update [web] set [webname] = ‘$webn‘ , [name] = ‘$name‘");
$conn->close(); //$conn=null;
echo "<script>alert(‘修改成功!‘);location=‘./‘;</script>";
}
}
?>
<b>【 <a href="./"><? echo $webname ?></a> 】</b>
<a href="">管理</a> <? if (isset($_cookie["admin"])){ ?> <a href="">修改资料</a> <a href="">安全退出</a><? ;} ?>
<? if ($abc=="user" && !isset($_cookie["admin"])){ ?>
<form method="post" action="">
用户名:<input name="name" type="text" value=""/>
密码:<input name="pws" type="password" value=""/>
<input name="add" type="submit" value="确定" />
</form>
<? ;} ?>
<? if ($abc=="edituser"){ ?>
<form method="post" action="">
留言本:<input name="webn" type="text" value="<? echo $webname; ?>" size="80"/>
<br />
用户名:<input name="name" type="text" value="<? echo $admincookie; ?>"/>
原密码:<input name="pws" type="password" value=""/>
新密码:<input name="newpws" type="password" value=""/>
<input name="add" type="submit" value="确定" />
</form>
<? ;} ?>
<hr/>
<?
$id=$_get[‘id‘];
$sj=date(‘y-m-d‘);
if($abc=="add"){
$nr=$_post[‘nr‘];
$ip=getenv("remote_addr");
if (!$nr){
echo "<script>alert(‘留言不能为空!‘);history.back();</script>";
}else{
$conn->execute("insert into [txt] (nr,sj) values (‘$nr‘,‘$sj‘)");
}
echo "<script>alert(‘操作成功!‘);location=‘./‘;</script>";
$conn->close(); $conn=null;
}
if($abc=="del"){
$conn->execute("delete from [txt] where [id]=".$id);
$conn->close(); $conn=null; header("location:./");
}
if($abc=="edit"){
$nr=$_post[‘nr‘];
$hf=$_post[‘hf‘];
$conn->execute("update [txt] set [nr] = ‘$nr‘ , [hf] = ‘$hf‘ where [id]=".$id);
$conn->close(); $conn=null; header("location:./");
}
$zd=$_get[‘zd‘];
if($zd!=""){
if($zd=="0")$zd=1; else $zd=0;
$conn->execute("update [txt] set [zd] = ‘$zd‘ where [id]=".$id);
$conn->close(); $conn=null; header("location:./");
}
?>
<center>
<form method="post" action="">
<textarea name="nr" cols="88" rows="8" style="line-height:25px;"></textarea><br /><br />
<input name="add" type="submit" value="发表留言" />
</form>
</center>
<hr/>
<?
//分页
$rs->open("select * from [txt] order by [zd] desc, [sj] desc",$conn,1,3);
$rs->pagesize=5;
$page=trim($_get[‘page‘]);
if($page=="" || is_numeric(intval($page))<=0){$page=1;}else if(intval($page)>$rs->pagecount){$page=$rs->pagecount;}
$page=intval($page);
if(!$rs->eof||$rs->bof){
$rs->absolutepage=$page; $mypagesize=$rs->pagesize; $i=$rs->recordcount()-($page-1)*$rs->pagesize;
while(!$rs->eof && $mypagesize>0 && $i>=$rs->recordcount()-1-$rs->pagesize*$page){
$id = $rs->fields(0)->value;
$nr = $rs->fields(1)->value;
$hf = $rs->fields(2)->value;
$sj = $rs->fields(3)->value;
$zd = $rs->fields(4)->value;
?>
<div style="border:#eee solid 1px; background:#f8f8f8; padding:0 10px;">
<div style="float:left;">
<? if ($zd!=0) echo "【 <font color=‘#008800‘>置顶</font> 】2881064151"; else echo "id.".$i; ?>
<? if ($_cookie["admin"]==$admincookie){ ?>
操作:<a href=‘‘><? if ($zd==0) echo "置顶"; else echo "取消置顶"; ?></a> |
<a href=‘‘>修改/回复</a> |
<a href=‘‘>删除</a>
<? ;} ?>
</div>
<div style="float:right;">
date:<? echo $sj; ?>
</div>
<div style="clear:both"></div>
</div>
<hr/>
<? if ($abc=="hf" && $id==$_get[‘id‘]){ ?>
<form method="post" action="" id="<? echo $id ?>">
留言:<textarea name="nr" cols="80" rows="8" style="line-height:25px;"><? echo $nr; ?></textarea><br />
回复:<textarea name="hf" cols="80" rows="8" style="line-height:25px;"><? echo $hf; ?></textarea><br />
操作:<input name="add" type="submit" value="回复/修改" />
</form>
<? ;} ?>
<div style="margin:20px;">
<?
$nr = str_replace("n","n".‘<br/>‘,$nr);
$nr = str_replace(" ",‘ ‘,$nr);
echo $nr."<br />";
?>
<?
if ($hf!=""){
echo "<font color=‘#aa0000‘>回复:";
$hf = str_replace("n","n".‘<br/>‘,$hf);
$hf = str_replace(" ",‘ ‘,$hf);
echo $hf."</font>";
}
?>
</div>
<hr/>
<? $rs->movenext; $mypagesize--; $i--; } } //分页循环 ?>
<center>
留言数(<? echo $rs->recordcount(); ?>)
<a href="">首页</a>
<a href="">上页</a>
第<? echo $page;?>/<? echo $rs->pagecount;?>页
<a href="">下页</a>
<a href="">尾页</a>
访问量(<? echo $ll ?>)
</center>
<? $rs->close(); $rs=null; $conn->close(); $conn=null; ?>
</body>
</html>
标签:doctype select sof round div meta null recordset 资料
原文地址:http://www.cnblogs.com/cbryge/p/5995338.html