event_join_single.inc.php 25 KB

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