PJBlog评论留言增加邮箱网址 记住访客信息
发布:老七 日期:2009年11月14日

为了增强博客的交互性 本来想换z-blog 试了下 动态转静态。。收录就要从零开始了
为了我那可怜的收录,决定到处找,到pj论坛 到pj博客上看,看怎么修改源码
搞了一个下午。终于搞成现在这个效果了 虽然效果还不是很好。但勉强够用了
下面列出修改方法。方便想增加交互性的pj用户 呵呵。希望你们不要走弯路。
首先:评论留言增加邮箱网址及博主回复通知评论留言人
注意:此功能基于留言评论邮件通知博主(增加后台开关),否则发送不了邮件。
打开class/cls_article.asp,找到:
- SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY FROM blog_Comment Where blog_ID="&LogID&" UNION ALL Select 0,tb_Intro,tb_Title,tb_PostTime,tb_URL,tb_Site,tb_ID,0,'127.0.0.1',0 FROM blog_Trackback Where blog_ID="&LogID&" orDER BY comm_PostTime "&comDesc
- SQL="Select comm_ID,comm_Content,comm_Author,comm_PostTime,comm_DisSM,comm_DisUBB,comm_DisIMG,comm_AutoURL,comm_PostIP,comm_AutoKEY,email,siteurl FROM blog_Comment Where blog_ID="&LogID&" UNION ALL Select 0,tb_Intro,tb_Title,tb_PostTime,tb_URL,tb_Site,tb_ID,0,'127.0.0.1',0,0,0 FROM blog_Trackback Where blog_ID="&LogID&" orDER BY comm_PostTime "&comDesc
- <%=blog_CommAuthor%></strong></a> <span class="commentinfo">
- <%
- if trim(commArr(10,Pcount))<>"" then
- response.write " <a href=mailto:"&trim(commArr(10,Pcount))&" target=_blank><img src=images/email1.gif border=0></a>"
- else
- response.write " <img src=images/noemail1.gif>"
- end if
- if trim(commArr(11,Pcount))<>"" and trim(commArr(11,Pcount))<>"http://" then
- response.write " <a href="&trim(commArr(11,Pcount))&" target=_blank><img src=images/url1.gif border=0></a>"
- else
- response.write " <img src=images/nourl1.gif>"
- end if
- %>
- <%if memName=empty or blog_validate=true then%><tr><td align="right" width="70"><strong>验证码:</strong></td><td align="left" style="padding:3px;"><input name="validate" type="text" size="4" class="userpass" maxlength="4"/> <%=getcode()%></td></tr><%end if%>
- <%if memName=empty then%><tr><td align="right" width="70"><strong>邮 箱:</strong></td><td align="left" style="padding:3px;"><input name="email" type="text" size="18" class="userpass" maxlength="24"/> 请填写您的邮箱.</td></tr><%end if%>
- <%if memName=empty then%><tr><td align="right" width="70"><strong>网 址:</strong></td><td align="left" style="padding:3px;"><input name="siteurl" type="text" class="userpass" value="http://" size="18" maxlength="24"/> 请填写您的网址.</td></tr><%end if%>
- password=trim(CheckStr(request.form("password")))
- dim email,siteurl
- email=trim(CheckStr(request.form("email")))
- siteurl=trim(CheckStr(request.form("siteurl")))
- IF (memName=empty or blog_validate=true) and cstr(lcase(Session("GetCode")))<>cstr(lcase(validate)) then
- ReInfo(0)="评论发表错误信息"
- ReInfo(1)="<b>验证码有误,请返回重新输入</b>
- <a href=""javascript:history.go(-1);"">请返回重新输入</a>"
- ReInfo(2)="ErrorIcon"
- postcomm=ReInfo
- exit function
- end if
- if memName=empty and email<>"" and IsValidEmail(email)=false then
- ReInfo(0)="评论发表错误信息"
- ReInfo(1)="<b>邮箱格式错误</b>
- <a href=""javascript:history.go(-1);"">请返回重新输入</a>"
- ReInfo(2)="ErrorIcon"
- postcomm=ReInfo
- exit function
- end if
- if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
- ReInfo(0)="评论发表错误信息"
- ReInfo(1)="<b>网址格式错误</b>
- <a href=""javascript:history.go(-1);"">请返回重新输入</a>"
- ReInfo(2)="ErrorIcon"
- postcomm=ReInfo
- exit function
- end if
- AddComm=array(array("blog_ID",post_logID),array("comm_Content",post_Message),array("comm_Author",username),array("comm_DisSM",post_DisSM),array("comm_DisUBB",post_DisUBB),array("comm_DisIMG",post_disImg),array("comm_AutoURL",post_DisURL),Array("comm_PostIP",getIP),Array("comm_AutoKEY",post_DisKEY))
- AddComm=array(array("blog_ID",post_logID),array("comm_Content",post_Message),array("comm_Author",username),array("comm_DisSM",post_DisSM),array("comm_DisUBB",post_DisUBB),array("comm_DisIMG",post_disImg),array("comm_AutoURL",post_DisURL),Array("comm_PostIP",getIP),Array("comm_AutoKEY",post_DisKEY),Array("email",email),Array("siteurl",siteurl))
- %>
- Function IsRightUrl(UrlStrng) '网址判断
- Dim regEx, retVal
- Set regEx = New RegExp
- regEx.Pattern = "^https?:\/\/[\u4E00-\u9FA5a-zA-Z\.\/0-9]{3,}[\u4E00-\u9FA5a-zA-Z\/0-9]{2,}$"
- regEx.IgnoreCase = False
- retVal = regEx.Test(UrlStrng)
- If retVal Then
- IsRightUrl = true
- Else
- IsRightUrl = false
- End If
- End Function
- Public function IsValidEmail(email) '邮箱判断
- dim names, name, i, c
- IsValidEmail = true
- names = Split(email, "@")
- if UBound(names) <> 1 then
- IsValidEmail = false
- exit function
- end if
- for each name in names
- if Len(name) <= 0 then
- IsValidEmail = false
- exit function
- end if
- for i = 1 to Len(name)
- c = Lcase(Mid(name, i, 1))
- if InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 and not IsNumeric(c) then
- IsValidEmail = false
- exit function
- end if
- next
- if Left(name, 1) = "." or Right(name, 1) = "." then
- IsValidEmail = false
- exit function
- end if
- next
- if InStr(names(1), ".") <= 0 then
- IsValidEmail = false
- exit function
- end if
- i = Len(names(1)) - InStrRev(names(1), ".")
- if i <> 2 and i <> 3 then
- IsValidEmail = false
- exit function
- end if
- if InStr(email, "..") > 0 then
- IsValidEmail = false
- end if
- end function
4.打开Plugins/GuestBook/bookaction.asp,找到
- post_Message=request.form("Message")
- dim email,siteurl
- email=trim(CheckStr(request.form("email")))
- siteurl=trim(CheckStr(request.form("siteurl")))
- if filterSpam(post_Message,"../../spam.xml") and stat_Admin=0 then
- showmsg "留言发表错误信息","<b>留言中包含被屏蔽的字符</b>
- <a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
- exit function
- end if
- if memName=empty and email<>"" and IsValidEmail(email)=false then
- showmsg "留言发表错误信息","<b>邮箱格式错误</b>
- <a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
- exit function
- end if
- if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
- showmsg "留言发表错误信息","<b>网址格式错误</b>
- <a href=""javascript:history.go(-1);"">返回</a>","WarningIcon","plugins"
- exit function
- end if
- Conn.ExeCute("Insert INTO blog_book(book_Messager,book_face,book_IP,book_Content,book_HiddenReply,email,siteurl) VALUES ('"&username&"','"&face&"','"&getIP()&"','"&post_Message&"',"&hiddenreply&")")
- Conn.ExeCute("Insert INTO blog_book(book_Messager,book_face,book_IP,book_Content,book_HiddenReply,email,siteurl) VALUES ('"&username&"','"&face&"','"&getIP()&"','"&post_Message&"',"&hiddenreply&",'"&email&"','"&siteurl&"')")
- <a href="member.asp?action=view&memName=<%=Server.URLEncode(GuestDB("book_Messager"))%>"><b><%=GuestDB("book_Messager")%></b></a> <span class="commentinfo">
- <%
- if trim(GuestDB("email"))<>"" then
- response.write " <a href=mailto:"&trim(GuestDB("email"))&" target=_blank><img src=images/email1.gif border=0></a>"
- else
- response.write " <img src=images/noemail1.gif>"
- end if
- if trim(GuestDB("siteurl"))<>"" and trim(GuestDB("siteurl"))<>"http://" then
- response.write " <a href="&trim(GuestDB("siteurl"))&" target=_blank><img src=images/url1.gif border=0></a>"
- else
- response.write " <img src=images/nourl1.gif>"
- end if
- %>
- <tr><td align="right" width="70"><strong>验证码:</strong></td><td align="left" style="padding:3px;"><input name="validate" type="text" size="4" class="userpass" maxlength="4"/> <%=getcode()%></td></tr>
- <%if memName=empty then%><tr><td align="right" width="70"><strong>邮 箱:</strong></td><td align="left" style="padding:3px;"><input name="email" type="text" size="18" class="userpass" maxlength="24"/> 请填写您的邮箱.</td></tr><%end if%>
- <%if memName=empty then%><tr><td align="right" width="70"><strong>网 址:</strong></td><td align="left" style="padding:3px;"><input name="siteurl" type="text" class="userpass" value="http://" size="18" maxlength="24"/> 请填写您的网址.</td></tr><%end if%>
- if memName=empty and email<>"" and IsValidEmail(email)=false then
- if memName=empty and IsValidEmail(email)=false then
- if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
- if memName=empty and IsRightUrl(siteurl)=false then
- if memName=empty and email<>"" and IsValidEmail(email)=false then
- if memName=empty and IsValidEmail(email)=false then
- if memName=empty and siteurl<>"" and siteurl<>"http://" and IsRightUrl(siteurl)=false then
- if memName=empty and IsRightUrl(siteurl)=false then
如果之前没加过评论留言加网址和邮箱功能,请下载附件,升级数据库,否则请跳过。
OK,全文结束。如果是全静态,修改完成后到后台重新生成。
然后:单击自动输入验证码
改进步骤: 1、在common/ajax.js的最后面添加如下代码:
- function get(url,obj1,obj2)
- {
-
- var xmlhttp = CreateXMLHTTP();
- if(!xmlhttp)
- {
- alert("你的浏览器不支持XMLHTTP!!");
- return;
- }
- xmlhttp.onreadystatechange=requestdata;
- xmlhttp.open("GET",url,true);
- xmlhttp.send(null);
- function requestdata()
- {
-
- fopen(obj1);
- echo(obj1,"<img src='images/loading.gif'>");
- if(xmlhttp.readyState==4)
- {
- if(xmlhttp.status==200)
- {
- if(obj1!=obj2){fclose(obj1);};
- $(obj2).value = xmlhttp.responseText;
-
- }
- }
-
- }
- }
2、在根目录下的Action.asp中找到
- If request.QueryString("action") = "checkAlias" then
替换为
- '-------------- [code] -----------------
- If request.QueryString("action") = "code" Then
- If ChkPost() Then
- Dim code
- code = Session("GetCode")
- Response.Write code
- End If
- '-------------- [Alias] -----------------
- ElseIf request.QueryString("action") = "checkAlias" then
3、更改模板文件:在template/static.htm中找到
- <input name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()"/>
- <img id="vcodeImg" src="about:blank" onerror="this.onerror=null;this.src='common/getcode.asp?s='+Math.random();" alt="验证码" title="看不清楚?点击刷新验证码!" style="margin-right:40px;cursor:pointer;width:40px;height:18px;margin-bottom:-4px;margin-top:3px;" onclick="src='common/getcode.asp?s='+Math.random()"/>
替换为
- <input id="validate" name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()" onclick="get('action.asp?action=code','c','validate')" />
- <img id="vcodeImg" src="about:blank" onerror="this.onerror=null;this.src='common/getcode.asp?s='+Math.random();" alt="验证码" title="看不清楚?点击刷新验证码!" style="margin-right:40px;cursor:pointer;width:40px;height:18px;margin-bottom:-4px;margin-top:3px;" onclick="src='common/getcode.asp?s='+Math.random()"/><span id="c">提示:单击验证码</span>
如果你使用的是动态或者半静态模式,那么你需要在class/cls_article.asp中将上面的代码替换为
- <input id="validate" name="validate" type="text" size="4" class="userpass" maxlength="4" onfocus="this.select()" onclick="get('action.asp?action=code','c','validate')" /> <%=getcode()%><span id="c">提示:单击验证码</span>
至此,修改完毕了。
最后:记住访客信息
在blogcomm.asp 中 Response.Cookies(CookieName)("memLastpost") = Now() 一句下方增加:
'将评论者资料写入cookies
Response.Cookies("VisitorName")=username
Response.Cookies("VisitorEmail")=email
Response.Cookies("VisitorWeb")=tsiteurl
在class/cls_article.asp 中 昵称/电邮/网址三个表单项文本框代码中把原默认value代码替换为:
value="<%response.write (request.cookies("VisitorName"))%>"/>
value="<%response.write (request.cookies("VisitorEmail"))%>"/>
value="<%response.write (request.cookies("VisitorWeb"))%>"/>
目前本博客已经升级了这两个代码模块。
您只要评论之后,系统就会通过cookies记住您在本站评论时留下的昵称、Email和网址了。
下次想要说些什么,直接输入您想说的就OK了。
按上面的步骤做就可以了 做之前做好备份哦。。呵呵! 危险 勿进~~
本来开始我也想用PJBLOG了,可是我的ASP主机快到期了,正好又买了新的PHP主机,所以就用WP了。
还有自动添加验证码不错哦。
[reply=老七,2009-11-15 07:07 AM]能说清楚点嘛 我好解决?[/reply]
我是照的戒聊的老版改的 和新版本不一样
但你这个可能就COOKIE不行 因为貌似浏览器不关 在其他页面 还是有的啊~
上一篇
下一篇
Tags:
相关文章:

[reply=老七,2009-11-14 01:35 PM]真的嘛?[/reply]