wsq_join.inc.php 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: install.php 34718 2014-07-14 08:56:39Z nemohou $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!$_G['uid']) {
  12. showmessage('not_loggedin', NULL, array(), array('login' => 1));
  13. }
  14. require_once DISCUZ_ROOT.'./source/plugin/wechat/wechat.lib.class.php';
  15. $tid = intval($_GET['tid']);
  16. $siteid = $_G['wechat']['setting']['wsq_siteid'];
  17. if($_GET['action']=='full'){
  18. $uid = intval($_G['uid']);
  19. include 'include/sms_func.php';
  20. if($_GET['formhash'] != $_G['formhash']){
  21. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',lang('message','submit_invalid')):lang('message','submit_invalid');
  22. $result['full'] = 2;
  23. echo json_encode($result);
  24. exit;
  25. }
  26. //验证人数
  27. $applynumber = intval($_GET['applynumber']); //本次验证人数
  28. $applynum = DB::result_first("SELECT SUM(applynumber) FROM ".DB::table('xj_eventapply')." WHERE tid='$tid' and verify=1"); //已报名人数
  29. $applycountnum = DB::result_first("SELECT event_number FROM ".DB::table('xj_event')." WHERE tid='$tid'"); //活动总人数
  30. if($applycountnum>0){
  31. if($applynumber > ($applycountnum-$applynum)){
  32. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',lang('plugin/xj_event', 'baomrsym')):lang('plugin/xj_event', 'baomrsym');
  33. $result['full'] = 2;
  34. echo json_encode($result);
  35. exit;
  36. }
  37. }
  38. //验证是否重复报名
  39. $myapplynum = DB::result_first("SELECT count(*) FROM ".DB::table('xj_eventapply')." WHERE tid='$tid' and uid=$uid");
  40. if($myapplynum > 0){
  41. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',lang('plugin/xj_event', 'qinwcfbm')):lang('plugin/xj_event', 'qinwcfbm');
  42. $result['full'] = 2;
  43. echo json_encode($result);
  44. exit;
  45. }
  46. $member = DB::fetch_first("SELECT extcredits1,extcredits2,extcredits3,extcredits4,extcredits5,extcredits6,extcredits7,extcredits8 FROM ".DB::table('common_member_count')." WHERE uid = ".$_G['uid']);
  47. $items = DB::fetch_first("SELECT starttime,userfield,setting,use_extcredits_num,use_extcredits FROM ".DB::table('xj_event')." WHERE tid = '$tid'");
  48. $event_starttime = dgmdate($items['starttime'],'dt');
  49. //判断积分够不够
  50. if($member['extcredits'.$items['use_extcredits']]<$items['use_extcredits_num']){
  51. $result['showmessage'] = $_G['setting']['extcredits'][$items['use_extcredits']]['title'].lang('plugin/xj_event', 'bgwfcj');
  52. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',$result['showmessage']):$result['showmessage'];
  53. $result['full'] = 2;
  54. echo json_encode($result);
  55. exit;
  56. }
  57. $userfield = unserialize($items['userfield']);
  58. $setting = unserialize($items['setting']);
  59. //判断表单是否有空白。
  60. foreach($_POST as $key => $value) {
  61. if(empty($value) && $key != 'message') {
  62. $result['showmessage'] = lang('message','activity_exile_field');
  63. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',$result['showmessage']):$result['showmessage'];
  64. $result['full'] = 2;
  65. echo json_encode($result);
  66. exit;
  67. }
  68. }
  69. $dateline = $_G['timestamp'];
  70. $eid = intval($_GET['eid']);
  71. $uid = $_G['uid'];
  72. $realname = addslashes($_GET['realname']);
  73. $mobile = addslashes($_GET['mobile']);
  74. $qq = addslashes($_GET['qq']);
  75. $bmmessage = addslashes($_GET['message']);
  76. $ufielddata = array();
  77. $selectuserfield = unserialize($items['userfield']);
  78. $sysuserfield = unserialize($_G['setting']['activityfield']);
  79. foreach($sysuserfield as $key => $value){
  80. if(in_array($key,$selectuserfield)){
  81. if(is_array($_GET[$key])){
  82. $ufielddata[$key] = implode(',',$_GET[$key]);
  83. }elseif($key=='birthday'){
  84. $ufielddata[$key] = $_GET['birthyear'].'-'.$_GET['birthmonth'].'-'.$_GET['birthday'];
  85. }elseif($key=='residecity'){
  86. $ufielddata[$key] = $_GET['resideprovince'].$_GET['residecity'].$_GET['residedist'].$_GET['residecommunity'];
  87. }else{
  88. $ufielddata[$key] = $_GET[$key];
  89. }
  90. }
  91. }
  92. $ufielddata = serialize($ufielddata);
  93. $eventapply = array();
  94. $eventapply['tid'] = $tid;
  95. $eventapply['eid'] = $eid;
  96. $eventapply['uid'] = $uid;
  97. $eventapply['realname'] = $realname;
  98. $eventapply['mobile'] = $mobile;
  99. $eventapply['qq'] = $qq;
  100. $eventapply['bmmessage'] = $bmmessage;
  101. $eventapply['dateline'] = $dateline;
  102. $eventapply['applynumber'] = $applynumber;
  103. $eventapply['ufielddata'] = $ufielddata;
  104. $eventapply['seccode'] = random(8,1);
  105. $eventapply['session'] = intval($_GET['session']);
  106. DB::insert('xj_eventapply',$eventapply);
  107. $num = DB::result_first("SELECT count(*) FROM ".DB::table('xj_event_member_info')." WHERE uid = '$uid'");
  108. if($num<1){
  109. DB::query("INSERT INTO ".DB::table('xj_event_member_info')." (uid) VALUES ('$uid')");
  110. }
  111. //积分操作
  112. /*
  113. if($items['use_extcredits_num']>0){
  114. updatemembercount($_G['uid'],array($items['use_extcredits']=>-$items['use_extcredits_num']));
  115. }
  116. */
  117. //调用微信支付设置
  118. if(file_exists($xj_event_wxset = DISCUZ_ROOT.'./data/sysdata/cache_xj_event_wxset.php')) {
  119. @include $xj_event_wxset;
  120. }
  121. if($wxset['wsqonly']){
  122. $zffyurl = $_G['siteurl']."plugin.php?id=xj_event:wsq_pay&tid=$tid";
  123. }else{
  124. $zffyurl = $_G['siteurl']."plugin.php?id=xj_event:event_pay&tid=$tid";
  125. }
  126. if($setting['noverify']==1){
  127. if($setting['eventpay']){
  128. $result['showmessage'] = lang('plugin/xj_event', 'bmzltjcgxzzrzfym');
  129. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',$result['showmessage']):$result['showmessage'];
  130. $result['tourl'] = $zffyurl;
  131. $result['full'] = 2;
  132. echo json_encode($result);
  133. exit;
  134. }else{
  135. DB::query("update ".DB::table('xj_eventapply')." set verify=1 where tid='$tid' and uid=".$_G['uid']); //自动审核
  136. //短信操作
  137. if($setting['seccode'] == 1){
  138. $message = cutstr($event_title,30).lang('plugin/xj_event', 'hdbmcgrs').':'.$applynumber.lang('plugin/xj_event', 'renyanzhengma').':'.$eventapply['seccode'].' '.lang('plugin/xj_event', 'huodongshijian').':'.$event_starttime;
  139. xjsendsms(array($eventapply['mobile']),$message,lang('plugin/xj_event', 'maomyzmdx'));
  140. sendpm($eventapply['uid'],'',$message,$event_uid);
  141. }
  142. notification_add($event_uid, 'system', $_G['username'].' '.lang('plugin/xj_event', 'bmcjlnd').' <a href="forum.php?mod=viewthread&tid='.$tid.'" target="_blank">'.$event_title.'</a> '.lang('plugin/xj_event', 'hdxtyzdsh'),array(),0);
  143. $result['showmessage'] = lang('plugin/xj_event', 'gxnbmcg');
  144. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',$result['showmessage']):$result['showmessage'];
  145. $result['tourl'] = "http://wsq.discuz.com/?c=index&a=viewthread&f=wx&tid={$tid}&siteid={$siteid}&_bpage=1";
  146. $result['full'] = 2;
  147. echo json_encode($result);
  148. exit;
  149. }
  150. }else{
  151. if($setting['eventpay']){
  152. $result['showmessage'] = lang('plugin/xj_event', 'bmzltjcgxzzrzfym');
  153. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',$result['showmessage']):$result['showmessage'];
  154. $result['tourl'] = $zffyurl;
  155. $result['full'] = 2;
  156. echo json_encode($result);
  157. exit;
  158. }
  159. notification_add($event_uid, 'system', 'activity_notice', array(
  160. 'tid' => $tid,
  161. 'subject' => $event_title,
  162. ));
  163. $result['showmessage'] = lang('plugin/xj_event', 'bmxxtjcgqddsh');
  164. $result['showmessage'] = $_G['charset']=='gbk'?iconv('GBK','UTF-8',$result['showmessage']):$result['showmessage'];
  165. $result['tourl'] = "http://wsq.discuz.com/?c=index&a=viewthread&f=wx&tid={$tid}&siteid={$siteid}&_bpage=1";
  166. $result['full'] = 2;
  167. echo json_encode($result);
  168. exit;
  169. }
  170. }elseif($_GET['action'] == 'cancel'){
  171. $items = DB::fetch_first("SELECT * FROM ".DB::table('xj_event')." A,".DB::table('forum_thread')." B WHERE A.tid=B.tid AND A.tid = '$tid'");
  172. if($items['activityexpiration']>$timestamp){
  173. $count = DB::result_first("SELECT count(*) FROM ".DB::table('xj_eventapply')." WHERE tid = '$tid' and uid = ".$_G['uid']);
  174. if($count < 1){
  175. showmessage('Access Denied');
  176. }
  177. DB::query("DELETE FROM ".DB::table('xj_eventapply')." WHERE tid = '$tid' and uid = ".$_G['uid']);
  178. //积分操作
  179. /*
  180. if($items['use_extcredits_num']>0){
  181. updatemembercount($_G['uid'],array($items['use_extcredits']=>$items['use_extcredits_num']));
  182. }
  183. */
  184. //notification_add($items['authorid'], 'system',$_G['username'].' 取消了活动 <a href="forum.php?mod=viewthread&tid='.$tid.'" target="_blank">'.$items['subject'].'</a> 报名',array(),0);
  185. notification_add($items['authorid'], 'system', 'activity_cancel', array(
  186. 'tid' => $tid,
  187. 'subject' => $items['subject'],
  188. 'reason' => $message
  189. ));
  190. showmessage(lang('plugin/xj_event', 'cgqxbm'),"http://wsq.discuz.com/?c=index&a=viewthread&f=wx&tid={$tid}&siteid={$siteid}&_bpage=1");
  191. }else{
  192. showmessage('Access Denied');
  193. }
  194. }
  195. $items = DB::fetch_first("SELECT * FROM ".DB::table('xj_event')." WHERE tid = '$tid'");
  196. $thread = DB::fetch_first("SELECT subject FROM ".DB::table('forum_thread')." WHERE tid = '$tid'");
  197. $setting = unserialize($items['setting']);
  198. $userfield = unserialize($items['userfield']);
  199. $selectuserfield = unserialize($items['userfield']);
  200. if($selectuserfield) {
  201. if($selectuserfield) {
  202. $htmls = $settings = array();
  203. require_once libfile('function/profile');
  204. foreach($selectuserfield as $fieldid) {
  205. if(empty($ufielddata['userfield'])) {
  206. $memberprofile = C::t('common_member_profile')->fetch($_G['uid']);
  207. foreach($selectuserfield as $val) {
  208. $ufielddata['userfield'][$val] = $memberprofile[$val];
  209. }
  210. unset($memberprofile);
  211. }
  212. $html = profile_setting($fieldid, $ufielddata['userfield'], false, true);
  213. if($html) {
  214. $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
  215. $htmls[$fieldid] = $html;
  216. }
  217. }
  218. }
  219. } else {
  220. $selectuserfield = '';
  221. }
  222. $applynumber = array();
  223. for($i=1;$i<=$items['event_number_max'];$i++){
  224. $applynumber[] = $i;
  225. }
  226. ?>
  227. <script type="text/javascript" src="http://wsq.discuz.com/cdn/discuz/js/openjs.js"></script>
  228. <script>
  229. var menu = new Array();
  230. WSQ.initBtmBar(menu);
  231. WSQ.showBtmBar();
  232. WSQ.initPlugin({name:'<?php echo $thread['subject'].lang('plugin/xj_event', 'baomin'); ?>'});
  233. var initWx = {
  234. 'img': '<?php echo $_G['siteurl']; ?>/static/image/common/logo.png',
  235. 'desc': '<?php echo $_G['bbsname'].lang('plugin/xj_event', 'huodzx'); ?>',
  236. 'title': '<?php echo $thread['subject']; ?>',
  237. 'pluginid':'xj_event:wsq_join_test',
  238. 'param': 'a=1&b=2'
  239. };
  240. WSQ.initShareWx(initWx);
  241. </script>
  242. <style type="text/css">
  243. #container {margin:5px;}
  244. body {height:100%;}
  245. .input1{padding:14px; line-height:14px; width:100%;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius:4px; border:1px solid #d8d8d8;}
  246. select{height:42px;-webkit-appearance:none;appearance:none;border:none;font-size:14px;padding:0px 10px;display:block;width:100%;-webkit-box-sizing:border-box;box-sizing:border-box;background-color: #FFFFFF;color:#aaa;border-radius:4px;}
  247. .selectdiv{margin-top:0px;outline:none;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius:4px; border:1px solid #d8d8d8;position:relative;}
  248. .checkbox {
  249. width: 19px;
  250. height: 25px;
  251. padding: 0 5px 0 0;
  252. background: url(checkbox.png) no-repeat;
  253. display: block;
  254. float: left;
  255. }
  256. label{float:left; font-size:14px; line-height:30px;}
  257. </style>
  258. <script type="text/javascript" src="source/plugin/xj_event/js/jquery.js"></script>
  259. <script type="text/javascript">
  260. $(function(){
  261. $("#testbtn").click(function(){
  262. $.ajax({
  263. type: 'POST',
  264. url: 'plugin.php?id=xj_event:wsq_join&tid=<?php echo $tid; ?>&action=full',
  265. //data: {level:'fff', roomnumber:'bbb'},
  266. data:$('#bmform').serialize(),
  267. dataType: 'json',
  268. cache: false,
  269. error: function(){
  270. alert('error');
  271. return false;
  272. },
  273. success:function(json){
  274. if(json.full == 2){
  275. alert(json.showmessage);
  276. if(json.tourl != null){
  277. top.location.href=json.tourl;
  278. }
  279. return false;
  280. }
  281. if(json.full == 1){
  282. alert('<?php echo lang('plugin/xj_event','gxnbmcg'); ?>');
  283. window.location.href="http://wsq.discuz.com/?c=index&a=viewthread&f=wx&tid=<?php echo $tid; ?>&siteid=<?php echo $siteid; ?>&_bpage=1";
  284. return true;
  285. }else{
  286. alert('error');
  287. return false;
  288. }
  289. }
  290. });
  291. });
  292. });
  293. function showdistrict(container, elems, totallevel, changelevel, containertype) {
  294. var pid = changelevel >= 1 && elems[0] && $("#"+elems[0]) ? $("#"+elems[0]).find('option:selected').attr('did') : 0;
  295. var cid = changelevel >= 2 && elems[1] && $("#"+elems[1]) ? $("#"+elems[1]).find('option:selected').attr('did') : 0;
  296. var did = changelevel >= 3 && elems[2] && $("#"+elems[2]) ? $("#"+elems[2]).find('option:selected').attr('did') : 0;
  297. var coid = changelevel >= 4 && elems[3] && $("#"+elems[3]) ? $("#"+elems[3]).find('option:selected').attr('did') : 0;
  298. var url = "home.php?mod=misc&ac=ajax&op=district&container="+container+"&containertype="+containertype
  299. +"&province="+elems[0]+"&city="+elems[1]+"&district="+elems[2]+"&community="+elems[3]
  300. +"&pid="+pid + "&cid="+cid+"&did="+did+"&coid="+coid+'&level='+totallevel+'&handlekey='+container+'&inajax=1'+(!changelevel ? '&showdefault=1' : '');
  301. ajaxget(url, container, '');
  302. }
  303. function ajaxget(aurl,acontainer,c){
  304. $.ajax({
  305. type: 'GET',
  306. url: aurl,
  307. dataType: 'xml',
  308. cache: false,
  309. error: function(){
  310. alert('error');
  311. return false;
  312. },
  313. success:function(xml){
  314. $("#"+acontainer).html($(xml).find('root').text());
  315. }
  316. });
  317. }
  318. </script>
  319. </head>
  320. <body>
  321. <div>
  322. <div style="height:20px;">
  323. <?php echo $setting['session']; ?>
  324. </div>
  325. <form name="bmform" id="bmform">
  326. <input type="hidden" name="formhash" value="<?php echo $_G['formhash'];?>" />
  327. <input type="hidden" name="eid" value="<?php echo $items['eid'];?>" />
  328. <?php if($setting['session']){ ?>
  329. <div style="padding:10px 30px;">
  330. <div class="selectdiv">
  331. <select name="session">
  332. <option><?php echo lang('plugin/xj_event','huodongcc'); ?></option>
  333. <?php foreach($setting['session'] as $key=>$value){ ?>
  334. <option value="<?php echo $key; ?>"><?php echo $value; ?></option>
  335. <?php } ?>
  336. </select>
  337. </div>
  338. </div>
  339. <?php }?>
  340. <?php
  341. if(!empty($selectuserfield)){
  342. foreach($selectuserfield as $fieldid){
  343. if($settings[$fieldid]['available']){
  344. if($settings[$fieldid]['formtype'] != 'file'){
  345. $htmls[$fieldid] = str_replace('class="px"','class="input1" placeholder="'.$settings[$fieldid]['title'].'"',$htmls[$fieldid]);
  346. $htmls[$fieldid] = preg_replace("/<div.+<\/div>/is", "", $htmls[$fieldid]);
  347. if(strpos($htmls[$fieldid],'select')>0){
  348. $htmls[$fieldid] = str_replace('tabindex="1">','tabindex="1"><option>'.$settings[$fieldid]['title'].'</option>',$htmls[$fieldid]);
  349. echo '<div style="padding:10px 30px;">'.$htmls[$fieldid].'</div>';
  350. }elseif(strpos($htmls[$fieldid],'checkbox')>0){
  351. //$htmls[$fieldid] = str_replace('type="checkbox"','type="checkbox" class="checkbox"',$htmls[$fieldid]);
  352. echo '<div style="padding:10px 30px;">'.$htmls[$fieldid].'<div style="clear:both;"></div></div>';
  353. }else{
  354. echo '<div style="padding:10px 30px;">'.$htmls[$fieldid].'</div>';
  355. }
  356. }else{
  357. }
  358. }
  359. }
  360. }
  361. ?>
  362. <div style="padding:10px 30px;">
  363. <div class="selectdiv">
  364. <select name="applynumber">
  365. <option value=""><?php echo lang('plugin/xj_event','baomingrs'); ?></option>
  366. <?php foreach($applynumber as $key=>$value){ ?>
  367. <option value="<?php echo $value; ?>"><?php echo $value; ?></option>
  368. <?php } ?>
  369. </select>
  370. </div>
  371. </div>
  372. <div style="padding:10px 30px;">
  373. <input name="message" type="text" placeholder="<?php echo lang('plugin/xj_event','liuyan'); ?>" class="input1">
  374. </div>
  375. </form>
  376. <a href="javascript:" id="testbtn" style="display:block; height:44px; line-height:44px; text-align:center; background-color:#ff4a00; color:#FFF;-moz-border-radius: 4px; -webkit-border-radius: 4px; border-radius:4px; margin:10px 30px; font-size:16px; font-weight:bold;"><?php echo lang('plugin/xj_event','baomin'); ?></a>
  377. </div>
  378. </body>
  379. </html>