public function doMobileIndex() { global $_GPC, $_W; $tourl = true; load()->model('mc'); $info = mc_oauth_userinfo($_W['acid']); $info2 = mc_fansinfo($info['openid'], $_W['acid']); if ($info2['follow'] == 1) { $tourl = false; } if (isset($_GPC['wd_code'])) { $title = '防伪测试'; $footer_off = 1; $SecurityCode = $_GPC['wd_code']; $logs['code'] = $SecurityCode; $sql = "SELECT * FROM " . tablename($this->data) . " WHERE code='{$SecurityCode}' LIMIT 1"; $member = pdo_fetch($sql); $states = 0; if (!empty($member)) { if ($tourl) { if (empty($member['tourl'])) { $member['tourl'] = "http://www.baidu.com"; } header('Location:' . $member['tourl']); } include $this->template('index'); } else { echo '您查询的防伪码不存在,请核对后重试!'; } } else { echo '您查询的防伪码不存在,请核对后重试!'; } exit; }
public function respond() { global $_W; load()->func('compat.biz'); $rid = $this->rule; $sql = "SELECT * FROM " . tablename('bm_top_reply') . " WHERE `rid`=:rid LIMIT 1"; $row = pdo_fetch($sql, array(':rid' => $rid)); if (empty($row['id'])) { return $this->respText("系统升级中,请稍候!"); } $desc = $row['desc']; //描述 $n = $row['n']; //粉丝基数 $fromuser = $this->message['from']; $num = mc_fansinfo($fromuser); $numx = $n + $num['fanid']; $name = $_W['account']['name']; //公众号名称 $str = str_replace('{name}', $name, $desc); $str = str_replace('{numx}', $numx, $str); if ($row['pictype'] == 1) { //$str = "嗨,欢迎关注【".$name."】,您是第".$numx."位关注人!\n".$desc."\n <a href='".$url."'>".$urltext."</a>"; return $this->respText($str); } else { $response['FromUserName'] = $this->message['to']; $response['ToUserName'] = $this->message['from']; $response['MsgType'] = 'news'; $response['ArticleCount'] = 1; $response['Articles'] = array(); $response['Articles'][] = array('Title' => $row['title'], 'Description' => $str, 'PicUrl' => !strexists($row['picurl'], 'http://') ? $_W['attachurl'] . $row['picurl'] : $row['picurl'], 'Url' => $row['urlx'], 'TagName' => 'item'); return $response; } }
function checkauth() { global $_W, $engine; load()->model('mc'); if (!empty($_W['member']) && (!empty($_W['member']['mobile']) || !empty($_W['member']['email']))) { return true; } if (!empty($_W['openid'])) { $fan = mc_fansinfo($_W['openid'], $_W['acid'], $_W['uniacid']); if (_mc_login(array('uid' => intval($fan['uid'])))) { return true; } if (defined('IN_API')) { $GLOBALS['engine']->died("抱歉,您需要先登录才能使用此功能,点击此处 <a href='" . __buildSiteUrl(url('auth/login')) . "'>【登录】</a>"); } } $forward = base64_encode($_SERVER['QUERY_STRING']); if ($_W['isajax']) { $result = array(); $result['url'] = url('auth/login', array('forward' => $forward), true); $result['act'] = 'redirect'; exit(json_encode($result)); } else { header("location: " . url('auth/login', array('forward' => $forward)), true); } exit; }
public function fetchFansInfo($openid) { global $_W; load()->model('mc'); $uid = mc_openid2uid($openid); $user = mc_fansinfo($_W['member']['uid'], $_W['acid'], $_W['uniacid']); if (empty($user)) { return null; } $user['credit'] = $this->fetchUserCredit($openid); $user['score'] = intval($user['credit']['credit1']); $user['money'] = $user['credit']['credit2']; return $user; }
public function respond() { global $_W; checkauth(); if (!$this->inContext) { $number = pdo_fetchcolumn(" SELECT COUNT(*) FROM " . tablename('mc_mapping_fans') . " WHERE uniacid = '{$_W['uniacid']}' and follow = 1 "); $list = pdo_fetch("select * from " . tablename('eso_sale_share_history') . " WHERE from_user = '******'openid']}' and uniacid = '{$_W['uniacid']}'"); if (empty($list)) { $reply = "欢迎关注【" . $_W['account']['name'] . "】\n你是第【" . $number . "】个会员"; // $reply ="欢迎关注【".$_W['account']['name']."】\n你是第【854】个会员"; } else { $shangji = pdo_fetch("select from_user from " . tablename('eso_sale_member') . " where id = '{$list['sharemid']}' and uniacid = '{$_W['uniacid']}'"); $member = mc_fansinfo($shangji['from_user']); $reply = "欢迎关注【" . $_W['account']['name'] . "】\n你是由【" . $member['nickname'] . "】推荐的第【" . $number . "】个会员"; } } return $this->respText($reply); }
function requreSubscribe() { global $_W; $hasSubscribe = 1; if (isset($_W['fans']['from_user']) && !empty($_W['fans']['from_user'])) { $openid = $_W['fans']['from_user']; $userinfo = mc_fansinfo($openid); if (!$userinfo || $userinfo['follow'] == 0) { $hasSubscribe = 0; } } else { $oauthAccount = $_W['oauth_account']; if (empty($oauthAccount)) { message('未指定网页授权公众号, 无法获取用户信息.', '', 'error'); } $userinfo = mc_oauth_userinfo(); $level = pdo_fetchcolumn("SELECT `level` FROM " . tablename('account_wechats') . " WHERE `uniacid`=:uniacid", array(':uniacid' => $_W['uniacid'])); if ($level == 4) { if ($userinfo['subscribe'] == 0) { $hasSubscribe = 0; } } else { $unionid = isset($userinfo['unionid']) ? $userinfo['unionid'] : ''; if (empty($unionid)) { message('获取unionid失败,请确认公众号已接入微信开放平台', '', 'error'); } $fieldsExist = pdo_fieldexists('mc_mapping_fans', 'unionid'); if (!$fieldsExist) { pdo_query("ALTER TABLE " . tablename('mc_mapping_fans') . " ADD column unionid varchar(255) default null"); } $openid = pdo_fetchcolumn("SELECT `openid` FROM " . tablename('mc_mapping_fans') . " WHERE `unionid`=:unionid AND `uniacid`=:uniacid ", array(':unionid' => $unionid, ':uniacid' => $_W['account']['uniacid'])); if (empty($openid)) { $hasSubscribe = 0; } else { $userinfo = mc_fansinfo($openid); if (!$userinfo || $userinfo['follow'] == 0) { $hasSubscribe = 0; } } } } return array('openid' => $openid, 'subscribe' => $hasSubscribe); }
function _mc_login($member) { global $_W; if (!empty($member) && !empty($member['uid'])) { $sql = 'SELECT `uid`,`realname`,`mobile`,`email`,`groupid`,`credit1`,`credit2`,`credit6` FROM ' . tablename('mc_members') . ' WHERE `uid`=:uid AND `uniacid`=:uniacid'; $member = pdo_fetch($sql, array(':uid' => $member['uid'], ':uniacid' => $_W['uniacid'])); if (!empty($member) && (!empty($member['mobile']) || !empty($member['email']))) { $_W['member'] = $member; $_SESSION['uid'] = $member['uid']; mc_group_update(); if (empty($_W['openid'])) { $fan = mc_fansinfo($member['uid']); if (!empty($fan)) { $_SESSION['openid'] = $fan['openid']; $_W['openid'] = $fan['openid']; $_W['fans'] = $fan; $_W['fans']['from_user'] = $_W['openid']; } else { $_W['openid'] = $member['uid']; $_W['fans'] = array('from_user' => $member['uid'], 'follow' => 0); } } isetcookie('logout', '', -60000); return true; } } return false; }
private function checkOpenid() { global $_W, $_GPC; $openid = $_W['openid']; $config = $this->module['config']; if (!empty($config['url'])) { if (!strexists($config['url'], 'http')) { $config['url'] = 'http://' . $config['url']; } } if (empty($openid)) { if (!empty($config['url'])) { message('..请先关注' . $_W['account']['name'] . '才能继续访问..', $config['url'], 'error'); } message('..请先关注' . $_W['account']['name'] . '才能继续访问..', url('home', array('i' => $_W['uniacid'])), 'error'); } load()->model('mc'); //手机端用户的必要加载项 $fans = mc_fansinfo($openid); $profile = mc_fetch($_W['member']['uid']); if ($fans['follow'] != 1) { if (empty($config['url'])) { message('..请先关注' . $_W['account']['name'] . '才能继续访问..', url('home', array('i' => $_W['uniacid'])), 'error'); } message('..请先关注' . $_W['account']['name'] . '才能继续访问..', $config['url'], 'error'); } $record = pdo_fetch('SELECT * FROM' . tablename($this->table_fans) . " WHERE uniacid = :uniacid AND openid = :openid", array(':uniacid' => $_W['uniacid'], ':openid' => $openid)); if (empty($record)) { $user = $this->getUserInfo($openid); if (empty($user)) { if (empty($profile['nickname'])) { $user['nickname'] = '匿名' . substr($openid, -4); } else { $user['nickname'] = $profile['nickname']; } if (empty($profile['avatar'])) { $user['headimgurl'] = $_W['siteroot'] . 'addons/luvwhispers/template/style/images/noheader.png'; } else { $user['headimgurl'] = $profile['avatar']; } } pdo_insert($this->table_fans, array('uniacid' => $_W['uniacid'], 'nickname' => $user['nickname'], 'headimgurl' => $user['headimgurl'], 'openid' => $openid, 'createtime' => TIMESTAMP)); } else { if ($record['isblack'] == 1) { message('哎呦,已被管理员封禁了呦..', url('home', array('i' => $_W['uniacid'])), 'error'); } if (TIMESTAMP - $record['createtime'] >= 604800) { $user = $this->getUserInfo($openid); if (!empty($user['nickname']) || empty($user['headimgurl'])) { pdo_update($this->table_fans, array('nickname' => $user['nickname'], 'headimgurl' => $user['headimgurl'], 'createtime' => TIMESTAMP), array('uniacid' => $_W['uniacid'], 'openid' => $openid)); } } } }
} if (empty($_W['account'])) { exit('指定(子)公众号不存在。'); } if (!empty($_SESSION['acid']) && $_W['acid'] != $_SESSION['acid'] || !empty($_SESSION['uniacid']) && $_W['uniacid'] != $_SESSION['uniacid']) { $keys = array_keys($_SESSION); foreach ($keys as $key) { unset($_SESSION[$key]); } unset($keys, $key); } $_SESSION['acid'] = $_W['acid']; $_SESSION['uniacid'] = $_W['uniacid']; if (!empty($_SESSION['openid'])) { $_W['openid'] = $_SESSION['openid']; $_W['fans'] = mc_fansinfo($_W['openid']); $_W['fans']['from_user'] = $_W['openid']; } if (!empty($_SESSION['uid']) || !empty($_W['fans']) && !empty($_W['fans']['uid'])) { $uid = intval($_SESSION['uid']); if (empty($uid)) { $uid = $_W['fans']['uid']; } _mc_login(array('uid' => $uid)); unset($uid); } if (empty($_W['openid']) && !empty($_SESSION['oauth_openid'])) { $_W['openid'] = $_SESSION['oauth_openid']; $_W['fans'] = array('openid' => $_SESSION['oauth_openid'], 'from_user' => $_SESSION['oauth_openid'], 'follow' => 0); } $oauth_acc = $_W['account'];
if (empty($_SESSION['openid']) && !empty($mc_oauth_fan['openid'])) { $_SESSION['openid'] = strval($mc_oauth_fan['openid']); } } } if ($scope == 'userinfo') { $url = "https://api.weixin.qq.com/sns/userinfo?access_token={$oauth['access_token']}&openid={$oauth['openid']}&lang=zh_CN"; $response = ihttp_get($url); if (!is_error($response)) { $userinfo = array(); $userinfo = @json_decode($response['content'], true); $userinfo['nickname'] = stripcslashes($userinfo['nickname']); $userinfo['avatar'] = $userinfo['headimgurl']; unset($userinfo['headimgurl']); $_SESSION['userinfo'] = base64_encode(iserializer($userinfo)); $fan = mc_fansinfo($_SESSION['openid']); if (!empty($fan)) { $record = array(); $record['updatetime'] = TIMESTAMP; $record['nickname'] = stripslashes($userinfo['nickname']); $record['tag'] = base64_encode(iserializer($userinfo)); pdo_update('mc_mapping_fans', $record, array('openid' => $fan['openid'], 'acid' => $_W['acid'], 'uniacid' => $_W['uniacid'])); } if (!empty($fan['uid']) || !empty($_SESSION['uid'])) { $uid = $fan['uid']; if (empty($uid)) { $uid = $_SESSION['uid']; } $user = mc_fetch($uid, array('nickname', 'gender', 'residecity', 'resideprovince', 'nationality', 'avatar')); $record = array(); if (empty($user['nickname']) && !empty($userinfo['nickname'])) {
<?php /** * 提交分数 * * @version $Id: billboard.inc.php 1 10:47 2015年09月16日Z lions $ * @copyright Copyright (c) 2013 - 2020, haobama.net, Inc. * @link http://www.haobama.net */ global $_GPC, $_W; $hasExists = pdo_fetch("SELECT * FROM " . tablename('lions_zq_billboard') . " WHERE `uniacid`=:uniacid AND `openid`=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $_GPC['openid'])); if ($hasExists && $hasExists['score'] < $_GPC['score']) { pdo_update('lions_zq_billboard', array('score' => $_GPC['score']), array('uniacid' => $_W['uniacid'], 'openid' => $_GPC['openid'])); } else { pdo_insert('lions_zq_billboard', array('uniacid' => $_W['uniacid'], 'openid' => $_GPC['openid'], 'score' => $_GPC['score'])); } $record = pdo_fetch("SELECT * FROM " . tablename('lions_zq_billboard') . " WHERE `uniacid`=:uniacid AND `openid`=:openid", array(':uniacid' => $_W['uniacid'], ':openid' => $_GPC['openid'])); $record['cur_score'] = $_GPC['score']; $record['top_score'] = pdo_fetchcolumn("SELECT `score` FROM " . tablename('lions_zq_billboard') . " WHERE `uniacid`=:uniacid ORDER BY `score` DESC LIMIT 1", array('uniacid' => $_W['uniacid'])); $records = pdo_fetchall("SELECT * FROM " . tablename('lions_zq_billboard') . " WHERE `uniacid`=:uniacid ORDER BY `score` DESC LIMIT 10", array(':uniacid' => $_W['uniacid'])); $str = ''; if ($records) { foreach ($records as $key => $item) { $userinfo = mc_fansinfo($item['openid']); $nickname = empty($userinfo) ? '匿名' : $userinfo['nickname']; $str .= '<tr style="height:30px;"><td>' . $nickname . '</td><td>' . $item['score'] . '</td></tr>'; } } $record['billboard'] = $str; echo json_encode($record); exit;
public function doMobileDetail() { global $_W, $_GPC; $id = intval($_GPC['id']); $detail = pdo_fetch("SELECT * FROM" . tablename($this->table_goods) . "WHERE id='{$id}'"); $size = 1; if (empty($detail['thumb1'])) { $size = 1; } if (!empty($detail['thumb2'])) { $size += 1; } if (!empty($detail['thumb3'])) { $size += 1; } $user = mc_fansinfo($_W['openid'], $_W['acid']); $url = "http://virtual.paipai.com/extinfo/GetMobileProductInfo?mobile={$detail['mobile']}&amount=10000"; $curl = curl_init(); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_TIMEOUT, 500); curl_setopt($curl, CURLOPT_URL, $url); $res = curl_exec($curl); curl_close($curl); $a = explode(')', substr($res, 1)); $c = '"' . iconv("gbk", "UTF-8", $a[0]) . '"'; $mobile = json_decode($c, true); $title = $detail['title']; $_share_img = $_W['attachurl'] . $detail['thumb1']; $_share = array('title' => $title, 'link' => '', 'imgUrl' => $_share_img, 'content' => $title); include $this->template('detail'); }
} if (empty($_SESSION['openid']) && !empty($mc_oauth_fan['openid'])) { $_SESSION['openid'] = strval($mc_oauth_fan['openid']); } } } if ($scope == 'userinfo') { $userinfo = $oauth_account->getOauthUserInfo($oauth['access_token'], $oauth['openid']); if (!is_error($userinfo)) { $userinfo['nickname'] = stripcslashes($userinfo['nickname']); if (!empty($userinfo['headimgurl'])) { $userinfo['headimgurl'] = rtrim($userinfo['headimgurl'], '0') . 132; } $userinfo['avatar'] = $userinfo['headimgurl']; $_SESSION['userinfo'] = base64_encode(iserializer($userinfo)); $fan = mc_fansinfo($oauth['openid']); if (!empty($fan)) { $record = array(); $record['updatetime'] = TIMESTAMP; $record['nickname'] = stripslashes($userinfo['nickname']); $record['tag'] = base64_encode(iserializer($userinfo)); pdo_update('mc_mapping_fans', $record, array('openid' => $fan['openid'], 'acid' => $_W['acid'], 'uniacid' => $_W['uniacid'])); } else { $record = array(); $record['updatetime'] = TIMESTAMP; $record['nickname'] = stripslashes($userinfo['nickname']); $record['tag'] = base64_encode(iserializer($userinfo)); $record['openid'] = $oauth['openid']; $record['acid'] = $_W['acid']; $record['uniacid'] = $_W['uniacid']; pdo_insert('mc_mapping_fans', $record);
public function doMobileShare() { global $_W, $_GPC; $pid = $_GPC['pid']; $rid = $_GPC['rid']; $rule = pdo_fetch('select * from ' . tablename($this->modulename . '_rule') . " where rid='{$rid}'"); if (empty($rule)) { message('该活动不存在!'); } load()->model('mc'); $info = mc_oauth_userinfo(); $openid = $info['openid']; $fans = mc_fansinfo($openid, $_W['acid'], $_W['uniacid']); $follow = $fans['follow']; $player = pdo_fetch('select * from ' . tablename($this->modulename . '_player') . " where rid='{$rule['rid']}' and openid='{$openid}'"); if (!empty($player)) { header('location:' . $this->createMobileUrl('index', array('rid' => $rid))); exit; } $player = pdo_fetch('select * from ' . tablename($this->modulename . '_player') . " where rid='{$rule['rid']}' and openid='{$pid}'"); if (!empty($player)) { $count = pdo_fetchcolumn('select sum(birds_num) from ' . tablename($this->modulename . "_share") . " where pid='{$player['id']}'"); $rate = $count / $rule['birds_success']; if ($count >= $rule['birds_success']) { $rate = 1; } } $share = pdo_fetch('select * from ' . tablename($this->modulename . '_share') . " where rid='{$rule['rid']}' and openid='{$openid}' and pid='{$player['id']}'"); if (empty($share) && $rule['describe_limit2']) { //记录下痕迹 用于助力者关注后 点击活动链接时 还能回到分享页面 $record = pdo_fetch('select * from ' . tablename($this->modulename . "_record") . " where openid='{$openid}' and pid='{$player['id']}' "); if (empty($record)) { pdo_insert($this->modulename . "_record", array('openid' => $openid, 'pid' => $player['id'])); } } //因说话气泡分两段位移,以rate=0.65为界 $edge = 0.65; //说话气泡的移动边界(当rate为0.65时,气泡前一段位移的rate相当于1) $rate = 0; if (!empty($player)) { $count = pdo_fetchcolumn('select sum(birds_num) from ' . tablename($this->modulename . "_share") . " where pid='{$player['id']}'"); $rate = $count / $rule['birds_success']; if ($count >= $rule['birds_success']) { $rate = 1; } } include $this->template('share'); }
public function doMobileMobile() { //这个操作被定义用来呈现 许愿手机首页 global $_W, $_GPC; $openid = $_W['openid']; $id = intval($_GPC['id']); if (!empty($id)) { $reply = pdo_fetch("SElECT * FROM" . tablename($this->tablename) . "WHERE rid=:rid LIMIT 1", array(':rid' => $id)); //增加浏览人数 pdo_update($this->tablename, array('viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id'])); } if (!empty($openid)) { $member = mc_fansinfo($openid); $follow = intval($member['follow']); if ($follow == 1) { include $this->template('mobile'); } else { echo "<script> alert('请先关注我们的官方微信!');parent.location.href='{$reply['gzurl']}'; </script>"; } } $signPackage = $this->getSignPackage(); }
public function doMobileOauthuserinfo() { global $_W, $_GPC; load()->model('mc'); // 假设当前应用必需会员头像 $avatar = ''; // 1 如果是会员(存在 uid),从会员信息中获取 if (!empty($_W['member']['uid'])) { $member = mc_fetch($_W['member']['uid']); if (!empty($member)) { $avatar = $member['avatar']; } } // 2 如果存在 fans 记录, 从 fans 中获取 if (empty($avatar)) { $fan = mc_fansinfo($_W['openid']); if (!empty($fan) && !empty($fan['tag'])) { $avatar = $fan['tag']['avatar']; } } //3 最后调用网页授权, 如果有权限 if (empty($avatar)) { if (!empty($_W['oauth_account'])) { $userinfo = mc_oauth_userinfo(); if (is_error($userinfo)) { // you code here message($ret['message']); } else { $avatar = $userinfo['tag']['avatar']; } } else { mc_require($_W['uid'], array('avatar')); } } echo "<img src='{$avatar}'>"; }
public function checkauth() { global $_W; load()->model('mc'); if (empty($_W['member']['uid'])) { if (!empty($_W['openid'])) { $fan = mc_fansinfo($_W['openid'], $_W['acid'], $_W['uniacid']); _mc_login(array('uid' => intval($fan['uid']))); } } if (empty($_W['member']['uid'])) { $sql = "SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE uniacid = :uniacid AND openid = :openid"; $params = array(':uniacid' => $_W['uniacid'], ':openid' => $_W['openid']); $fans = pdo_fetch($sql, $params); if (!empty($fans)) { if (!empty($fans['uid'])) { _mc_login(array('uid' => intval($fans['uid']))); if (empty($_W['member']['uid'])) { return false; } else { return $_W['member']['uid']; } } else { return $this->doMobileRegistMember(); } } else { return $this->doMobileRegistFans(); } } else { load()->func('communication'); if (empty($_W['acid'])) { $_W['acid'] = pdo_fetchcolumn("SELECT acid FROM " . tablename('mc_mapping_fans') . " WHERE uniacid='{$_W['uniacid']}' AND openid = '{$_W['openid']}'"); } $account = account_fetch($_W['acid']); load()->classs('weixin.account'); $accObj = WeixinAccount::create($_W['account']['acid']); $account['access_token']['token'] = $accObj->fetch_token(); if (empty($account['access_token']['token'])) { return false; } $url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=" . $account['access_token']['token'] . "&openid=" . $_W['openid'] . "&lang=zh_CN"; $re = ihttp_get($url); if ($re['code'] == 200) { $userinfo = json_decode($re['content'], true); if ($userinfo['errcode'] == '41001') { } } $data = array('nickname' => stripslashes($userinfo['nickname']), 'avatar' => trim($userinfo['headimgurl']), 'gender' => $userinfo['sex'], 'nationality' => $userinfo['country'], 'resideprovince' => $userinfo['province'] . '省', 'residecity' => $userinfo['city'] . '市'); pdo_update('mc_members', $data, array('uid' => $_W['member']['uid'])); return $_W['member']['uid']; } }
public function doMobilePtjperfect() { //这个操作被定义用户 呈现用户完善信息的页面 global $_W, $_GPC; require_once 'sms.php'; load()->model('mc'); load()->func('tpl'); $avatar = ''; $openid = $_W['openid']; $count = 0; $uid = $_W['member']['uid']; if (!empty($_W['member']['uid'])) { $member = mc_fetch(intval($_W['member']['uid']), array('avatar', 'nickname')); if (!empty($member)) { $avatar = $member['avatar']; $nickname = $member['nickname']; } } if (empty($avatar)) { $fan = mc_fansinfo($_W['openid']); if (!empty($fan)) { $avatar = $fan['avatar']; } } if (empty($avatar)) { $userinfo = mc_oauth_userinfo(); if (!is_error($userinfo) && !empty($userinfo) && is_array($userinfo) && !empty($userinfo['avatar'])) { $avatar = $userinfo['avatar']; $nickname = $userinfo['nickname']; } } if (empty($avatar) && !empty($_W['member']['uid'])) { $avatar = mc_require($_W['member']['uid'], array('avatar')); } if (empty($avatar)) { // 提示用户关注公众号。; //echo "最终没有获取到头像,follow: {$_W['fans']['follow']}"; } else { $src = $avatar; } //////////////////////////////////////mc调用结束//////////////////////////// $sms = json_decode($sms, true); if ($_GPC['tel'] and $_GPC['verify'] !== 'ing') { //对TEL进行动态正则匹配 $tel = $_GPC['tel']; $t = preg_match('/^1[34578]\\d{9}$/', $tel); if ($t) { //给前端号码 $tel = $_GPC['tel']; message('tel_success'); } else { message('tel_fail'); } } if ($_GPC['verify'] === 'ing') { //开始构造短信信息 $statusStr = array("0" => "POSTED", "-1" => "参数不全", "-2" => "服务器空间不支持,请确认支持curl或者fsocket,联系您的空间商解决或者更换空间!", "30" => "密码错误", "40" => "账号不存在", "41" => "余额不足", "42" => "帐户已过期", "43" => "IP地址限制", "50" => "内容含有敏感词"); $smsapi = "http://api.smsbao.com/"; //$user = "******"; //短信平台帐号 $user = $sms['sms_account']; //$pass = md5("wa7plus"); //短信平台密码 $pass = md5($sms['sms_password']); $m_content = substr(time(), -4, 4); //要发送的短信内容 $time = 1; $content = "【老司机】" . "您的验证码为: {$m_content}," . "在{$time}分钟内有效---{$_W['account']['name']}"; $phone = $_GPC['tel']; //要发送短信的手机号码 $sendurl = $smsapi . "sms?u=" . $user . "&p=" . $pass . "&m=" . $phone . "&c=" . urlencode($content); $result = file_get_contents($sendurl); $msg = $statusStr[$result]; $resarr = array("msg" => $msg, "content" => $m_content); $res = json_encode($resarr); message($res); } $name = $_GPC['name']; $phone = $_GPC['phone']; $openid = $_W['openid']; if (isset($name) && isset($phone)) { pdo_insert('ptj_profile', array('name' => $name, 'phone' => $phone, 'sure' => 1, 'openid' => $openid)); } include $this->template('perfect'); }
function Mobile_GetMember($theThis, $uniacid, $id, $openid) { global $_W, $_GPC; $rd = new ReturnData(""); load()->model('account'); $account = uni_fetch(); load()->model('mc'); $fans = mc_fansinfo($openid, $uniacid); $member = mc_fetch($fans['uid'], array('realname', 'mobile', 'qq', 'msn')); if (empty($member)) { $rd->setMsg("无法识别您的身份,请发送关键字到公众号 “" . $account['name'] . "” 参加活动"); $rd->setCode(200); } $rd->addData('fans', $fans); $rd->addData('member', $member); return $rd; }
public function _auser($rid, $afrom_user, $uniacid = '') { global $_GPC, $_W; load()->model('mc'); if (empty($uniacid)) { $uniacid = !empty($_W['uniacid']) ? $_W['uniacid'] : $_W['acid']; } $auser = pdo_fetch("SELECT avatar, nickname FROM " . tablename($this->table_users) . " WHERE uniacid = :uniacid and rid = :rid and from_user = :afrom_user ", array(':uniacid' => $uniacid, ':rid' => $rid, ':afrom_user' => $afrom_user)); if (empty($auser)) { $auser = pdo_fetch("SELECT avatar, nickname FROM " . tablename($this->table_data) . " WHERE uniacid = :uniacid and rid = :rid and from_user = :afrom_user ", array(':uniacid' => $uniacid, ':rid' => $rid, ':afrom_user' => $afrom_user)); if (empty($auser)) { $auser = mc_fansinfo($row['afrom_user']); } } return $auser; }
* 分享记录 * * @version $Id: share.inc.php 1 18:58 2015年09月15日Z lions $ * @copyright Copyright (c) 2013 - 2020, dzh6.com, Inc. * @link http://www.dzh6.com */ global $_GPC, $_W; $_accounts = $accounts = uni_accounts(); load()->model('mc'); if (empty($accounts) || !is_array($accounts) || count($accounts) == 0) { message('请指定公众号'); } if (!isset($_GPC['acid'])) { $account = array_shift($_accounts); if ($account !== false) { $acid = intval($account['acid']); } } else { $acid = intval($_GPC['acid']); if (!empty($acid) && !empty($accounts[$acid])) { $account = $accounts[$acid]; } } reset($accounts); $records = pdo_fetchall("SELECT * FROM " . tablename('lions_zq_billboard') . " WHERE `uniacid`=:uniacid ORDER BY `score` DESC", array(':uniacid' => $_W['uniacid'])); if (!empty($records)) { foreach ($records as $key => $item) { $records[$key]['user'] = mc_fansinfo($item['openid'], $acid, $_W['uniacid']); } } include $this->template('share');
$pars = array(); $pars[':uniacid'] = $_W['uniacid']; if (preg_match(REGULAR_MOBILE, $post['username'])) { $sql .= ' AND `mobile`=:mobile'; $pars[':mobile'] = $post['username']; } else { $sql .= ' AND `email`=:email'; $pars[':email'] = $post['username']; } $user = pdo_fetch($sql, $pars); if (empty($user)) { exit('不存在该账号的用户资料'); } } if ($reregister) { $fans = mc_fansinfo($_W['openid']); if ($fans['uid'] != $user['uid']) { pdo_update('mc_mapping_fans', array('uid' => $user['uid']), array('fanid' => $fans['fanid'])); pdo_delete('mc_mapping_fans', array('uid' => $fans['uid'])); } } if (_mc_login($user)) { exit('success'); } exit('未知错误导致登陆失败'); } template('auth/login'); exit; } elseif ($do == 'uc') { if ($_W['ispost'] && $_W['isajax']) { if (empty($uc_setting) || $uc_setting['status'] != 1) {
private function booking($message) { global $_W; if ($message['event'] == 'unsubscribe' || $message['event'] == 'subscribe') { $todaystat = pdo_get('stat_fans', array('date' => date('Ymd'), 'uniacid' => $_W['uniacid'])); if ($message['event'] == 'unsubscribe') { if (empty($todaystat)) { $updatestat = array('new' => 0, 'uniacid' => $_W['uniacid'], 'cancel' => 1, 'cumulate' => 0, 'date' => date('Ymd')); pdo_insert('stat_fans', $updatestat); } else { $updatestat = array('cancel' => $todaystat['cancel'] + 1); $updatestat['cumulate'] = intval($todaystat['cumulate']) - 1; pdo_update('stat_fans', $updatestat, array('id' => $todaystat['id'])); } } elseif ($message['event'] == 'subscribe') { if (empty($todaystat)) { $updatestat = array('new' => 1, 'uniacid' => $_W['uniacid'], 'cancel' => 0, 'cumulate' => 1, 'date' => date('Ymd')); pdo_insert('stat_fans', $updatestat); } else { $updatestat = array('new' => $todaystat['new'] + 1, 'cumulate' => $todaystat['cumulate'] + 1); pdo_update('stat_fans', $updatestat, array('id' => $todaystat['id'])); } } } $setting = uni_setting($_W['uniacid'], array('passport')); load()->model('mc'); $fans = mc_fansinfo($message['from']); $default_groupid = cache_load("defaultgroupid:{$_W['uniacid']}"); if (empty($default_groupid)) { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); cache_write("defaultgroupid:{$_W['uniacid']}", $default_groupid); } if (!empty($fans)) { $rec = array(); if (!empty($fans['follow'])) { if ($message['event'] == 'unsubscribe') { $rec['follow'] = 0; $rec['followtime'] = 0; $rec['unfollowtime'] = $message['time']; } } else { if ($message['event'] != 'unsubscribe' && $message['event'] != 'ShakearoundUserShake') { $rec['follow'] = 1; $rec['followtime'] = $message['time']; $rec['unfollowtime'] = 0; } } $member = array(); if (!empty($fans['uid'])) { $member = mc_fetch($fans['uid']); } if (empty($member)) { if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { $data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@012wz.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); } } if (!empty($rec)) { pdo_update('mc_mapping_fans', $rec, array('acid' => $_W['acid'], 'openid' => $message['from'], 'uniacid' => $_W['uniacid'])); } } else { $rec = array(); $rec['acid'] = $_W['acid']; $rec['uniacid'] = $_W['uniacid']; $rec['uid'] = 0; $rec['openid'] = $message['from']; $rec['salt'] = random(8); if ($message['event'] == 'unsubscribe') { $rec['follow'] = 0; $rec['followtime'] = 0; $rec['unfollowtime'] = $message['time']; } else { $rec['follow'] = 1; $rec['followtime'] = $message['time']; $rec['unfollowtime'] = 0; } if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { $data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@012wz.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); } pdo_insert('mc_mapping_fans', $rec); } }
private function booking($message) { global $_W; $setting = uni_setting($_W['uniacid'], array('passport')); load()->model('mc'); $fans = mc_fansinfo($message['from']); if (!empty($fans)) { $rec = array(); if (!empty($fans['follow'])) { if ($message['event'] == 'unsubscribe') { $rec['follow'] = 0; $rec['followtime'] = 0; $rec['unfollowtime'] = $message['time']; } } else { if ($message['event'] != 'unsubscribe' && $message['event'] != 'ShakearoundUserShake') { $rec['follow'] = 1; $rec['followtime'] = $message['time']; $rec['unfollowtime'] = 0; } } $member = array(); if (!empty($fans['uid'])) { $member = mc_fetch($fans['uid']); } if (empty($member)) { if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@we7.cc', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); } } if (!empty($rec)) { pdo_update('mc_mapping_fans', $rec, array('acid' => $_W['acid'], 'openid' => $message['from'], 'uniacid' => $_W['uniacid'])); } } else { $rec = array(); $rec['acid'] = $_W['acid']; $rec['uniacid'] = $_W['uniacid']; $rec['uid'] = 0; $rec['openid'] = $message['from']; $rec['salt'] = random(8); if ($message['event'] == 'unsubscribe') { $rec['follow'] = 0; $rec['followtime'] = 0; $rec['unfollowtime'] = $message['time']; } else { $rec['follow'] = 1; $rec['followtime'] = $message['time']; $rec['unfollowtime'] = 0; } if (!isset($setting['passport']) || empty($setting['passport']['focusreg'])) { $default_groupid = pdo_fetchcolumn('SELECT groupid FROM ' . tablename('mc_groups') . ' WHERE uniacid = :uniacid AND isdefault = 1', array(':uniacid' => $_W['uniacid'])); $data = array('uniacid' => $_W['uniacid'], 'email' => md5($message['from']) . '@we7.cc', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP); $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); } pdo_insert('mc_mapping_fans', $rec); } }
private function _wwx_login($member) { global $_W; load()->model('mc'); if (!empty($member) && !empty($member['uid'])) { $sql = 'SELECT `uid`,`mobile`,`email` FROM ' . tablename('mc_members') . ' WHERE `uid`=:uid AND `uniacid`=:uniacid'; $member = pdo_fetch($sql, array(':uid' => $member['uid'], ':uniacid' => $_W['uniacid'])); if (!empty($member)) { $fan = mc_fansinfo($member['uid']); $_W['member'] = $member; $_SESSION['uid'] = $member['uid']; $_SESSION['openid'] = $fan['openid']; $_W['openid'] = $fan['openid']; $_W['fans'] = $fan; $_W['fans']['from_user'] = $_W['openid']; setcookie(WUXIAN_COOKIE_OPENID . $_W['uniacid'], $_W['openid'], time() + 86400); setcookie(WUXIAN_COOKIE_CHECKOPENID . $_W['uniacid'], $_W['openid'], time() + 600); setcookie("mid", '', time() - 1); isetcookie('logout', '', -60000); return true; } } return false; }
<?php /** * [WeEngine System] Copyright (c) 2014 WE7.CC * WeEngine is NOT a free software, it under the license terms, visited http://www.we7.cc/ for more details. */ defined('IN_IA') or exit('Access Denied'); $_W['setting']['authmode'] = empty($_W['setting']['authmode']) ? 1 : $_W['setting']['authmode']; unset($_SESSION['uid']); if ($_GPC['__auth']) { $auth = @json_decode(base64_decode($_GPC['__auth']), true); if (is_array($auth) && !empty($auth['openid']) && !empty($auth['acid']) && !empty($auth['time']) && !empty($auth['hash'])) { if ($_W['setting']['authmode'] == 2 && abs($auth['time'] - TIMESTAMP) < 180 || $_W['setting']['authmode'] == 1) { $fan = mc_fansinfo($auth['openid'], $auth['acid'], $_W['uniacid']); if (!empty($fan)) { $hash = md5("{$auth['openid']}{$auth['time']}{$fan['salt']}{$_W['config']['setting']['authkey']}"); if ($auth['hash'] == $hash) { if ($_W['setting']['authmode'] == 2) { $rec = array(); do { $rec['salt'] = random(8); } while ($rec['salt'] == $fan['salt']); pdo_update('mc_mapping_fans', $rec, array('uniacid' => $_W['uniacid'], 'acid' => $auth['acid'], 'openid' => $auth['openid'])); } $_SESSION['uniacid'] = $_W['uniacid']; $_SESSION['acid'] = $auth['acid']; $_SESSION['openid'] = $auth['openid']; $member = mc_fetch($fan['uid']); if (!empty($member)) { $_SESSION['uid'] = $fan['uid']; }
/** * 检测用户是否关注 * @param $openid * @throws Exception */ private function check_follow($openid = null) { global $_W, $_GPC; $uniacid = $_W['uniacid']; $openid = $openid == null ? $_W['openid'] : $openid; if (empty($openid)) { throw new Exception("您没有关注本微信平台,点击确认前往关注", 4509); } $fans_info = mc_fansinfo($_W['openid']); if (empty($fans_info) || $fans_info['follow'] == 0) { throw new Exception("您没有关注本微信平台,点击确认前往关注", 4510); } }