0) { $Appbyme = true; } if (strpos($_SERVER["HTTP_USER_AGENT"], 'MAGAPP') > 0) { $magapp = true; } if (strpos($_SERVER['HTTP_USER_AGENT'], 'QianFan') > 0) { $QianFan = true; } if ($Appbyme && !$_G['uid']) { //安米登录 exit(''); } if ($magapp && !$_G['uid']) { //马甲登录 exit(' '); } if ($QianFan && !$_G['uid']) { //千帆登录 exit(' '); } //调用核心类 include 'source/plugin/xj_event/include/core.class.php'; $eventcore = new xj_eventcore(); //邀请报名的来源 if ($_COOKIE['xj_event_fromuid']) { $fromuid = intval($_COOKIE['xj_event_fromuid']); } $tid = intval($_GET['tid']); if ($_G['mobile']) { if ($_G['wechat']['setting']['wsq_allow']) { if (!$_G['uid'] && $_G['mobile']) { $url = "http://wsq.discuz.com/index.php?c=index&a=plugin&siteid=" . $_G['wechat']['setting']['wsq_siteid'] . "&pluginid=xj_event:autologin¶m=" . urlencode(base64_encode("reload=event_join&tid=$tid")) . "&login=yes&mobile=2"; dheader('location: ' . $url); exit; } } else { if (!$_G['uid'] && $_G['mobile']) { //$url = 'member.php?mod=logging&action=login&mobile=2'; $thisurl = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; $url = $_G['siteurl'] . 'member.php?mod=logging&action=login&referer=' . urlencode($thisurl); //$url = $_G['siteurl'].'member.php?mod=logging&action=login&referer='.urlencode($_G['siteurl'].'plugin.php?id=xj_event:wsqcenter&mod=event_view&tid='.$tid); dheader('location: ' . $url); exit; } } } if (!$_G['uid']) { showmessage('not_loggedin', null, array(), array('login' => 1)); } include 'include/sms_func.php'; $tid = intval($_GET['tid']); $uid = intval($_G['uid']); $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'")); $eid = $items['eid']; $setting = unserialize($items['setting']); if ($setting['onlysubscribeweixin']) { //仅限关注微信报名 if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){ require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php'; $xj_wxmessagecore = new xj_wxmessagecore(); $res = $xj_wxmessagecore->getweixinuserinfo($_G['uid']); if($res['subscribe']!=1){ $url = $_G['siteurl'].'plugin.php?id=xj_event:wsqcenter&mod=guanzhu'; if($_G['mobile']){ dheader('location: '.$url); }else{ if($_G['cache']['plugin']['xj_event']['weixinurl']){ $url = $_G['cache']['plugin']['xj_event']['weixinurl']; } showmessage(lang('plugin/xj_event','qingxianguanzhuweixinhaozbm'),$url); } } } } //报名返回链接 if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/wsqcenter/event_view.php')) { $retrunurl = $_G['siteurl'] . 'plugin.php?id=xj_event:wsqcenter&mod=event_view&tid=' . $tid; } else { $retrunurl = $_G['siteurl'] . 'forum.php?mod=viewthread&tid=' . $tid; } //调用微信支付设置 if (file_exists($xj_event_wxset = DISCUZ_ROOT . './data/sysdata/cache_xj_event_wxset.php')) { @include $xj_event_wxset; } if ($wxset['wsqonly']) { if (strpos($_SERVER['HTTP_USER_AGENT'], 'MicroMessenger') === false) { $zffyurl = $_G['siteurl'] . "plugin.php?id=xj_event:event_pay&tid=$tid"; } else { $zffyurl = $_G['siteurl'] . "plugin.php?id=xj_event:wsq_pay&tid=$tid"; } } else { $zffyurl = $_G['siteurl'] . "plugin.php?id=xj_event:event_pay&tid=$tid"; } if ($_GET['action'] == 'joinfull') { if ($_GET['formhash'] != $_G['formhash']) { showmessage('submit_invalid'); } $post = file_get_contents("php://input"); $post = json_decode($post, true); $post = $post[0]; if ($_G['charset'] == 'gbk') { foreach ($post as $key => $value) { $post[$key] = iconv('utf-8', 'gbk', $value); } } //验证手机号和身份证 if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/checkapply/checkapply_single.php')) { @include 'module/checkapply/checkapply_single.php'; } //判断回复后才可以报名 if ($setting['reply']) { $replys = DB::result_first("SELECT count(*) FROM " . DB::table('forum_post') . " WHERE tid='$tid' AND first<>1 AND invisible>=0 AND authorid = " . $_G['uid']); if ($replys < 1) { $result['full'] = 2; $result['message'] = lang('plugin/xj_event', 'huifuhoucaikeyibaoming'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; echo json_encode($result); exit; } } //验证是否已报名 $count = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and uid=$uid"); if ($count > 0) { $result['full'] = 2; $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', lang('plugin/xj_event', 'qinwcfbm')) : lang('plugin/xj_event', 'baomrsym'); echo json_encode($result); exit; } //验证报名名额是否够 $applynumber = intval($post['applynumber']); //本次报名人数 //报名人数是零不可以报名 if ($applynumber <= 0) { $result['full'] = 2; $result['message'] = lang('plugin/xj_event', 'qxzbmrs'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; echo json_encode($result); exit; } //判断其它报名费用类型的人数是否比总人数多 if ($setting['cost']) { $costapplynumber = 0; foreach ($setting['cost'] as $value) { $costapplynumber = $costapplynumber + $post['cost' . $value['id']]; } if ($costapplynumber != $applynumber) { $result['full'] = 2; $result['message'] = lang('plugin/xj_event', 'bmrszsbd'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; echo json_encode($result); exit; } } $applynum = DB::result_first("SELECT SUM(applynumber) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and verify=1"); //已报名人数 $applycountnum = DB::result_first("SELECT event_number FROM " . DB::table('xj_event') . " WHERE tid='$tid'"); //活动总人数 if ($applycountnum > 0) { if ($applynumber > ($applycountnum - $applynum)) { $result['full'] = 2; $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', lang('plugin/xj_event', 'baomrsym')) : lang('plugin/xj_event', 'baomrsym'); echo json_encode($result); exit; } } //获取活动组织人的ID $event_uid = $items['authorid']; //活动标题 $event_title = $items['subject']; //活动开始时间 $event_starttime = dgmdate($items['starttime'], 'dt'); //判断积分够不够 $member = DB::fetch_first("SELECT extcredits1,extcredits2,extcredits3,extcredits4,extcredits5,extcredits6,extcredits7,extcredits8 FROM " . DB::table('common_member_count') . " WHERE uid = " . $_G['uid']); /* if($member['extcredits'.$items['use_extcredits']]<($items['use_extcredits_num']*$applynumber)){ $result['full'] = 2; $result['message'] = $_G['setting']['extcredits'][$items['use_extcredits']]['title'].lang('plugin/xj_event', 'bgwfcj'); $result['message'] = $_G['charset'] == 'gbk'?iconv('gbk','utf-8',$result['message']):$result['message']; echo json_encode($result); exit; } */ //报名资料入数据库 $ufielddata = array(); foreach ($post as $key2 => $value2) { if ($key2 != 'message' && $key2 != 'session') { $ufielddata[$key2] = $value2; } } //新的报名字段的报名资料入数据库 if($setting['myuserfield']){ $myuserfield = $eventcore->GetUserField($setting['myuserfield']); } foreach ($myuserfield as $value) { $ufielddata['myfield' . $value['id']] = $post['myfield' . $value['id']]; } //多种费用报名项 if ($setting['cost']) { foreach ($setting['cost'] as $value) { $ufielddata['cost' . $value['id']] = intval($post['cost' . $value['id']]); } } $ufielddata = serialize($ufielddata); $eventapply = array(); $eventapply['tid'] = $tid; $eventapply['eid'] = $items['eid']; $eventapply['uid'] = $uid; $eventapply['realname'] = addslashes($post['realname']); $eventapply['qq'] = addslashes($post['qq']); $eventapply['mobile'] = addslashes($post['mobile']); $eventapply['bmmessage'] = addslashes($post['message']); $eventapply['dateline'] = $_G['timestamp']; $eventapply['applynumber'] = intval($post['applynumber']); $eventapply['ufielddata'] = $ufielddata; $eventapply['seccode'] = random(8, 1); $eventapply['session'] = intval($post['session']); $eventapply['first'] = 1; if ($fromuid != $_G['uid']) { $eventapply['fromuid'] = $fromuid; } $applyid = DB::insert('xj_eventapply', $eventapply,true); //用户活动相关的信息数据表是否存在,不存在就新建 $num = DB::result_first("SELECT count(*) FROM " . DB::table('xj_event_member_info') . " WHERE uid = '$uid'"); if ($num == 0) { DB::query("INSERT INTO " . DB::table('xj_event_member_info') . " (uid) VALUES ('$uid')"); } //积分操作 /* if($items['use_extcredits_num']>0){ $extnum = $items['use_extcredits_num'] * $applynumber; updatemembercount($_G['uid'],array($items['use_extcredits']=>-$extnum)); } */ if ($setting['noverify'] == 1) { //报名不审核 if ($setting['eventpay']) { //如果在线支付 $result['full'] = 1; $result['message'] = lang('plugin/xj_event', 'bmzltjcgxzzrzfym'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; $result['url'] = $zffyurl; $result['btntxt'] = lang('plugin/xj_event', 'zhifufy'); $result['btntxt'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['btntxt']) : $result['btntxt']; echo json_encode($result); exit; } else { DB::query("update " . DB::table('xj_eventapply') . " set verify=1 where tid='$tid' and uid=$uid"); //自动审核 //邀请的奖励处理 if (file_exists(DISCUZ_ROOT . './source/plugin/xj_event/module/invitation/event_yqjl.php')) { if ($setting['yqjl_jfs'] > 0 && $fromuid != $_G['uid']) { $yqjl = array(); $yqjl['tid'] = $tid; $yqjl['fromuid'] = $fromuid; $yqjl['applyuid'] = $_G['uid']; $yqjl['jfs'] = $setting['yqjl_jfs'] * $applynumber; $yqjl['jflx'] = $setting['yqjl_jflx']; $yqjl['dateline'] = $_G['timestamp']; DB::insert('xj_event_yqjl_log', $yqjl); updatemembercount($yqjl['fromuid'], array($yqjl['jflx'] => +$yqjl['jfs'])); notification_add($fromuid, 'system', $_G['username'] . lang('plugin/xj_event', 'beiniyaoqinbaomincanjiale') . ' ' . $event_title . ' ' . lang('plugin/xj_event', 'huodonghuode') . $yqjl['jfs'] . $_G['setting']['extcredits'][$yqjl['jflx']]['title'] . lang('plugin/xj_event', 'jiangli')); } } //短信操作 if ($setting['seccode'] == 1) { $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; //xjsendsms(array($eventapply['mobile']),$message,lang('plugin/xj_event', 'maomyzmdx')); sendsms_vcode($eventapply['mobile'], $event_title, $applynumber, $eventapply['seccode']); sendpm($eventapply['uid'], '', $message, $event_uid); } elseif ($setting['success_sms'] == 1) { sendsms_success($eventapply['mobile'], $event_title, $event_starttime); } notification_add($event_uid, 'system', $_G['username'] . ' ' . lang('plugin/xj_event', 'bmcjlnd') . ' ' . $event_title . ' ' . lang('plugin/xj_event', 'hdxtyzdsh'), array(), 0); //微信消息 if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){ require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php'; $xj_wxmessagecore = new xj_wxmessagecore(); $xj_wxmessagecore->send_eventmessage($_G['uid'],$tid,1); $xj_wxmessagecore->send_eventapplymessage($applyid,$event_uid,2); } $result['full'] = 1; $result['message'] = lang('plugin/xj_event', 'gxnbmcg'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; $result['url'] = $_G['siteurl'] . "forum.php?mod=viewthread&tid=$tid"; echo json_encode($result); exit; } } else { //报名审核时 if ($setting['eventpay']) { //如果在线支付 $result['full'] = 1; $result['message'] = lang('plugin/xj_event', 'bmzltjcgxzzrzfym'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; $result['url'] = $zffyurl; $result['btntxt'] = lang('plugin/xj_event', 'zhifufy'); $result['btntxt'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['btntxt']) : $result['btntxt']; echo json_encode($result); exit; } //发通知 notification_add($event_uid, 'system', 'activity_notice', array('tid' => $tid, 'subject' => $event_title)); //微信消息 if($_G['cache']['plugin']['xj_wxmessage']['wxlogin']){ $event_admins = array(); $event_admins[] = $event_uid; foreach ($setting['event_admin'] as $v) { $event_admins[] = DB::result_first("SELECT uid FROM ".DB::table('common_member')." WHERE username='$v'"); } require_once DISCUZ_ROOT . './source/plugin/xj_wxmessage/class/core.class.php'; $xj_wxmessagecore = new xj_wxmessagecore(); $xj_wxmessagecore->send_eventapplyshmessage($applyid,$event_admins,3); } $result['full'] = 1; $result['message'] = lang('plugin/xj_event', 'bmxxtjcgqddsh'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; $result['url'] = $_G['siteurl'] . "forum.php?mod=viewthread&tid=$tid"; echo json_encode($result); exit; } } //取消报名 if ($_GET['action'] == 'cannel') { if ($_GET['formhash'] != $_G['formhash']) { showmessage('submit_invalid'); } $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'"); if ($items['activityexpiration'] > $timestamp) { $applynumber = DB::result_first("SELECT applynumber FROM " . DB::table('xj_eventapply') . " WHERE tid = '$tid' and uid = " . $_G['uid']); DB::query("DELETE FROM " . DB::table('xj_eventapply') . " WHERE tid = '$tid' and uid = " . $_G['uid']); //还原积分操作 /* if($items['use_extcredits_num']>0){ $extnum = $items['use_extcredits_num']*$applynumber; updatemembercount($_G['uid'],array($items['use_extcredits']=>$extnum)); } */ //通知 notification_add($items['authorid'], 'system', 'activity_cancel', array( 'tid' => $tid, 'subject' => $items['subject'], 'reason' => $message, )); if ($_GET['inajax']) { $result = array(); $result['full'] = 1; $result['return'] = $return; $result['message'] = lang('plugin/xj_event', 'huodongquxiaochenggong'); $result['message'] = $_G['charset'] == 'gbk' ? iconv('gbk', 'utf-8', $result['message']) : $result['message']; $result['url'] = $_G['siteurl'] . 'plugin.php?id=xj_event:wsqcenter&mod=my_join'; echo json_encode($result); exit(); } else { dheader('location: ' . $retrunurl); } } else { exit('Access Denied'); } } if ($_GET['action'] == 'checkseccode') { if ($_GET['formhash'] != $_G['formhash']) { showmessage('submit_invalid'); } $eid = intval($_GET['eid']); if (!$_GET['seccode']) { showmessage(lang('plugin/xj_event', 'yzmwxhzyjsy')); } $seccode = dhtmlspecialchars(trim($_GET['seccode'])); $apply = DB::fetch_first("SELECT applyid,uid FROM " . DB::table('xj_eventapply') . " WHERE eid='$eid' AND secstate=0 AND seccode='$seccode'"); $applyid = $apply['applyid']; if ($applyid) { DB::update('xj_eventapply', array('secstate' => 1, 'sectime' => $_G['timestamp']), "applyid=$applyid"); notification_add($apply['uid'], 'system', lang('plugin/xj_event', 'ndhdbmyzm') . " $seccode " . lang('plugin/xj_event', 'yishiyong'), array(), 1); showmessage(lang('plugin/xj_event', 'yzmyxyzcg'), "forum.php?mod=viewthread&tid=$tid"); } else { showmessage(lang('plugin/xj_event', 'yzmwxhzyjsy')); } } //验证是否已报名 $count = DB::result_first("SELECT count(*) FROM " . DB::table('xj_eventapply') . " WHERE tid='$tid' and uid=$uid"); if ($count > 0) { dheader('location: ' . $_G['siteurl'] . 'forum.php?mod=viewthread&tid=' . $tid); } //报名时可能选择的人数 $items['event_number_max'] = $items['event_number_max'] > 0 ? $items['event_number_max'] : 1; $applynumber = array(); for ($i = 1; $i <= $items['event_number_max']; $i++) { $applynumber[] = $i; } //获取用户报名字段 if ($_G['mobile']) { $userfield = unserialize($items['userfield']); $selectuserfield = unserialize($items['userfield']); if ($selectuserfield) { if ($selectuserfield) { $htmls = $settings = array(); require_once libfile('function/profile'); foreach ($selectuserfield as $fieldid) { if (empty($ufielddata['userfield'])) { $memberprofile = C::t('common_member_profile')->fetch($_G['uid']); foreach ($selectuserfield as $val) { if ($val == 'birthday') { $ufielddata['userfield']['birthyear'] = $memberprofile['birthyear']; $ufielddata['userfield']['birthmonth'] = $memberprofile['birthmonth']; } $ufielddata['userfield'][$val] = $memberprofile[$val]; } unset($memberprofile); } $html = profile_setting($fieldid, $ufielddata['userfield'], false, true); if ($fieldid == 'birthday') { $memberprofile = C::t('common_member_profile')->fetch($_G['uid']); $mybirthday = $memberprofile['birthyear'] . '-' . $memberprofile['birthmonth'] . '-' . $memberprofile['birthday']; $mybirthday = strtotime($mybirthday); $mybirthday = date("Y-m-d", $mybirthday); $html = ''; } if ($fieldid == 'residecity') { $html = '