本文记述为dedecms增加并完善留言邮件提醒、留言后台管理等相关功能。
1、增加邮箱格式验证并提示;
找到dedecms留言页“guestbook.php”文件,在需要进行验证的位置处加入以下代码(可按需修改):
| 1 2 3 4 5 6 7 8
| //验证邮箱if ($email !=""){ if(!eregi("^[a-z0-9_\-]+(\.[_a-z0-9\-]+)*@([_a-z0-9\-]+\.)+([a-z]{2}'aero'arpa'biz'com'coop'edu'gov'info'int'jobs'mil'museum'name'nato'net'org'pro'travel)$",$email)) { ShowMsg("错误: E-Mail 地址有误!","-1"); exit(); } }
|
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
2、留言成功发送邮件到指定邮箱地址:
找到dedecms留言页“guestbook.php”文件,在需要进行验证的位置处加入以下代码,引用时注意“$msg”变量的赋值变化,可按需更改:
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
| //发送EMAILif($needCheck==1) { require_once(DEDEINC."/oxwindow.class.php"); $mailbody = ''; $basehost = preg_replace("#http:\/\/#", '', $cfg_basehost); $mailtitle = "您的网站' $basehost '上有新留言"; $mailbody .= "姓名:$uname \r\n"; $mailbody .= "标题:$title \r\n"; $mailbody .= "内容:$msg \r\n"; $mailbody .= "E-mail:$email \r\n"; $mailbody .= "Powered by http://www.bmqy.net !"; $headers = "From: ".$cfg_adminemail."\r\nReply-To: ".$cfg_adminemail; $email='bmqy@qq.com';//改为要接收邮件的邮箱 if($cfg_sendmail_bysmtp == 'Y' && !empty($cfg_smtp_server)) { $mailtype = 'TXT'; require_once(DEDEINC.'/mail.class.php'); $smtp = new smtp($cfg_smtp_server,$cfg_smtp_port,true,$cfg_smtp_usermail,$cfg_smtp_password); $smtp->debug = false; $smtp->sendmail($email,$cfg_webname,$cfg_smtp_usermail, $mailtitle, $mailbody, $mailtype); } else { @mail($email, $mailtitle, $mailbody, $headers); } } //发送EMAIL结束
|
| ---------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
3、后台增加留言管理功能:
-
首先下载附件
-
解压后得到2个文件guestbook.php和guestbook.htm
-
将guestbook.php文件 复制的 dede(后台管理目录)目录下
-
将guestbook.htm 文件 复制的dede/templets 目录下
-
进入织梦后台,模块->管理模块->留言簿模块->修改
-
找到安装程序,将里面的link链接改为guestbook.php
-
点击卸载留言簿模块,不要刷新,再安装一次该模块
该模块详细安装步骤步骤可参考: 增加dedecms后台留言管理功能。
再此附上本人修改过的版本,改善了查看留言页的样式排版,
点此下载dedecms留言管理模块.zip 亦可自行按需更改。
附:查看留言页效果图: