%
//====== Gusetbook PAGE LOGIC ================================
// Copyright 2005 SiC. All Rights Reserved.
// Last Update: 2005-02-26 23:57:15
//============================================================
if(theCache.settings["enableGuestBook"]!=1||gbookDB==""){
// If register is disabled
pageHeader(lang["error"]);
redirectMessage(lang["error"], lang["gbook_disabled"], lang["goback"], "default.asp", false, "errorbox");
pageFooter();
}else{
// Initialize DB Connection
var connGBook=new DBConn(gbookDB);
connGBook.open();
switch(String(input["act"])){
case "save":
commentSave();
break;
case "edit":
commentEdit(false);
break;
case "update":
commentEdit(true);
break;
case "delete":
commentDelete();
break;
default:
theCache.genSecurityCode();
// View Guestbook
pageHeader(lang["guestbook"]);
showGuestBook();
}
pageFooter();
connGBook.close();
if(inDebug) showSQLGB();
}
// Output GuestBook ////////////////////////////////////////////////////////////////////////////
function showGuestBook(){
var sqlWHERE="";
var strURLPrefix="?";
var arrKeywords="";
// Check current page number
if(input["page"]){
input["page"]=func.checkInt(input["page"]);
if(input["page"]<=0){
input["page"]=1;
}
}else{
input["page"]=1;
}
// Check if has search keywords
if(input["q"]){
sqlWHERE += " WHERE gb_hidden=False";
arrKeywords=input["q"].split(" ");
for(var i=0;i2){
sqlWHERE += " AND (gb_content LIKE '%"+func.checkStr(arrKeywords[i])+"%' OR gb_reply LIKE '%"+func.checkStr(arrKeywords[i])+"%')";
}
}
strURLPrefix += strURLPrefix=="?" ? "" : "&";
strURLPrefix += "q="+input["q"];
}
// Check if has highlight keywords
if(input["hl"]){
arrKeywords=input["hl"].split(" ");
strURLPrefix += strURLPrefix=="?" ? "" : "&";
strURLPrefix += "hl="+input["hl"];
}
var entryPerPage = theCache.settings["entryPerPageGuestBook"];
var entryCount=0;
var entries = connGBook.query("SELECT * FROM [Guestbook]"+sqlWHERE+" ORDER BY gb_postTime DESC", entryPerPage, input["page"], false);
if(entries){
for(var i=0;i"+lang["username_invalid"]+"";
}else if(connBlog.query("SELECT user_id FROM [blog_User] WHERE user_name='"+func.checkStr(input["comm_username"])+"'")){
strError+="
"+lang["user_exist"]+"
";
}
theUser.id=0;
theUser.username=input["comm_username"];
}
}
// Check for data
strError+=checkPostData(bCheckCode);
// Check for ubbFlags
var strUbbFlags=getUbbFlags();
if(strError!=""){
pageHeader(lang["error"]);
redirectMessage(lang["error"], strError, lang["goback"], "javascript:window.history.back();", false, "errorbox");
}else{
var arrInsert={ "gb_content": input["message"],
"gb_userid": theUser.id,
"gb_username": theUser.username,
"gb_ubbFlags": strUbbFlags,
"gb_hidden": input["comm_hidden"]=="true" ? true:false,
"gb_postTime": new Date(),
"gb_ip": theUser.IP
};
connGBook.insert("guestbook", arrInsert);
// Clean up to avoid abuse
Session("lbsSecurityCode")=undefined;
// Flood Control
Session("FloodControl")=new Date();
// Output ok message
pageHeader(lang["done"]);
redirectMessage(lang["done"], lang["comment_save_done"], lang["redirect"], "?", true, "messagebox");
}
}
}
// Check Post Form Data -----------------------
function checkPostData(bCheckCode){
var strError="";
// Check Security Code
if(theCache.settings["enableSecurityCode"]==1 && bCheckCode && Session("lbsSecurityCode")!=input["scode"]){
strError+="
"+lang["scode_invalid"]+"
";
}
// Workaround for content/reply swap when the user has reply rights
if(input["entry"]){
input["reply"]=input["message"];
input["message"]=input["entry"];
if(input["reply"].length>theCache.settings["maxCommentLength"]||input["reply"].length<2){
strError+="