gbookfun.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. <?php
  2. //发表留言
  3. function AddMemberGbook($add){
  4. global $empire,$dbtbpre;
  5. //验证码
  6. $keyvname='checkspacegbkey';
  7. ecmsCheckShowKey($keyvname,$add['key'],1);
  8. //用户
  9. $userid=intval($add['userid']);
  10. $ur=$empire->fetch1("select ".eReturnSelectMemberF('userid')." from ".eReturnMemberTable()." where ".egetmf('userid')."='$userid' limit 1");
  11. if(empty($ur['userid']))
  12. {
  13. printerror("NotUsername","",1);
  14. }
  15. //发表者
  16. $uid=(int)getcvar('mluserid');
  17. if($uid)
  18. {
  19. $uname=RepPostVar(getcvar('mlusername'));
  20. }
  21. else
  22. {
  23. $uid=0;
  24. $uname=trim($add['uname']);
  25. }
  26. //实名验证
  27. eCheckHaveTruenameCK('msps',0);
  28. $uname=dgdb_tosave($uname);
  29. $gbtext=dgdb_tosave($add['gbtext']);
  30. if(empty($uname)||!trim($gbtext))
  31. {
  32. printerror("EmptyMemberGbook","history.go(-1)",1);
  33. }
  34. $isprivate=intval($add['isprivate']);
  35. $addtime=date("Y-m-d H:i:s");
  36. $ip=egetip();
  37. $eipport=egetipport();
  38. $sql=$empire->query("insert into {$dbtbpre}enewsmembergbook(userid,isprivate,uid,uname,ip,addtime,gbtext,retext,eipport) values($userid,$isprivate,$uid,'$uname','$ip','$addtime','$gbtext','','$eipport');");
  39. ecmsEmptyShowKey($keyvname);//清空验证码
  40. if($sql)
  41. {
  42. printerror("AddMemberGbookSuccess",EcmsGetReturnUrl(),1);
  43. }
  44. else
  45. {
  46. printerror("DbError","history.go(-1)",1);
  47. }
  48. }
  49. //回复留言
  50. function ReMemberGbook($add){
  51. global $empire,$dbtbpre;
  52. $user_r=islogin();//是否登陆
  53. $gid=intval($add['gid']);
  54. if(!$gid)
  55. {
  56. printerror("EmptyReMemberGbook","history.go(-1)",1);
  57. }
  58. $retext=dgdb_tosave($add['retext']);
  59. $sql=$empire->query("update {$dbtbpre}enewsmembergbook set retext='$retext' where gid='$gid' and userid='$user_r[userid]'");
  60. if($sql)
  61. {
  62. printerror("ReMemberGbookSuccess",EcmsGetReturnUrl(),1);
  63. }
  64. else
  65. {
  66. printerror("DbError","history.go(-1)",1);
  67. }
  68. }
  69. //删除留言
  70. function DelMemberGbook($add){
  71. global $empire,$dbtbpre;
  72. $user_r=islogin();//是否登陆
  73. $gid=intval($add['gid']);
  74. if(!$gid)
  75. {
  76. printerror("NotDelMemberGbookid","history.go(-1)",1);
  77. }
  78. $sql=$empire->query("delete from {$dbtbpre}enewsmembergbook where gid='$gid' and userid='$user_r[userid]'");
  79. if($sql)
  80. {
  81. printerror("DelMemberGbookSuccess",EcmsGetReturnUrl(),1);
  82. }
  83. else
  84. {
  85. printerror("DbError","history.go(-1)",1);
  86. }
  87. }
  88. //批量删除留言
  89. function DelMemberGbook_All($add){
  90. global $empire,$dbtbpre;
  91. $user_r=islogin();//是否登陆
  92. $gid=$add['gid'];
  93. $count=count($gid);
  94. if(empty($count))
  95. {
  96. printerror("NotDelMemberGbookid","history.go(-1)",1);
  97. }
  98. for($i=0;$i<$count;$i++)
  99. {
  100. $addsql.="gid='".intval($gid[$i])."' or ";
  101. }
  102. $addsql=substr($addsql,0,strlen($addsql)-4);
  103. $sql=$empire->query("delete from {$dbtbpre}enewsmembergbook where (".$addsql.") and userid='$user_r[userid]'");
  104. if($sql)
  105. {
  106. printerror("DelMemberGbookSuccess",EcmsGetReturnUrl(),1);
  107. }
  108. else
  109. {
  110. printerror("DbError","history.go(-1)",1);
  111. }
  112. }
  113. ?>