event_sms.inc.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. include DISCUZ_ROOT . './source/plugin/xj_event/include/sms_func.php';
  11. include DISCUZ_ROOT . './source/plugin/xj_event/include/func.php';
  12. $tid = intval($_GET['tid']);
  13. //权限限制
  14. $thread = DB::fetch_first("SELECT authorid,setting FROM ".DB::table('forum_thread')." A,".DB::table('xj_event')." B WHERE A.tid='$tid' and A.tid = B.tid");
  15. $setting = unserialize($thread['setting']);
  16. //判断是不是管理团队
  17. $event_admin = false;
  18. if(in_array($_G['username'],$setting['event_admin'])){
  19. $event_admin = true;
  20. }
  21. if($_G['groupid']>1 && $_G['uid']!=$thread['authorid'] && !$event_admin){
  22. showmessage('quickclear_noperm');
  23. }
  24. //获取剩余积分
  25. if($_G['cache']['plugin']['xj_event']['smscredit']){
  26. $smscredit = $_G['cache']['plugin']['xj_event']['smscredit'];
  27. $mysmscredit = DB::result_first("SELECT extcredits$smscredit FROM ".DB::table('common_member_count')." WHERE uid = ".$_G['uid']);
  28. }
  29. if($_GET['action']=='send'){
  30. if(!submitcheck('smssubmit')){
  31. showmessage('submit_invalid');
  32. }
  33. $item = DB::fetch_first("SELECT subject FROM ".DB::table('forum_thread')." WHERE tid = '$tid'");
  34. $event = DB::fetch_first("SELECT * FROM ".DB::table('xj_event')." WHERE tid = '$tid'");
  35. $event_title = $item['subject'];
  36. $event_time = dgmdate($event['starttime'],'dt');
  37. $mobile = array();
  38. if($_GET['alluser'] == 0 && $_GET['applyid']){
  39. $applyids = implode(',',$_GET['applyid']);
  40. $query = DB::query("SELECT mobile FROM ".DB::table('xj_eventapply')." WHERE tid = $tid AND applyid in($applyids)");
  41. while($value = DB::fetch($query)){
  42. $mobile[] = $value['mobile'];
  43. }
  44. }elseif($_GET['alluser'] == 1){
  45. $query = DB::query("SELECT mobile FROM ".DB::table('xj_eventapply')." WHERE tid='$tid'");
  46. while($value = DB::fetch($query)){
  47. $mobile[] = $value['mobile'];
  48. }
  49. }elseif($_GET['alluser'] == 2){
  50. $query = DB::query("SELECT mobile FROM ".DB::table('xj_eventapply')." WHERE tid='$tid' AND verify=1");
  51. while($value = DB::fetch($query)){
  52. $mobile[] = $value['mobile'];
  53. }
  54. }elseif($_GET['alluser'] == 3){
  55. $query = DB::query("SELECT mobile FROM ".DB::table('xj_eventapply')." WHERE tid='$tid' AND verify=0");
  56. while($value = DB::fetch($query)){
  57. $mobile[] = $value['mobile'];
  58. }
  59. }
  60. if($_G['cache']['plugin']['xj_event']['smscredit']){ //设置了消耗积分才操作
  61. $sendcount = count($mobile);
  62. if($mysmscredit<$sendcount){
  63. $onerror = lang('plugin/xj_event', 'ningde').$_G['setting']['extcredits'][$smscredit]['title'].lang('plugin/xj_event', 'bzdxfssbqcz');
  64. }else{
  65. DB::query("UPDATE ".DB::table('common_member_count')." SET extcredits".$smscredit." = extcredits".$smscredit." - ".$sendcount." WHERE uid=".$_G['uid']);
  66. }
  67. }
  68. //如果前面没有错误就开始群发
  69. if(!$onerror){
  70. $sendtime = '';
  71. if($_GET['sendtime']){
  72. $sendtime = $_GET['sendtime'].':00';
  73. }
  74. $mobile = implode(',',$mobile);
  75. //$sendstate = xjsendsms($mobile,$message_content,lang('plugin/xj_event', 'huodongqunfa'),$sendtime);
  76. if($_GET['smstemplate']=='SMS_2195001'){
  77. $sendstate = sendsms_notice($mobile,$event_title,$event_time);
  78. }elseif($_GET['smstemplate']=='SMS_8971161'){
  79. $editor = $_GET['editor'];
  80. $editorphone = $_GET['editorphone'];
  81. $sendstate = sendsms_notice_hnmm($mobile,$event_title,$event_time,$event['event_address'],$editor,$editorphone);
  82. }
  83. if($sendstate == 'ok'){
  84. $onerror = lang('plugin/xj_event', 'chenggong');
  85. }else{
  86. $onerror = lang('plugin/xj_event', 'fasongshibai');
  87. }
  88. }
  89. }
  90. $listcount = DB::result_first("SELECT COUNT(*) FROM ".DB::table('xj_eventapply')." WHERE tid='$tid'");
  91. $perpage = 10; //每页数
  92. $page = $_GET['page']?$_GET['page']:1;
  93. if(@ceil($listcount/$perpage) < $page) {
  94. $page = 1;
  95. }
  96. $start_limit = ($page - 1) * $perpage;
  97. $multipage = mymulti($listcount,$perpage,$page,"plugin.php?id=xj_event:event_sms&tid=$tid",0,10,false,true,false,'sms_display');
  98. $query = DB::query("SELECT * FROM ".DB::table('xj_eventapply')." A,".DB::table('common_member')." B WHERE A.uid = B.uid and A.tid = '$tid' ORDER BY A.verify DESC,A.dateline LIMIT $start_limit,$perpage");
  99. $accesslist = array();
  100. while($value = DB::fetch($query)){
  101. $value['dateline'] = date('Y-m-d H:i:s',$value['dateline']);
  102. $value['sharenum'] = DB::result_first("SELECT count(*) FROM ".DB::table('xj_eventthread')." A,".DB::table('forum_thread')." B WHERE A.tid=B.tid and A.eid=".$value['eid']." and B.authorid=".$value['uid']);
  103. $accesslist[] = $value;
  104. }
  105. include template('xj_event:event_sms');
  106. ?>