Exemple #1
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     //$content = $this->message['content'];
     $openid = $this->message['from'];
     load()->model('mc');
     $uid = mc_openid2uid($openid);
     $row = pdo_fetch("SELECT awardprompt,currentprompt,floorprompt,setting FROM " . tablename('superman_floor') . " WHERE rid={$rid}");
     $rule_name = pdo_fetchcolumn("SELECT name FROM " . tablename('rule') . " WHERE id={$rid}");
     if ($row) {
         $setting = unserialize($row['setting']);
         if (!$setting['repeat_floor']) {
             $floor = $this->get_floor();
             if ($floor) {
                 $result = str_replace('{RULENAME}', $rule_name, $row['floorprompt']);
                 $result = str_replace('{FLOOR}', $floor['id'], $result);
                 $result = str_replace('{TIME}', date('Y-m-d H:i:s', $floor['dateline']), $result);
                 $winninginfo = $_W['siteroot'] . 'app/' . $this->createMobileUrl('winninginfo', array('rid' => $rid));
                 //return $this->respText($result);
                 $news = array(array('title' => '您已参与过本活动!', 'description' => $result, 'picurl' => '', 'url' => $winninginfo));
                 return $this->respNews($news);
             }
         }
     }
     $new_data = array('dateline' => $_W['timestamp'], 'openid' => $openid);
     pdo_insert("superman_floor_{$rid}", $new_data, false);
     $new_id = pdo_insertid();
     if ($new_id <= 0) {
         return $this->respText('系统异常,请稍后重试!');
     }
     $awards = pdo_fetchall("SELECT * FROM " . tablename('superman_floor_award') . " WHERE rid={$rid}");
     $prompt = pdo_fetch("SELECT awardprompt,currentprompt,floorprompt,setting FROM " . tablename('superman_floor') . " WHERE rid={$rid}");
     if ($awards) {
         foreach ($awards as $item) {
             $floors = explode(',', $item['floors']);
             if (in_array($new_id, $floors)) {
                 $new_data = array('rid' => $rid, 'floor' => $new_id, 'uid' => $uid, 'uniacid' => $_W['uniacid'], 'openid' => $openid, 'award_id' => $item['id'], 'ip' => $_W['clientip'], 'dateline' => $_W['timestamp']);
                 pdo_insert('superman_floor_winner', $new_data);
                 $winner_id = pdo_insertid();
                 $result = str_replace('{RULENAME}', $rule_name, $row['awardprompt']);
                 $result = str_replace('{FLOOR}', $new_id, $result);
                 $result = str_replace('{AWARD}', $item['title'], $result);
                 $result = str_replace('{DESCRIPTION}', $item['description'], $result);
                 $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$winner_id}|{$openid}", 'ENCODE'), 'rid' => $rid));
                 $winninginfo = $_W['siteroot'] . 'app/' . $this->createMobileUrl('winninginfo', array('rid' => $rid));
                 $news = array(array('title' => '恭喜您,获得' . $item['title'] . '!', 'description' => $result, 'picurl' => '', 'url' => $url));
                 return $this->respNews($news);
             }
         }
     }
     $result = str_replace('{RULENAME}', $rule_name, $row['currentprompt']);
     $result = str_replace('{FLOOR}', $new_id, $result);
     $winninginfo = $_W['siteroot'] . 'app/' . $this->createMobileUrl('winninginfo', array('rid' => $rid));
     $news = array(array('title' => '未中奖,再接再厉!', 'description' => $result, 'picurl' => '', 'url' => $winninginfo));
     return $this->respNews($news);
 }
Exemple #2
0
 public function doMobileInfosubmit()
 {
     global $_W, $_GPC;
     $title = '提交领奖信息';
     list($rid, $winner_id, $openid) = explode('|', superman_authcode(trim($_GPC['_x']), 'DECODE'));
     if (empty($rid) || empty($winner_id) || empty($openid)) {
         message('非法请求!');
     }
     $active = pdo_fetch("SELECT * FROM " . tablename('rule') . " WHERE id='{$rid}'");
     if (!$active) {
         message('活动已结束!');
     }
     $success = false;
     if (checksubmit()) {
         $realname = trim($_GPC['realname']);
         if (empty($realname)) {
             message('请填写姓名!');
         }
         $mobile = trim($_GPC['mobile']);
         if (empty($mobile)) {
             message('请填写电话号码!');
         }
         $qq = trim($_GPC['qq']);
         if (empty($qq)) {
             message('请填写QQ号码!');
         }
         $winner = $update_data = array('realname' => $realname, 'mobile' => $mobile, 'qq' => $qq);
         pdo_update('superman_floor_winner', $update_data, array('id' => $winner_id));
         $success = true;
     } else {
         $winner = pdo_fetch("SELECT * FROM " . tablename('superman_floor_winner') . " WHERE id='{$winner_id}'");
     }
     include $this->template('infosubmit');
 }
Exemple #3
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $from_user = $this->message['from'];
     $reply = pdo_fetch("SELECT * FROM " . tablename('stonefish_luckynum') . " WHERE rid = :rid", array(':rid' => $rid));
     //查询是否中奖但没有提供信息
     $zhongjiang = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('stonefish_luckynum_fans') . " WHERE rid = :rid and uniacid=:uniacid and from_user=:from_user and zhongjiang=1", array(':rid' => $rid, ':uniacid' => $_W['uniacid'], ':from_user' => $from_user));
     //查询是否中奖但没有提供信息
     //赞助商
     if (!empty($reply['sponsors1'])) {
         if (!empty($reply['sponsors1link'])) {
             $ad_info = "<a target=\"_blank\" href=\"" . $reply['sponsors1link'] . "\">" . $reply['sponsors1'] . "</a>";
         } else {
             $ad_info = $reply['sponsors1'];
         }
     }
     if (!empty($reply['sponsors2'])) {
         if (!empty($reply['sponsors2link'])) {
             $ad_info .= "\n<a target=\"_blank\" href=\"" . $reply['sponsors2link'] . "\">" . $reply['sponsors2'] . "</a>";
         } else {
             $ad_info .= "\n" . $reply['sponsors2'];
         }
     }
     if (!empty($reply['sponsors3'])) {
         if (!empty($reply['sponsors3link'])) {
             $ad_info .= "\n<a target=\"_blank\" href=\"" . $reply['sponsors3link'] . "\">" . $reply['sponsors3'] . "</a>";
         } else {
             $ad_info .= "\n" . $reply['sponsors3'];
         }
     }
     if (!empty($reply['sponsors4'])) {
         if (!empty($reply['sponsors4link'])) {
             $ad_info .= "\n<a target=\"_blank\" href=\"" . $reply['sponsors4link'] . "\">" . $reply['sponsors4'] . "</a>";
         } else {
             $ad_info .= "\n" . $reply['sponsors4'];
         }
     }
     if (!empty($reply['sponsors5'])) {
         if (!empty($reply['sponsors5link'])) {
             $ad_info .= "\n<a target=\"_blank\" href=\"" . $reply['sponsors5link'] . "\">" . $reply['sponsors5'] . "</a>";
         } else {
             $ad_info .= "\n" . $reply['sponsors5'];
         }
     }
     if (!empty($ad_info)) {
         $ad_info = "\n———————————\n" . $ad_info;
     }
     //赞助商
     //查询活动状态
     if ($reply == false) {
         return $this->respText("活动已取消..." . $ad_info);
     }
     if ($reply['isshow'] == 0) {
         return $this->respText($reply['show_instruction'] . $ad_info);
     }
     if ($reply['starttime'] > time()) {
         return $this->respText($reply['time_instruction'] . $ad_info);
     }
     if ($reply['endtime'] < time()) {
         $result = $reply['end_instruction'];
         if ($zhongjiang) {
             $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$from_user}", 'ENCODE')));
             $result .= $reply['award_instruction'] . "<a href='{$url}'>" . $reply['ticketinfo'] . "</a>";
         }
         return $this->respText($result . $ad_info);
     }
     //查询活动状态
     $limittype = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('stonefish_luckynum_fans') . " WHERE rid=:rid and uniacid=:uniacid and from_user=:from_user", array(':rid' => $rid, ':uniacid' => $_W['uniacid'], ':from_user' => $from_user));
     //第一次参与显示分享给好友链接
     if ($limittype == 0) {
         $share = "\n———————————\n<a target=\"_blank\" href=\"" . $_W['siteroot'] . 'app/' . $this->createMobileUrl('share', array('rid' => $rid)) . "\">快拉小伙伴一起幸运数字吧</a>";
     }
     //第一次参与显示分享给好友链接
     //查询参与次数限制
     if ($reply['limittype']) {
         if ($limittype) {
             $result = $reply['limit_instruction'];
             if ($zhongjiang) {
                 $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$from_user}", 'ENCODE')));
                 $result .= $reply['award_instruction'] . "<a href='{$url}'>" . $reply['ticketinfo'] . "</a>";
             }
             return $this->respText($result . $share . $ad_info);
         }
     }
     //查询参与次数限制
     //查询中奖次数
     $awardnum = pdo_fetchcolumn("SELECT count(*) FROM " . tablename('stonefish_luckynum_fans') . " WHERE rid = :rid and uniacid=:uniacid and from_user=:from_user and zhongjiang>=1", array(':rid' => $rid, ':uniacid' => $_W['uniacid'], ':from_user' => $from_user));
     if ($reply['limittype'] == 0 && $awardnum >= $reply['awardnum']) {
         $result = $reply['awardnum_instruction'];
         if ($zhongjiang) {
             $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$from_user}", 'ENCODE')));
             $result .= $reply['award_instruction'] . "<a href='{$url}'>" . $reply['ticketinfo'] . "</a>";
         }
         return $this->respText($result . $share . $ad_info);
     }
     //查询中奖次数
     //查询最后一个数字记录
     $lastnumber = pdo_fetchcolumn("SELECT number FROM " . tablename('stonefish_luckynum_fans') . " WHERE rid = :rid and uniacid=:uniacid ORDER BY `number` desc", array(':rid' => $rid, ':uniacid' => $_W['uniacid']));
     $lastnumber = $lastnumber + 1;
     if ($lastnumber == 1) {
         $lastnumber = $reply['luckynumstart'];
     }
     //查询最后一个数字记录
     //判断是否包含过滤数字
     $luckynumfilter = explode(',', $reply['luckynumfilter']);
     foreach ($luckynumfilter as $luckynumfilteritem) {
         $lastnumber = str_replace($luckynumfilteritem, $luckynumfilteritem + 1, $lastnumber);
     }
     //判断是否包含过滤数字
     $new_data = array('rid' => $rid, 'uniacid' => $_W['uniacid'], 'number' => $lastnumber, 'dateline' => $_W['timestamp'], 'from_user' => $from_user, 'ip' => $_W['clientip']);
     pdo_insert("stonefish_luckynum_fans", $new_data, false);
     $new_id = pdo_insertid();
     if ($new_id <= 0) {
         return $this->respText('系统异常,请稍后重试!');
     }
     $awards = pdo_fetchall("SELECT * FROM " . tablename('stonefish_luckynum_award') . " WHERE rid={$rid} ORDER BY `id` ASC");
     if ($awards) {
         foreach ($awards as $item) {
             $numbers = explode(',', $item['numbers']);
             if (in_array($lastnumber, $numbers)) {
                 $up_data = array('award_id' => $item['id'], 'zhongjiang' => 1);
                 pdo_update('stonefish_luckynum_fans', $up_data, array('id' => $new_id));
                 $result = str_replace('{LUCKYNUM}', $lastnumber, $reply['awardprompt']);
                 $result = str_replace('{AWARD}', $item['title'], $result);
                 $result = str_replace('{DESCRIPTION}', $item['description'], $result);
                 $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$from_user}", 'ENCODE')));
                 $result .= "<a href='{$url}'>" . $reply['ticketinfo'] . "</a>";
                 return $this->respText($result . $share . $ad_info);
                 if ($reply['limittype'] || $reply['limittype'] == 0 && $awardnum >= $reply['awardnum']) {
                     break;
                 }
             }
         }
     }
     $result = str_replace('{LUCKYNUM}', $lastnumber, $reply['currentprompt']);
     if ($zhongjiang) {
         $url = $_W['siteroot'] . 'app/' . $this->createMobileUrl('infosubmit', array('_x' => superman_authcode("{$rid}|{$from_user}", 'ENCODE')));
         $result .= $reply['award_instruction'] . "<a href='{$url}'>" . $reply['ticketinfo'] . "</a>";
     }
     return $this->respText($result . $share . $ad_info);
 }
Exemple #4
0
 public function doMobileInfosubmit()
 {
     global $_W, $_GPC;
     list($rid, $from_user) = explode('|', superman_authcode(trim($_GPC['_x']), 'DECODE'));
     if (empty($rid) || empty($from_user)) {
         message('非法请求!');
     }
     $reply = pdo_fetch("select * from " . tablename('stonefish_luckynum') . " where rid = :rid order by `id` desc", array(':rid' => $rid));
     $isfansname = explode(',', $reply['isfansname']);
     $fansID = pdo_fetchcolumn("select uid as fansID from " . tablename('mc_mapping_fans') . " where openid='" . $from_user . "'");
     $profile = mc_fetch($fansID, array('avatar', 'nickname', 'realname', 'mobile', 'qq', 'email', 'address', 'gender', 'telephone', 'idcard', 'company', 'occupation', 'position'));
     $success = false;
     if (checksubmit()) {
         //查询规则保存哪些数据
         $updata = array();
         if ($reply['isrealname']) {
             $updata['realname'] = $_GPC['realname'];
         }
         if ($reply['ismobile']) {
             $updata['mobile'] = $_GPC['mobile'];
         }
         if ($reply['isqq']) {
             $updata['qq'] = $_GPC['qq'];
         }
         if ($reply['isemail']) {
             $updata['email'] = $_GPC['email'];
         }
         if ($reply['isaddress']) {
             $updata['address'] = $_GPC['address'];
         }
         if ($reply['isgender']) {
             $updata['gender'] = $_GPC['gender'];
         }
         if ($reply['istelephone']) {
             $updata['telephone'] = $_GPC['telephone'];
         }
         if ($reply['isidcard']) {
             $updata['idcard'] = $_GPC['idcard'];
         }
         if ($reply['iscompany']) {
             $updata['company'] = $_GPC['company'];
         }
         if ($reply['isoccupation']) {
             $updata['occupation'] = $_GPC['occupation'];
         }
         if ($reply['isposition']) {
             $updata['position'] = $_GPC['position'];
         }
         pdo_update('stonefish_luckynum_fans', array('zhongjiang' => 2), array('rid' => $rid, 'from_user' => $from_user, 'zhongjiang' => 1));
         $temp = pdo_update('stonefish_luckynum_fans', $updata, array('rid' => $rid, 'from_user' => $from_user));
         if ($temp === false) {
             $success = false;
         } else {
             if ($reply['isfans']) {
                 load()->model('mc');
                 mc_update($fans_ID, $updata);
             }
             $success = true;
         }
     }
     include $this->template('infosubmit');
 }
Exemple #5
0
 public function doMobileInfosubmit()
 {
     global $_W, $_GPC;
     $uid = mc_openid2uid($_W['openid']);
     $rid = intval($_GPC['rid']);
     if ($_W['openid']) {
         $member = mc_fetch($_W['openid'], array('realname', 'mobile', 'qq'));
         if ($member['realname'] && $member['mobile'] && $member['qq']) {
             message('您已提交过领奖信息,稍后自动跳转至已中奖品列表页面!', $this->createMobileUrl('winlist', array('op' => 'never', 'openid' => $_W['openid'], 'rid' => $rid)));
         } else {
             $title = '提交领奖信息';
             list($rid, $winner_id, $openid) = explode('|', superman_authcode(trim($_GPC['_x']), 'DECODE'));
             if (empty($rid) || empty($winner_id) || empty($openid)) {
                 message("非法请求");
             }
             $active = pdo_fetch("SELECT * FROM " . tablename('rule') . " WHERE id = {$rid}");
             if (!$active) {
                 message('活动已结束');
             }
             $success = false;
             if (checksubmit()) {
                 $realname = trim($_GPC['realname']);
                 if (empty($realname)) {
                     message('请填写姓名!');
                 }
                 $mobile = trim($_GPC['mobile']);
                 if (empty($mobile)) {
                     message('请填写电话号码!');
                 }
                 $qq = trim($_GPC['qq']);
                 if (empty($qq)) {
                     message('请填写QQ号码!');
                 }
                 $winner = $update_data = array('realname' => $realname, 'mobile' => $mobile, 'qq' => $qq);
                 //pdo_update('superman_floor_winner', $update_data, array('id' => $winner_id));
                 mc_update($uid, $update_data);
                 $success = true;
                 message('提交个人中奖信息成功,稍后自动跳转至已中奖品列表页面!', $this->createMobileUrl('winlist', array('op' => 'never', 'openid' => $_W['openid'], 'rid' => $_GPC['rid'])));
             }
             include $this->template('infosubmit');
         }
     } else {
         message('非法请求!');
     }
 }