PHP 代碼:
<?php
$host = "localhost";
$name = "";
$user = "";
$pass = "";
$lovewallname = "";
$keyword = "";
$base_url = "";
$adminpassword = "e10adc3949ba59abbe56e057f20f883e";
function connectmysql(){
global $host,$user,$pass,$name;
$conn = mysql_pconnect($host,$user,$pass) or die("connect to mysql error!");
mysql_select_db($name,$conn);
mysql_query("set names 'utf-8'");
return $conn;
}
$conn = connectmysql();
$query = mysql_query("select id from lovewall where ischeck=1 ORDER BY id DESC limit 0, 1",$conn);
$row = mysql_fetch_object($query);
$lastnum = $row->id;
$header = "<html>\r\n<head>\r\n<title>".$lovewallname."</title>\r\n<meta http-equiv=\"Page-Exit\" content=\"blendTrans(Duration=1)\" />\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />\r\n<meta name=\"keyword\" content=\"".$keyword."\" />\r\n<link rel=\"stylesheet\" href=\"./temp/style.css\" type=\"text/css\" />\r\n<script language=\"javascript\" type=\"text/javascript\" src=\"./temp/temp.js\"></script>\r\n</head>\r\n<body>\r\n<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\"><tr>\r\n<td width=\"240\" height=\"82\" align=\"center\" bgcolor=\"#ffffff\"><a href=\"./lovewall.php\" target=\"_top\"><img src=\"./temp/left.jpg\" width=\"240\" height=\"82\" border=0></a></td>\r\n<td background=\"./temp/right.jpg\" align=\"right\">我们的生活充满阳光^_^ <p><a href=\"http://www.niumowang.org\" target=_blank>牛魔王俱乐部<a> <br>How many roads must a man run before he sleep on the sand?</td>\r\n</tr></table>\r\n";
$top = "<table width=\"100%\" border=0><tr><td width=\"30%\"><a href=\"./lovewall.php?action=post\">开始在爱墙永久发布你的祝福纸条</a></td><td width=\"40%\" align=right><form name=\"get\" action=\"lovewall.php\" method=post><input type=\"text\" name=\"id\" value=\"".$lastnum."\" size=\"5\"></td><td width=\"10%\"><input type=\"submit\" name=\"submit\" value=\"纸条号码\" maxlenth=\"10\"></form></td></tr></table>\r\n";
$footer = "<div id=\"tj\" style=\"position:absolute;text-align:center;left:0;top:1030;width:1000px;height:50px;\">写下你永恒的爱情 | 写下你永恒的友情 | 写下你永久的亲情 | 爱墙与你的爱一起成长<p>Copyright (C) 2006 <a href=\"".$base_url."\" title=\"".$lovewallname."\">".$lovewallname."</a>, All Rights Reserved<p>本站代码为<a href=\"http://www.niumowang.org\">牛魔王</a>独立编写,为PHP+Mysql+cache结构,获得以及使用这个代码是免费的。但是,未经牛魔王明确许可,任何人不得用于商业用途</div>\r\n</body>\r\n</html>";
$id = $HTTP_GET_VARS['id']?$HTTP_GET_VARS['id']:$_POST['id'];
if ($HTTP_GET_VARS['action']=="post") {
$step = $_POST['step'];
$message = $_POST['message'];
$author = $_POST['author'];
$tagcolor = $_POST['tagcolor'];
}
if ($HTTP_GET_VARS['action']=="admin") {
if ($_POST['password']!="") $pass=md5($_POST['password']);
$password = $HTTP_GET_VARS['password']?$HTTP_GET_VARS['password']:$pass;
$del = $HTTP_GET_VARS['del']?$HTTP_GET_VARS['del']:$_POST['del'];
$page = $HTTP_GET_VARS['page']?$HTTP_GET_VARS['page']:$_POST['page'];
$id = $HTTP_GET_VARS['id']?$HTTP_GET_VARS['id']:$_POST['id'];
}
$id = ereg_replace("[^0-9_]","",$id);
switch ($HTTP_GET_VARS['action']){
case 'admin':admin();break;
case 'post':post();break;
default:main();break;
}
function main(){
global $header,$top,$id,$footer,$conn;
$content = "";
$content.=$header.$top;
$plus = "ORDER BY time DESC";
if ($id!="") $plus = "and id=".$id;
$query = mysql_query("select id,message,time,width,height,color,author from lovewall where ischeck=1 $plus",$conn);
while($row = mysql_fetch_object($query)){
$content.="<div id=\"Layer".$row->id."\" class=\"cccc\" style=\"filter:alpha(opacity=100);position:absolute;left:".$row->width."px;top:".$row->height."px;z-index:".$row->id.";background-color: ".$row->color.";\"><table border=0 ><tr><td style=\"cursor:move;\" width=\"94%\" onmousedown=MDown(Layer".$row->id.")>第".$row->id."条 ".str_replace("-", "/", $row->time)."</td><td style=\"cursor:hand\" onclick=\"ssdel()\" width=\"5%\">√</td></tr><tr><td style=\"height:100px;padding:5px;\" colspan=\"2\">".$row->message."<div class=\"name\">".$row->author."</div></td></tr></table></div>\r\n";
}
$content.=$footer;
echo $content;
}
function post(){
global $header,$footer,$step,$author,$tagcolor,$message,$base_url,$lovewallname,$conn;
$content = "";
if ($step==""){
$color = array("#FFFFFF","#FF0099","#FF0000","#FF6600","#FF84FF","#FFFF00","#FF00FF","#FF9900","#FFCCFF","#BFABFF","#E4E45A","#FFCC00","#BFFFFF","#FAD6F0","#FFCE7D","#FFA68C","#BDBEDE","#FFCC66","#73E7FF","#8CEFD6","#EBA87B","#97EB76","#CEEB76","#EEEEEE");
$tagcolor = $color[mt_rand(0,23)];
$plus = "<table cellSpacing=\"1\" cellPadding=\"3\" align=\"center\" border=\"0\" width=\"540\">
<SCRIPT LANGUAGE=\"JavaScript\">
<!--//
function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else
countfield.value = maxlimit - field.value.length;
}
var ie = false;
function getObj(id) {
if (ie) { return document.all[id]; }
else { return document.getElementById(id); }
}
function setColor(color) {
getObj('cardsample').style.background = '' + color;
document.post.tagcolor.value = color ;
}
//-->
</SCRIPT>
<form name=\"post\" action=\"./lovewall.php?action=post\" method=\"post\">
<tbody><tr><td><div id=\"cardsample\" class=\"cccc\" style=\"filter:alpha(opacity=100);position:absolute;left:5px;top:120px;z-index:5;background-color: ".$tagcolor.";\"><table border=0 ><tr><td style=\"cursor:move;\" width=\"94%\">第XXX条 </td><td style=\"cursor:hand\" width=\"5%\">√</td></tr><tr><td style=\"height:100px;padding:5px;\" colspan=\"2\"><div id=\"contentsample\"></div><div id=\"authsample\" class=\"name\"></div></td></tr></table></div></td></tr><tr><td width=\"140\">输入你的祝福纸条内容<p>还能输入<input readonly style=\"border:0;\" type=\"text\" name=\"remLen\" size=\"3\" maxlength=\"3\" value=\"100\">个字</td>
<td width=\"400\"><textarea name=\"message\" style=\"background-color: #fffbc5\" wrap=\"physical\" cols=\"50\" rows=\"8\" onKeyDown=\"textCounter(this.form.message,this.form.remLen,100);\" onKeyUp=\"textCounter(this.form.message,this.form.remLen,100);document.getElementById('contentsample').innerHTML=this.value;\"></textarea> <table cellpadding=\"2\" cellspacing=\"1\" border=\"0\">
<tr>
<td>颜色:<input type=\"hidden\" name=\"tagcolor\" value=\"".$tagcolor."\" /></td>
<td><a href=\"javascript:setColor('#FFFFFF');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #404040;height:25px; width:25px; background: #FFFFFF\"></div></a></td>
<td><a href=\"javascript:setColor('#FF0099');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FF0099\"></div></a></td>
<td><a href=\"javascript:setColor('#FF0000');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FF0000\"></div></a></td>
<td><a href=\"javascript:setColor('#FF6600');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FF6600\"></div></a></td>
<td><a href=\"javascript:setColor('#FF84FF');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FF84FF\"></div></a></td>
<td><a href=\"javascript:setColor('#FFFF00');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #404040;height:25px; width:25px; background: #FFFF00\"></div></a></td>
<td><a href=\"javascript:setColor('#FF00FF');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FF00FF\"></div></a></td>
<td><a href=\"javascript:setColor('#FF9900');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FF9900\"></div></a></td>
<td><a href=\"javascript:setColor('#FFCCFF');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FFCCFF\"></div></a></td>
<td><a href=\"javascript:setColor('#BFABFF');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #BFABFF\"></div></a></td>
<td><a href=\"javascript:setColor('#E4E45A');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #E4E45A\"></div></a></td>
<td><a href=\"javascript:setColor('#FFCC00');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FFCC00\"></div></a></td>
</tr>
<tr>
<td> </td>
<td><a href=\"javascript:setColor('#BFFFFF');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #BFFFFF\"></div></a></td>
<td><a href=\"javascript:setColor('#FAD6F0');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FAD6F0\"></div></a></td>
<td><a href=\"javascript:setColor('#FFCE7D');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FFCE7D\"></div></a></td>
<td><a href=\"javascript:setColor('#FFA68C');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FFA68C\"></div></a></td>
<td><a href=\"javascript:setColor('#BDBEDE');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #404040;height:25px; width:25px; background: #BDBEDE\"></div></a></td>
<td><a href=\"javascript:setColor('#FFCC66');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #FFCC66\"></div></a></td>
<td><a href=\"javascript:setColor('#73E7FF');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #73E7FF\"></div></a></td>
<td><a href=\"javascript:setColor('#8CEFD6');\"><div id=\"color330\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #8CEFD6\"></div></a></td>
<td><a href=\"javascript:setColor('#EBA87B');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #EBA87B\"></div></a></td>
<td><a href=\"javascript:setColor('#97EB76');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #97EB76\"></div></a></td>
<td><a href=\"javascript:setColor('#CEEB76');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #CEEB76\"></div></a></td>
<td><a href=\"javascript:setColor('#EEEEEE');\"><div id=\"color325\" style=\"cursor:pointer;border:1px solid #808080;height:25px; width:25px; background: #EEEEEE\"></div></a></td>
</tr>
</table>
许愿人姓名:<input name=\"author\" onkeyup=\"javascript:document.getElementById('authsample').innerHTML=this.value;\" type=\"text\" id=\"author\" value=\"\" size=\"12\" maxlength=\"10\" /></td></tr>
<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\" 第一步 开始发布你的祝福纸条(共2步) \"></td></tr><input type=\"hidden\" name=\"step\" value=\"publish\"></form>
<tr><td height=\"50\"></td><td><tr><td></td><td colspan=\"2\"><textarea readonly name=\"guize\" wrap=\"physical\" cols=\"50\" rows=\"10\">
一、你可以免费发布,支持爱墙以及你的爱永恒不朽,请把爱墙推荐给你的朋友。
二、所有祝福纸条在爱墙永久保存。记住您的祝福纸条号码可以随时查看。
三、请勿发布有违法律、道德、公序良俗以及任何本站认为不适合在爱墙发布的信息。本站保留随时删除此类纸条的权利。删除这些纸条之前不会通知发布人。
四、如果你不选择一个颜色,系统会随机产生一个,如果你不写名字,就以匿名发表,为公平,位置都是随机的</textarea></td></tr>
<tr><td height=\"50\"></td><td><tr></tr></tbody></table>";
}
if ($step=="publish"){
$plus = $tagcolor.$author."<table cellSpacing=\"1\" cellPadding=\"3\" align=\"center\" border=\"0\" width=\"540\">\r\n<SCRIPT LANGUAGE=\"JavaScript\">\r\n<!--//\r\nfunction textCounter(field, countfield, maxlimit) {\r\nif (field.value.length > maxlimit) \r\nfield.value = field.value.substring(0, maxlimit);\r\nelse\r\ncountfield.value = maxlimit - field.value.length;\r\n}\r\n//-->\r\n</SCRIPT>\r\n<form name=\"post\" action=\"./lovewall.php?action=post\" method=\"post\">\r\n<tbody><tr><td height=\"50\"></td></tr><tr><td width=\"140\">输入你的祝福纸条内容<p>还能输入<input readonly style=\"border:0;\" type=\"text\" name=\"remLen\" size=\"3\" maxlength=\"3\" value=\"100\">个字</td>\r\n<td width=\"400\"><textarea name=\"message\" style=\"background-color: #fffbc5\" wrap=\"physical\" cols=\"50\" rows=\"7\" onKeyDown=\"textCounter(this.form.message,this.form.remLen,100);\" onKeyUp=\"textCounter(this.form.message,this.form.remLen,100);\">".$message."</textarea></td></tr>\r\n<tr><td></td><td><input type=\"submit\" name=\"submit\" value=\" 第二步 开始发布你的祝福纸条(共2步) \"></td></tr><input type=\"hidden\" name=\"step\" value=\"post\"><input type=\"hidden\" name=\"tagcolor\" value=\"".$tagcolor."\"><input type=\"hidden\" name=\"author\" value=\"".$author."\"></form>\r\n<tr><td height=\"50\"></td><td><tr><td></td><td colspan=\"2\">你确定不再修改了吗?一旦发布,就是永恒。要是你改好了,按上面的按钮立刻发布吧^_^</td></tr>\r\n<tr><td height=\"50\"></td><td><tr></tr></tbody></table>\r\n";
}
if ($step=="post"){
if ($tagcolor=="#FFFFFF") {
$tagcolor=="#000000";
}
$width = mt_rand(0,793);
$height = mt_rand(120,820);
$color="ff0000";
$message = trim($message);
if(getenv('HTTP_CLIENT_IP')) {
$onlineip = getenv('HTTP_CLIENT_IP');
} elseif(getenv('HTTP_X_FORWARDED_FOR')) {
$onlineip = getenv('HTTP_X_FORWARDED_FOR');
} elseif(getenv('REMOTE_ADDR')) {
$onlineip = getenv('REMOTE_ADDR');
} else {
$onlineip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
}
$ip = explode('.',"$onlineip");
$onlineip = $ip[0]."#".$ip[1]."#".$ip[2]."#".$ip[3];
$time = strftime("%Y-%m-%d %H:%M:%S",time());
if ($message!="") mysql_query("Insert Into lovewall(ip,message,time,width,height,color,author,ischeck) values('$onlineip','$message','$time','$width','$height','$tagcolor','$author','1')",$conn);
$id = mysql_insert_id($conn);
$plus = "<table cellSpacing=\"1\" cellPadding=\"3\" align=\"center\" border=\"0\" width=\"540\">\r\n<tbody><tr><td height=\"50\">恭喜你,你的爱已经发布在<a href=\"".$base_url."\" title=\"".$lovewallname."\">".$lovewallname."</a>了,您的字条位置是随机生成的<br>\r\n永久ID: <font color=\"red\">".$id."</font> ,快拿笔记住它吧,任何时候你可以通过<a href=\"".$base_url."/lovewall.php?id=".$id."\">".$base_url."/lovewall.php?id=".$id."</a>来查看^_^\r\n<br>还等什么,快把上面的地址告诉你爱的人吧,难道你要独享这个乐趣?</td></tr><tr><td width=\"540\"></td></tr>\r\n</tbody></table>\r\n";
}
$content.=$header;
$content.=$plus;
$content.=$footer;
echo $content;
}
function admin(){
global $header,$footer,$adminpassword,$page,$del,$id,$password,$base_url,$lovewallname,$conn;
$ton = "40";
$page = ($page=="")?1:$page;
$limit = ($page-1)*$ton;
if ($password!=$adminpassword) $plus = "<table cellSpacing=\"1\" cellPadding=\"3\" align=\"center\" border=\"0\" width=\"540\"><tbody><tr><td height=\"50\"><form name=\"post\" action=\"./lovewall.php?action=admin\" method=\"post\">管理密码:<input name=\"password\" value=\"\"> <input type=\"submit\" name=\"submit\" value=\"管理\"></td></tr><tr><td width=\"540\"></td></tr></tbody></table>";
else {
if ($del=="1"&&$id!="") mysql_query("Delete From lovewall where id=$id",$conn);
$query = mysql_query("select id,ip,message,time from lovewall where ischeck=1 ORDER BY id DESC limit $limit,$ton",$conn);
while($row = mysql_fetch_object($query)){
$plus.=" ".$row->ip."_<a href=\"lovewall.php?action=admin&password=$password&del=1&id=".$row->id."\">".$row->id."</a>:".$row->message.$row->time."<br>\r\n";
}
$plus.="分页:";
$fuck = mysql_query("select id,ip,message,time from lovewall where ischeck=1 ORDER BY id DESC",$conn);
$count = mysql_num_rows($fuck);
$pagenum = $count/$ton;
for ($i=1;$i<$pagenum;$i++){
$plus.="<a href=\"lovewall.php?action=admin&password=$password&page=".$i."\">".$i."</a> ";
if ($i%40=="0") $plus.="<br>\r\n";
}
}
$content = "";
$content.=$header;
$content.=$plus;
$content.=$footer;
echo $content;
}
?>