public function __construct() { global $_W; load()->func('communication'); $openid = $_W['openid']; if (!empty($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('uniacid' => $_W['uniacid'], 'from_user' => $openid, 'nickname' => $content['nickname'], 'avatar' => $content['headimgurl']); $profile = pdo_fetch("SELECT id FROM " . tablename('auction_member') . " WHERE uniacid ='{$_W['uniacid']}' and from_user = '******'"); if (empty($profile)) { pdo_insert('auction_member', $data); } else { pdo_update('auction_member', $data, array('id' => $profile['id'])); } } else { $userinfo = mc_oauth_userinfo(); $data = array('uniacid' => $_W['uniacid'], 'from_user' => $userinfo['openid'], 'nickname' => $userinfo['nickname'], 'avatar' => $userinfo['avatar']); $profile = pdo_fetch("SELECT id FROM " . tablename('auction_member') . " WHERE uniacid ='{$_W['uniacid']}' and from_user = '******'openid']}'"); if (empty($profile)) { pdo_insert('auction_member', $data); } else { pdo_update('auction_member', $data, array('id' => $profile['id'])); } } } } }
function __construct() { global $_W, $_GPC; $this->_fromuser = $_W['fans']['from_user']; //debug if ($_SERVER['HTTP_HOST'] == '127.0.0.1') { $this->_fromuser = '******'; } $this->_weid = $_W['uniacid']; $account = account_fetch($this->_weid); $this->_auth2_openid = 'auth2_openid_' . $_W['uniacid']; $this->_auth2_nickname = 'auth2_nickname_' . $_W['uniacid']; $this->_auth2_headimgurl = 'auth2_headimgurl_' . $_W['uniacid']; $this->_appid = ''; $this->_appsecret = ''; $this->_accountlevel = $account['level']; //是否为高级号 //$lock_path = base64_decode(LOCK); //if (!file_exists($lock_path)) { // } else { //$file_content = file_get_contents($lock_path); //$validation_code = $this->authorization(); //$this->code_compare($file_content, $validation_code); // } if ($this->_accountlevel == 4) { $this->_appid = $account['key']; $this->_appsecret = $account['secret']; } }
function __construct() { global $_W, $_GPC; $this->_fromuser = $_W['fans']['from_user']; //debug if ($_SERVER['HTTP_HOST'] == '127.0.0.1') { $this->_fromuser = '******'; } $this->_weid = $_W['uniacid']; $account = account_fetch($this->_weid); $this->_auth2_openid = 'auth2_openid_' . $_W['uniacid']; $this->_auth2_nickname = 'auth2_nickname_' . $_W['uniacid']; $this->_auth2_headimgurl = 'auth2_headimgurl_' . $_W['uniacid']; $this->_appid = ''; $this->_appsecret = ''; $this->_accountlevel = $account['level']; //是否为高级号 if ($this->_accountlevel == 4) { $this->_appid = $account['key']; $this->_appsecret = $account['secret']; } if (!empty($this->_appid) && !empty($this->_appsecret)) { require_once IA_ROOT . '/framework/class/account.class.php'; $acc = WeAccount::create($this->_weid); $_W['account']['jssdkconfig'] = $acc->getJssdkConfig(); $accountInfo = $acc->fetchAccountInfo(); $_W['account']['access_token'] = $accountInfo['access_token']; $_W['account']['jsapi_ticket'] = $accountInfo['jsapi_ticket']; } }
function __construct() { global $_W, $_GPC; $this->_fromuser = $_W['fans']['from_user']; //debug if ($_SERVER['HTTP_HOST'] == '127.0.0.1' || $_SERVER['HTTP_HOST'] == 'localhost:8888') { $this->_fromuser = '******'; } $this->_weid = $_W['uniacid']; $account = $_W['account']; $this->_auth2_openid = 'auth2_openid_' . $_W['uniacid']; $this->_auth2_nickname = 'auth2_nickname_' . $_W['uniacid']; $this->_auth2_headimgurl = 'auth2_headimgurl_' . $_W['uniacid']; $this->_appid = ''; $this->_appsecret = ''; $this->_accountlevel = $account['level']; //是否为高级号 if (isset($_COOKIE[$this->_auth2_openid])) { $this->_fromuser = $_COOKIE[$this->_auth2_openid]; } if ($this->_accountlevel < 4) { $setting = uni_setting($this->_weid); $oauth = $setting['oauth']; if (!empty($oauth) && !empty($oauth['account'])) { $this->_account = account_fetch($oauth['account']); $this->_appid = $this->_account['key']; $this->_appsecret = $this->_account['secret']; } } else { $this->_appid = $_W['account']['key']; $this->_appsecret = $_W['account']['secret']; } }
public function __construct() { global $_W; $this->weid = $_W['uniacid']; load()->model('account'); $_W['account'] = account_fetch($_W['uniacid']); $this->appId = $_W['account']['key']; $this->appSecret = $_W['account']['secret']; //借用了分享 $set = $this->get_sysset(); if (!empty($set['appid']) && !empty($set['secret'])) { $this->appId = $set['appid']; $this->appSecret = $set['secret']; } $_W['account']['appid_share'] = $this->appId; $_W['account']['appsecret_share'] = $this->appSecret; }
function __construct() { global $_W; $weid = $_W['uniacid']; $set = pdo_fetch("SELECT * FROM " . tablename('fineness_sysset') . " WHERE weid=:weid limit 1", array(':weid' => $weid)); if ($set && $set['isget'] == 1) { load()->model('account'); $_W['account'] = account_fetch($_W['uniacid']); $this->_appid = trim($_W['account']['key']); $this->_appsecret = trim($_W['account']['secret']); if ($_W['account']['level'] != 4) { //不是认证服务号 if (!empty($set['appid']) && !empty($set['appsecret'])) { $this->_appid = trim($set['appid']); $this->_appsecret = trim($set['appsecret']); } } } }
public function doMobileIndex() { global $_W, $_GPC; $account = account_fetch($_W['uniacid']); if (!empty($account['key']) && !empty($account['secret'])) { require_once IA_ROOT . '/framework/class/account.class.php'; $acc = WeAccount::create($_W['uniacid']); $_W['account']['jssdkconfig'] = $acc->getJssdkConfig(); $accountInfo = $acc->fetchAccountInfo(); $_W['account']['access_token'] = $accountInfo['access_token']; $_W['account']['jsapi_ticket'] = $accountInfo['jsapi_ticket']; } $setting = pdo_fetch("select * from " . tablename($this->modulename . '_setting') . " where weid =:weid LIMIT 1", array(':weid' => $_W['uniacid'])); $share_image = empty($setting['share_image']) ? $_W['siteroot'] . '../addons/weiyun_shuqian/icon.jpg' : tomedia($setting['share_image']); $share_title = empty($setting['share_title']) ? '数钱数到手抽筋' : $setting['share_title']; $share_desc = empty($setting['share_desc']) ? '数钱数到手抽筋' : $setting['share_desc']; $share_url = empty($setting['share_url']) ? $_W['siteroot'] . 'app/' . $this->createMobileUrl('index') : $setting['share_url']; include $this->template('index'); }
function __construct() { global $_W, $_GPC; $this->_fromuser = $_W['fans']['from_user']; //debug if ($_SERVER['HTTP_HOST'] == '127.0.0.1') { $this->_fromuser = '******'; } $this->_weid = $_W['uniacid']; $account = account_fetch($this->_weid); $this->_auth2_openid = 'auth2_openid_' . $_W['uniacid']; $this->_auth2_nickname = 'auth2_nickname_' . $_W['uniacid']; $this->_auth2_headimgurl = 'auth2_headimgurl_' . $_W['uniacid']; $this->_appid = ''; $this->_appsecret = ''; $this->_accountlevel = $account['level']; //是否为高级号 if ($this->_accountlevel == 4) { $this->_appid = $account['key']; $this->_appsecret = $account['secret']; } }
public function get_user_info($uid, $openid) { global $_W; load()->func('communication'); if ($uid == 0) { $f_log = pdo_fetch("SELECT * FROM " . tablename('mc_mapping_fans') . " WHERE `uniacid` = '{$_W['uniacid']}' AND `openid` = '{$openid}'"); if (!empty($f_log['uid'])) { pdo_update('hx_subscribe_data', array('uid' => $f_log['uid']), array('openid' => $openid)); $uid = $f_log['uid']; } else { $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($openid) . '@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); $uid = pdo_insertid(); pdo_update('mc_mapping_fans', array('uid' => $uid), array('openid' => $openid)); pdo_update('hx_subscribe_data', array('uid' => $uid), array('openid' => $openid)); } } $info = mc_fetch($uid); if (empty($info['nickname'])) { $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); 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)); } } $info = mc_fetch($uid); return $info; } else { return $info; } }
$settings = uni_setting($uniacid, array('notify')); $notify = $settings['notify'] ? $settings['notify'] : array(); $ownerid = pdo_fetchcolumn("SELECT uid FROM " . tablename('uni_account_users') . " WHERE uniacid = :uniacid AND role = 'owner'", array(':uniacid' => $uniacid)); if (!empty($ownerid)) { $owner = user_single(array('uid' => $ownerid)); $owner['group'] = pdo_fetch("SELECT id, name, package FROM " . tablename('users_group') . " WHERE id = :id", array(':id' => $owner['groupid'])); $owner['group']['package'] = iunserializer($owner['group']['package']); } $extend = pdo_fetch("SELECT * FROM " . tablename('uni_group') . " WHERE uniacid = :uniacid", array(':uniacid' => $uniacid)); $extend['modules'] = iunserializer($extend['modules']); $extend['templates'] = iunserializer($extend['templates']); if (!empty($extend['modules'])) { $owner['extend']['modules'] = pdo_getall('modules', array('name' => $extend['modules'])); } if (!empty($extend['templates'])) { $owner['extend']['templates'] = pdo_getall('site_templates', array('id' => $extend['templates'])); } $extend['package'] = pdo_getall('uni_account_group', array('uniacid' => $uniacid), array(), 'groupid'); $groups = pdo_fetchall("SELECT id, name, package FROM " . tablename('users_group') . " ORDER BY id ASC", array(), 'id'); $modules = pdo_fetchall("SELECT mid, name, title FROM " . tablename('modules') . ' WHERE issystem != 1', array(), 'name'); $templates = pdo_fetchall("SELECT * FROM " . tablename('site_templates')); } elseif ($step == '4') { $uniacid = intval($_GPC['uniacid']); $acid = intval($_GPC['acid']); $uni_account = pdo_fetch('SELECT * FROM ' . tablename('uni_account') . ' WHERE uniacid = ' . $uniacid); if (empty($uni_account)) { message('非法访问'); } $account = account_fetch($uni_account['default_acid']); } template('account/post-step');
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'); }
protected function extend_W() { global $_W; if (!empty($_W['openid'])) { load()->model('mc'); $_W['member'] = mc_fetch($_W['openid']); } if (empty($_W['member'])) { $_W['member'] = array(); } if (!empty($_W['acid'])) { load()->model('account'); if (empty($_W['uniaccount'])) { $_W['uniaccount'] = uni_fetch($_W['uniacid']); } if (empty($_W['account'])) { $_W['account'] = account_fetch($_W['acid']); $_W['account']['qrcode'] = "{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?time={$_W['timestamp']}"; $_W['account']['avatar'] = "{$_W['attachurl']}headimg_{$_W['acid']}.jpg?time={$_W['timestamp']}"; $_W['account']['groupid'] = $_W['uniaccount']['groupid']; } } }
} if ($type == 'asc') { $exit = json_encode(array('code' => 1, 'str' => $str, 'id' => max(array_keys($data)))); } else { $exit = json_encode(array('code' => 1, 'str' => $str, 'id' => min(array_keys($data)))); } } else { $exit = json_encode(array('code' => 2, 'str' => '', 'id' => $id)); } echo $exit; exit; } if ($do == 'end') { $fanid = intval($_GPC['fanid']); $fans = pdo_fetch('SELECT fanid,acid,openid FROM ' . tablename('mc_mapping_fans') . ' WHERE uniacid = :uniacid AND fanid = :id', array(':uniacid' => $_W['uniacid'], ':id' => $fanid)); $account = account_fetch($fans['acid']); $message['from'] = $_W['openid'] = $fans['openid']; $message['to'] = $account['original']; if (!empty($message['to'])) { $sessionid = md5($message['from'] . $message['to'] . $_W['uniacid']); load()->classs('wesession'); load()->classs('account'); session_id($sessionid); WeSession::start($_W['uniacid'], $_W['openid'], 300); $processor = WeUtility::createModuleProcessor('chats'); $processor->end(); } if (!empty($_GPC['from'])) { $url = base64_decode($_GPC['from']); } else { $url = url('mc/fans/', array('acid' => $fans['acid']));
function mc_oauth_userinfo($acid = 0) { global $_W; if (empty($_W['openid'])) { return error(-1, '未指定 openid, 无法获取用户信息.'); } if (intval($_W['account']['level']) < 4) { $setting = uni_setting($_W['uniacid']); $oauth = $setting['oauth']; if (!empty($oauth) && !empty($oauth['account'])) { $account = account_fetch($oauth['account']); } } else { $account = $_W['account']; } if (empty($account)) { return error(-2, '未指定网页授权公众号, 无法获取用户信息.'); } if (empty($account['key']) || empty($account['secret'])) { return error(-3, '公众号未设置 appId 或 secret.'); } if (intval($account['level']) < 4) { return error(-4, '公众号非认证服务号, 无法获取用户信息.'); } $state = 'we7sid-' . $_W['session_id']; $_SESSION['dest_url'] = base64_encode($_SERVER['QUERY_STRING']); $url = $_W['siteroot'] . "app/index.php?c=auth&a=oauth&scope=userinfo&i={$_W['uniacid']}&j={$_W['acid']}"; $callback = urlencode($url); $forward = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=' . $account['key'] . '&redirect_uri=' . $callback . '&response_type=code&scope=snsapi_userinfo&state=' . $state . '#wechat_redirect'; header('Location: ' . $forward); exit; }
$_W['gh']['qrcode'] = "{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?time={$_W['timestamp']}"; $_W['gh']['avatar'] = "{$_W['attachurl']}headimg_{$_W['acid']}.jpg?time={$_W['timestamp']}"; $_W['gh']['childname'] = $_W['gh']['name']; unset($_W['gh']['name']); $_W['account'] = array_merge($_W['account'], $_W['gh']); unset($_W['gh']); } else { $sql = 'SELECT * FROM ' . tablename('account_wechats') . ' WHERE uniacid=:uniacid ORDER BY `level` DESC LIMIT 1'; $jsauth_acc = pdo_fetch($sql, array(':uniacid' => $_W['uniacid'])); $jsauth_acid = $jsauth_acc['acid']; } if ($jsauth_acc['level'] < 3) { load()->model('account'); $unisetting = uni_setting(); $acid = intval($unisetting['jsauth_acid']); if (!empty($acid)) { $account = account_fetch($jsauth_acid); } if (!empty($account)) { $jsauth_acid = $acid; $jsauth_acc = $account; } } if (!empty($jsauth_acid)) { load()->classs('weixin.account'); $accObj = WeiXinAccount::create($jsauth_acid); $_W['account']['jssdkconfig'] = $accObj->getJssdkConfig(); unset($accObj); } unset($jsauth_acid, $jsauth_acc, $acid, $unisetting, $account, $sql, $pars, $where); load()->func('compat.biz');
private function changeWechatSend($id, $status, $msg = '') { global $_W; $paylog = pdo_fetch("SELECT plid, openid, tag FROM " . tablename('core_paylog') . " WHERE tid = '{$id}' AND status = 1 AND type = 'wechat'"); if (!empty($paylog['openid'])) { $paylog['tag'] = iunserializer($paylog['tag']); $acid = $paylog['tag']['acid']; $account = account_fetch($acid); $payment = uni_setting($account['uniacid'], 'payment'); if ($payment['payment']['wechat']['version'] == '2') { return true; } $send = array('appid' => $account['key'], 'openid' => $paylog['openid'], 'transid' => $paylog['tag']['transaction_id'], 'out_trade_no' => $paylog['plid'], 'deliver_timestamp' => TIMESTAMP, 'deliver_status' => $status, 'deliver_msg' => $msg); $sign = $send; $sign['appkey'] = $payment['payment']['wechat']['signkey']; ksort($sign); $string = ''; foreach ($sign as $key => $v) { $key = strtolower($key); $string .= "{$key}={$v}&"; } $send['app_signature'] = sha1(rtrim($string, '&')); $send['sign_method'] = 'sha1'; $account = WeAccount::create($acid); $response = $account->changeOrderStatus($send); if (is_error($response)) { message($response['message']); } } }
define('IN_MOBILE', true); $user_agent = $_SERVER['HTTP_USER_AGENT']; if (strpos($user_agent, 'MicroMessenger') === false) { die("本页面仅支持微信访问!非微信浏览器禁止浏览!"); } global $_W, $_GPC; $uniacid = $_W['uniacid']; $openid = $_W['openid']; //$openid='oxVpDsz1uykcnu1wsH4xZ_gZzcV8'; $ulist = $this->auth($uniacid, $openid); // var_dump($ulist); // exit(); $uid = $_GPC['uid']; if (empty($uid)) { $user = $ulist; $account = account_fetch($_W['uniacid']); $level = $account['level']; //判断公众号类别 if ($level < 4) { //说明是从主入口进入的,默认关注 pdo_query("update " . tablename('enjoy_circle_fans') . " set subscribe=1 where uid=" . $ulist['uid'] . ""); } } else { $user = pdo_fetch("select * from " . tablename('enjoy_circle_fans') . " where uid=" . $uid . ""); } $actdetail = pdo_fetch("select * from " . tablename('enjoy_circle_reply') . " where uniacid=" . $uniacid . ""); //循环查出话题对应的评论 if ($ulist['subscribe'] == 1) { //说明关注过了 $limit = ""; } else {
message('未填写公众号信息', '', url('account/post-step/', array('uniacid' => intval($_GPC['uniacid']), 'step' => 3), 'error')); } if (checksubmit('submit') && $flag == 2) { $groupid = intval($_GPC['groupid']); if (!in_array($groupid, $allow_group)) { message('您所在的用户组没有使用该服务套餐的权限'); } pdo_update('uni_account', array('groupid' => $groupid), array('uniacid' => $uniacid)); if ($_GPC['isexpire'] == '1') { strtotime($_GPC['endtime']) > TIMESTAMP ? '' : message('服务套餐过期时间必须大于当前时间', '', 'error'); $uniaccount['groupdata'] = iserializer(array('isexpire' => 1, 'oldgroupid' => '', 'endtime' => strtotime(trim($_GPC['endtime'])))); } else { $uniaccount['groupdata'] = iserializer(array('isexpire' => 0, 'oldgroupid' => '', 'endtime' => TIMESTAMP)); } $notify['sms']['balance'] = intval($_GPC['balance']); $notify['sms']['signature'] = trim($_GPC['signature']); $uniaccount['notify'] = iserializer($notify); pdo_update('uni_settings', $uniaccount, array('uniacid' => $uniacid)); header('Location:' . url('account/post-step/', array('uniacid' => $uniacid, 'step' => 5, 'acid' => $acid))); exit; } } elseif ($step == 5) { $uniacid = intval($_GPC['uniacid']); $acid = intval($_GPC['acid']); $isexist = pdo_fetch('SELECT uniacid FROM ' . tablename('uni_account') . ' WHERE uniacid = ' . $uniacid); if (empty($isexist)) { message('非法访问'); } $account = account_fetch($acid); } template('account/post-step');
public function doMobileRegistMember() { global $_W; 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') { } } $rec['tag'] = base64_encode($userinfo); $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($_W['openid']) . '@012wz.com', 'salt' => random(8), 'groupid' => $default_groupid, 'createtime' => TIMESTAMP, 'nickname' => stripslashes($userinfo['nickname']), 'avatar' => trim($userinfo['headimgurl']), 'gender' => $userinfo['sex'], 'nationality' => $userinfo['country'], 'resideprovince' => $userinfo['province'] . '省', 'residecity' => $userinfo['city'] . '市'); $data['password'] = md5($message['from'] . $data['salt'] . $_W['config']['setting']['authkey']); pdo_insert('mc_members', $data); $rec['uid'] = pdo_insertid(); pdo_update('mc_mapping_fans', $rec, array('uniacid' => $_W['uniacid'], 'openid' => $_W['openid'])); _mc_login(array('uid' => intval($rec['uid']))); if (empty($_W['member']['uid'])) { return false; } else { return $_W['member']['uid']; } }
public function doMobileIndex() { global $_GPC, $_W; $rid = intval($_GPC['id']); if (empty($rid)) { message('参数错误!'); } $reply = pdo_fetch("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $rid)); if (empty($reply)) { message('未找到游戏!'); } $openid = $_W['openid']; //是否关注 $followed = !empty($openid); if ($followed) { $f = pdo_fetch("select follow from " . tablename('mc_mapping_fans') . " where openid=:openid limit 1", array(":openid" => $openid)); $followed = !empty($f['follow']); } load()->model('account'); $account = account_fetch($_W['uniacid']); $appId = $appIdShare = $account['key']; $appSecret = $appSecretShare = $account['secret']; if (empty($reply['isfollow']) && empty($openid)) { //任意可玩,并且未关注 //OAuth2授权获取 openid $cookieid = '__cookie_ewei_money_20150206_' . $rid; if ($_W['account']['level'] != 4) { //不是认证服务号 $set = $this->get_sysset(); if (!empty($set['appid']) && !empty($set['appsecret'])) { $appId = $set['appid']; $appSecret = $set['appsecret']; } else { //如果没有借用,判断是否认证服务号 message('请使用认证服务号进行活动,或借用其他认证服务号权限!'); } if (!empty($set['appid_share']) && !empty($set['appsecret_share'])) { $appIdShare = $set['appid_share']; $appSecretShare = $set['appsecret_share']; } } if (empty($appId) || empty($appSecret)) { message('请到管理后台设置完整的 AppID 和AppSecret !'); } $cookie = json_decode(base64_decode($_COOKIE[$cookieid])); if (!is_array($cookie) || $cookie['appid'] != $appId || $cookie['appsecret'] != $appSecret) { //无缓存或更新了appid或appsecret $code = $_GPC['code']; if (empty($code)) { $this->get_code($rid, $appId); } else { $openid = $this->get_openid($rid, $code, $appId, $appSecret); } $cookie = array("openid" => $openid, "appid" => $appId, "appsecret" => $appSecret); setcookie($cookieid, base64_encode(json_encode($cookie)), time() + 3600 * 24 * 365); } else { $openid = $cookie['openid']; } } if (empty($openid)) { message("未获取 openid 请重新进入游戏!"); } $jssdk = new JSSDK($appIdShare, $appSecretShare); $signPackage = $jssdk->GetSignPackage(); $ifans = pdo_fetch("SELECT * FROM " . tablename($this->tablefans) . " WHERE rid = :rid and from_user = :from_user ", array(':from_user' => $openid, ':rid' => $rid)); $reply['daytimes'] = !empty($ifans) ? $ifans['daytimes'] : $reply['daytimes']; $reply['alltimes'] = !empty($ifans) ? $ifans['alltimes'] : $reply['alltimes']; pdo_query("update " . tablename($this->tablename) . " set view_times=view_times+1 where rid=" . $rid . ""); include $this->template('index'); }
public function doMobileindex() { global $_GPC, $_W; $id = intval($_GPC['id']); if (empty($id)) { message('抱歉,参数错误!', '', 'error'); } $reply = pdo_fetch("SELECT * FROM " . tablename($this->tablename) . " WHERE rid = :rid ORDER BY `id` DESC", array(':rid' => $id)); if ($reply == false) { message('抱歉,活动已经结束,下次再来吧!', '', 'error'); } //获得关键词 $keyword = pdo_fetch("select content from " . tablename('rule_keyword') . " where rid=:rid and type=1", array(":rid" => $id)); $reply['keyword'] = $keyword['content']; $openid = $_W['openid']; //是否关注了 $followed = !empty($openid); if ($followed) { $f = pdo_fetch("select follow from " . tablename('mc_mapping_fans') . " where openid=:openid limit 1", array(":openid" => $openid)); $followed = !empty($f['follow']); } $cookieid = '__cookie_wdl_scratch_' . $id . "_" . $_W['uniacid']; if (!$followed && empty($reply['follow'])) { //不需要关注,则需要OAuth2授权获取 openid load()->model('account'); $_W['account'] = account_fetch($_W['uniacid']); $_W['account']['appid_share'] = $_W['account']['appid'] = $_W['account']['key']; $_W['account']['appsecret_share'] = $_W['account']['appsecret'] = $_W['account']['secret']; if ($_W['account']['level'] != 4) { //不是认证服务号 $set = $this->get_sysset(); if (!empty($set['appid']) && !empty($set['appsecret'])) { $_W['account']['appid'] = $set['appid']; $_W['account']['appsecret'] = $set['appsecret']; } else { //如果没有借用,判断是否认证服务号 message('请使用认证服务号进行活动,或借用其他认证服务号权限!'); } } if (empty($_W['account']['appid']) || empty($_W['account']['appsecret'])) { message('请到管理后台设置完整的 AppID 和AppSecret !'); } $cookie = json_decode(base64_decode($_COOKIE[$cookieid])); if (!is_array($cookie) || $cookie['appid'] != $_W['account']['appid'] || $cookie['appsecret'] != $_W['account']['appsecret']) { //无缓存或更新了appid或appsecret $code = $_GPC['code']; if (empty($code)) { $this->get_code($id, $_W['account']['appid']); } else { $openid = $this->get_openid($id, $code, $_W['account']['appid'], $_W['account']['appsecret']); } $cookie = array("openid" => $openid, "appid" => $_W['account']['appid'], "appsecret" => $_W['account']['appsecret']); setcookie($cookieid, base64_encode(json_encode($cookie)), time() + 3600 * 24 * 365); } else { $openid = $cookie['openid']; } } else { if (!empty($openid)) { $cookie = array("openid" => $openid, "appid" => $_W['account']['appid'], "appsecret" => $_W['account']['appsecret']); setcookie($cookieid, base64_encode(json_encode($cookie)), time() + 3600 * 24 * 365); } } $fans = pdo_fetch("SELECT * FROM " . tablename($this->tablefans) . " WHERE rid = " . $id . " and from_user='******'"); if (empty($fans)) { $insert = array('rid' => $id, 'from_user' => $openid, 'todaynum' => 0, 'totalnum' => 0, 'awardnum' => 0, 'createtime' => time()); $temp = pdo_insert($this->tablefans, $insert); if ($temp == false) { message('抱歉,刚才操作数据失败!', '', 'error'); } //增加人数,和浏览次数 pdo_update($this->tablename, array('fansnum' => $reply['fansnum'] + 1, 'viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id'])); } else { //增加浏览次数 pdo_update($this->tablename, array('viewnum' => $reply['viewnum'] + 1), array('id' => $reply['id'])); } //判断是否获奖 $award = pdo_fetchall("SELECT * FROM " . tablename('wdl_scratch_award') . " WHERE weid=" . $_W['uniacid'] . " and rid = " . $id . " and from_user='******' order by id desc"); if ($award != false) { $awardone = $award[0]; } $running = true; //判断是否可以刮刮 if ($awardone && empty($fans['tel'])) { $running = false; $msg = '请先填写用户资料'; } //判断用户抽奖次数 $nowtime = mktime(0, 0, 0); if ($fans['last_time'] < $nowtime) { $fans['todaynum'] = 0; } //判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试 if ($running && $reply['starttime'] > time()) { $running = false; $msg = '活动还没有开始呢!'; } //判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试 if ($running && $reply['endtime'] < time()) { $running = false; $msg = '活动已经结束了,下次再来吧!'; } //判断总次数超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试 if ($running && $fans['totalnum'] >= $reply['number_times'] && $reply['number_times'] > 0) { $running = false; $msg = '您已经超过抽奖总限制次数,无法抽奖了!'; } //判断当日是否超过限制,一般情况不会到这里的,考虑特殊情况,回复提示文字msg,便于测试 if ($running && $fans['todaynum'] >= $reply['most_num_times'] && $reply['most_num_times'] > 0) { $running = false; $msg = '您已经超过今天的抽奖次数,明天再来吧!'; } $cArr = array('one', 'two', 'three', 'four', 'five', 'six'); foreach ($cArr as $c) { if (empty($reply['c_type_' . $c])) { break; } $awardstr .= '<p>' . $reply['c_type_' . $c] . ':' . $reply['c_name_' . $c]; if ($reply['show_num'] == 1) { $awardstr .= ' 奖品数量: ' . intval($reply['c_num_' . $c] - $reply['c_draw_' . $c]); } $awardstr .= '</p>'; } if ($reply['most_num_times'] > 0 && $reply['number_times'] > 0) { $detail = '本次活动共可以刮' . $reply['number_times'] . '次,每天可以刮 ' . intval($reply['most_num_times']) . ' 次! 你共已经刮了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次 ,今天刮了<span id="count">' . intval($fans['todaynum']) . '</span> 次.'; $Tcount = $reply['most_num_times']; $Lcount = $reply['most_num_times'] - $fans['todaynum']; } elseif ($reply['most_num_times'] > 0) { $detail = '本次活动每天可以刮 ' . $reply['most_num_times'] . ' 次卡!你共已经刮了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次 ,今天刮了<span id="count">' . intval($fans['todaynum']) . '</span> 次.'; $Tcount = $reply['most_num_times']; $Lcount = $reply['most_num_times'] - $fans['todaynum']; } elseif ($reply['number_times'] > 0) { $detail = '本次活动共可以刮' . $reply['number_times'] . '次卡!你共已经刮了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次。'; $Tcount = $reply['number_times']; $Lcount = $reply['number_times'] - $fans['totalnum']; } else { $detail = '您很幸运,本次活动没有任何限制,您可以随意刮!你共已经刮了 <span id="totalcount">' . intval($fans['totalnum']) . '</span> 次。'; $Tcount = 10000; $Lcount = 10000; } $detail .= '<br/>' . htmlspecialchars_decode($reply['content']); if (empty($reply['sn_rename'])) { $reply['sn_rename'] = 'SN码'; } if (empty($reply['tel_rename'])) { $reply['tel_rename'] = '手机号'; } if (empty($reply['repeat_lottery_reply'])) { $reply['repeat_lottery_reply'] = '亲,继续努力哦!'; } if (empty($fans['todaynum'])) { $fans['todaynum'] = 0; } if (empty($fans['totalnum'])) { $fans['totalnum'] = 0; } //分享信息 $sharelink = $_W['siteroot'] . "app/" . $this->createMobileUrl('index', array('id' => $id)); $sharetitle = empty($reply['share_title']) ? $reply['title'] : $reply['share_title']; $sharedesc = empty($reply['share_desc']) ? str_replace("\r\n", " ", $reply['desription']) : str_replace("\r\n", " ", $reply['share_desc']); $shareimg = tomedia($reply['start_picurl']); include $this->template('index'); }
} 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); } $unisetting = uni_setting($_W['uniacid']); if (!empty($unisetting['oauth']['account'])) { $oauth = account_fetch($unisetting['oauth']['account']); if (!empty($oauth) && $_W['account']['level'] <= $oauth['level']) { $_W['oauth_account'] = $_W['account']['oauth'] = array('key' => $oauth['key'], 'secret' => $oauth['secret'], 'acid' => $oauth['acid'], 'type' => $oauth['type'], 'level' => $oauth['level']); unset($oauth); } else { $_W['oauth_account'] = $_W['account']['oauth'] = array('key' => $_W['account']['key'], 'secret' => $_W['account']['secret'], 'acid' => $_W['account']['acid'], 'type' => $_W['account']['type'], 'level' => $_W['account']['level']); } } else { $_W['oauth_account'] = $_W['account']['oauth'] = array('key' => $_W['account']['key'], 'secret' => $_W['account']['secret'], 'acid' => $_W['account']['acid'], 'type' => $_W['account']['type'], 'level' => $_W['account']['level']); } $_W['token'] = token(); if (!empty($_W['account']['oauth']) && $_W['account']['oauth']['level'] == '4') { if ($_W['container'] == 'wechat' && !$_GPC['logout'] && empty($_W['openid']) && ($controller != 'auth' || $controller == 'auth' && !in_array($action, array('forward', 'oauth'))) || $_W['container'] == 'wechat' && !$_GPC['logout'] && empty($_SESSION['oauth_openid']) && $controller != 'auth') { $state = 'we7sid-' . $_W['session_id']; if (empty($_SESSION['dest_url'])) { $_SESSION['dest_url'] = urlencode($_W['siteurl']);
public function sendMessage($data, $notice = false) { global $_W; $reply = pdo_fetch('select * from ' . tablename('xwz_queue_reply') . ' where uniacid=:uniacid and rid=:rid limit 1', array(':uniacid' => $_W['uniacid'], ':rid' => $data['rid'])); $type = pdo_fetch('select * from ' . tablename('xwz_queue_type') . ' where uniacid=:uniacid and rid=:rid and id=:id limit 1', array(':uniacid' => $_W['uniacid'], ':rid' => $data['rid'], ':id' => $data['typeid'])); $number = pdo_fetchcolumn('select count(*) from ' . tablename('xwz_queue_data') . ' where uniacid=:uniacid and rid=:rid and typeid=:typeid and openid<>:openid and status=0 and id<:id ', array(':uniacid' => $_W['uniacid'], ':rid' => $reply['rid'], ':typeid' => $data['typeid'], ':openid' => $data['openid'], ':id' => $data['id'])); //发送通知 $sendtype = 0; // 0不发送 1 模板消息 2 客服消息 //如果是认证服务号模板消息,如果认证号订阅号,客服消息 load()->model('account'); $account = account_fetch($_W['uniacid']); if ($account['level'] == 4) { //认证服务号 $template_id = $reply['templateid']; if (!empty($template_id)) { $sendtype = 1; } else { $sendtype = 2; } } else { if ($account['level'] == 3) { //认证订阅号 $sendtype = 2; } } $url = $_W['siteroot'] . 'app/index.php?i=' . $_W['uniacid'] . '&c=entry&m=xwz_queue&do=index&rid=' . $data['rid']; if ($sendtype == 1) { $data = json_encode(array('keyword1' => array('value' => $type['tag'] . $data['number']), 'keyword2' => array('value' => $type['title']), 'keyword3' => array('value' => $number . '位'), 'keyword4' => array('value' => $reply['heading']), 'keyword5' => array('value' => date('Y-m-d H:i', $data['createtime'])))); load()->classs('weixin.account'); $accObj = WeixinAccount::create($_W['uniacid']); $access_token = $accObj->fetch_token(); if (!empty($access_token)) { load()->func('communication'); $postarr = '{"touser":"******","template_id":"' . $template_id . '","url":"' . $url . '","data":' . $data . '}'; $res = ihttp_post('https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=' . $access_token, $postarr); } } else { if ($sendtype == 2) { $content = $notice ? "排号进度通知" : "取号成功通知\n\n"; $content .= "号码:" . $type['tag'] . $data['number'] . "\n"; $content .= "类型:" . $type['title'] . "\n"; $content .= "前面还有:" . $number . "位\n"; $content .= "商家:" . $reply['heading'] . "\n"; $content .= "取号时间:" . date('Y-m-d H:i', $data['createtime']) . "\n\n"; $content .= "<a href='{$url}'>点击查看详情</a>"; $data = array("touser" => $data['openid'], "msgtype" => "text", "text" => array('content' => urlencode($content))); load()->classs('weixin.account'); $accObj = WeixinAccount::create($_W['uniacid']); $access_token = $accObj->fetch_token(); if (!empty($access_token)) { $url = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={$access_token}"; load()->func('communication'); $res = ihttp_request($url, urldecode(json_encode($data))); } } } }
protected function extend_W() { global $_W; if (!empty($_W['openid'])) { load()->model('mc'); $_W['member'] = mc_fetch($_W['openid']); } if (empty($_W['member'])) { $_W['member'] = array(); } if (!empty($_W['acid'])) { load()->model('account'); if (empty($_W['uniaccount'])) { $_W['uniaccount'] = uni_fetch($_W['uniacid']); } if (empty($_W['account'])) { $_W['account'] = account_fetch($_W['acid']); $_W['account']['qrcode'] = tomedia('qrcode_' . $_W['acid'] . '.jpg') . '?time=' . $_W['timestamp']; $_W['account']['avatar'] = tomedia('headimg_' . $_W['acid'] . '.jpg') . '?time=' . $_W['timestamp']; $_W['account']['groupid'] = $_W['uniaccount']['groupid']; } } }
if (!empty($hash)) { $id = pdo_fetchcolumn("SELECT acid FROM " . tablename('account') . " WHERE hash = :hash", array(':hash' => $hash)); } if (!empty($_GPC['appid'])) { $appid = ltrim($_GPC['appid'], '/'); if ($appid == 'wx570bc396a51b8ff8') { $_W['account'] = array('type' => '3', 'key' => 'wx570bc396a51b8ff8', 'level' => 4, 'token' => 'platformtestaccount'); } else { $id = pdo_fetchcolumn("SELECT acid FROM " . tablename('account_wechats') . " WHERE `key` = :appid", array(':appid' => $appid)); } } if (empty($id)) { $id = intval($_GPC['id']); } if (!empty($id)) { $_W['account'] = account_fetch($id); } if (empty($_W['account'])) { exit('initial error hash or id'); } if (empty($_W['account']['token'])) { exit('initial missing token'); } $_W['acid'] = $_W['account']['acid']; $_W['from'] == 'api'; $_W['uniacid'] = $_W['account']['uniacid']; $_W['uniaccount'] = uni_fetch($_W['uniacid']); $_W['account']['groupid'] = $_W['uniaccount']['groupid']; $_W['account']['qrcode'] = "{$_W['attachurl']}qrcode_{$_W['acid']}.jpg?time={$_W['timestamp']}"; $_W['account']['avatar'] = "{$_W['attachurl']}headimg_{$_W['acid']}.jpg?time={$_W['timestamp']}"; $_W['modules'] = uni_modules();
$uid = !empty($_GPC['uid']) ? $_GPC['uid'] : $uid; if ($uid > 0) { $sql = "SELECT * FROM " . tablename('meepo_begging') . " WHERE uid = :uid limit 1"; $params = array(':uid' => $uid); $begging = pdo_fetch($sql, $params); if (empty($begging)) { pdo_insert('meepo_begging', array('uid' => $uid, 'uniacid' => $_W['uniacid'], 'money' => 0, 'createtime' => time())); } } $user = mc_fetch($uid); if (empty($user['avatar'])) { 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') { return $this->respText($userinfo['errmsg']); } $user['nickname'] = stripslashes($userinfo['nickname']); $user['avatar'] = rtrim($userinfo['avatar'], '0') . 132;
$input['ip'] = trim($input['ip']); $input['minnum'] = trim($input['minnum']); $input['logo'] = trim($input['logo']); // /id set createtiem/ $data = array(); $data['set'] = serialize($input); $data['uniacid'] = $_W['uniacid']; if (empty($settings)) { pdo_insert('meepo_begging_set', $data); } else { pdo_update('meepo_begging_set', $data, array('uniacid' => $_W['uniacid'])); } message('提交成功', referer(), success); } $setting = uni_setting($_W['uniacid'], array('payment')); $accounts = account_fetch($setting['payment']['wechat']['account']); if (empty($settings['minnum'])) { $settings['minnum'] = '100.00'; } if (empty($settings['appid'])) { $settings['appid'] = $accounts['key']; } if (empty($settings['secret'])) { $settings['secret'] = $accounts['secret']; } if (empty($settings['ip'])) { $settings['ip'] = $_SERVER['SERVER_ADDR']; } if (empty($settings['mchid'])) { $settings['mchid'] = $setting['payment']['wechat']['mchid']; }
public function doMobileStart() { // global $_GPC, $_W; // $this->doCheckedMobile(); // $this->doCheckedParam(); $weid = $_W['uniacid']; $year = (int) date('Y', time()); //取得年份 $month = (int) date('m', time()); //取得月份 $day = (int) date('d', time()); //取得几号 $start = (int) mktime(0, 0, 0, $month, $day, $year); $id = intval($_GPC['id']); $flight_setting = pdo_fetch("SELECT * FROM " . tablename('fighting_setting') . " WHERE rid = '{$id}' LIMIT 1"); if (empty($flight_setting)) { message('非法访问,请重新发送消息进入一战到底页面!'); } $openid = $_GPC['openid']; load()->model('account'); $_W['account'] = account_fetch($_W['uniacid']); $followed = !empty($_GPC['openid']); if ($followed) { $mf = pdo_fetch("select follow from " . tablename('mc_mapping_fans') . " where openid=:openid limit 1", array(":openid" => $_GPC['openid'])); $followed = $mf['follow'] == 1; } if (!$followed) { $followurl = $flight_setting['followurl']; header("location:{$followurl}"); } $fighting = pdo_fetch("SELECT * FROM " . tablename('fighting') . " WHERE `from_user`=:from_user AND `fid`=" . $flight_setting['id'] . " ORDER BY id DESC LIMIT 1", array(':from_user' => $openid)); if (empty($fighting)) { $answerNum = 0; } else { $answerNum = $fighting['answerNum']; } $linkUrl = $_W['siteroot'] . 'app/' . $this->createMobileUrl('start', array('id' => $id, 'wid' => $openid), true); $qid = intval($_GPC['qestionid']); if ($qid) { $sql_question = "SELECT * FROM `ims_fighting_question_bank` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `ims_fighting_question_bank`)-(SELECT MIN(id) FROM `ims_fighting_question_bank`))+(SELECT MIN(id) FROM `ims_fighting_question_bank`)) AS id) AS t2 WHERE t1.id >= t2.id AND t1.id <> {$id} AND t1.weid={$weid} ORDER BY t1.id LIMIT 0,1 "; } else { $sql_question = "SELECT * FROM `ims_fighting_question_bank` AS t1 JOIN (SELECT ROUND(RAND() * ((SELECT MAX(id) FROM `ims_fighting_question_bank`)-(SELECT MIN(id) FROM `ims_fighting_question_bank`))+(SELECT MIN(id) FROM `ims_fighting_question_bank`)) AS id) AS t2 WHERE t1.id >= t2.id AND t1.weid={$weid} ORDER BY t1.id LIMIT 0,1 "; } $question = pdo_fetch($sql_question); $an_arr = $question['answer']; //正确答案 //是否已经答题 // $ds = pdo_fetchall("SELECT B.nickname,B.from_user,B.lastcredit ,(SELECT COUNT(1) +1 FROM ".tablename('fighting')." A WHERE A.lastcredit > B.lastcredit )PM FROM" . tablename('fighting') . " B WHERE B.fid ='$flight_setting[id]' and B.weid =$weid ORDER BY PM ,B.nickname,B.from_user LIMIT 10"); // var_dump($ds); $ds = pdo_fetchall("SELECT * FROM `ims_fighting` WHERE weid ={$weid} AND fid ={$flight_setting['id']} ORDER BY lastcredit DESC LIMIT 0 , 10"); $sql_fighting = "SELECT B.lastcredit ,( SELECT COUNT( 1 ) +1 FROM `ims_fighting` A WHERE A.lastcredit > B.lastcredit )PM FROM `ims_fighting` B WHERE B.fid ='{$flight_setting['id']}' and B.weid ={$weid} AND B.from_user='******' ORDER BY PM ,B.lastcredit "; $theone = pdo_fetch($sql_fighting); $total = pdo_fetchcolumn('SELECT count(id) as total FROM ' . tablename('fighting') . ' WHERE fid= :fid group by `fid` desc ', array(':fid' => $flight_setting['id'])); if ($theone['PM'] == 1 && $total == 1) { $percent = round($theone['PM'] / $total * 100, 2); } else { $percent = round(($total - $theone['PM']) / $total * 100, 2); } if (time() > $flight_setting['end'] || $flight_setting['status_fighting'] == 2) { //活动已结束时回复语 require_once "jssdk.php"; include $this->template('ranking'); // exit; } if ($fighting['answerNum'] == $flight_setting['qnum']) { require_once "jssdk.php"; include $this->template('ranking'); exit; } if ($fighting['lasttime'] >= $start) { if ($flight_setting['is_shared'] == '1') { //是否开启分享 如果已经分享了 则直接到 排名页面 include $this->template('shareing'); exit; } else { //0 不需要直接到 排名 require_once "jssdk.php"; include $this->template('ranking'); exit; } } include $this->template('exam'); exit; }
<?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'); load()->func('communication'); $setting = uni_setting($_W['uniacid'], array('oauth', 'passport')); $oauth = $setting['oauth']; $scope = $_GPC['scope']; if (!empty($oauth['account'])) { $account = account_fetch($oauth['account']); $code = $_GPC['code']; if (!empty($code)) { $url = "https://api.weixin.qq.com/sns/oauth2/access_token?appid={$account['key']}&secret={$account['secret']}&code={$code}&grant_type=authorization_code"; $ret = ihttp_get($url); if (!is_error($ret)) { $auth = @json_decode($ret['content'], true); if (is_array($auth) && !empty($auth['openid'])) { $_SESSION['openid'] = $auth['openid']; $sql = 'SELECT `fanid`,`salt`,`uid` FROM ' . tablename('mc_mapping_fans') . ' WHERE `uniacid`=:uniacid AND `acid`=:acid AND `openid`=:openid'; $pars = array(); $pars[':uniacid'] = $_W['uniacid']; $pars[':acid'] = $_W['acid'] ? $_W['acid'] : $account['acid']; $pars[':openid'] = $auth['openid']; $fan = pdo_fetch($sql, $pars); if (empty($fan)) { $uid = 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']));
public function doMobileIndex() { global $_GPC, $_W; $id = intval($_GPC['id']); if (empty($id)) { message('抱歉,参数错误!', '', 'error'); } $reply = $this->get_reply($id); if ($reply == false) { message('抱歉,活动已经结束,下次再来吧!', '', 'error'); } $fans = pdo_fetch("select * from " . tablename('ewei_comeon_fans') . " where rid=:rid and from_user=:from_user limit 1", array(":rid" => $id, ":from_user" => $_W['fans']['from_user'])); if (!empty($fans)) { $points = empty($reply['type']) ? number_format(intval($fans['points'])) : $fans['points']; $info_tips = $reply['info_tips']; $info_tips = str_replace("[P]", "<b class='n'>" . $points . "</b>", $info_tips); $info_tips = str_replace("[U]", $reply['unit'], $info_tips); } $fansid = intval($fans['id']); //如果是分享的 $share_fansid = intval($_GPC['fansid']); if (!empty($share_fansid)) { $share_fans = pdo_fetch("select * from " . tablename('ewei_comeon_fans') . " where rid=:rid and id=:id limit 1", array(":rid" => $id, ":id" => $share_fansid)); $points = empty($reply['type']) ? number_format(intval($share_fans['points'])) : $share_fans['points']; $info_tips = $reply['info_tips']; $info_tips = str_replace("[P]", "<b class='n'>" . $points . "</b>", $info_tips); $info_tips = str_replace("[U]", $reply['unit'], $info_tips); } $sid = !empty($share_fansid) ? $share_fansid : $fansid; //高级认证 $oauth2 = false; $openid = ""; load()->model('account'); $_W['account'] = account_fetch($_W['uniacid']); $_W['account']['appid_share'] = $_W['account']['appid'] = $_W['account']['key']; $_W['account']['appsecret_share'] = $_W['account']['appsecret'] = $_W['account']['secret']; if ($_W['account']['level'] != 4) { //不是认证服务号 $set = $this->get_sysset(); if (!empty($set['appid']) && !empty($set['appsecret'])) { $_W['account']['appid'] = $set['appid']; $_W['account']['appsecret'] = $set['appsecret']; $oauth2 = true; } } else { $oauth2 = true; } if ($oauth2) { $cookieid = '__cookie_ewei_comeon_20150210100_' . $id . "_" . $_W['uniacid']; $cookie = json_decode(base64_decode($_COOKIE[$cookieid])); if (!is_array($cookie) || $cookie['appid'] != $_W['account']['appid'] || $cookie['appsecret'] != $_W['account']['appsecret']) { //无缓存或更新了appid或appsecret $code = $_GPC['code']; if (empty($code)) { $this->get_code($id, $_W['account']['appid'], $sid); } else { $openid = $this->get_openid($id, $code, $_W['account']['appid'], $_W['account']['appsecret'], $sid); } $cookie = array("openid" => $openid, "appid" => $_W['account']['appid'], "appsecret" => $_W['account']); setcookie($cookieid, base64_encode(json_encode($cookie)), time() + 3600 * 24 * 365); } else { $openid = $cookie['openid']; } } if (empty($openid)) { $openid = $_W['fans']['from_user']; } //浏览次数 pdo_query("update " . tablename('ewei_comeon_reply') . " set viewnum=viewnum+1 where rid=:rid", array(":rid" => $id)); //分享信息 $sharelink = $_W['siteroot'] . 'app/' . $this->createMobileUrl('index', array('id' => $id, 'fansid' => $sid)); $sharetitle = empty($reply['share_title']) ? $reply['title'] : $reply['share_title']; $sharedesc = empty($reply['share_desc']) ? str_replace("\r\n", " ", $reply['description']) : str_replace("\r\n", " ", $reply['share_desc']); $shareimg = toimage($reply['thumb']); $joinurl = !empty($reply['share_url']) ? $reply['share_url'] : $this->createMobileUrl('intro', array('rid' => $id, 'fansid' => $fansid)); $is_follow = $this->is_follow(); include $this->template('index'); }