gbookfun.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. //发表留言
  3. function AddGbook($add){
  4. global $empire,$dbtbpre,$level_r,$public_r;
  5. //验证本时间允许操作
  6. eCheckTimeCloseDo('gbook');
  7. //验证IP
  8. eCheckAccessDoIp('gbook');
  9. CheckCanPostUrl();//验证来源
  10. if($add['bid'])
  11. {
  12. $bid=(int)$add['bid'];
  13. }
  14. else
  15. {
  16. $bid=(int)getcvar('gbookbid');
  17. }
  18. $name=dgdb_tosave(trim($add[name]));
  19. $email=dgdb_tosave($add[email]);
  20. $mycall=dgdb_tosave($add[mycall]);
  21. $lytext=dgdb_tosave($add[lytext]);
  22. if(empty($bid)||empty($name)||empty($email)||!trim($lytext))
  23. {
  24. printerror("EmptyGbookname","history.go(-1)",1);
  25. }
  26. if(!chemail($email))
  27. {
  28. printerror("EmailFail","history.go(-1)",1);
  29. }
  30. //验证码
  31. $keyvname='checkgbookkey';
  32. if($public_r['gbkey_ok'])
  33. {
  34. ecmsCheckShowKey($keyvname,$add['key'],1);
  35. }
  36. $lasttime=getcvar('lastgbooktime');
  37. if($lasttime)
  38. {
  39. if(time()-$lasttime<$public_r['regbooktime'])
  40. {
  41. printerror("GbOutTime","",1);
  42. }
  43. }
  44. //版面是否存在
  45. $br=$empire->fetch1("select bid,checked,groupid from {$dbtbpre}enewsgbookclass where bid='$bid';");
  46. if(empty($br[bid]))
  47. {
  48. printerror("EmptyGbook","history.go(-1)",1);
  49. }
  50. //权限
  51. $user=array();
  52. if($br['groupid'])
  53. {
  54. $user=islogin();
  55. if($level_r[$br[groupid]][level]>$level_r[$user[groupid]][level])
  56. {
  57. printerror("HaveNotEnLevel","history.go(-1)",1);
  58. }
  59. }
  60. //实名验证
  61. eCheckHaveTruename('gb',$user['userid'],$user['username'],$user['isern'],$user['checked'],0);
  62. $lytime=date("Y-m-d H:i:s");
  63. $ip=egetip();
  64. $eipport=egetipport();
  65. $userid=(int)getcvar('mluserid');
  66. $username=RepPostVar(getcvar('mlusername'));
  67. $sql=$empire->query("insert into {$dbtbpre}enewsgbook(name,email,`mycall`,lytime,lytext,retext,bid,ip,checked,userid,username,eipport) values('$name','$email','$mycall','$lytime','$lytext','','$bid','$ip','$br[checked]','$userid','$username','$eipport');");
  68. ecmsEmptyShowKey($keyvname);//清空验证码
  69. if($sql)
  70. {
  71. esetcookie("lastgbooktime",time(),time()+3600*24);//设置最后发表时间
  72. $reurl=DoingReturnUrl("../tool/gbook/?bid=$bid",$add['ecmsfrom']);
  73. printerror("AddGbookSuccess",$reurl,1);
  74. }
  75. else
  76. {printerror("DbError","history.go(-1)",1);}
  77. }
  78. ?>