コード例 #1
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileIndex()
 {
     global $_W, $_GPC;
     checkauth();
     $fromuser = fans_require($_W['fans']['from_user'], array('nickname', 'mobile'), '需要完善资料后才能玩.');
     $rid = $_GPC['rid'];
     $follow = fans_search($_W['fans']['from_user'], array('follow'));
     if ($follow['follow'] == 1) {
         if (intval($_GPC['id'])) {
             $score = pdo_fetchcolumn("select score from" . tablename('bj_tgame_user') . "where rid =" . $rid . ".and from_user ='******'from_user'] . "'");
             if ($score < $_GPC['score']) {
                 $update = array('score' => $_GPC['score'], 'realname' => $fromuser['nickname']);
                 $score = $_GPC['score'];
                 pdo_update('bj_tgame_user', $update, array('id' => $_GPC['id'], 'weid' => $_W['weid']));
             }
             message($score, '', 'ajax');
         }
         $from_user = pdo_fetch("select id from_user, rid from" . tablename('bj_tgame_user') . "where from_user ='******'from_user'] . "'");
         if (empty($from_user['from_user'])) {
             $insert = array('id' => $_GPC['id'], 'weid' => $_W['weid'], 'rid' => $rid, 'from_user' => $fromuser['from_user'], 'realname' => $fromuser['nickname'], 'score' => 0);
             pdo_insert('bj_tgame_user', $insert);
         }
         //$from_user = pdo_fetch("select id, rid from".tablename('bj_tgame_user')."where from_user ='******'from_user']. "'");
         if ($from_user['rid'] != $rid) {
             $update = array('rid' => $rid);
             pdo_update('bj_tgame_user', $update, array('id' => $from_user['id']));
         }
         $realname = $fromuser['nickname'];
         $user = pdo_fetch("select * from" . tablename('bj_tgame_user') . "where rid =" . $rid . ".and from_user ='******'from_user'] . "'");
     }
     $set = pdo_fetch("select * from" . tablename('bj_tgame_reply') . "where rid =" . $rid);
     include $this->template('index');
 }
コード例 #2
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileLottery()
 {
     global $_GPC, $_W;
     $title = '摇钱树送积分';
     $useragent = addslashes($_SERVER['HTTP_USER_AGENT']);
     if (strpos($useragent, 'MicroMessenger') === false && strpos($useragent, 'Windows Phone') === false) {
         exit;
     }
     if (empty($_W['fans']['from_user'])) {
         //message('非法访问,请重新发送消息进入摇钱树页面!1');
     }
     $fromuser = $_W['fans']['from_user'];
     //$profile = fans_require($fromuser, array('realname', 'mobile', 'qq'), '需要完善资料后才能摇钱树.');
     $id = intval($_GPC['id']);
     $yqs = pdo_fetch("SELECT id, maxlottery, default_tips, rule FROM " . tablename('yqs_reply') . " WHERE rid = '{$id}' LIMIT 1");
     if (empty($yqs)) {
         message('非法访问,请重新发送消息进入摇钱树页面!2');
     }
     $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('yqs_winner') . " WHERE createtime > '" . strtotime(date('Y-m-d')) . "' AND from_user = '******' AND award <> ''");
     $member = fans_search($fromuser);
     $myaward = pdo_fetchall("SELECT award, description FROM " . tablename('yqs_winner') . " WHERE from_user = '******' AND award <> '' AND rid = '{$id}' ORDER BY createtime DESC");
     $sql = "SELECT a.award, b.realname FROM " . tablename('yqs_winner') . " AS a\n\t\t\t\tLEFT JOIN " . tablename('fans') . " AS b ON a.from_user = b.from_user WHERE b.mobile <> '' AND b.realname <> '' AND a.award <> '' AND a.rid = '{$id}' ORDER BY a.createtime DESC LIMIT 20";
     $otheraward = pdo_fetchall($sql);
     include $this->template('lottery');
 }
コード例 #3
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $sql = "SELECT * FROM " . tablename('signin_reply') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     if (empty($row['id'])) {
         return array();
     }
     $now = time();
     $start_time = $this->module['config']['start_time'];
     $start_time = strtotime($start_time);
     $end_time = $this->module['config']['end_time'];
     $end_time = strtotime($end_time);
     $date = date('Y-m-d');
     $date = strtotime($date);
     $times = $this->module['config']['times'];
     $credit = $this->module['config']['credit'];
     $limit = $this->module['config']['rank'];
     $message = $this->message;
     $from = $message['from'];
     $todaytotal = pdo_fetchall("SELECT * FROM " . tablename('signin_record') . " WHERE `time` >= :date ", array(':date' => $date));
     $totalnum = count($todaytotal);
     $userrank = $totalnum + 1;
     $todaysignin = pdo_fetchall("SELECT * FROM " . tablename('signin_record') . " WHERE `from_user` = :from_user and `time` >= :date ", array(':from_user' => $from, ':date' => $date));
     $signinednum = count($todaysignin);
     $signinnum = $signinednum + 1;
     $profile = fans_search($from);
     if (!empty($profile['realname'])) {
         if ($now >= $start_time && $now <= $end_time) {
             if ($signinednum < $times) {
                 $insert = array('id' => null, 'weid' => $_W['weid'], 'from_user' => $from, 'name' => $profile['realname'], 'time' => $now, 'rank' => $userrank);
                 pdo_insert('signin_record', $insert);
                 $data = array('credit1' => $credit + $profile['credit1']);
                 fans_update($from, $data);
                 $top = "SELECT * FROM " . tablename('signin_record') . " WHERE `time` >= :date order by rank asc limit {$limit}";
                 $rs = pdo_fetchall($top, array(':date' => $date));
                 $value = array();
                 foreach ($rs as $value) {
                     $record .= 'NO.' . $value['rank'] . '      ' . $value['name'] . '      ' . date('H:i', $value['time']) . "\n";
                 }
                 $nowcredite = fans_search($from);
                 return $this->respText('这是您今天第' . $signinnum . '次签到' . "\n\n" . '排名第' . $userrank . "\n\n" . '本次获取' . $credit . '个积分' . "\n\n" . '累计拥有' . $nowcredite['credit1'] . '个积分' . "\n\n" . '今日签到排行榜:' . "\n\n" . $record);
             } else {
                 $top = "SELECT * FROM " . tablename('signin_record') . " WHERE `from_user` = :from_user and `time` >= :date order by rank asc limit 10";
                 $rs = pdo_fetchall($top, array(':from_user' => $from, ':date' => $date));
                 $value = array();
                 foreach ($rs as $value) {
                     $record .= 'NO.' . $value['rank'] . '      ' . date('m-d H:i:s', $value['time']) . "\n";
                 }
                 return $this->respText($row['overnum'] . "\n\n" . '您的签到记录为' . "\n" . $record);
             }
         } else {
             return $this->respText($row['overtime']);
         }
     } else {
         return $this->respNews(array('Title' => "请先登记", 'Description' => "点击进入登记", 'PicUrl' => "", 'Url' => $this->createMobileUrl('register')));
     }
 }
コード例 #4
0
 public function respond()
 {
     global $_GPC, $_W;
     $rid = $this->rule;
     $message = $this->message;
     $from = $message['from'];
     $profile = fans_search($from);
     $sql = "SELECT * FROM " . tablename('xfmarket_reply') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     if (empty($row['id'])) {
         return array();
     }
     return $this->respNews(array('Title' => $row['title'], 'Description' => $tips . $row['description'], 'PicUrl' => $row['picture'], 'Url' => $this->createMobileUrl('list', array('rid' => $rid))));
 }
コード例 #5
0
 public function respond()
 {
     global $_W;
     $rid = $this->rule;
     $content = trim($this->message['content']);
     $from_user = $this->message['from'];
     $info = fans_search($from_user);
     if (!$this->inContext) {
         //无上下文
         //将参与者写入表
         $sql = "SELECT * FROM " . tablename($this->tablename_log) . " WHERE `rid`=:rid AND `fid`=:fid LIMIT 1";
         $f = pdo_fetch($sql, array(':rid' => $rid, ':fid' => $info['id']));
         if ($f['chk_answer']) {
             return $this->respText("对不起,你已参加过答题。<a href='" . $this->createMobileUrl('show', array('id' => $rid)) . "'>点击查看详情</a>。");
         }
         $sql = "SELECT * FROM " . tablename($this->tablename) . " WHERE `rid`=:rid LIMIT 1";
         $row = pdo_fetch($sql, array(':rid' => $rid));
         isset($_SESSION['q']) ? $q = $_SESSION['q'] : ($_SESSION['q'] = $q = $this->question($row['qid']));
         $pre_txt = "回复数字选择答案,0退出\n======";
         $qtxt = $this->get_question($q);
         $q_config = $this->get_config($q);
         $this->beginContext();
         return $this->respText($pre_txt . "\n" . $qtxt . "\n" . $q_config);
     }
     //上下文
     if ($content == '0') {
         $this->endContext();
         session_destroy();
         return $this->respText("感谢参与,您已回到普通模式!\n回复 ? 获得帮助。");
     }
     //增加0选项
     $q_config_count = $this->get_config_count($_SESSION['q']);
     $q_config_count[] = '0';
     if (!in_array($content, $q_config_count)) {
         return $this->respText('错误的选项,请按提示输入。');
     }
     //选择后正式进入
     pdo_insert($this->tablename_log, array('fid' => $info['id'], 'rid' => $rid));
     pdo_run("UPDATE " . tablename($this->tablename_log) . " SET `chk_answer`=" . $content . " WHERE `fid`=" . $info['id'] . " AND `rid`=" . $rid);
     if ($content == $this->get_answer($_SESSION['q'])) {
         $title = "回答正确!";
     } else {
         $title = "回答错误!";
     }
     $this->endContext();
     session_destroy();
     return $this->respText($title . "<a href='" . $this->createMobileUrl('show', array('id' => $rid)) . "'>点击查看详情</a>。");
 }
コード例 #6
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileIndex()
 {
     global $_GPC, $_W;
     $from = $_W['fans']['from_user'];
     $rid = intval($_GPC['rid']);
     $weid = intval($_GPC['weid']);
     $date = date('Y-m-d');
     $date = strtotime($date);
     $now = time();
     $profile = fans_search($from);
     $sql = "SELECT * FROM " . tablename('exchange_reply') . " WHERE `rid`=:rid";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     $row['picture'] = $_W['attachurl'] . trim($row['picture'], '/');
     $title = $row['title'];
     //$newcredit = $profile['credit1'] - $row['price'];
     $numax = floor($profile['credit1'] / $row['price']);
     $exchanged = pdo_fetchall("SELECT sum(nums) as enum FROM " . tablename('exchange_record') . " WHERE rid = :rid ", array(':rid' => $rid));
     $userexchangeinfo = pdo_fetchall("SELECT nums, cprice, time FROM " . tablename('exchange_record') . " WHERE rid = :rid AND openid = :openid ", array(':rid' => $rid, ':openid' => $from));
     $usertodayexchang = pdo_fetchall("SELECT * FROM " . tablename('exchange_record') . " WHERE rid = :rid AND openid = :openid AND `time` >= :date ", array(':rid' => $rid, ':openid' => $from, ':date' => $date));
     $usertodaynum = count($usertodayexchang);
     $allowexchange = $row['amount'] - $exchanged['0']['enum'];
     if ($numax >= 1) {
         for ($i = 1; $i <= $numax; $i++) {
             $n = $i;
             $nn[] = $n;
         }
     }
     if (!empty($_GPC['submit'])) {
         if ($usertodaynum >= $row['times']) {
             message('每天只能兑换' . $row['times'] . '次哟~~', 'refresh', 'error');
         }
         if ($_GPC['nums'] <= $allowexchange) {
             $data = array('realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'credit1' => $profile['credit1'] - $_GPC['cprice']);
             fans_update($from, $data);
             $insert = array('weid' => $weid, 'rid' => $rid, 'openid' => $from, 'name' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'nums' => $_GPC['nums'], 'cprice' => $_GPC['cprice'], 'time' => $now);
             if (pdo_insert('exchange_record', $insert)) {
                 $id = pdo_insertid();
             }
         } else {
             die('<script>location.href = "' . $this->createMobileUrl('error', array('rid' => $_GPC['rid'], 'id' => $id)) . '";</script>');
         }
         die('<script>location.href = "' . $this->createMobileUrl('success', array('rid' => $_GPC['rid'], 'id' => $id)) . '";</script>');
     }
     include $this->template('index');
 }
コード例 #7
0
 public function respond()
 {
     global $_GPC, $_W;
     $rid = $this->rule;
     $message = $this->message;
     $from = $message['from'];
     $profile = fans_search($from);
     $sql = "SELECT * FROM " . tablename('hotel_reply') . " WHERE `rid`=:rid LIMIT 1";
     $row = pdo_fetch($sql, array(':rid' => $rid));
     if (empty($row['id'])) {
         return array();
     }
     $now = time();
     $tablenum = $this->module['config']['tablenum'];
     //$reply = pdo_fetchall("SELECT * FROM ".tablename('hotel_order')." WHERE rid = :rid AND openid = :openid ORDER BY time DESC", array(':rid' => $rid, ':openid' => $from ));
     //print_r($cfghost);
     return $this->respNews(array('Title' => $row['title'], 'Description' => $tips . $row['description'], 'PicUrl' => $row['picture'], 'Url' => $this->createMobileUrl('index', array('rid' => $rid))));
 }
コード例 #8
0
 public function respond()
 {
     //这里定义此模块进行消息处理时的具体过程, 请查看WORMWOOD文档来编写你的代码
     global $_W;
     $rid = $this->rule;
     $message = $this->message;
     $content = $message['content'];
     $from_user = $message['from'];
     $fans = fans_search($from_user);
     $reply = pdo_fetch("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
     if (!$this->inContext) {
         $this->beginContext(60);
         return $this->respText($reply['msg']);
     }
     if ($content == '0') {
         $this->endContext();
         session_destroy();
         return $this->respText($reply['msg_fail']);
     }
     if ($content == '1') {
         $msg = pdo_fetchall("SELECT * FROM " . tablename('msg_reply') . " WHERE `rid` = :rid AND `fid` = :fid ORDER BY `id` DESC", array(':rid' => $rid, ':fid' => $fans['id']));
         if (empty($msg)) {
             $this->endContext();
             session_destroy();
             return $this->respText('暂无留言……');
         }
         $i = 1;
         foreach ($msg as $value) {
             $reply_txt = $reply_txt . $i++ . '、' . $value['msg'] . "\t" . date('m-d', $value['create_time']) . "\n";
         }
         $this->endContext();
         session_destroy();
         return $this->respText($reply_txt);
     }
     $insert = array('rid' => $rid, 'fid' => $fans['id'], 'weid' => $_W['weid'], 'msg' => $content, 'create_time' => time());
     if ($id = pdo_insert('msg_reply', $insert)) {
         $this->endContext();
         session_destroy();
         return $this->respText($reply['msg_succ']);
     } else {
         return $this->respText($reply['msg_fail']);
     }
 }
コード例 #9
0
ファイル: site.php プロジェクト: noikiy/mygit
 public function domobileprofile()
 {
     global $_GPC, $_W;
     $profile = fans_search($_W['fans']['from_user'], array('nickname', 'credit1', 'credit2', 'avatar'));
     if (empty($profile['avatar'])) {
         load()->func('communication');
         $openid = $_W['openid'];
         $account = account_fetch($_W['acid']);
         //获取公众号信息
         $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $account['access_token']['token'] . "&openid=" . $openid . "&lang=zh_CN";
         $re = ihttp_get($url);
         //ihttp_get()封装的 http GET 请求方法
         if ($re['code'] == 200) {
             $content = json_decode($re['content'], true);
             if ($content['subscribe'] == 1) {
                 //此人已关注
                 $data = array('nickname' => $content['nickname'], 'gender' => $content['sex'], 'avatar' => $content['headimgurl'], 'resideprovince' => $content['province'], 'residecity' => $content['city'], 'nationality' => $content['country']);
                 pdo_update('mc_members', $data, array('uid' => $_W['member']['uid']));
                 pdo_update('mc_mapping_fans', array('follow' => 1), array('acid' => $_W['acid'], 'openid' => $openid));
                 $profile = fans_search($_W['fans']['from_user'], array('nickname', 'credit1', 'credit2', 'avatar'));
             }
         }
     }
     $carttotal = $this->getCartTotal();
     include $this->template('profile');
 }
コード例 #10
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileGuanhuai()
 {
     global $_GPC, $_W;
     $op = trim($_GPC['op']) ? trim($_GPC['op']) : 'index';
     checkauth();
     $user = fans_search($_W['fans']['from_user'], array('realname', 'mobile'));
     $weid = $_W['weid'];
     $car = pdo_fetch("SELECT * FROM " . tablename('we7car_care') . " WHERE weid = :weid AND from_user = :from_user LIMIT 1", array(':weid' => $_W['weid'], ':from_user' => $_W['fans']['from_user']));
     if (!empty($car)) {
         $car['brand_val'] = $car['brand_id'] . '=' . $car['brand_cn'];
         $car['series_val'] = $car['series_id'] . '=' . $car['series_cn'];
         $car['type_val'] = $car['type_id'] . '=' . $car['type_cn'];
         $car_insurance_nextDate = $car['car_insurance_lastDate'] + 86400 * 90;
         $car_care_nextDate = $car['car_care_nextDate'] + 86400 * 365;
         $insurance_days = floor(($car_insurance_nextDate - TIMESTAMP) / 86400);
         $care_days = floor(($car_insurance_nextDate - TIMESTAMP) / 86400);
         $car['car_startTime'] = $car['car_startTime'] ? date('Y-m-d', $car['car_startTime']) : date('Y-m-d');
         $car['car_insurance_lastDate'] = $car['car_insurance_lastDate'] ? date('Y-m-d', $car['car_insurance_lastDate']) : date('Y-m-d');
         $car['car_care_lastDate'] = $car['car_care_lastDate'] ? date('Y-m-d', $car['car_care_lastDate']) : date('Y-m-d');
     } else {
         $car['car_startTime'] = date('Y-m-d');
         $car['car_insurance_lastDate'] = date('Y-m-d');
         $car['car_care_lastDate'] = date('Y-m-d');
     }
     if ($user) {
         $car['car_userName'] = $user['realname'];
         $car['car_mobile'] = $user['mobile'];
     }
     //获取车主关怀顶部图片
     $banner = pdo_fetchcolumn("SELECT guanhuai_thumb FROM " . tablename('we7car_set') . " WHERE  weid = :weid  ", array(':weid' => $_W['weid']));
     if ($op == 'caredit') {
         $brands = pdo_fetchall("SELECT id,title FROM " . tablename('we7car_brand') . " WHERE `weid` = :weid AND `status` = 1 AND `status` = 1 ORDER BY `listorder` DESC", array(':weid' => $_W['weid']));
         $eseries = pdo_fetchall('SELECT id,title FROM ' . tablename('we7car_series') . " WHERE `weid` = :weid AND `bid` = :bid AND `status` = 1 ORDER BY listorder DESC", array(':weid' => $_W['weid'], ':bid' => $car['brand_id']));
         $etypes = pdo_fetchall('SELECT id,title FROM ' . tablename('we7car_type') . " WHERE `weid` = :weid AND `sid` = :sid AND `status` = 1 ORDER BY listorder DESC", array(':weid' => $_W['weid'], ':sid' => $car['series_id']));
         if (checksubmit('submit')) {
             $brand = explode('=', $_GPC['brand']);
             $series = explode('=', $_GPC['serie']);
             $types = explode('=', $_GPC['types']);
             $insert = array('weid' => $_W['weid'], 'from_user' => $_W['fans']['from_user'], 'brand_id' => intval($brand[0]), 'brand_cn' => trim($brand[1]), 'series_id' => trim($series[0]), 'series_cn' => trim($series[1]), 'type_id' => trim($types[0]), 'type_cn' => trim($types[1]), 'car_note' => trim($_GPC['car_note']), 'car_no' => trim($_GPC['car_no']), 'car_userName' => trim($_GPC['car_userName']), 'car_mobile' => trim($_GPC['car_mobile']), 'car_startTime' => strtotime($_GPC['car_startTime']), 'car_insurance_lastDate' => strtotime($_GPC['car_insurance_lastDate']), 'car_insurance_lastCost' => trim($_GPC['car_insurance_lastCost']), 'car_care_mileage' => trim($_GPC['car_care_mileage']), 'car_care_lastDate' => strtotime($_GPC['car_care_lastDate']), 'car_care_lastCost' => trim($_GPC['car_care_lastCost']), 'car_insurance_lastDate' => strtotime($_GPC['car_insurance_lastDate']), 'createtime' => TIMESTAMP);
             if (!empty($_FILES['car_photo']['tmp_name'])) {
                 $upload = file_upload($_FILES['car_photo']);
                 if (is_error($upload)) {
                     message($upload['message']);
                 }
                 $insert['car_photo'] = $upload['path'];
             }
             if (empty($car['id'])) {
                 $temp = pdo_insert('we7car_care', $insert);
             } else {
                 $temp = pdo_update('we7car_care', $insert, array('id' => $car['id']));
             }
             if ($temp == false) {
                 message('抱歉,更新爱车数据失败!', create_url('mobile/module', array('do' => 'Guanhuai', 'name' => 'car', 'op' => 'caredit', 'from_user' => $_W['fans']['from_user'])), 'error');
             } else {
                 message('更新爱车数据成功!', create_url('mobile/module', array('do' => 'Guanhuai', 'name' => 'car', 'op' => 'index', 'weid' => $weid, 'from_user' => $_W['fans']['from_user'])), 'success');
             }
         }
         include $this->template('guanhuai_caredit');
     }
     if ($op == 'index') {
         include $this->template('guanhuai_index');
     }
 }
コード例 #11
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileReady()
 {
     global $_GPC, $_W;
     $this->check_member();
     $id = intval($_GPC['id']);
     if (empty($id)) {
         exit;
     }
     $weid = $_W['weid'];
     $member_info = $this->getMemberInfo();
     $paper_info = $this->getPaperInfo($id);
     //print_r($paper_info);exit;
     if (checksubmit()) {
         $username = trim($_GPC['username']);
         $mobile = trim($_GPC['mobile']);
         $email = trim($_GPC['email']);
         $data = array();
         $data['realname'] = $username;
         $data['mobile'] = $mobile;
         fans_update($this->_from_user, $data);
         //更新用户信息
         $array = array();
         $array['username'] = $username;
         $array['mobile'] = $mobile;
         $array['email'] = $email;
         $params = array();
         $params['from_user'] = $this->_from_user;
         $params['weid'] = $weid;
         pdo_update('ewei_exam_member', $array, $params);
         //更新考试人数记录
         $this->updatePaperMemberNum($id, 1);
         //插入学员考试记录
         $data = array();
         $data['weid'] = $weid;
         $data['paperid'] = $id;
         $data['memberid'] = $member_info['id'];
         $data['times'] = 0;
         $data['countdown'] = $paper_info['times'] * 60;
         $data['score'] = 0;
         $data['did'] = 0;
         $data['createtime'] = time();
         pdo_insert('ewei_exam_paper_member_record', $data);
         $recordid = pdo_insertid();
         $url = $this->createMobileUrl('start', array('paperid' => $id, 'recordid' => $recordid, 'page' => 1));
         die(json_encode(array("result" => 1, "url" => $url)));
     } else {
         //更新访问人数记录
         $fans = fans_search($_W['fans']['from_user'], array('nickname', 'email', 'mobile'));
         $this->updatePaperMemberNum($id, 0);
         include $this->template('ready');
     }
 }
コード例 #12
0
ファイル: gethome.inc.php プロジェクト: eduNeusoft/weixin
$user['footer'] = $setting['otherFooterLeft'] ? $setting['otherFooterLeft'] : '立即打赏';
$user['meto'] = $setting['otherFooterRight'] ? $setting['otherFooterRight'] : '我也要参加';
$user['checkFollow'] = $_W['siteroot'] . 'app/' . $this->createMobileUrl('checkFollow');
if ($_GPC['uid'] == $_W['member']['uid']) {
    $user['isMe'] = true;
} else {
    $user['isMe'] = false;
}
$user['notMemessage'] = $setting['otherTopMessage'] ? $setting['otherTopMessage'] : '参加乞讨活动,需要向帮好友支付任意金额,支付完成后自动跳转自己的活动链接,请收藏!';
$user['isMemessage'] = $setting['topMessage'] ? $setting['topMessage'] : '赶紧告诉小伙伴吧,凑足了饭钱,就不会饿肚子了!';
if (empty($user['title'])) {
    $user['title'] = '一分也是爱,大爷赏点吧!';
}
$sql = "SELECT * FROM " . tablename('meepo_begging_user') . " WHERE uid = :uid AND status = :status ORDER BY createtime DESC";
$params = array(':uid' => $uid, ':status' => 1);
$items = pdo_fetchall($sql, $params);
foreach ($items as $ri) {
    $user2 = fans_search($ri['fopenid']);
    $ri['avatar'] = $user2['avatar'];
    $ri['nickname'] = $user2['nickname'];
    $ri['time'] = time() - $ri['createtime'];
    $res = get_timef($ri['createtime'], time());
    $date = $res['day'];
    $hour = $res['hour'];
    $minute = $res['min'];
    $second = $res['sec'];
    if (!empty($ri)) {
        $user['items'][] = $ri;
    }
}
die(json_encode($user));
コード例 #13
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileLottery()
 {
     global $_GPC, $_W;
     $title = '刮刮卡';
     if (empty($_W['fans']['from_user'])) {
         message('非法访问,请重新发送消息进入抽奖页面!');
     }
     $fromuser = $_W['fans']['from_user'];
     $profile = fans_require($fromuser, array('realname', 'mobile', 'qq'), '需要完善资料后才能抽奖.');
     $id = intval($_GPC['id']);
     $scratchcard = pdo_fetch("SELECT id, periodlottery, maxlottery, rule, hitcredit, misscredit, background FROM " . tablename('scratchcard_reply') . " WHERE rid = '{$id}' LIMIT 1");
     if (empty($scratchcard)) {
         message('非法访问,请重新发送消息进入抽奖页面!');
     }
     $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('scratchcard_winner') . " WHERE createtime > '" . strtotime(date('Y-m-d')) . "' AND from_user = '******' AND status <> 3 AND award <> ''");
     $member = fans_search($fromuser);
     $myaward = pdo_fetchall("SELECT w.id, w.award, w.description, w.status,a.inkind FROM " . tablename('scratchcard_winner') . " w left join " . tablename('scratchcard_award') . " a on w.aid = a.id  WHERE w.from_user = '******' AND w.aid != '0' AND w.award <> '' AND w.rid = '{$id}' ORDER BY w.createtime DESC");
     $mycredit = pdo_fetchcolumn("SELECT SUM(description) FROM " . tablename('scratchcard_winner') . " WHERE from_user = '******' AND aid = '0' AND award <> '' AND rid = '{$id}'");
     $mycredit = !empty($mycredit) ? $mycredit : '0';
     $allaward = pdo_fetchall("SELECT id, title, probalilty, description, inkind FROM " . tablename('scratchcard_award') . " WHERE rid = '{$id}' ORDER BY id ASC");
     //过期
     if (!empty($scratchcard['periodlottery'])) {
         $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('scratchcard_winner') . " WHERE createtime > '" . strtotime(date('Y-m-d')) . "' AND from_user = '******' AND status <> 3");
         $lastdate = pdo_fetchcolumn("SELECT createtime FROM " . tablename('scratchcard_winner') . " WHERE from_user = '******' AND status <> 3 ORDER BY createtime DESC");
         if ($total >= intval($scratchcard['maxlottery']) && strtotime(date('Y-m-d')) < strtotime(date('Y-m-d', $lastdate)) + $scratchcard['periodlottery'] * 86400) {
             $message = '您还未到达可以再次抽奖的时间<br>下次可抽奖时间为:' . date('Y-m-d', strtotime(date('Y-m-d', $lastdate)) + $scratchcard['periodlottery'] * 86400);
         }
     } else {
         $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('scratchcard_winner') . " WHERE createtime > '" . strtotime(date('Y-m-d')) . "' AND from_user = '******' AND status <> 3");
         if (!empty($scratchcard['maxlottery']) && $total >= $scratchcard['maxlottery']) {
             $message = $scratchcard['periodlottery'] ? '您已经超过当日抽奖次数' : '您已经超过最大抽奖次数';
         }
     }
     include $this->template('lottery');
 }
コード例 #14
0
ファイル: site.php プロジェクト: aspnmy/weizan
 public function doMobileShow()
 {
     global $_W, $_GPC;
     $rid = trim($_GPC['rid']);
     $reply = pdo_fetch("SELECT * FROM " . tablename('bm_qrsign_reply') . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid));
     if (time() > strtotime($reply['endtime'])) {
         if (empty($reply['memo2'])) {
             $msg = '对不起,活动已经于' . $reply['endtime'] . '结束,感谢您的参与!!!';
         } else {
             $msg = $reply['memo2'];
         }
         message($msg, $reply['url2'], 'success');
     }
     if (time() < strtotime($reply['starttime'])) {
         if (empty($reply['memo1'])) {
             $msg = '对不起,活动将于' . $reply['starttime'] . '开始,敬请期待!!!';
         } else {
             $msg = $reply['memo1'];
         }
         message($msg, $reply['url1'], 'success');
     }
     if (empty($_W['fans']['nickname'])) {
         mc_oauth_userinfo();
     }
     if ($reply['pictype'] == 1) {
         if (empty($_W['fans']['follow']) || $_W['fans']['follow'] == 0) {
             header("Location: " . $reply['urlx']);
             exit;
         }
     }
     $op = trim($_GPC['op']);
     $qrmoney = $_GPC['qrmoney'];
     $from_user = $_W['fans']['openid'];
     $qrpicurl = $_W['attachurl'] . $reply['qrcode'];
     if ($op == 'post') {
         if ($qrmoney < 0.01) {
             message('支付金额错误,请重新录入!', $this->createMobileUrl('show', array('rid' => $rid, 'from_user' => $from_user)), 'error');
         }
         $data = array('rid' => $rid, 'dateline' => TIMESTAMP, 'clientOrderId' => TIMESTAMP, 'qrmoney' => $qrmoney, 'status' => 0, 'fromuser' => $from_user, 'username' => $_W['fans']['nickname'], 'avatar' => $_W['fans']['tag']['avatar'], 'credit' => $reply['n']);
         pdo_insert('bm_qrsign_payed', $data);
         $params = array('tid' => $data['clientOrderId'], 'ordersn' => $data['clientOrderId'], 'title' => '扫码支付', 'fee' => $data['qrmoney'], 'user' => $from_user);
         $this->pay($params);
         exit;
     } else {
         if ($op == 'sign') {
             $rec = pdo_fetch("select * from " . tablename('bm_qrsign_record') . " where rid= " . $rid . " and fromuser= '******' order by sign_time desc");
             if (!empty($rec)) {
                 $Date_1 = date("Y-m-d", time());
                 $Date_2 = date("Y-m-d", $rec['sign_time']);
                 $Date_List_a1 = explode("-", $Date_1);
                 $Date_List_a2 = explode("-", $Date_2);
                 $d1 = mktime(0, 0, 0, $Date_List_a1[1], $Date_List_a1[2], $Date_List_a1[0]);
                 $d2 = mktime(0, 0, 0, $Date_List_a2[1], $Date_List_a2[2], $Date_List_a2[0]);
                 $Days = round(($d1 - $d2) / 3600 / 24);
                 if ($Days == 0) {
                     $msg = '感谢您的参与,每个人每天只可以签到一次哦!!!';
                     message($msg, $reply['urly'], 'success');
                 }
             }
             $insert = array('rid' => $rid, 'fromuser' => $from_user, 'username' => $_W['fans']['nickname'], 'avatar' => $_W['fans']['tag']['avatar'], 'sign_time' => $_W['timestamp'], 'credit' => $reply['n']);
             pdo_insert('bm_qrsign_record', $insert);
             $user = fans_search($from_user);
             $sql_member = "SELECT a.uid FROM " . tablename('mc_mapping_fans') . " a inner join " . tablename('mc_members') . " b on a.uid=b.uid WHERE a.openid='{$from_user}'";
             $uid = pdo_fetchcolumn($sql_member);
             mc_credit_update($uid, 'credit1', intval($reply['n']), array(0 => 'system', 1 => '扫码签到送积分'));
             $user = fans_search($from_user);
             $msg = '恭喜签到成功,您已获得奖励积分' . $reply['n'] . '分,您目前的总积分为' . $user['credit1'] . '分!';
             message($msg, $reply['urly'], 'success');
         }
     }
     include $this->template('show');
 }
コード例 #15
0
ファイル: site.php プロジェクト: eduNeusoft/weixin
 public function doWebManage()
 {
     global $_W, $_GPC;
     $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'display';
     $rid = intval($_GPC['id']);
     if ($operation == 'display') {
         $pindex = max(1, intval($_GPC['page']));
         $psize = 50;
         if (!empty($_GPC['nickname'])) {
             $openids = pdo_fetchall("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE nickname LIKE :nickname", array(':nickname' => '%' . $_GPC['nickname'] . '%'), 'openid');
             if (!empty($openids)) {
                 $condition = " AND openid IN ('" . implode("','", array_keys($openids)) . "')";
             }
         }
         if (!empty($condition) || empty($_GPC['nickname'])) {
             $list = pdo_fetchall("SELECT * FROM " . tablename('shake_member') . " WHERE rid = :rid {$condition} ORDER BY shakecount DESC LIMIT " . ($pindex - 1) * $psize . ',' . $psize, array(':rid' => $rid), 'openid');
             $total = pdo_fetchcolumn('SELECT COUNT(*) FROM ' . tablename('shake_member') . " WHERE rid = :rid {$condition}", array(':rid' => $rid));
             $pager = pagination($total, $pindex, $psize);
             load()->model('mc');
             $fans = mc_fetch(array_keys($list), array('realname', 'mobile'));
         }
     } elseif ($operation == 'post') {
         $id = intval($_GPC['id']);
         $item = pdo_fetch("SELECT * FROM " . tablename('shake_member') . " WHERE id = '{$id}'");
         if (checksubmit('submit')) {
             pdo_update('shake_member', array('remark' => $_GPC['remark']), array('id' => $id));
             message('更新信息成功!', $this->createWebUrl('manage', array('id' => $item['rid'])), 'success');
         }
         $item['profile'] = fans_search($item['openid'], array('mobile', 'realname'));
     }
     include $this->template('manage');
 }
コード例 #16
0
ファイル: site.php プロジェクト: keycoolkui/weixinfenxiao
 public function doMobileUcount()
 {
     global $_GPC, $_W;
     $effective = true;
     $msg = "输送体力未成功";
     $useragent = addslashes($_SERVER['HTTP_USER_AGENT']);
     if (strpos($useragent, 'MicroMessenger') === false && strpos($useragent, 'Windows Phone') === false) {
         $effective = false;
         $msg = "只能在微信中输送哦!";
     }
     $id = intval($_GPC['id']);
     $uid = intval($_GPC['uid']);
     if (!$uid) {
         $effective = false;
     }
     $url = $this->createMobileUrl('rank', array('id' => $id));
     $user = pdo_fetch("SELECT * FROM " . tablename('zzz_user') . " WHERE id = '{$uid}' and rid=" . $id . " LIMIT 1");
     if ($user) {
         $member = fans_search($user['from_user']);
         if ($uid && $effective) {
             if (!isset($_COOKIE["hlzzzx"])) {
                 setcookie('hlzzzx', 1, TIMESTAMP + 86400);
                 $data = array('count' => $user['count'] + 1, 'friendcount' => $user['friendcount'] + 1);
                 pdo_update('zzz_user', $data, array('id' => $uid, 'rid' => $id));
                 $msg = '你已成功为' . $member['nickname'] . '输送体力!';
             } else {
                 $msg = '一天只能输送一次体力哦!';
             }
         }
     }
     message($msg, $url);
 }
コード例 #17
0
ファイル: site.php プロジェクト: keycoolkui/weixinfenxiao
 public function setOrderCredit($orderid, $add = true)
 {
     $order = pdo_fetch("SELECT * FROM " . tablename($this->modulename . '_order') . " WHERE id=:id LIMIT 1", array(':id' => $orderid));
     if (empty($order)) {
         return false;
     }
     $ordergoods = pdo_fetchall("SELECT goodsid, total FROM " . tablename($this->modulename . '_order_goods') . " WHERE orderid = '{$orderid}'", array(), 'goodsid');
     if (!empty($ordergoods)) {
         $goods = pdo_fetchall("SELECT * FROM " . tablename($this->modulename . '_goods') . " WHERE id IN ('" . implode("','", array_keys($ordergoods)) . "')");
     }
     //增加积分
     if (!empty($goods)) {
         $credits = 0;
         foreach ($goods as $g) {
             $credits += $g['credit'] * $g['total'];
         }
         load()->model('mc');
         load()->func('compat.biz');
         $uid = mc_openid2uid($order['from_user']);
         $fans = fans_search($uid, array("credit1"));
         if (!empty($fans)) {
             //                if ($add) {
             //                    $new_credit = $credits + $fans['credit1'];
             //                } else {
             //                    $new_credit = $fans['credit1'] - $credits;
             //                    if ($new_credit <= 0) {
             //                        $new_credit = 0;
             //                    }
             //                }
             $uid = intval($fans['uid']);
             $remark = $add == true ? '微点餐积分奖励 订单ID:' . $orderid : '微点餐积分扣除 订单ID:' . $orderid;
             $log = array();
             $log[0] = $uid;
             $log[1] = $remark;
             mc_credit_update($uid, 'credit1', $credits, $log);
             //pdo_update('mc_members', array("credit1" => $new_credit), array('uid' => $uid));
         }
     }
     return true;
 }
コード例 #18
0
    //找出总价格
    $row = pdo_fetchall("SELECT total,price FROM " . tablename('shopping3_cart') . " WHERE from_user = :from_user AND weid = '{$weid}' ", array(':from_user' => $_W['fans']['from_user']));
    $totalnum = 0;
    $totalprice = 0;
    foreach ($row as $v) {
        $totalnum = $totalnum + intval($v['total']);
        $totalprice = $totalprice + intval($v['total']) * floatval($v['price']);
    }
    include $this->template('wl_checkout');
} else {
    $cart = pdo_fetchall("SELECT * FROM " . tablename('shopping3_cart') . " WHERE  weid = '{$weid}' AND from_user = '******'fans']['from_user']}'", array(), 'goodsid');
    $otalprice = 0;
    if (!empty($cart)) {
        $goods = pdo_fetchall("SELECT id, title, thumb, marketprice, unit, total FROM " . tablename('shopping3_goods') . " WHERE id IN ('" . implode("','", array_keys($cart)) . "')");
        if (!empty($goods)) {
            foreach ($goods as $row) {
                if (empty($cart[$row['id']]['total'])) {
                    continue;
                }
                //购物车不考虑库存
                /* if ($row['total'] != -1 && $row['total'] < $cart[$row['id']]['total']) {
                				message('抱歉,“'.$row['title'].'”此商品库存不足!', $this->createMobileUrl('wlcart'), 'error');
                			} */
                $price += floatval($row['marketprice']) * intval($cart[$row['id']]['total']);
            }
        }
    }
    //				fans_update($_W['fans']['from_user'], $newsfans);
    $fans = fans_search($from, array('nickname', 'mobile', 'gender', 'address'));
    include $this->template('wl_cart');
}
コード例 #19
0
ファイル: site.php プロジェクト: ChainBoy/wxfx
 public function doWebSpread()
 {
     global $_W, $_GPC;
     load()->func('tpl');
     if (!$_W['ispost']) {
         $this->doWebAuth();
         checklogin();
     }
     $op = empty($_GPC['op']) ? 'leaflet' : $_GPC['op'];
     $rulekeywordcount = pdo_fetchcolumn("SELECT count(id) FROM " . tablename('rule_keyword') . " WHERE uniacid=:uniacid and module='wwx_fxxt' and content='二维码'", array(":uniacid" => $_W['uniacid']));
     $boolrule = false;
     if ($rulekeywordcount >= 1) {
         $boolrule = true;
     }
     if ($op == 'checkspreadrule') {
         if (!empty($_GPC['boolrule'])) {
             $rulekeywordcount = pdo_fetchall("SELECT rid FROM " . tablename('rule_keyword') . " WHERE uniacid=:uniacid and module='wwx_fxxt' and content='二维码'", array(":uniacid" => $_W['uniacid']));
             foreach ($rulekeywordcount as $k => $v) {
                 pdo_delete('rule', array('id' => $v['rid'], 'uniacid' => $_W['uniacid'], 'module' => 'wwx_fxxt'));
             }
             pdo_delete('rule_keyword', array('module' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'], 'content' => '二维码'));
             $insert = array('uniacid' => $_W['uniacid'], 'name' => '二维码(系统维护)', 'module' => 'wwx_fxxt', 'displayorder' => 0, 'status' => 1);
             pdo_insert('rule', $insert);
             $rid = pdo_insertid();
             $insert = array('uniacid' => $_W['uniacid'], 'rid' => $rid, 'module' => 'wwx_fxxt', 'content' => '二维码', 'type' => 1, 'displayorder' => 0, 'status' => 1);
             pdo_insert('rule_keyword', $insert);
             message('设置分销专属二维码成功,请进入自定义菜单绑定关键字\'二维码\'!', referer(), 'success');
         } else {
             if ($boolrule == true) {
                 $rulekeywordcount = pdo_fetchall("SELECT rid FROM " . tablename('rule_keyword') . " WHERE uniacid=:uniacid and module='wwx_fxxt' and content='二维码'", array(":uniacid" => $_W['uniacid']));
                 foreach ($rulekeywordcount as $k => $v) {
                     pdo_delete('rule', array('id' => $v['rid'], 'uniacid' => $_W['uniacid'], 'module' => 'wwx_fxxt'));
                 }
                 pdo_delete('rule_keyword', array('module' => 'wwx_fxxt', 'uniacid' => $_W['uniacid'], 'content' => '二维码'));
                 message('系统已去除分销专属\'二维码\'关键字触发', referer(), 'success');
             }
         }
         $op = 'leaflet';
     }
     if ($op == 'delete') {
         pdo_update('wwx_fxxt_channel', array('isdel' => 1, 'createtime' => time()), array('channel' => $_GPC['channel'], "uniacid" => $_W['uniacid']));
         message("删除成功", referer(), "success");
     } else {
         if ($op == 'leaflet') {
             $mylist = pdo_fetchall("SELECT * FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid and isdel=0", array(":uniacid" => $_W['uniacid']));
         } else {
             if ($op == 'active') {
                 $channel = intval($_GPC['channel']);
                 pdo_update('wwx_fxxt_channel', array('active' => 0), array('uniacid' => $_W['uniacid']));
                 pdo_update('wwx_fxxt_channel', array('createtime' => time()), array('uniacid' => $_W['uniacid'], 'channel' => $channel));
                 pdo_update('wwx_fxxt_channel', array('createtime' => time(), 'active' => 1), array('uniacid' => $_W['uniacid'], 'channel' => $channel));
                 message('设定当前活跃传单成功', referer(), 'success');
             } else {
                 if ($op == 'post') {
                     $item = array();
                     if (!empty($_GPC['channel'])) {
                         $item = pdo_fetch("SELECT * FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid AND channel=:channel", array(":uniacid" => $_W['uniacid'], ":channel" => $_GPC['channel']));
                     }
                     $item = $this->decode_channel_param($item, $item['bgparam']);
                     ///12.生成二维码位置信息等等
                     if (checksubmit('submit')) {
                         $tagArr = explode('.', $_GPC['bg']);
                         $tagArr = end($tagArr);
                         if (strcasecmp('jpg', $tagArr) != 0) {
                             message('传单背景图必须是jpg格式。不支持png等其他格式。', referer(), 'error');
                         }
                         $bgparam = $this->encode_channel_param($_GPC);
                         ///12.1生成二维码位置信息等等
                         $msgtype = empty($_GPC['msgtype']) ? 1 : $_GPC['msgtype'];
                         if (!empty($_GPC['channel'])) {
                             pdo_delete('wwx_fxxt_qr', array('uniacid' => $_W['uniacid']));
                             pdo_update('wwx_fxxt_channel', array('title' => $_GPC['title'], 'createtime' => time(), 'bg' => $_GPC['bg'], 'msgtype' => $msgtype, 'bgparam' => $bgparam, 'notice' => $_GPC['notice']), array('channel' => $_GPC['channel'], 'uniacid' => $_W['uniacid']));
                             pdo_update('wwx_fxxt_qr', array('expiretime' => 1), array('channel' => $_GPC['channel']));
                             message('更新成功', referer(), 'success');
                         } else {
                             $list_count = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('wwx_fxxt_channel') . " WHERE uniacid=:uniacid and isdel=0", array(":uniacid" => $_W['uniacid']));
                             $active = $list_count == 0;
                             pdo_insert('wwx_fxxt_channel', array('title' => $_GPC['title'], 'createtime' => time(), 'notice' => $_GPC['notice'], 'msgtype' => $msgtype, 'bg' => $_GPC['bg'], 'bgparam' => $bgparam, 'active' => $active, 'isdel' => 0, 'uniacid' => $_W['uniacid']));
                             message('新建成功', $this->createWebUrl('spread', array('op' => 'leaflet')), 'success');
                         }
                     }
                 } else {
                     if ($op == 'log') {
                         $pindex = max(1, intval($_GPC['page']));
                         $psize = 100;
                         $my_follows_sql = "select l.createtime createtime, l.nickname, l.avatar, v.openid,v.follower_count from " . tablename('mc_members') . " l,(select a.uid, a.openid, count(b.from_user) follower_count from " . tablename('mc_mapping_fans') . " a left join  " . tablename('wwx_fxxt_share_history') . " b on b.uniacid=a.uniacid and b.sharemid=(select x.id from " . tablename('wwx_fxxt_member') . " x where x.uniacid=:uniacid and x.from_user=a.openid  limit 1)  and b.from_user!=a.openid  where a.openid in(\nselect from_user from " . tablename('mc_mapping_fans') . "  where uniacid=:uniacid and follow=1 UNION (select from_user from " . tablename('wwx_fxxt_share_history') . " where uniacid=:uniacid )\nUNION (select m.from_user from " . tablename('wwx_fxxt_member') . " m where m.uniacid = :uniacid))) v where l.uid=v.uid group by v.openid ORDER BY follower_count DESC LIMIT " . ($pindex - 1) * $psize . ",{$psize}";
                         $mylist = pdo_fetchall($my_follows_sql, array(':uniacid' => $_W['uniacid']));
                         if (!empty($mylist)) {
                             $total = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b WHERE a.uniacid=:uniacid and a.uid=b.uid", array(':uniacid' => $_W['uniacid']));
                             $pager = pagination($total, $pindex, $psize);
                         }
                     } else {
                         if ($op == 'user') {
                             $from_user = $_GPC['from_user'];
                             $fans = fans_search($from_user, array('nickname', 'createtime', 'credit1'));
                             $myheadimg = pdo_fetchcolumn('SELECT avatar FROM ' . tablename('mc_mapping_fans') . " a, " . tablename('mc_members') . " b WHERE a.uniacid = :uniacid  AND a.openid = :openid and a.uid=b.uid LIMIT 1", array(':uniacid' => $_W['uniacid'], ':openid' => $from_user));
                             $fans['avatar'] = $myheadimg;
                             $mylist = pdo_fetchall("select d.createtime d.createtime, d.nickname, d.avatar from " . tablename('mc_members') . " d,(SELECT b.uid uid FROM " . tablename('wwx_fxxt_share_history') . " a LEFT JOIN " . tablename('mc_mapping_fans') . " b ON a.uniacid=b.uniacid and a.from_user = b.openid WHERE a.sharemid = (select id from " . tablename('wwx_fxxt_member') . " c where c.from_user=:leader and c.uniacid=:uniacid  limit 1) and a.from_user!=:leader AND a.uniacid=:uniacid) e where d.uid=e.uid ", array(':leader' => $from_user, ':uniacid' => $_W['uniacid']));
                         } else {
                             message('error!', '', 'error');
                         }
                     }
                 }
             }
         }
     }
     include $this->template('spread');
 }
コード例 #20
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileResearch()
 {
     global $_W, $_GPC;
     $reid = intval($_GPC['id']);
     $tableName = $_GPC['tableName'];
     $sql = 'SELECT * FROM ' . tablename('research') . ' WHERE `weid`=:weid AND `reid`=:reid';
     $params = array();
     $params[':weid'] = $_W['weid'];
     $params[':reid'] = $reid;
     $activity = pdo_fetch($sql, $params);
     $title = $activity['title'];
     if ($activity['status'] != '1') {
         message('当前预约活动已经停止.');
     }
     if (!$activity) {
         message('非法访问.');
     }
     if ($activity['starttime'] > TIMESTAMP) {
         message('当前预约活动还未开始!');
     }
     if ($activity['endtime'] < TIMESTAMP) {
         message('当前预约活动已经结束!');
     }
     $sql = 'SELECT * FROM ' . tablename('research_fields') . ' WHERE `reid`=:reid ORDER BY `refid`';
     $params = array();
     $params[':reid'] = $reid;
     $ds = pdo_fetchall($sql, $params);
     if (!$ds) {
         message('非法访问.');
     }
     if (checksubmit()) {
         $pretotal = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('research_rows') . " WHERE reid = :reid AND openid = :openid", array(':reid' => $reid, ':openid' => $_W['fans']['from_user']));
         if ($pretotal >= $activity['pretotal']) {
             message('抱歉!每人只能提交' . $activity['pretotal'] . "次!", referer(), 'error');
         }
         //start
         $tableType = $_GPC['field_34'];
         $booktime = empty($_GPC['field_38']) ? strtotime(date('Y-m-d')) : strtotime($_GPC['field_38']);
         $totalRooms = pdo_fetchcolumn("SELECT tableAmount FROM " . tablename('research_tables') . " WHERE tableName = :tableName ", array(':tableName' => $tableType));
         $checkAmount = pdo_fetchcolumn("SELECT COUNT(*) FROM " . tablename('research_bookdetails') . " WHERE tableName = :tableName and arrivalDate = :arrivalDate", array(':tableName' => $tableType, ':arrivalDate' => $booktime));
         if ($checkAmount + 1 > $totalRooms) {
             message('此房间已经预定满!', '', 'tips');
         }
         //end
         $row = array();
         $row['reid'] = $reid;
         $row['openid'] = $_W['fans']['from_user'];
         $row['createtime'] = TIMESTAMP;
         $datas = array();
         $fields = array();
         foreach ($ds as $r) {
             $fields[$r['refid']] = $r;
         }
         foreach ($_GPC as $key => $value) {
             if (strexists($key, 'field_')) {
                 $refid = intval(str_replace('field_', '', $key));
                 $field = $fields[$refid];
                 if ($refid && $field) {
                     $entry = array();
                     $entry['reid'] = $reid;
                     $entry['rerid'] = 0;
                     $entry['refid'] = $refid;
                     if (in_array($field['type'], array('number', 'text', 'calendar', 'email', 'textarea', 'radio', 'range', 'select'))) {
                         $entry['data'] = strval($value);
                     }
                     if (in_array($field['type'], array('checkbox'))) {
                         if (!is_array($value)) {
                             continue;
                         }
                         $entry['data'] = implode(';', $value);
                     }
                     $datas[] = $entry;
                 }
             }
         }
         if ($_FILES) {
             foreach ($_FILES as $key => $file) {
                 if (strexists($key, 'field_')) {
                     $refid = intval(str_replace('field_', '', $key));
                     $field = $fields[$refid];
                     if ($refid && $field && $file['name'] && $field['type'] == 'image') {
                         $entry = array();
                         $entry['reid'] = $reid;
                         $entry['rerid'] = 0;
                         $entry['refid'] = $refid;
                         $ret = file_upload($file);
                         if (!$ret['success']) {
                             message('上传图片失败, 请稍后重试.');
                         }
                         $entry['data'] = trim($ret['path']);
                         $datas[] = $entry;
                     }
                 }
             }
         }
         if (empty($datas)) {
             message('非法访问.', '', 'error');
         }
         if (pdo_insert('research_rows', $row) != 1) {
             message('保存失败.');
         }
         $rerid = pdo_insertid();
         if (empty($rerid)) {
             message('保存失败.');
         }
         foreach ($datas as &$r) {
             $r['rerid'] = $rerid;
             pdo_insert('research_data', $r);
         }
         //插入到 ims_research_booktable_details
         $detailsData = array();
         $detailsData['tableName'] = $_GPC['field_34'];
         $detailsData['personNo'] = $_GPC['field_35'];
         $detailsData['contact'] = $_GPC['field_36'];
         $detailsData['phone'] = $_GPC['field_37'];
         $arrivalDate = empty($_GPC['field_38']) ? TIMESTAMP : strtotime($_GPC['field_38']);
         $detailsData['arrivalDate'] = $arrivalDate;
         $detailsData['remark'] = $_GPC['field_39'];
         $detailsData['status'] = 'P';
         $detailsData['createtime'] = time();
         pdo_insert('research_bookdetails', $detailsData);
         if (empty($activity['starttime'])) {
             $record = array();
             $record['starttime'] = TIMESTAMP;
             pdo_update('research', $record, array('reid' => $reid));
         }
         //发送预约
         if (!empty($datas) && !empty($activity['noticeemail'])) {
             foreach ($datas as $row) {
                 $body .= "{$fields[$row['refid']]['title']} : {$row['data']} <br />";
             }
             ihttp_email($activity['noticeemail'], $activity['title'] . '的预约提醒', $body);
         }
         message($activity['information'], 'refresh');
     }
     $initRange = false;
     $initCalendar = false;
     $binds = array();
     foreach ($ds as &$r) {
         if ($r['type'] == 'range') {
             $initRange = true;
         }
         if ($r['type'] == 'calendar') {
             $initCalendar = true;
         }
         if ($r['value']) {
             $r['options'] = explode(',', $r['value']);
         }
         if ($r['bind']) {
             $binds[] = $r['bind'];
         }
     }
     if (!empty($_W['fans']['from_user']) && !empty($binds)) {
         $profile = fans_search($_W['fans']['from_user'], $binds);
         if ($profile['gender']) {
             if ($profile['gender'] == '0') {
                 $profile['gender'] = '保密';
             }
             if ($profile['gender'] == '1') {
                 $profile['gender'] = '男';
             }
             if ($profile['gender'] == '2') {
                 $profile['gender'] = '女';
             }
         }
         foreach ($ds as &$r) {
             if ($profile[$r['bind']]) {
                 $r['default'] = $profile[$r['bind']];
             }
         }
     }
     include $this->template('submit');
 }
コード例 #21
0
    }
    foreach ($_W['modules'] as $name => $module) {
        if (isset($membermodules[$module['mid']]) || !empty($module['issystem']) || in_array($module['mid'], (array) $groupsmodules['modules'])) {
            $modulesimple = array('mid' => $module['mid'], 'name' => $module['name'], 'title' => $module['title']);
            $_W['account']['modules'][$module['name']] = $module;
            if ($accountmodules[$module['mid']]['config']) {
                $_W['account']['modules'][$module['name']]['config'] = $accountmodules[$module['mid']]['config'];
            }
        }
    }
}
unset($membermodules);
unset($_W['modules']);
$session = json_decode(base64_decode($_GPC['__msess']), true);
if (is_array($session)) {
    $row = fans_search($session['openid'], array('id', 'salt', 'weid', 'from_user', 'follow', 'createtime', 'nickname', 'avatar'));
    if (!empty($row) && $row['weid'] == $_W['weid']) {
        $hash = substr(md5("{$session['openid']}{$row['salt']}{$_W['config']['setting']['authkey']}"), 5, 5);
        if ($session['hash'] == $hash) {
            unset($row['salt']);
            $_W['fans'] = $row;
        }
    }
    if (!empty($_W['account']['modules']['member'])) {
        $row = pdo_fetch("SELECT * FROM " . tablename('card_members') . " WHERE from_user = :from_user AND weid = :weid", array(':from_user' => $session['openid'], ':weid' => $_W['weid']));
        $row1 = pdo_fetch("SELECT * FROM " . tablename('fans') . " WHERE from_user = :from_user AND weid = :weid", array(':from_user' => $session['openid'], ':weid' => $_W['weid']));
        $cardlevel = pdo_fetch("SELECT * FROM " . tablename('card') . " WHERE weid = '{$_W['weid']}'");
        if (!empty($row)) {
            if (!empty($row1['avatarfixed'])) {
                $_W['fans']['avatar'] = $row1['avatarfixed'];
            }
コード例 #22
0
ファイル: site.php プロジェクト: aspnmy/weizan
 public function doMobileResearch()
 {
     global $_W, $_GPC;
     $reid = intval($_GPC['id']);
     $sql = 'SELECT * FROM ' . tablename('research') . ' WHERE `weid`=:weid AND `reid`=:reid';
     $params = array();
     $params[':weid'] = $_W['uniacid'];
     $params[':reid'] = $reid;
     $activity = pdo_fetch($sql, $params);
     if (empty($_W['fans']['openid'])) {
         message('请先关注公众号再来参加活动吧!');
     }
     if ($activity['status'] != '1') {
         message('当前预约活动已经停止.');
     }
     if (!$activity) {
         message('非法访问.');
     }
     if ($activity['starttime'] > TIMESTAMP) {
         message('当前预约活动还未开始!');
     }
     if ($activity['endtime'] < TIMESTAMP) {
         message('当前预约活动已经结束!');
     }
     $title = $activity['title'];
     $sql = 'SELECT * FROM ' . tablename('research_fields') . ' WHERE `reid` = :reid ORDER BY `displayorder` DESC, `refid`';
     $params = array();
     $params[':reid'] = $reid;
     $ds = pdo_fetchall($sql, $params);
     if (!$ds) {
         message('非法访问.');
     }
     $initRange = $initCalendar = false;
     $binds = array();
     foreach ($ds as &$r) {
         if ($r['type'] == 'range') {
             $initRange = true;
         }
         if ($r['type'] == 'calendar') {
             $initCalendar = true;
         }
         if ($r['value']) {
             $r['options'] = explode(',', $r['value']);
         }
         if ($r['bind']) {
             $binds[$r['type']] = $r['bind'];
         }
         if ($r['type'] == 'reside') {
             $reside = $r;
         }
     }
     if (checksubmit('submit')) {
         $sql = 'SELECT COUNT(*) FROM ' . tablename('research_rows') . ' WHERE `reid` = :reid AND `openid` = :openid';
         $params = array(':reid' => $reid, ':openid' => $_W['fans']['from_user']);
         $pretotal = pdo_fetchcolumn($sql, $params);
         if ($pretotal >= $activity['pretotal']) {
             message('抱歉,每人只能预约' . $activity['pretotal'] . "次!", referer(), 'error');
         }
         $sql = 'SELECT `rerid` FROM ' . tablename('research_rows') . ' WHERE `reid` = :reid GROUP BY `openid`';
         unset($params[':openid']);
         $allTotal = pdo_fetchall($sql, $params);
         if (count($allTotal) >= $activity['alltotal']) {
             pdo_update('research', array('endtime' => TIMESTAMP), array('reid' => $reid));
             message('当前预约活动已经结束!');
         }
         $row = array();
         $row['reid'] = $reid;
         $row['openid'] = $_W['fans']['from_user'];
         $row['createtime'] = TIMESTAMP;
         $datas = $fields = $update = array();
         foreach ($ds as $value) {
             $fields[$value['refid']] = $value;
         }
         foreach ($_GPC as $key => $value) {
             if (strexists($key, 'field_')) {
                 $bindFiled = substr(strrchr($key, '_'), 1);
                 if (!empty($bindFiled)) {
                     $update[$bindFiled] = $value;
                 }
                 $refid = intval(str_replace('field_', '', $key));
                 $field = $fields[$refid];
                 if ($refid && $field) {
                     $entry = array();
                     $entry['reid'] = $reid;
                     $entry['rerid'] = 0;
                     $entry['refid'] = $refid;
                     if (in_array($field['type'], array('number', 'text', 'calendar', 'email', 'textarea', 'radio', 'range', 'select', 'image'))) {
                         $entry['data'] = strval($value);
                     }
                     if (in_array($field['type'], array('checkbox'))) {
                         if (!is_array($value)) {
                             continue;
                         }
                         $entry['data'] = implode(';', $value);
                     }
                     $datas[] = $entry;
                 }
             }
         }
         if ($_FILES) {
             load()->func('file');
             foreach ($_FILES as $key => $file) {
                 if (strexists($key, 'field_')) {
                     $refid = intval(str_replace('field_', '', $key));
                     $field = $fields[$refid];
                     if ($refid && $field && $file['name'] && $field['type'] == 'image') {
                         $entry = array();
                         $entry['reid'] = $reid;
                         $entry['rerid'] = 0;
                         $entry['refid'] = $refid;
                         $ret = file_upload($file);
                         if (!$ret['success']) {
                             message('上传图片失败, 请稍后重试.');
                         }
                         $entry['data'] = trim($ret['path']);
                         $datas[] = $entry;
                     }
                 }
             }
         }
         // 兼容会员居住地字段
         if (!empty($_GPC['reside'])) {
             if (in_array('reside', $binds)) {
                 $update['resideprovince'] = $_GPC['reside']['province'];
                 $update['residecity'] = $_GPC['reside']['city'];
                 $update['residedist'] = $_GPC['reside']['district'];
             }
             foreach ($_GPC['reside'] as $key => $value) {
                 $resideData = array('reid' => $reside['reid']);
                 $resideData['rerid'] = 0;
                 $resideData['refid'] = $reside['refid'];
                 $resideData['data'] = $value;
                 $datas[] = $resideData;
             }
         }
         // 更新关联会员资料
         if (!empty($update)) {
             load()->model('mc');
             mc_update($_W['member']['uid'], $update);
         }
         if (empty($datas)) {
             message('非法访问.', '', 'error');
         }
         if (pdo_insert('research_rows', $row) != 1) {
             message('保存失败.');
         }
         $rerid = pdo_insertid();
         if (empty($rerid)) {
             message('保存失败.');
         }
         foreach ($datas as &$r) {
             $r['rerid'] = $rerid;
             pdo_insert('research_data', $r);
         }
         if (empty($activity['starttime'])) {
             $record = array();
             $record['starttime'] = TIMESTAMP;
             pdo_update('research', $record, array('reid' => $reid));
         }
         if (!empty($datas)) {
             $image = $body = '';
             foreach ($datas as $row) {
                 if (substr($row['data'], 0, 6) != 'images') {
                     $body .= '<h4>' . $fields[$row['refid']]['title'] . ':' . $row['data'] . '</h4>';
                 } else {
                     $image .= '<p>' . $fields[$row['refid']]['title'] . ': <img src="' . tomedia($row['data']) . '" /></p>';
                 }
             }
             // 发送邮件提醒
             if (!empty($activity['noticeemail'])) {
                 load()->func('communication');
                 ihttp_email($activity['noticeemail'], $activity['title'] . '的预约提醒', $image . $body);
             }
             // 发送短信提醒
             if (!empty($activity['mobile'])) {
                 load()->model('cloud');
                 cloud_prepare();
                 $body = '项目' . $activity['title'] . '于' . date('Y-m-d H:i') . '有了新的预约信息,请到后台查看具体内容.' . random(3);
                 cloud_sms_send($activity['mobile'], $body);
             }
         }
         message($activity['information'], 'refresh');
     }
     // 兼容会员居住地字段
     foreach ($binds as $key => $value) {
         if ($value == 'reside') {
             unset($binds[$key]);
             $binds[] = 'resideprovince';
             $binds[] = 'residecity';
             $binds[] = 'residedist';
             break;
         }
     }
     if (!empty($_W['fans']['from_user']) && !empty($binds)) {
         $profile = fans_search($_W['fans']['from_user'], $binds);
         if ($profile['gender']) {
             if ($profile['gender'] == '0') {
                 $profile['gender'] = '保密';
             }
             if ($profile['gender'] == '1') {
                 $profile['gender'] = '男';
             }
             if ($profile['gender'] == '2') {
                 $profile['gender'] = '女';
             }
         }
         foreach ($ds as &$r) {
             if ($profile[$r['bind']]) {
                 $r['default'] = $profile[$r['bind']];
             }
         }
     }
     load()->func('tpl');
     include $this->template('submit');
 }
コード例 #23
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 /**
  * [doMobileSlotmac 进入活动页面]
  * @return [type] [description]
  */
 public function doMobileSlotmac()
 {
     global $_W, $_GPC;
     $weid = $_GPC['weid'];
     checklogin();
     //时间中奖
     $prizestat = '';
     //所中奖项
     $prizenow = '';
     $prizeid = 0;
     if (!empty($_GPC['weid'])) {
         //获取活动id
         $hdid = $_GPC['macid'];
         /*
         $op = new Model('openid');
         $op->find(array('wid'=>$wid,'wxid'=>$wxid));
         */
         if (empty($_W['fans']['from_user']) || 'fromuser' == $_W['fans']['from_user']) {
             message('非法访问,请重新发送消息进入砸蛋页面!');
         }
         $fromuser = $_W['fans']['from_user'];
         //查找用户信息
         $member = fans_search($fromuser, array('nickname', 'mobile'));
         //查找对应活动的信息
         $hd = pdo_fetch('SELECT * FROM ' . tablename('slotmac') . " WHERE weid='{$_W['weid']}' AND id='{$hdid}'");
         if ($hd['starttime'] > time()) {
             include $this->template('activitynotscratch');
         } elseif ($hd['endtime'] < time()) {
             include $this->template('activityend');
         } else {
             //出奖次数
             $hasjingpin = true;
             $hdlog = pdo_fetch('SELECT count(*) FROM ' . tablename('slotmac_record') . ' WHERE hid=:hid AND jdate=:jd', array(':hid' => $hdid, ':jd' => date('Y-m-d', time())));
             $cjcs = $hdlog['count(*)'];
             $zdcs = intval($hd['per_maxprisum']);
             if ($zdcs > 0 && $cjcs >= $zdcs) {
                 $hasjingpin = false;
             }
             //参加总次数
             $hdlog = pdo_fetch("SELECT count(*) FROM " . tablename('slotmac_record') . " WHERE chatid=:cid AND hid=:hid", array(':cid' => $fromuser, ':hid' => $hdid));
             $yjzcs = $hdlog['count(*)'];
             //是否已经参见过活动
             $hdlog = pdo_fetch('SELECT count(*) FROM ' . tablename('slotmac_record') . ' WHERE chatid=:cid AND hid=:hid AND jdate=:jd', array(':cid' => $fromuser, ':hid' => $hdid, ':jd' => date('Y-m-d', time())));
             $yjcs = $hdlog['count(*)'];
             //找到最后一个参加活动的人手机号
             $hdlog = pdo_fetch('SELECT * FROM ' . tablename('slotmac_record') . ' WHERE hid=:hid AND jx<>:jx AND tel IS NOT NULL ORDER BY id DESC', array(':hid' => $hdid, ':jx' => '0'));
             //是否查询到中奖记录
             $prizestat = empty($hdlog);
             if (!empty($hdlog) && strlen($hdlog['tel']) == 11) {
                 $hdlog['tel'] = substr($hdlog['tel'], 0, 5) . '****' . substr($hdlog['tel'], 9, 2);
             } else {
                 $hdlog['id'] = null;
             }
             //剩余机会
             $sycs = intval($hd['perday_sum']) - $yjcs;
             //剩余机会
             $syzcs = intval($hd['per_sum']) - $yjzcs;
             $sycs = $sycs < $syzcs ? $sycs : $syzcs;
             $jxmc = '谢谢参与';
             $jx = '0';
             //非会员不参与有奖
             $yjmj = '0';
             //需要收集会员卡
             $gljs = 1;
             //概率基数
             if ($sycs > 0) {
                 if ($hasjingpin) {
                     //随机定下奖项
                     for ($i = 3; $i > 0; $i--) {
                         if (1 == $i) {
                             $mc = '一等奖';
                         }
                         if (2 == $i) {
                             $mc = '二等奖';
                         }
                         if (3 == $i) {
                             $mc = '三等奖';
                         }
                         $ms = 'prize' . $i . '_name';
                         $gl = 'prize' . $i . '_prob';
                         $sl = 'prize' . $i . '_num';
                         $yj = 'prize' . $i . '_now';
                         if (intval($hd[$sl]) - intval($hd[$yj]) > 0) {
                             //还有剩余奖品
                             $gls = rand(0, 100000000);
                             if ($gls < doubleval($hd[$gl]) * 1000000) {
                                 $jx = $i;
                                 $jxmc = $hd[$mc];
                                 $jxms = $hd[$ms];
                                 $prizenow = $hd[$ms];
                                 $prizeid = $i;
                                 break;
                             }
                         }
                     }
                 }
             } else {
                 include $this->template('chanceend');
             }
         }
     } else {
         die;
     }
     include $this->template('slotmac');
 }
コード例 #24
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileResearch()
 {
     global $_W, $_GPC;
     $reid = intval($_GPC['id']);
     $sql = 'SELECT * FROM ' . tablename('research') . ' WHERE `weid`=:weid AND `reid`=:reid';
     $params = array();
     $params[':weid'] = $_W['weid'];
     $params[':reid'] = $reid;
     $activity = pdo_fetch($sql, $params);
     $title = $activity['title'];
     if ($activity['status'] != '1') {
         message('当前预约活动已经停止.');
     }
     if (!$activity) {
         message('非法访问.');
     }
     if ($activity['starttime'] > TIMESTAMP) {
         message('当前预约活动还未开始!');
     }
     if ($activity['endtime'] < TIMESTAMP) {
         message('当前预约活动已经结束!');
     }
     $sql = 'SELECT * FROM ' . tablename('research_fields') . ' WHERE `reid`=:reid ORDER BY `refid`';
     $params = array();
     $params[':reid'] = $reid;
     $ds = pdo_fetchall($sql, $params);
     if (!$ds) {
         message('非法访问.');
     }
     $initRange = false;
     $initCalendar = false;
     $binds = array();
     foreach ($ds as &$r) {
         if ($r['type'] == 'range') {
             $initRange = true;
         }
         if ($r['type'] == 'calendar') {
             $initCalendar = true;
         }
         if ($r['value']) {
             $r['options'] = explode(',', $r['value']);
         }
         if ($r['bind']) {
             $binds[] = $r['bind'];
         }
     }
     if (!empty($_W['fans']['from_user']) && !empty($binds)) {
         $profile = fans_search($_W['fans']['from_user'], $binds);
         if ($profile['gender']) {
             if ($profile['gender'] == '0') {
                 $profile['gender'] = '保密';
             }
             if ($profile['gender'] == '1') {
                 $profile['gender'] = '男';
             }
             if ($profile['gender'] == '2') {
                 $profile['gender'] = '女';
             }
         }
         foreach ($ds as &$r) {
             if ($profile[$r['bind']]) {
                 $r['default'] = $profile[$r['bind']];
             }
         }
     }
     include $this->template('submit');
 }
コード例 #25
0
ファイル: site.php プロジェクト: keycoolkui/weixinfenxiao
 public function oauth2($authurl)
 {
     global $_GPC, $_W;
     load()->func('communication');
     $state = $_GPC['state'];
     //1为关注用户, 0为未关注用户
     $code = $_GPC['code'];
     $oauth2_code = "https://api.weixin.qq.com/sns/oauth2/access_token?appid=" . $this->_appid . "&secret=" . $this->_appsecret . "&code=" . $code . "&grant_type=authorization_code";
     $content = ihttp_get($oauth2_code);
     $token = @json_decode($content['content'], true);
     if (empty($token) || !is_array($token) || empty($token['access_token']) || empty($token['openid'])) {
         echo '<h1>获取微信公众号授权' . $code . '失败[无法取得token以及openid], 请稍后重试! 公众平台返回原始数据为: <br />' . $content['meta'] . '<h1>';
         exit;
     }
     $from_user = $token['openid'];
     if ($this->_accountlevel != 2) {
         //普通号
         $authkey = intval($_GPC['authkey']);
         if ($authkey == 0) {
             $url = $authurl;
             $oauth2_code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $this->_appid . "&redirect_uri=" . urlencode($url) . "&response_type=code&scope=snsapi_userinfo&state=0#wechat_redirect";
             header("location:{$oauth2_code}");
         }
     } else {
         //再次查询是否为关注用户
         $profile = fans_search($from_user);
         if ($profile['follow'] == 1) {
             //关注用户直接获取信息
             $state = 1;
         } else {
             //未关注用户跳转到授权页
             $url = $authurl;
             $oauth2_code = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" . $this->_appid . "&redirect_uri=" . urlencode($url) . "&response_type=code&scope=snsapi_userinfo&state=0#wechat_redirect";
             header("location:{$oauth2_code}");
         }
     }
     if ($state == 1) {
         //已关注用户
         $oauth2_url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $this->_appid . "&secret=" . $this->_appsecret . "";
         $content = ihttp_get($oauth2_url);
         $token_all = @json_decode($content['content'], true);
         if (empty($token_all) || !is_array($token_all) || empty($token_all['access_token'])) {
             echo '<h1>获取微信公众号授权失败[无法取得access_token], 请稍后重试! 公众平台返回原始数据为: <br />' . $content['meta'] . '<h1>';
             exit;
         }
         $access_token = $token_all['access_token'];
         $oauth2_url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN";
     } else {
         //未关注用户
         $access_token = $token['access_token'];
         $oauth2_url = "https://api.weixin.qq.com/sns/userinfo?access_token=" . $access_token . "&openid=" . $from_user . "&lang=zh_CN";
         //https://api.weixin.qq.com/sns/userinfo?access_token=ACCESS_TOKEN&openid=OPENID
     }
     //使用全局ACCESS_TOKEN获取OpenID的详细信息
     $content = ihttp_get($oauth2_url);
     $info = @json_decode($content['content'], true);
     if (empty($info) || !is_array($info) || empty($info['openid']) || empty($info['nickname'])) {
         echo '<h1>获取微信公众号授权失败[无法取得info], 请稍后重试! 公众平台返回原始数据为: <br />' . $content['meta'] . '<h1>' . 'state:' . $state . 'nickname' . $profile['nickname'] . 'weid:' . $profile['weid'];
         exit;
     }
     $headimgurl = $info['headimgurl'];
     $nickname = $info['nickname'];
     //设置cookie信息
     setcookie($this->_auth2_headimgurl, $headimgurl, time() + 3600 * 24);
     setcookie($this->_auth2_nickname, $nickname, time() + 3600 * 24);
     setcookie($this->_auth2_openid, $from_user, time() + 3600 * 24);
     return $info;
 }
コード例 #26
0
ファイル: site.php プロジェクト: eduNeusoft/weixin
 public function doMobileCourse()
 {
     global $_GPC, $_W;
     $this->check_member();
     $id = intval($_GPC['id']);
     if (empty($id)) {
         exit;
     }
     $weid = $_W['uniacid'];
     $member_info = $this->getMemberInfo();
     if (!empty($id)) {
         $item = pdo_fetch("select * from " . tablename('ewei_exam_course') . " where id=:id AND status = 1 limit 1", array(":id" => $id));
     }
     $is_reserve = 0;
     if ($item['ctype']) {
         if ($item['fansnum'] < $item['ctotal']) {
             $is_reserve = 1;
         }
     } else {
         $time = time();
         if ($time >= $item['starttime'] && $time <= $item['endtime']) {
             $is_reserve = 1;
         }
     }
     // 查看当前用户是否已经预约过该课程
     $params = array('courseid' => $id);
     $sql = 'SELECT `id` FROM ' . tablename('ewei_exam_course_reserve') . " WHERE `weid` = :weid AND `courseid` = :courseid AND `memberid` = :memberid";
     $params[':weid'] = $weid;
     $params[':memberid'] = $member_info['id'];
     $reserved = pdo_fetchcolumn($sql, $params);
     if (checksubmit()) {
         if (!empty($reserved)) {
             die(json_encode(array("result" => 2, "error" => "抱歉,该课程您已经预约过了!")));
         }
         $username = trim($_GPC['username']);
         $mobile = trim($_GPC['mobile']);
         $email = trim($_GPC['email']);
         $data = array('realname' => $username, 'mobile' => $mobile);
         //更新用户信息
         $array = array();
         $array['username'] = $username;
         $array['mobile'] = $mobile;
         $array['email'] = $email;
         $params = array();
         $params['from_user'] = $this->_from_user;
         $params['weid'] = $weid;
         pdo_update('ewei_exam_member', $array, $params);
         //插入学员考试记录
         $data = array();
         $data['weid'] = $weid;
         $data['ordersn'] = date('md') . sprintf("%04d", $_W['fans']['id']) . random(4, 1);
         $data['courseid'] = $id;
         $data['memberid'] = $member_info['id'];
         $data['username'] = $username;
         $data['mobile'] = $mobile;
         $data['email'] = $email;
         $data['times'] = 0;
         $data['createtime'] = time();
         $data['times'] = 0;
         pdo_insert('ewei_exam_course_reserve', $data);
         $reserveid = pdo_insertid();
         $url = $this->createMobileUrl('reserve', array('id' => $reserveid));
         die(json_encode(array("result" => 1, "url" => $url)));
     } else {
         $fans = fans_search($_W['fans']['from_user'], array('nickname', 'email', 'mobile'));
         //更新访问人数记录
         $this->updateCourseMemberNum($id, 0);
         include $this->template('course');
     }
 }
コード例 #27
0
<?php

/**
 * [WDL] Copyright (c) 2013 wormwood.com
 */
defined('IN_IA') or exit('Access Denied');
$weid = $_W['weid'];
$_W['setting']['authmode'] = empty($_W['setting']['authmode']) ? 1 : $_W['setting']['authmode'];
if ($_GPC['__auth']) {
    $pass = @base64_decode($_GPC['__auth']);
    $pass = @json_decode($pass, true);
    if (is_array($pass) && !empty($pass['fans']) && !empty($pass['time']) && !empty($pass['hash'])) {
        if ($_W['setting']['authmode'] == 2 && abs($pass['time'] - TIMESTAMP) < 180 || $_W['setting']['authmode'] == 1) {
            $row = fans_search($pass['fans'], array('salt'));
            if (!is_array($row) || empty($row['salt'])) {
                $row = array('from_user' => $pass['fans'], 'salt' => '');
            }
            $hash = md5("{$pass['fans']}{$pass['time']}{$row['salt']}{$_W['config']['setting']['authkey']}");
            if ($pass['hash'] == $hash) {
                if ($_W['setting']['authmode'] == 2) {
                    $row = array();
                    $row['salt'] = random(8);
                    fans_update($pass['fans'], $row);
                }
                $cookie = array();
                $cookie['openid'] = $pass['fans'];
                $cookie['hash'] = substr(md5("{$pass['fans']}{$row['salt']}{$_W['config']['setting']['authkey']}"), 5, 5);
                $session = base64_encode(json_encode($cookie));
                isetcookie('__msess', $session, 30 * 86400);
            }
        }
コード例 #28
0
ファイル: index.inc.php プロジェクト: aspnmy/weizan
}
$this_month_b = $current_month['0'];
$this_month_e = $current_month['1'];
$this_year = substr($this_month_b, 0, 4);
$this_month = substr($this_month_b, 5, 2);
$last_month_b = $current_last_month['0'];
$last_month_e = $current_last_month['1'];
$last_month = substr(str_replace('-', '', $last_month_b), 0, 6);
$next_month_b = $current_next_month['0'];
$next_month_e = $current_next_month['1'];
$next_month = substr(str_replace('-', '', $next_month_b), 0, 6);
$month_usersigned_info = pdo_fetchall("SELECT * FROM " . tablename('nsign_record') . " WHERE `uid` = :uid AND `sign_time` >= :this_month_b AND `sign_time` <= :this_month_e", array(':uid' => $_W['member']['uid'], ':this_month_b' => strtotime($this_month_b), ':this_month_e' => strtotime($this_month_e)));
$value = array();
foreach ($month_usersigned_info as $value) {
    $user_signed_days .= date('d', $value['sign_time']) . ',';
    //粉丝当月签到日期
}
$user_signed_days = '[' . $user_signed_days . ']';
$user_lastsign_info = pdo_fetch("SELECT * FROM " . tablename('nsign_record') . " WHERE `uid` = :uid ORDER BY sign_time DESC LIMIT 1 ", array(':uid' => $_W['member']['uid']));
$user_maxallsign_num = $user_lastsign_info['maxtotal_sign_num'];
$today_usersigned_info = pdo_fetchall("SELECT * FROM " . tablename('nsign_record') . " WHERE `uid` = :uid AND sign_time >= :current_date ", array(':uid' => $_W['member']['uid'], ':current_date' => strtotime($current_date)));
$today_usersigned_num = count($today_usersigned_info);
if (empty($user_maxallsign_num)) {
    $user_maxallsign_num = 0;
}
$profile = fans_search($fromuser);
if (!empty($rid)) {
    $reply = pdo_fetch("SELECT * FROM " . tablename('nsign_reply') . " WHERE rid = :rid ", array(':rid' => $rid));
}
$Picurl = $_W['attachurl'] . $reply['picture'];
include $this->template('index');
コード例 #29
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileAddress()
 {
     global $_W, $_GPC;
     $from = $_GPC['from'];
     $returnurl = urldecode($_GPC['returnurl']);
     $this->checkAuth();
     // $operation = !empty($_GPC['op']) ? $_GPC['op'] : 'post';
     $operation = $_GPC['op'];
     if ($operation == 'post') {
         $id = intval($_GPC['id']);
         $data = array('weid' => $_W['weid'], 'openid' => $_W['fans']['from_user'], 'realname' => $_GPC['realname'], 'mobile' => $_GPC['mobile'], 'province' => $_GPC['province'], 'city' => $_GPC['city'], 'area' => $_GPC['area'], 'address' => $_GPC['address']);
         if (empty($_GPC['realname']) || empty($_GPC['mobile']) || empty($_GPC['address'])) {
             message('请输完善您的资料!');
         }
         if (!empty($id)) {
             unset($data['weid']);
             unset($data['openid']);
             pdo_update('shopping_address', $data, array('id' => $id));
             message($id, '', 'ajax');
         } else {
             pdo_update('shopping_address', array('isdefault' => 0), array('weid' => $_W['weid'], 'openid' => $_W['fans']['from_user']));
             $data['isdefault'] = 1;
             pdo_insert('shopping_address', $data);
             $id = pdo_insertid();
             if (!empty($id)) {
                 message($id, '', 'ajax');
             } else {
                 message(0, '', 'ajax');
             }
         }
     } elseif ($operation == 'default') {
         $id = intval($_GPC['id']);
         pdo_update('shopping_address', array('isdefault' => 0), array('weid' => $_W['weid'], 'openid' => $_W['fans']['from_user']));
         pdo_update('shopping_address', array('isdefault' => 1), array('id' => $id));
         message(1, '', 'ajax');
     } elseif ($operation == 'detail') {
         $id = intval($_GPC['id']);
         $row = pdo_fetch("SELECT id, realname, mobile, province, city, area, address FROM " . tablename('shopping_address') . " WHERE id = :id", array(':id' => $id));
         message($row, '', 'ajax');
     } elseif ($operation == 'remove') {
         $id = intval($_GPC['id']);
         if (!empty($id)) {
             $address = pdo_fetch("select isdefault from " . tablename('shopping_address') . " where id='{$id}' and weid='{$_W['weid']}' and openid='{$_W['fans']['from_user']}' limit 1 ");
             if (!empty($address)) {
                 //pdo_delete("shopping_address",  array('id'=>$id, 'weid' => $_W['weid'], 'openid' => $_W['fans']['from_user']));
                 //修改成不直接删除,而设置deleted=1
                 pdo_update("shopping_address", array("deleted" => 1, "isdefault" => 0), array('id' => $id, 'weid' => $_W['weid'], 'openid' => $_W['fans']['from_user']));
                 if ($address['isdefault'] == 1) {
                     //如果删除的是默认地址,则设置是新的为默认地址
                     $maxid = pdo_fetchcolumn("select max(id) as maxid from " . tablename('shopping_address') . " where weid='{$_W['weid']}' and openid='{$_W['fans']['from_user']}' limit 1 ");
                     if (!empty($maxid)) {
                         pdo_update('shopping_address', array('isdefault' => 1), array('id' => $maxid, 'weid' => $_W['weid'], 'openid' => $_W['fans']['from_user']));
                         die(json_encode(array("result" => 1, "maxid" => $maxid)));
                     }
                 }
             }
         }
         die(json_encode(array("result" => 1, "maxid" => 0)));
     } else {
         $profile = fans_search($_W['fans']['from_user'], array('resideprovince', 'residecity', 'residedist', 'address', 'realname', 'mobile'));
         $address = pdo_fetchall("SELECT * FROM " . tablename('shopping_address') . " WHERE deleted=0 and openid = :openid", array(':openid' => $_W['fans']['from_user']));
         $carttotal = $this->getCartTotal();
         include $this->template('address');
     }
 }
コード例 #30
0
ファイル: site.php プロジェクト: alextiannus/wormwood_wechat
 public function doMobileAbout()
 {
     global $_GPC, $_W;
     $weid = $_W['account']['weid'];
     $rid = intval($_GPC['rid']);
     $id = intval($_GPC['id']);
     $fromuser = $_W['fans']['from_user'];
     $orderinfo = pdo_fetchall("SELECT * FROM " . tablename('hotel_order') . " WHERE rid = :rid AND openid = :openid ORDER BY time DESC", array(':rid' => $rid, ':openid' => $fromuser));
     $ordernum = count($orderinfo);
     $profile = fans_search($fromuser);
     $detail = pdo_fetch("SELECT * FROM " . tablename('hotel_reply') . " WHERE rid = :rid ", array(':rid' => $rid));
     $detail['picture'] = $_W['attachurl'] . $detail['picture'];
     include $this->template('about');
 }