<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>Shrimpy`s GuestBook!!!</title>
<link href="/SGB.css" rel="stylesheet" type="text/css">
<style type="text/css">
<!--
.style1 {
font-size: 12px;
color: #666699;
}
.style3 {
font-size: 12px;
color: #6600CC;
}
-->
</style>
</head>
<body>
<form action="index.php?type=add" method="post" name="postthreads" class="unnamed1" id="postthreads">
<div align="center">
你的大名(*):
<input name="guestname" type="text" id="guestname" value="" size="20" maxlength="50">
<br>
你的标题(*):
<input name="threadtitle" type="text" id="threadtitle" size="20" maxlength="200">
<br>
来自:
<input name="guestfrom" type="text" id="guestfrom" size="20" maxlength="200">
<br>
主页:
<input name="guestpage" type="text" id="guestpage" value="http://" size="20" maxlength="200">
<br>
email:
<input name="guestemail" type="text" id="guestemail" value="@" size="20" maxlength="200">
<br>
<br>
<textarea name="threadcontent" cols="40" rows="10" id="threadcontent">内容!!!
我什么都不写你吹!!!</textarea>
<br>
<input type="submit" name="Submit" value="提交">
</div>
</form>
<div align="center"><br>
<?php
if($_GET[type]=="add"){
$guestname =$_POST['guestname'];
$threadtitle =$_POST['threadtitle'];
$guestfrom =$_POST['guestfrom'];
$guestpage =$_POST['guestpage'];
$guestemail =$_POST['guestemail'];
$threadcontent=$_POST['threadcontent'];
$threadcontent=htmlspecialchars($threadcontent);
$threadcontent=ereg_replace("\r\n","<br>",$threadcontent);
$threadcontent=ereg_replace("\r","<br>",$threadcontent);
$td =date("Y年n月d日 g:i:s a l"); //2005年1月19日 5:39:20 pm Thursday ************
$linestore =$td."||".$guestname."||".$threadtitle."||".$guestfrom."||".$guestpage."||".$guestemail."||".$threadcontent."\n"; //collect all the message in order to store into data.txt
$temp =fopen("data.txt","r+");
$tempdata =fread($temp,filesize("data.txt"));
fclose($temp);
$f =fopen("data.txt","r+"); //get handle
fputs($f,$linestore);
fputs($f,$tempdata);
fclose($f); // bring data into data.txt
} ?>
<br>
</div>
<?
$file =file("data.txt");
$datanum =sizeof($file);
$pagesize =3; // each page three threads
$pagenum =ceil($datanum/$pagesize); //total pages
if(isset($page)){
$currentpage =$page; // control prevpage and nextpage
if($_GET[ps]=="stridenow"){ // control striding page
$currentpage=$_POST['stridepage'];}
$prevpage =$currentpage-1;
$nextpage =$currentpage+1;
// $toppost =($currentpage-1)*$pagesize;
// $bottompost=($currentpage*$pagesize);
}else{
$currentpage =1; //initial
$toppost =0;
$bottompost =3;}
?>
<div align="center"><br>
<form action="index.php?ps=stridenow" method="post" name="stride" class="style3" id="stride">
你现在在<? echo $currentpage ?>页 你想跳到
<input name="stridepage" type="text" id="stridepage" value="" size="3">
页
<input type="submit" name="Submit2" value="ok">
一共有<? echo "$pagenum";?>页 <? echo "$datanum" ?>篇留言<br>
</form>
</div>
<?
if($prevpage>=0)
{
$prevpage =$currentpage-1;
}
else{$prevpage =0;}
if($nextpage<=$pagenum)
{
$nextpage =$currentpage+1;
}
else{$nextpage =$pagenum;}
$toppost =($currentpage-1)*$pagesize;
$bottompost=($currentpage*$pagesize);
for($i=$toppost;$i<$bottompost;$i=$i+1)
{
$expdata =explode("||",$file[$i]);
?>
<table width="400" border="0" align="center" bordercolor="#FFCC66">
<tr bgcolor="#FFCC66" class="unnamed1">
<td colspan="2" class="unnamed1"><div align="right" class="style1"><? echo $expdata[0]; ?></div></td>
</tr>
<tr bgcolor="#CCCCCC" class="unnamed1">
<td class="unnamed1"><div align="left"></div>
大名:<?php echo $expdata[1]; ?></td>
<td class="unnamed1">来自:<? echo $expdata[3] ;?></td>
</tr>
<tr bgcolor="#CCCCCC" class="unnamed1">
<td width="200" class="unnamed1"> <div align="left">邮箱:<a href="mailto: <? echo $expdata[5] ;?>"><? echo $expdata[5]; ?></a></div></td>
<td class="unnamed1"><div align="left"><span class="unnamed1">页子:</span><a href="<? echo $expdata[4] ; ?>" target="_blank"><? echo $expdata[4]?></a></div></td>
</tr>
<tr bgcolor="#CCCCCC" class="unnamed1">
<td colspan="2" class="unnamed1">标题:<?php echo $expdata[2]; ?></td>
</tr>
<tr bgcolor="#FFCC66" class="unnamed1">
<td colspan="2" align="left" class="unnamed1"><?php echo $expdata[6]; ?></td>
</tr>
</table>
<p><br>
</p>
</div>
<? } //for ?>
<div align="center"><? if($currentpage!=1){ ?>
<p><a href=index.php?page=<? echo $prevpage ?>>上一页</a><? } ?>
<? if($currentpage!=$pagenum){ ?>
<a href=index.php?page=<? echo $nextpage ?>>下一页</a><? } ?></p>
</div>
</body>
</html>