📄 guestbook.php
字号:
<?
#################################################################################################
#
# project : phpBook
# filename : guestbook.php
# last modified by : Erich Fuchs
# e-mail : office@smartisoft.com
# purpose : Guestbook
#
#################################################################################################
$proctime_start=microtime();
# Include Configs & Variables
#################################################################################################
require ("config.php");
if (strstr (getenv('HTTP_USER_AGENT'), 'MSIE')) { // Browser Detection
$in_field_size="50";
$text_field_size="31";
} else {
$in_field_size="30";
$text_field_size="24";
}
# Connect DB
#################################################################################################
mysql_connect($server, $db_user, $db_pass) or died("Database Connect Error");
# Process
#################################################################################################
if ($action=="submit") { // Add an action
if (!$in && !$delid && !$delcommentid && !$commentid) {
header("Location: $PHP_SELF");
exit;
} elseif ($delid && $admin==$adminpass) {
mysql_db_query($database, "DELETE FROM guestbook WHERE id='$delid'") or died("Database Query Error");
header("Location: $PHP_SELF?offset=$offset&poffset=$poffset&admin=$admin");
exit;
} elseif ($delcommentid && $admin==$adminpass) {
mysql_db_query($database, "UPDATE guestbook SET comment='' where id='$delcommentid'") or died("Database Query Error");
header("Location: $PHP_SELF?offset=$offset&poffset=$poffset&admin=$admin");
exit;
} elseif ($commentid && $admin==$adminpass) {
if(isset($comment)){
$action=changed;
mysql_db_query($database, "UPDATE guestbook SET comment='".encode_msg($comment)."' where id='$commentid'") or died("Database Query Error");
} else {
$action="";
}
header("Location: $PHP_SELF?commentid=$commentid&action=$action&offset=$offset&poffset=$poffset&admin=$admin");
exit;
} else {
if (isbanned()) {
header("Location: $PHP_SELF");
exit;
}
$add_date=time();
$result=mysql_db_query($database, "SELECT * FROM guestbook WHERE ip='$REMOTE_ADDR' AND timestamp>($add_date-(60*$timelimit))") or died("Database Query Error");
$query=mysql_fetch_array($result);
if ($query) {
header("Location: $PHP_SELF");
exit;
}
$in = strip_array($in);
$in['message'] = encode_msg($in['message']); // Add SQL compatibilty & Smilie Convert
$in['http'] = str_replace("http://", "", $in['http']); // Remove http:// from URLs
if ($in['name'] == "") { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$name_empty</center></body></html>"); }
if ($in['icq'] != "" && ($in['icq'] < 1000 || $in['icq'] > 999999999)) { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$icq_wrong</center></body></html>"); }
if (!eregi("^[0-9a-z]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$",$in['email']) && $in['email'] != "") { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$non_valid_email</center></body></html>"); }
if (strlen($in['message']) < $limit["0"] || strlen($in['message']) > $limit["1"]) { died("<html><head><title>$guestbook_head</title>$languagemetatag</head><body><center>$message_incorrect $limit[0] $and $limit[1] $characters.</center></body></html>"); }
if ($in['email'] == "") { $in['email'] = "none"; }
if ($in['icq'] == "") { $in['icq'] = 0; }
if ($in['http'] == "") { $in['http'] = "none"; }
if ($in['location'] == "0") { $in['location'] = "none"; }
$in['browser'] = $HTTP_USER_AGENT;
mysql_db_query($database, "INSERT INTO guestbook (name, email, http, icq, message, timestamp, ip, location, browser)
VALUES('$in[name]', '$in[email]','$in[http]','$in[icq]','$in[message]','$add_date', '$REMOTE_ADDR','$in[location]','$in[browser]')")
or died("Database Query Error");
if ($gb_notify) {
@mail("$gb_notify","$gb_notifysubj","$notify_text $in[name]\n\n".censor_msg($in[message]),"From: $gb_notify");
}
if ($timelimit) {
setcookie("phpbookcookie","$guestbook_head", time()+(60*$timelimit),"/");
}
if ($admin) {$adminlink="?admin=$admin";}
header("Location: $PHP_SELF$adminlink");
exit;
}
} else { // Show the entries #####################
# Header
#################################################################################################
echo "<html>\n";
echo " <head>\n";
echo " <title>$guestbook_head</title>\n";
echo " <link rel=\"stylesheet\" type=\"text/css\" href=\"style.css\">\n";
echo " $languagemetatag\n";
echo " <meta name=\"robots\" content=\"index, nofollow\">\n";
echo " <meta name=\"revisit-after\" content=\"20 days\">\n";
echo " <script language=\"Javascript\">\n";
echo " function floodprotect() {\n";
echo " alert(\"$banned\");\n";
echo " }\n";
echo " </script>\n";
echo " </head>\n";
echo "<body>\n";
# The Main-Section
#################################################################################################
echo" <table align=\"$table_align\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\" margin=1 width=\"$table_width\" height=\"$table_height\">\n";
echo" <tr>\n";
echo" <td class=\"class1\">\n";
echo" <table align=\"center\" border=\"0\" cellspacing=\"0\" cellpadding=\"3\" width=\"100%\" height=\"$table_height\">\n";
echo" <tr>\n";
echo" <td class=\"class2\">\n";
if ($action=="add") {
echo " <table>\n";
echo " <tr>\n";
echo " <td width=\"1%\">\n";
echo " <div class=\"mainheader\">$guestbook_head</div>\n";
echo " </td>\n";
echo " <td>\n";
echo " <div class=\"mainmenu\">$gb_link1head</div></div>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <div class=\"maintext\">\n";
echo " <br>\n";
echo " <table align=\"center\">\n";
echo " <Form action=\"$PHP_SELF?action=submit\" method=\"post\">\n";
echo " <tr>\n";
echo " <td><div class=\"maininputleft\">$gbadd_name</div></td>\n";
echo " <td><input type=\"text\" name=\"in[name]\" size=\"$in_field_size\" maxlength=\"35\"></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td><div class=\"maininputleft\">$gbadd_location</div></td>\n";
if ($location_text) {
echo " <td><input type=\"text\" name=\"in[location]\" size=\"$in_field_size\" maxlength=\"35\"></td>\n";
} else {
echo " <td class=\"class_add2\"><select name=\"in[location]\">\n";
echo " <option value=\"0\" SELECTED>$location_sel</option>\n";
include ("$loc_dir/$locations");
echo " </select></td>\n";
}
echo " </tr>\n";
echo " <tr>\n";
echo " <td><div class=\"maininputleft\">$gbadd_email</div></td>\n";
echo " <td><input type=\"text\" name=\"in[email]\" size=\"$in_field_size\" maxlength=\"35\"></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td><div class=\"maininputleft\">$gbadd_icq</div></td>\n";
echo " <td><input type=\"text\" name=\"in[icq]\" size=\"$in_field_size\" value=\"\" maxlength=\"12\"></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td><div class=\"maininputleft\">$gbadd_url</div></td>\n";
echo " <td><input type=\"text\" name=\"in[http]\" size=\"$in_field_size\" maxlength=\"60\" value=\"http://\"></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td valign=\"top\"><div class=\"maininputleft\">$gbadd_msg<br><br>\n";
echo " <div class=\"xsmallleft\"><a href=\"smiliehelp.php\"
onClick='enterWindow=window.open(\"smiliehelp.php\",\"Smilie\",
\"width=300,height=450,top=100,left=100,scrollbars=yes\"); return false'
onmouseover=\"window.status='$smiliehelp'; return true;\"
onmouseout=\"window.status=''; return true;\">$smiley_help</a></div>\n";
echo " <div class=\"xsmallleft\"><a href=\"urlcodehelp.php\"
onClick='enterWindow=window.open(\"urlcodehelp.php\",\"URLCode\",
\"width=550,height=450,top=100,left=100,scrollbars=yes\"); return false'
onmouseover=\"window.status='$urlcodehelp'; return true;\"
onmouseout=\"window.status=''; return true;\">$url_code_help</a></div>\n";
echo " </div></td>\n";
echo " <td><textarea rows=\"8\" name=\"in[message]\" cols=\"$text_field_size\"></textarea></td>\n";
echo " </tr>\n";
echo " <tr>\n";
echo " <td></td>\n";
echo " <td><br><input type=\"hidden\" name=\"admin\" value=\"$admin\"><input type=\"submit\" Value=\"$submit\"></td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " </form>\n";
echo " </div>\n";
} elseif ($action=="admin" && $admin==$adminpass) {
echo " <table>\n";
echo " <tr>\n";
echo " <td width=\"1%\">\n";
echo " <div class=\"mainheader\">$guestbook_head</div>\n";
echo " </td>\n";
echo " <td>\n";
echo " <div class=\"mainmenu\">";
echo " <a href=\"$PHP_SELF?admin=$admin\" onmouseover=\"window.status='$gb_link5desc'; return true;\" onmouseout=\"window.status=''; return true;\">$gb_link5</a> || ";
echo " $gb_link2head</div>\n";
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <div class=\"maintext\">\n";
echo " <br>\n";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -