index.php 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. require("../../class/connect.php");
  3. $id=(int)$_GET['id'];
  4. $classid=(int)$_GET['classid'];
  5. if($id&&$classid)
  6. {
  7. include("../../class/db_sql.php");
  8. include("../../data/dbcache/class.php");
  9. $link=db_connect();
  10. $empire=new mysqlquery();
  11. $doajax=(int)$_GET['doajax'];
  12. $editor=1;
  13. $mid=$class_r[$classid]['modid'];
  14. if(empty($class_r[$classid][tbname]))
  15. {
  16. $doajax==1?ajax_printerror('','','ErrorUrl',1):printerror('ErrorUrl','',1);
  17. }
  18. //是否启用
  19. if($public_r['diggcmids'])
  20. {
  21. if(strstr($public_r['diggcmids'],','.$mid.','))
  22. {
  23. $doajax==1?ajax_printerror('','','ErrorUrl',1):printerror('ErrorUrl','',1);
  24. }
  25. }
  26. $checkid=$classid.'n'.$id;
  27. $checktime=time()+30*24*3600;
  28. //连续提交
  29. if($public_r['digglevel']!=0)//cookie
  30. {
  31. if(getcvar('lastdiggid')==$checkid)
  32. {
  33. $doajax==1?ajax_printerror('','','ReDigg',1):printerror('ReDigg','',1);
  34. }
  35. }
  36. //字段
  37. $fnum=$empire->gettotal("select count(*) as total from {$dbtbpre}enewsf where tbname='".$class_r[$classid][tbname]."' and (f='diggtop' or f='diggdown')");
  38. if(empty($fnum))
  39. {
  40. $doajax==1?ajax_printerror('','','ErrorUrl',1):printerror('ErrorUrl','',1);
  41. }
  42. //验证信息
  43. $num=$empire->gettotal("select count(*) as total from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id' and classid='$classid' limit 1");
  44. if(empty($num))
  45. {
  46. $doajax==1?ajax_printerror('','','ErrorUrl',1):printerror('ErrorUrl','',1);
  47. }
  48. //验证IP
  49. $ip='';
  50. if($public_r['digglevel']==2)
  51. {
  52. $ip=egetip();
  53. }
  54. //验证会员
  55. if($public_r['digglevel']==3)
  56. {
  57. include("../../member/class/user.php");
  58. $cklgr=qCheckLoginAuthstr();
  59. if(!$cklgr['islogin'])
  60. {
  61. $doajax==1?ajax_printerror('','','NotLogin',1):printerror('NotLogin','',1);
  62. }
  63. $ip=(int)getcvar('mluserid');
  64. }
  65. $ip=str_replace(',','',$ip);
  66. $ip=RepPostVar($ip);
  67. //重复验证
  68. if($public_r['digglevel']>1)
  69. {
  70. $ipr=$empire->fetch1("select classid,ips from {$dbtbpre}enewsdiggips where id='$id' and classid='$classid' limit 1");
  71. if(strstr($ipr['ips'],','.$ip.','))
  72. {
  73. $doajax==1?ajax_printerror('','','ReDigg',1):printerror('ReDigg','',1);
  74. }
  75. else
  76. {
  77. if(empty($ipr['classid']))
  78. {
  79. $newips=','.$ip.',';
  80. $usql=$empire->query("insert into {$dbtbpre}enewsdiggips(id,classid,ips) values('$id','$classid','$newips');");
  81. }
  82. else
  83. {
  84. $newips=$ipr['ips']?$ipr['ips'].$ip.',':','.$ip.',';
  85. $usql=$empire->query("update {$dbtbpre}enewsdiggips set ips='$newips' where id='$id' and classid='$classid' limit 1");
  86. }
  87. }
  88. }
  89. $dotop=(int)$_GET['dotop'];
  90. $f='diggtop';
  91. $n='+1';
  92. if($dotop)
  93. {
  94. $mess='DoDiggGSuccess';
  95. }
  96. else
  97. {
  98. if($fnum==2)
  99. {
  100. $f='diggdown';
  101. }
  102. else
  103. {
  104. $n='-1';
  105. }
  106. $mess='DoDiggBSuccess';
  107. }
  108. $sql=$empire->query("update {$dbtbpre}ecms_".$class_r[$classid][tbname]." set ".$f."=".$f.$n." where id='$id'");
  109. if($sql)
  110. {
  111. if($public_r['digglevel']!=0)
  112. {
  113. esetcookie('lastdiggid',$checkid,$checktime); //最后发布
  114. }
  115. if($doajax==1)
  116. {
  117. $nr=$empire->fetch1("select ".$f." from {$dbtbpre}ecms_".$class_r[$classid][tbname]." where id='$id'");
  118. ajax_printerror($nr[$f],RepPostVar($_GET['ajaxarea']),$mess,1);
  119. }
  120. else
  121. {
  122. printerror($mess,EcmsGetReturnUrl(),1);
  123. }
  124. }
  125. else
  126. {
  127. $doajax==1?ajax_printerror('','','DbError',1):printerror('DbError','',1);
  128. }
  129. }
  130. ?>