event_vote.inc.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * [³¬¼¶»î¶¯(xj_event.{modulename})] (C)2012-2099 Powered by åÐÒ£¹¤×÷ÊÒ.
  4. * Version: 1.0
  5. * Date: 2012-9-15 10:27
  6. */
  7. if(!defined('IN_DISCUZ')) {
  8. exit('Access Denied');
  9. }
  10. $tid = intval($_GET["tid"]);
  11. $eid = intval($_GET["eid"]);
  12. $uid = $_G["uid"];
  13. $ip = $_G["clientip"];
  14. $nowtime = $_G["timestamp"];
  15. $eventinfo = DB::fetch_first("SELECT tid,setting FROM ".DB::table('xj_event')." WHERE eid='$eid'");
  16. $setting = unserialize($eventinfo['setting']);
  17. $votestarttime = dgmdate($setting['vote']['votestarttime'],'dt');
  18. $voteendtime = dgmdate($setting['vote']['voteendtime'],'dt');
  19. $votecheckhour = $setting['vote']['votecheckhour'];
  20. $votechecknumber = $setting['vote']['votechecknumber'];
  21. $votechecktime = $_G['timestamp']-3600*$votecheckhour;
  22. if($setting[vote][openvote]!=1){
  23. showmessage(lang('plugin/xj_event', 'bhdwkqtp'));
  24. }else{
  25. if($nowtime<$setting['vote']['votestarttime']){
  26. showmessage(lang('plugin/xj_event', 'tphwks'));
  27. }
  28. if($nowtime>$setting['vote']['voteendtime']){
  29. showmessage(lang('plugin/xj_event', 'tpyjjs'));
  30. }
  31. }
  32. if($setting['vote']['ipcheck'] == 1){
  33. $votes = DB::result_first("SELECT COUNT(*) FROM ".DB::table('xj_event_vote_log')." WHERE tid='$tid' and ip='$ip' AND votetime>$votechecktime");
  34. if($votes>=$votechecknumber){
  35. showmessage(lang('plugin/xj_event', 'mei').$votecheckhour.lang('plugin/xj_event', 'xsznt').$votechecknumber.lang('plugin/xj_event', 'pqshztp'));
  36. }
  37. }
  38. if($setting['vote']['usercheck'] == 1){
  39. if($uid==0){
  40. showmessage(lang('plugin/xj_event', 'ykwftpqdl'));
  41. }
  42. $votes = DB::result_first("SELECT COUNT(*) FROM ".DB::table('xj_event_vote_log')." WHERE tid='$tid' and uid='$uid' AND votetime>$votechecktime");
  43. if($votes>=$votechecknumber){
  44. showmessage(lang('plugin/xj_event', 'mei').$votecheckhour.lang('plugin/xj_event', 'xsznt').$votechecknumber.lang('plugin/xj_event', 'pqshztp'));
  45. }
  46. }
  47. if($_GET['formhash'] != $_G['formhash']){
  48. showmessage('submit_invalid');
  49. }
  50. DB::query("INSERT INTO ".DB::table('xj_event_vote_log')." (eid,tid,uid,ip,votetime) VALUES ($eid,$tid,$uid,'$ip',$nowtime)");
  51. DB::query("UPDATE ".DB::table('xj_eventthread')." set votes = votes+1 WHERE tid = '$tid'");
  52. $items = DB::fetch_first("SELECT votes FROM ".DB::table('xj_eventthread')." WHERE tid='$tid'");
  53. showmessage(lang('plugin/xj_event', 'dqps').' <strong id="recommentc" class="xi1 xs2">'.$items['votes'].'</strong><br />'.lang('plugin/xj_event', 'tpcg'));
  54. ?>