event_join.inc.php 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  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. if (strpos($_SERVER["HTTP_USER_AGENT"], 'Appbyme') > 0) {
  11. $Appbyme = true;
  12. }
  13. if (strpos($_SERVER["HTTP_USER_AGENT"], 'MAGAPP') > 0) {
  14. $magapp = true;
  15. }
  16. if (strpos($_SERVER['HTTP_USER_AGENT'], 'QianFan') > 0) {
  17. $QianFan = true;
  18. }
  19. $tid = intval($_GET['tid']);
  20. $items = DB::fetch(DB::query("SELECT A.*,B.authorid,B.subject FROM " . DB::table('xj_event') . " A LEFT JOIN " . DB::table('forum_thread') . " B ON A.tid = B.tid WHERE A.tid = '$tid'"));
  21. $setting = unserialize($items['setting']);
  22. if ($setting['onlyappbymejoin']) { //仅APP报名
  23. if (!$Appbyme && !$magapp) {
  24. //showmessage(lang('plugin/xj_event', 'qxzsjappkhdbm'), $_G['cache']['plugin']['xj_event']['appurl']);
  25. dheader('location: '.$_G['cache']['plugin']['xj_event']['appurl']);
  26. }
  27. }
  28. if ($Appbyme && !$_G['uid']) {
  29. //安米登录
  30. exit('<script language="javascript" src="source/plugin/xj_event/js/appbyme.js"></script><script>connectAppbymeJavascriptBridge(function(bridge){
  31. AppbymeJavascriptBridge.login(function(data){
  32. top.location.href="' . $_G['siteurl'] . 'plugin.php?id=xj_event:event_join&tid=' . $_GET['tid'] . '";
  33. });
  34. });
  35. </script>');
  36. }
  37. if ($magapp && !$_G['uid']) {
  38. //马甲登录
  39. exit('<script src="source/plugin/xj_event/js/magjs-x.js"></script>
  40. <script>
  41. mag.toLogin(function(){
  42. var url = "' . $_G['siteurl'] . 'plugin.php?id=xj_event:event_join&tid=' . $_GET['tid'] . '",
  43. params = {
  44. name: "zz"
  45. };
  46. mag.newWin(url, params);
  47. //window.location.href="' . 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '";
  48. });
  49. </script>
  50. ');
  51. }
  52. if ($QianFan && !$_G['uid']) {
  53. //千帆登录
  54. exit('<script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script><script> function QFH5ready(){QFH5.jumpLogin(function(state,data){
  55. if(state==1){
  56. QFH5.refresh(1);
  57. }else{
  58. //登陆失败
  59. alert(data.error);//data.error: string
  60. }
  61. });
  62. }
  63. </script>
  64. ');
  65. }
  66. //调用核心类
  67. include 'source/plugin/xj_event/include/core.class.php';
  68. $eventcore = new xj_eventcore();
  69. if ($_COOKIE['xj_event_fromuid']) {
  70. $fromuid = intval($_COOKIE['xj_event_fromuid']);
  71. }
  72. $tid = intval($_GET['tid']);
  73. $items = DB::fetch(DB::query("SELECT A.*,B.authorid,B.subject FROM " . DB::table('xj_event') . " A LEFT JOIN " . DB::table('forum_thread') . " B ON A.tid = B.tid WHERE A.tid = '$tid'"));
  74. $setting = unserialize($items['setting']);
  75. if ($setting['onlyappbymejoin']) {
  76. if (!$Appbyme && !$magapp) {
  77. showmessage(lang('plugin/xj_event', 'qxzsjappkhdbm'), $_G['cache']['plugin']['xj_event']['appurl']);
  78. }
  79. }
  80. if ($setting['onlyvip']) {
  81. $vipgroup = unserialize($_G['cache']['plugin']['xj_event']['vipgroupid']);
  82. if (!in_array($_G['groupid'], $vipgroup)) {
  83. showmessage(lang('plugin/xj_event', 'benhuodongjingxian') . ($_G['cache']['plugin']['xj_card']['cardname'] ? $_G['cache']['plugin']['xj_card']['cardname'] : 'VIP') . lang('plugin/xj_event', 'yonghubaomin'), 'plugin.php?id=xj_card');
  84. exit;
  85. }
  86. }
  87. if ($setting['nodaibaoming']) {
  88. if ($_GET['action'] == 'cannel') {
  89. dheader('location: plugin.php?id=xj_event:event_join_single&tid=' . $tid . '&action=cannel&formhash=' . $_GET['formhash']);
  90. } else {
  91. dheader('location: plugin.php?id=xj_event:event_join_single&tid=' . $tid);
  92. }
  93. }
  94. //报名返回链接
  95. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/wsqcenter/event_view.php')) {
  96. $retrunurl = $_G['siteurl'] . 'plugin.php?id=xj_event:wsqcenter&mod=event_view&tid=' . $tid;
  97. } else {
  98. $retrunurl = $_G['siteurl'] . 'forum.php?mod=viewthread&tid=' . $tid;
  99. }
  100. if ($_G['mobile']) {
  101. if ($_G['wechat']['setting']['wsq_allow']) {
  102. if (!$_G['uid'] && $_G['mobile']) {
  103. $url = "http://wsq.discuz.com/index.php?c=index&a=plugin&siteid=" . $_G['wechat']['setting']['wsq_siteid'] . "&pluginid=xj_event:autologin&param=" . urlencode(base64_encode("reload=event_join&tid=$tid")) . "&login=yes&mobile=2";
  104. dheader('location: ' . $url);
  105. exit;
  106. }
  107. } else {
  108. if (!$_G['uid'] && $_G['mobile']) {
  109. //$url = 'member.php?mod=logging&action=login&mobile=2';
  110. $thisurl = $_G['siteurl'] . 'plugin.php?id=xj_event:event_join&tid=' . $tid;
  111. $url = $_G['siteurl'] . 'member.php?mod=logging&action=login&referer=' . urlencode($thisurl);
  112. //$url = $_G['siteurl'].'member.php?mod=logging&action=login&referer='.urlencode($_G['siteurl'].'plugin.php?id=xj_event:wsqcenter&mod=event_view&tid='.$tid);
  113. dheader('location: ' . $url);
  114. exit;
  115. }
  116. }
  117. }
  118. if (!$_G['uid']) {
  119. showmessage('not_loggedin', null, array(), array('login' => 1));
  120. }
  121. if ($setting['onlysubscribeweixin']) { //仅限关注微信报名
  122. if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){
  123. require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php';
  124. $xj_wxmessagecore = new xj_wxmessagecore();
  125. $res = $xj_wxmessagecore->getweixinuserinfo($_G['uid']);
  126. if($res['subscribe']!=1){
  127. $url = $_G['siteurl'].'plugin.php?id=xj_event:wsqcenter&mod=guanzhu';
  128. if($_G['mobile']){
  129. dheader('location: '.$url);
  130. }else{
  131. if($_G['cache']['plugin']['xj_event']['weixinurl']){
  132. $url = $_G['cache']['plugin']['xj_event']['weixinurl'];
  133. }
  134. showmessage(lang('plugin/xj_event','qingxianguanzhuweixinhaozbm'),$url);
  135. }
  136. }
  137. }
  138. }
  139. include 'include/sms_func.php';
  140. $tid = intval($_GET['tid']);
  141. $uid = intval($_G['uid']);
  142. $eid = $items['eid'];
  143. //调用微信支付设置
  144. if (file_exists($xj_event_wxset = DISCUZ_ROOT . './data/sysdata/cache_xj_event_wxset.php')) {
  145. @include $xj_event_wxset;
  146. }
  147. if ($wxset['wsqonly']) {
  148. if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') === false) {
  149. $zffyurl = $_G['siteurl'] . "plugin.php?id=xj_event:event_pay&tid=$tid";
  150. } else {
  151. $zffyurl = $_G['siteurl'] . "plugin.php?id=xj_event:wsq_pay&tid=$tid";
  152. }
  153. } else {
  154. $zffyurl = $_G['siteurl'] . "plugin.php?id=xj_event:event_pay&tid=$tid";
  155. }
  156. if ($_GET['action'] == 'joinfull') {
  157. if ($_GET['formhash'] != $_G['formhash']) {
  158. showmessage('submit_invalid');
  159. }
  160. $post = file_get_contents("php://input");
  161. $post = json_decode($post, true);
  162. if ($_G['charset'] == 'gbk') {
  163. foreach ($post as $key => $value) {
  164. foreach ($value as $key2 => $value2) {
  165. $post[$key][$key2] = iconv('utf-8', 'gbk', $value2);
  166. }
  167. }
  168. }
  169. //验证手机号和身份证
  170. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/checkapply/checkapply.php')) {
  171. @include 'module/checkapply/checkapply.php';
  172. }
  173. //判断回复后才可以报名
  174. if ($setting['reply']) {
  175. $replys = DB::result_first("SELECT count(*) FROM " . DB::table('forum_post') . " WHERE tid='$tid' AND first<>1 AND invisible>=0 AND authorid = " . $_G['uid']);
  176. if ($replys < 1) {
  177. $result['full'] = 2;
  178. $result['message'] = lang('plugin/xj_event', 'huifuhoucaikeyibaoming');
  179. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message'];
  180. echo json_encode($result);
  181. exit;
  182. }
  183. }
  184. //验证必须回复才可以报名
  185. $replys = DB::result_first("SELECT count(*) FROM " . DB::table('forum_post') . " WHERE tid='$tid' AND first<>1 AND invisible>=0 AND authorid = " . $_G['uid']);
  186. if ($setting['reply'] && $replys < 1) {
  187. $result['full'] = 2;
  188. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', lang('plugin/xj_event', 'hfhkybm')) : lang('plugin/xj_event', 'hfhkybm');
  189. echo json_encode($result);
  190. exit;
  191. }
  192. //验证是否已报名
  193. $count = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and uid=$uid");
  194. if ($count > 0) {
  195. $result['full'] = 2;
  196. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', lang('plugin/xj_event', 'qinwcfbm')) : lang('plugin/xj_event', 'baomrsym');
  197. echo json_encode($result);
  198. exit;
  199. }
  200. //验证报名名额是否够
  201. $applynumber = count($post); //本次报名人数
  202. $applynum = DB::result_first("SELECT SUM(applynumber) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and verify=1"); //已报名人数
  203. $applycountnum = DB::result_first("SELECT event_number FROM " . DB::table('xj_event') . " WHERE tid='$tid'"); //活动总人数
  204. if ($applycountnum > 0) {
  205. if ($applynumber > ($applycountnum - $applynum)) {
  206. $result['full'] = 2;
  207. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', lang('plugin/xj_event', 'baomrsym')) : lang('plugin/xj_event', 'baomrsym');
  208. echo json_encode($result);
  209. exit;
  210. }
  211. }
  212. //获取活动组织人的ID
  213. $event_uid = $items['authorid'];
  214. //活动标题
  215. $event_title = $items['subject'];
  216. //活动开始时间
  217. $event_starttime = dgmdate($items['starttime'], 'dt');
  218. //判断积分够不够
  219. $member = DB::fetch_first("SELECT extcredits1,extcredits2,extcredits3,extcredits4,extcredits5,extcredits6,extcredits7,extcredits8 FROM " . DB::table('common_member_count') . " WHERE uid = " . $_G['uid']);
  220. /*
  221. if($member['extcredits'.$items['use_extcredits']]<($items['use_extcredits_num']*$applynumber)){
  222. $result['full'] = 2;
  223. $result['message'] = $_G['setting']['extcredits'][$items['use_extcredits']]['title'].lang('plugin/xj_event', 'bgwfcj');
  224. $result['message'] = $_G['charset'] == 'gbk'?iconv('gbk','utf-8',$result['message']):$result['message'];
  225. echo json_encode($result);
  226. exit;
  227. }
  228. */
  229. //报名资料入数据库
  230. $first = 1;
  231. if($setting['myuserfield']){
  232. $myuserfield = $eventcore->GetUserField($setting['myuserfield']); //新报名字段
  233. }
  234. foreach ($post as $key => $value) {
  235. $ufielddata = array();
  236. foreach ($value as $key2 => $value2) {
  237. if ($key2 != 'message' && $key2 != 'session') {
  238. $ufielddata[$key2] = $value2;
  239. }
  240. }
  241. //新的报名字段的报名资料入数据库
  242. foreach ($myuserfield as $val) {
  243. $ufielddata['myfield' . $val['id']] = $value['myfield' . $val['id']];
  244. }
  245. $ufielddata = serialize($ufielddata);
  246. $eventapply = array();
  247. $eventapply['tid'] = $tid;
  248. $eventapply['eid'] = $items['eid'];
  249. $eventapply['uid'] = $uid;
  250. $eventapply['realname'] = addslashes($value['realname']);
  251. $eventapply['qq'] = addslashes($value['qq']);
  252. $eventapply['mobile'] = addslashes($value['mobile']);
  253. $eventapply['bmmessage'] = addslashes($value['message']);
  254. $eventapply['dateline'] = $_G['timestamp'];
  255. $eventapply['applynumber'] = 1;
  256. $eventapply['ufielddata'] = $ufielddata;
  257. $eventapply['seccode'] = random(8, 1);
  258. $eventapply['session'] = intval($value['session']);
  259. $eventapply['first'] = $first;
  260. if ($fromuid != $_G['uid']) {
  261. $eventapply['fromuid'] = $fromuid;
  262. }
  263. $applyid = DB::insert('xj_eventapply', $eventapply,true);
  264. $first = 0; //代报名的是0
  265. }
  266. //用户活动相关的信息数据表是否存在,不存在就新建
  267. $num = DB::result_first("SELECT count(*) FROM " . DB::table('xj_event_member_info') . " WHERE uid = '$uid'");
  268. if ($num == 0) {
  269. DB::query("INSERT INTO " . DB::table('xj_event_member_info') . " (uid) VALUES ('$uid')");
  270. }
  271. //积分操作
  272. /*
  273. if($items['use_extcredits_num']>0){
  274. $extnum = $items['use_extcredits_num'] * $applynumber;
  275. updatemembercount($_G['uid'],array($items['use_extcredits']=>-$extnum));
  276. }
  277. */
  278. if ($setting['noverify'] == 1) {
  279. //报名不审核
  280. if ($setting['eventpay']) {
  281. //如果在线支付
  282. $result['full'] = 1;
  283. $result['message'] = lang('plugin/xj_event', 'bmzltjcgxzzrzfym');
  284. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message'];
  285. $result['url'] = $zffyurl;
  286. $result['btntxt'] = lang('plugin/xj_event', 'zhifufy');
  287. $result['btntxt'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['btntxt']) : $result['btntxt'];
  288. echo json_encode($result);
  289. exit;
  290. } else {
  291. DB::query("update " . DB::table('xj_eventapply') . " set verify=1 where tid='$tid' and uid=$uid"); //自动审核
  292. //邀请的奖励处理
  293. if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/invitation/event_yqjl.php')) {
  294. if ($setting['yqjl_jfs'] > 0 && $fromuid != $_G['uid']) {
  295. $yqjl = array();
  296. $yqjl['tid'] = $tid;
  297. $yqjl['fromuid'] = $fromuid;
  298. $yqjl['applyuid'] = $_G['uid'];
  299. $yqjl['jfs'] = $setting['yqjl_jfs'] * $applynumber;
  300. $yqjl['jflx'] = $setting['yqjl_jflx'];
  301. $yqjl['dateline'] = $_G['timestamp'];
  302. DB::insert('xj_event_yqjl_log', $yqjl);
  303. updatemembercount($yqjl['fromuid'], array($yqjl['jflx'] => +$yqjl['jfs']));
  304. notification_add($fromuid, 'system', $_G['username'] . lang('plugin/xj_event', 'beiniyaoqinbaomincanjiale') . ' <a href="forum.php?mod=viewthread&tid=' . $tid . '" target="_blank">' . $event_title . '</a> ' . lang('plugin/xj_event', 'huodonghuode') . $yqjl['jfs'] . $_G['setting']['extcredits'][$yqjl['jflx']]['title'] . lang('plugin/xj_event', 'jiangli'));
  305. }
  306. }
  307. //短信操作
  308. if ($setting['seccode'] == 1) {
  309. $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;
  310. //xjsendsms(array($eventapply['mobile']),$message,lang('plugin/xj_event', 'maomyzmdx'));
  311. sendsms_vcode($eventapply['mobile'], $event_title, $applynumber, $eventapply['seccode']);
  312. sendpm($eventapply['uid'], '', $message, $event_uid);
  313. } elseif ($setting['success_sms'] == 1) {
  314. sendsms_success($eventapply['mobile'], $event_title, $event_starttime);
  315. //易活动短信
  316. //$smsuid = DB::result_first("SELECT uid FROM ".DB::table('common_member')." WHERE username='".$setting['event_admin'][0]."'");
  317. //$smsmobile = DB::result_first("SELECT mobile FROM ".DB::table('common_member_profile')." WHERE uid=$smsuid");
  318. //sendsms_notice_yhd($eventapply['mobile'],$event_title,$event_starttime,$items['event_address'],$smsmobile);
  319. }
  320. 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);
  321. //微信消息
  322. if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){
  323. require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php';
  324. $xj_wxmessagecore = new xj_wxmessagecore();
  325. $xj_wxmessagecore->send_eventmessage($_G['uid'],$tid,1);
  326. $xj_wxmessagecore->send_eventapplymessage($applyid,$event_uid,2);
  327. }
  328. $result['full'] = 1;
  329. $result['message'] = lang('plugin/xj_event', 'gxnbmcg');
  330. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message'];
  331. $result['url'] = $_G['siteurl'] . "forum.php?mod=viewthread&tid=$tid";
  332. echo json_encode($result);
  333. exit;
  334. }
  335. } else {
  336. //报名审核时
  337. if ($setting['eventpay']) {
  338. //如果在线支付
  339. $result['full'] = 1;
  340. $result['message'] = lang('plugin/xj_event', 'bmzltjcgxzzrzfym');
  341. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message'];
  342. $result['url'] = $zffyurl;
  343. $result['btntxt'] = lang('plugin/xj_event', 'zhifufy');
  344. $result['btntxt'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['btntxt']) : $result['btntxt'];
  345. echo json_encode($result);
  346. exit;
  347. }
  348. //发通知
  349. notification_add($event_uid, 'system', 'activity_notice', array('tid' => $tid, 'subject' => $event_title));
  350. //微信消息
  351. if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){
  352. $event_admins = array();
  353. $event_admins[] = $event_uid;
  354. foreach ($setting['event_admin'] as $v) {
  355. $event_admins[] = DB::result_first("SELECT uid FROM ".DB::table('common_member')." WHERE username='$v'");
  356. }
  357. require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php';
  358. $xj_wxmessagecore = new xj_wxmessagecore();
  359. $xj_wxmessagecore->send_eventapplyshmessage($applyid,$event_admins,3);
  360. }
  361. $result['full'] = 1;
  362. $result['message'] = lang('plugin/xj_event', 'bmxxtjcgqddsh');
  363. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message'];
  364. $result['url'] = $_G['siteurl'] . "forum.php?mod=viewthread&tid=$tid";
  365. echo json_encode($result);
  366. exit;
  367. }
  368. }
  369. //取消报名
  370. if ($_GET['action'] == 'cannel') {
  371. if ($_GET['formhash'] != $_G['formhash']) {
  372. showmessage('submit_invalid');
  373. }
  374. $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'");
  375. if ($items['activityexpiration'] > $timestamp) {
  376. $count = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid = '$tid' and uid = " . $_G['uid']);
  377. if ($count < 1) {
  378. exit('Access Denied');
  379. }
  380. $applynumber = $count;
  381. DB::query("DELETE FROM " . DB::table('xj_eventapply') . " WHERE tid = '$tid' and uid = " . $_G['uid']);
  382. //还原积分操作
  383. /*
  384. if($items['use_extcredits_num']>0){
  385. $extnum = $items['use_extcredits_num']*$applynumber;
  386. updatemembercount($_G['uid'],array($items['use_extcredits']=>$extnum));
  387. }
  388. */
  389. //通知
  390. notification_add($items['authorid'], 'system', 'activity_cancel', array(
  391. 'tid' => $tid,
  392. 'subject' => $items['subject'],
  393. 'reason' => $message,
  394. ));
  395. if ($_GET['inajax']) {
  396. $result = array();
  397. $result['full'] = 1;
  398. $result['return'] = $return;
  399. $result['message'] = lang('plugin/xj_event', 'huodongquxiaochenggong');
  400. $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message'];
  401. $result['url'] = $_G['siteurl'] . 'plugin.php?id=xj_event:wsqcenter&mod=my_join';
  402. echo json_encode($result);
  403. exit();
  404. } else {
  405. dheader('location: ' . $retrunurl);
  406. }
  407. } else {
  408. exit('Access Denied');
  409. }
  410. }
  411. if ($_GET['action'] == 'checkseccode') {
  412. if ($_GET['formhash'] != $_G['formhash']) {
  413. showmessage('submit_invalid');
  414. }
  415. $eid = intval($_GET['eid']);
  416. if (!$_GET['seccode']) {
  417. showmessage(lang('plugin/xj_event', 'yzmwxhzyjsy'));
  418. }
  419. $seccode = dhtmlspecialchars(trim($_GET['seccode']));
  420. $apply = DB::fetch_first("SELECT applyid,uid FROM " . DB::table('xj_eventapply') . " WHERE eid='$eid' AND secstate=0 AND seccode='$seccode'");
  421. $applyid = $apply['applyid'];
  422. if ($applyid) {
  423. DB::update('xj_eventapply', array('secstate' => 1, 'sectime' => $_G['timestamp']), "applyid=$applyid");
  424. notification_add($apply['uid'], 'system', lang('plugin/xj_event', 'ndhdbmyzm') . " $seccode " . lang('plugin/xj_event', 'yishiyong'), array(), 1);
  425. showmessage(lang('plugin/xj_event', 'yzmyxyzcg'), "forum.php?mod=viewthread&tid=$tid");
  426. } else {
  427. showmessage(lang('plugin/xj_event', 'yzmwxhzyjsy'));
  428. }
  429. }
  430. //验证是否已报名
  431. $count = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and uid=$uid");
  432. if ($count > 0) {
  433. dheader('location: ' . $_G['siteurl'] . 'forum.php?mod=viewthread&tid=' . $tid);
  434. }
  435. //获取用户报名字段
  436. if ($_G['mobile']) {
  437. $userfield = unserialize($items['userfield']);
  438. $selectuserfield = unserialize($items['userfield']);
  439. if ($selectuserfield) {
  440. if ($selectuserfield) {
  441. $htmls = $settings = array();
  442. require_once libfile('function/profile');
  443. foreach ($selectuserfield as $fieldid) {
  444. if (empty($ufielddata['userfield'])) {
  445. $memberprofile = C::t('common_member_profile')->fetch($_G['uid']);
  446. foreach ($selectuserfield as $val) {
  447. if ($val == 'birthday') {
  448. $ufielddata['userfield']['birthyear'] = $memberprofile['birthyear'];
  449. $ufielddata['userfield']['birthmonth'] = $memberprofile['birthmonth'];
  450. }
  451. $ufielddata['userfield'][$val] = $memberprofile[$val];
  452. }
  453. unset($memberprofile);
  454. }
  455. $html = profile_setting($fieldid, $ufielddata['userfield'], false, true);
  456. if ($fieldid == 'birthday') {
  457. $memberprofile = C::t('common_member_profile')->fetch($_G['uid']);
  458. $mybirthday = $memberprofile['birthyear'] . '-' . $memberprofile['birthmonth'] . '-' . $memberprofile['birthday'];
  459. $mybirthday = strtotime($mybirthday);
  460. $mybirthday = date("Y-m-d", $mybirthday);
  461. $html = '<input name="birthday" type="date" id="birthday" value="' . $mybirthday . '" class="join_text" />';
  462. }
  463. if ($fieldid == 'residecity') {
  464. $html = '<div><input type="hidden" name="residecity" value=""><span></span> <button class="residecity ui-btn">' . lang('plugin/xj_event', 'select') . '</button><span></span></div>';
  465. }
  466. if ($html) {
  467. if (strpos($html, 'checkbox') > 0) {
  468. $html = '<fieldset data-role="controlgroup">' . $html . '</fieldset>';
  469. $html = str_replace(' class="lb"', '', $html);
  470. //echo $html;
  471. //exit();
  472. }
  473. //下拉列表
  474. if (strpos($html, 'select name=') > 0 && strpos($html, 'name="birthprovince"') < 1) {
  475. if (strpos($html, 'name="gender"') > 0) {
  476. preg_match('/name\=\"(.+?)\"/i', $html, $selectname);
  477. preg_match_all('/value\=\"(.+?)\"/i', $html, $optionvalue);
  478. preg_match_all('/\"\>(.+?)\<\/op/i', $html, $optiontext);
  479. $html = '<div class="xjselect"><input type="hidden" name="' . $selectname[1] . '" id="' . $selectname[1] . '" value="">';
  480. foreach ($optionvalue[1] as $opkey => $opvalue) {
  481. $html .= '<span style="background-color:#ccc; font-size:14px; padding:3px 12px; color:#FFF; border-radius:4px; margin-bottom:5px; margin-right:5px; float:left;font-weight:normal; text-shadow:none;" data-value="' . $opvalue . '">' . $optiontext[1][$opkey] . '</span>';
  482. }
  483. $html .= '</div><div style="clear:both;"></div>';
  484. } else {
  485. preg_match('/name\=\"(.+?)\"/i', $html, $selectname);
  486. preg_match_all('/value\=\"(.+?)\"/i', $html, $optionvalue);
  487. $html = '<div class="xjselect"><input type="hidden" name="' . $selectname[1] . '" id="' . $selectname[1] . '" value="">';
  488. foreach ($optionvalue[1] as $opvalue) {
  489. $html .= '<span style="background-color:#ccc; font-size:14px; padding:3px 12px; color:#FFF; border-radius:4px; margin-bottom:5px; margin-right:5px; float:left;font-weight:normal; text-shadow:none;" data-value="' . $opvalue . '">' . $opvalue . '</span>';
  490. }
  491. $html .= '</div><div style="clear:both;"></div>';
  492. }
  493. }
  494. $html = preg_replace("/<div class=\"rq mtn\" id=\"showerror.+<\/div>/is", "", $html);
  495. if (strpos($html, 'type="text"') > 0) {
  496. $html = str_replace('class="px"', 'class="join_text"', $html);
  497. }
  498. $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
  499. $htmls[$fieldid] = $html;
  500. }
  501. }
  502. }
  503. } else {
  504. $selectuserfield = '';
  505. }
  506. } else {
  507. $userfield = unserialize($items['userfield']);
  508. $selectuserfield = unserialize($items['userfield']);
  509. if ($selectuserfield) {
  510. if ($selectuserfield) {
  511. $htmls = $settings = array();
  512. require_once libfile('function/profile');
  513. foreach ($selectuserfield as $fieldid) {
  514. if (empty($ufielddata['userfield'])) {
  515. $memberprofile = C::t('common_member_profile')->fetch($_G['uid']);
  516. foreach ($selectuserfield as $val) {
  517. if ($val == 'birthday') {
  518. $ufielddata['userfield']['birthyear'] = $memberprofile['birthyear'];
  519. $ufielddata['userfield']['birthmonth'] = $memberprofile['birthmonth'];
  520. }
  521. $ufielddata['userfield'][$val] = $memberprofile[$val];
  522. }
  523. unset($memberprofile);
  524. }
  525. $html = profile_setting($fieldid, $ufielddata['userfield'], false, true);
  526. if ($fieldid == 'birthday') {
  527. $memberprofile = C::t('common_member_profile')->fetch($_G['uid']);
  528. $mybirthday = $memberprofile['birthyear'] . '-' . $memberprofile['birthmonth'] . '-' . $memberprofile['birthday'];
  529. $html = '<div style="height:36px;"><input name="birthday" type="text" value="' . $mybirthday . '" class="dateselect" /><div></div></div>';
  530. }
  531. if ($fieldid == 'residecity') {
  532. $html = '<div style="height:36px;"><input type="hidden" name="residecity" value=""><span></span> <button class="residecity">' . lang('plugin/xj_event', 'select') . '</button><span></span></div>';
  533. }
  534. if ($html) {
  535. $settings[$fieldid] = $_G['cache']['profilesetting'][$fieldid];
  536. $htmls[$fieldid] = $html;
  537. }
  538. }
  539. }
  540. } else {
  541. $selectuserfield = '';
  542. }
  543. }
  544. //新的报名字段
  545. if($setting['myuserfield']){
  546. $myuserfield = $eventcore->GetUserField($setting['myuserfield']);
  547. }
  548. include template('xj_event:event_join');