/** * 组装配置信息 * @param $url * return json */ public function InitConfig($url) { $info = get_token_appinfo(); //appId $appid = 'wxaa3ddf43e19630ee'; //$secret = '2946a5c98f49087208212f9bcba69379'; $appid = $info['appid']; $secret = $info['secret']; //生成签名的时间戳 //生成签名的随机串 $nonceStr = $timestamp = 12345678901; $access_token = get_access_token(); if (empty($access_token)) { $auth = file_get_contents("https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=" . $appid . "&secret=" . $secret); $token = json_decode($auth); $t = get_object_vars($token); //转换成数组 $access_token = $t['access_token']; //输出access_token } $jsapi_contents = file_get_contents("https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=" . $access_token . "&type=jsapi"); $jsapi = json_decode($jsapi_contents); $j = get_object_vars($jsapi); $jsapi_ticket = $j['ticket']; //get JSAPI $and = "jsapi_ticket=" . $jsapi_ticket . "&noncestr=" . $nonceStr . "×tamp=" . $timestamp . "&url=" . $url . ""; $signature = sha1($and); $arr['appId'] = $appid; $arr['timestamp'] = $timestamp; $arr['nonceStr'] = $nonceStr; $arr['signature'] = $signature; echo json_encode($arr); //输出json数据 }
function reply($dataArr, $keywordArr = array()) { $map['id'] = $keywordArr['aim_id']; $info = M('auto_reply')->where($map)->find(); if ($info['msg_type'] == 'news') { $map_news['group_id'] = $info['group_id']; $list = M('material_news')->where($map_news)->select(); $param['publicid'] = get_token_appinfo('', 'id'); foreach ($list as $k => $vo) { if ($k > 8) { continue; } $articles[] = array('Title' => $vo['title'], 'Description' => $vo['intro'], 'PicUrl' => get_cover_url($vo['cover_id']), 'Url' => $this->_getNewsUrl($vo, $param)); } $res = $this->replyNews($articles); } elseif ($info['msg_type'] == 'image') { if ($info['image_id']) { // $d['image_id']=url_img_html(get_cover_url($d['image_id'])); $media_id = D('Common/Custom')->get_image_media_id($info['image_id']); } else { if ($info['image_material']) { $map2['id'] = $info['image_material']; $media_img = M('material_image')->where($map2)->find(); $media_id = $media_img['image_id']; if (!$media_id) { $media_id = D('Common/Custom')->get_image_media_id($media_img['cover_id']); } } } $this->replyImage($media_id); } else { $contetn = replace_url(htmlspecialchars_decode($info['content'])); $this->replyText($contetn); } }
function bind() { if (defined('IN_WEIXIN') && IN_WEIXIN || isset($_GET['is_stree']) || !C('USER_OAUTH')) { return false; } $isWeixinBrowser = isWeixinBrowser(); if (!$isWeixinBrowser) { $this->error('请在微信里打开'); } $info = get_token_appinfo(); $param['appid'] = $info['appid']; $callback = U('bind'); if ($_GET['state'] != 'weiphp') { $param['redirect_uri'] = $callback; $param['response_type'] = 'code'; $param['scope'] = 'snsapi_userinfo'; $param['state'] = 'weiphp'; $info['is_bind'] && ($param['component_appid'] = C('COMPONENT_APPID')); $url = 'https://open.weixin.qq.com/connect/oauth2/authorize?' . http_build_query($param) . '#wechat_redirect'; redirect($url); } elseif ($_GET['state'] == 'weiphp') { if (empty($_GET['code'])) { exit('code获取失败'); } $param['code'] = I('code'); $param['grant_type'] = 'authorization_code'; if ($info['is_bind']) { $param['appid'] = I('appid'); $param['component_appid'] = C('COMPONENT_APPID'); $param['component_access_token'] = D('Addons://PublicBind/PublicBind')->_get_component_access_token(); $url = 'https://api.weixin.qq.com/sns/oauth2/component/access_token?' . http_build_query($param); } else { $param['secret'] = $info['secret']; $url = 'https://api.weixin.qq.com/sns/oauth2/access_token?' . http_build_query($param); } $content = file_get_contents($url); $content = json_decode($content, true); if (!empty($content['errmsg'])) { exit($content['errmsg']); } $url = 'https://api.weixin.qq.com/sns/userinfo?access_token=' . $content['access_token'] . '&openid=' . $content['openid'] . '&lang=zh_CN'; $data = file_get_contents($url); $data = json_decode($data, true); if (!empty($data['errmsg'])) { exit($data['errmsg']); } $data['status'] = 2; empty($data['headimgurl']) && ($data['headimgurl'] = ADDON_PUBLIC_PATH . '/default_head.png'); $uid = D('Common/Follow')->init_follow($content['openid'], $info['token']); D('Common/User')->updateInfo($uid, $data); $url = Cookie('__forward__'); if ($url) { Cookie('__forward__', null); } else { $url = U('userCenter'); } redirect($url); } }
public function _initialize() { $token = get_token(); $public = get_token_appinfo($token); $this->appID = trim($public['appid']); $this->appSecret = trim($public['secret']); $this->accessToken = get_access_token(); }
function getPackageData($id) { $info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['id'] = $id; $data['jumpURL'] = addons_url("Xydzp://Xydzp/show", $param); return $data; }
public function __construct($token = '') { empty ( $token ) && $token = get_token (); $info = get_token_appinfo ( $token ); if (empty ( $info ['appid'] )) { return 0; } $this->appId = $info ['appid']; }
function getPackageData($id) { $info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['id'] = $id; $data['reserve'] = $this->getInfo($id); return $data; }
function personal() { $param['uid'] = $GLOBALS['mid']; $param['publicid'] = get_token_appinfo('', 'id'); $links = array(array('url' => addons_url('BusinessCard://Wap/detail', $param), 'title' => '我的名片', 'icon' => '', 'group' => '我的互动', 'new_count' => 0), array('url' => addons_url('BusinessCard://Wap/collected', $param), 'title' => '我收藏的名片', 'icon' => '', 'group' => '我的互动', 'new_count' => 0), array('url' => addons_url('BusinessCard://Wap/collecting', $param), 'title' => '收藏我的名片', 'icon' => '', 'group' => '我的互动', 'new_count' => 0)); // new_count 为新消息的数目,如果大于0,会在个人空间里的链接旁边显示新消息数目 // 下面实现获取new_count的功能 return $links; }
function _initialize() { parent::_initialize(); // 使用提示 $param['shop_id'] = $this->shop_id; $param['publicid'] = get_token_appinfo('', 'id'); $normal_tips = '点击选中下面模板即可实时切换模板,请慎重点击。选择后可点击<a target="_blank" href="' . addons_url('Shop://Wap/index', $param) . '">这里</a>进行预览'; $this->assign('normal_tips', $normal_tips); }
function lists() { $token = get_token(); $info = get_token_appinfo(); $info['addon_config'] = json_decode($info['addon_config'], true); $this->assign('info', $info); $this->assign('token', $token); // dump ( $info ); $this->display(); }
function getPackageData($id) { $id = I('id', 0, 'intval'); $map['token'] = get_token(); $return['public_info'] = get_token_appinfo($map['token']); $return['info'] = M('survey')->where($map)->find(); // 添加模板目录 $return['template'] = $return['info']['template'] == "" ? "default" : $return['info']['template']; return $return; }
function getPackageData($vote_id) { $info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['vote_id'] = $vote_id; $data['jumpURL'] = addons_url("Vote://Vote/Vote", $param); $data['vote'] = $this->getInfo($vote_id); $data['button_name'] = '马上开始'; return $data; }
function getPackageData($ask_id) { $info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['ask_id'] = $ask_id; $data['jumpURL'] = addons_url("Ask://Ask/ask", $param); $data['ask'] = $this->getAskInfo($ask_id); $data['button_name'] = '马上开始'; return $data; }
function getPackageData($id) { $token = get_token(); $return['publicInfo'] = $info = $publicInfo = get_token_appinfo($token); //$uid = session ( 'mid' ); $param['publicid'] = $info['id']; $param['id'] = $id = I('id'); $openid = get_openid(); // $return ['canJoin'] = ! empty ( $openid ) && ! empty ( $token ) && ! ($this->_is_overtime ( $id )) && ! ($this->_is_join ( $id, $uid, $token )); return $return; }
function index() { $id = $map['id'] = I('id', 0, 'intval'); $map['token'] = get_token(); $public_info = get_token_appinfo($map['token']); $overtime = $this->_is_overtime($id); $overtime = $overtime ? '1' : '0'; $this->assign('overtime', $overtime); $info = M('survey')->where($map)->find(); $this->assign('info', $info); $this->assign('public_info', $public_info); $this->display(); }
function index() { $id = I('id'); $info = D('CardVouchers')->getInfo($id); $public_info = get_token_appinfo(); $sha1['timestamp'] = NOW_TIME; $sha1['appsecre'] = trim($info['appsecre']); $sha1['card_id'] = $card_id = trim($info['card_id']); $sha1['signature'] = getSHA1($sha1); $info['card_ext'] = "{\"code\":\"{$sha1['code']}\",\"openid\":\"{$sha1['openid']}\",\"timestamp\":\"{$sha1['timestamp']}\",\"signature\":\"{$sha1['signature']}\"}"; $this->assign('info', $info); $this->assign('public_info', $public_info); $this->display(); }
function index() { $info = $publicInfo = get_token_appinfo(); $param['publicid'] = $info['id']; $param['id'] = $id = I('id'); $openid = get_openid(); $token = get_token(); $followid = $this->mid; $info = $this->_getGuessInfo($id); $canJoin = !empty($openid) && !empty($token) && !$this->_is_overtime($id) && !$this->_is_join($id, $followid, $token); $this->assign('canJoin', $canJoin); $this->assign('publicInfo', $publicInfo); $this->display(); }
function index() { $info = $public_info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['ask_id'] = $ask_id = I('id'); $url = addons_url("Ask://Ask/ask", $param); $ask = D('Ask')->getAskInfo($ask_id); $this->assign('ask', $ask); $this->assign('button_name', '马上开始'); $this->assign('jumpURL', $url); // dump ( $content ); // exit (); $this->assign('public_info', $public_info); $this->display(); }
function getPackageData($id) { $info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['id'] = $id; $data['jumpURL'] = addons_url("Coupon://Wap/set_sn_code", $param); $data['info'] = $this->getInfo($id); // 店铺地址 $maps['coupon_id'] = $id; $list = M('coupon_shop_link')->where($maps)->select(); $shop_ids = getSubByKey($list, 'shop_id'); if (!empty($shop_ids)) { $map_shop['id'] = array('in', $shop_ids); $shop_list = M('coupon_shop')->where($map_shop)->select(); $data['shop_list'] = $shop_list; } return $data; }
function getDataByAjax() { $min = I('min', 60, 'intval') * 60; $time = date('YmdHi', NOW_TIME - $min); $map['publicid'] = get_token_appinfo('', 'id'); $map['time'] = array('gt', $time); // dump ( $map ); $list = M('online_count')->where($map)->limit(1500)->order('time asc')->select(); // lastsql(); foreach ($list as $v) { $resy[] = intval($v['count']); $resx[] = date('H:i', $v['time'] . '00'); } $resData['x'] = $resx; $resData['y'] = $resy; // echo(implode ( ',', $y )); // echo json_encode ( $res ); $this->ajaxReturn($resData, 'JSON'); }
function getPackageData($id) { $param['prizeid'] = $id; $return['service_info'] = $info = get_token_appinfo(); $param['publicid'] = $info['id']; $return['data'] = $data = $this->getInfo($id); // 设置奖品页面领取对应的跳转链接 $prizetype = $data['prize_type']; if ($prizetype == '0') { $return['jumpurl'] = addons_url("RealPrize://RealPrize/save_address", $param); } else { $return['jumpurl'] = addons_url("RealPrize://RealPrize/address", $param); } // 获取奖品类型名称,方便显示 $return['tname'] = $prizetype == '0' ? '虚拟物品' : '实体物品'; // 服务号信息 $return['template'] = $template = $data['template'] == "" ? "default" : $data['template']; return $return; }
/** * 获取插件配置 * 获取的优先级:当前用户插件权限》当前公众号设置》后台默认配置》安装文件上的配置 */ function getList($is_admin = false) { // 当前公众号的设置 $map['token'] = get_token(); if (empty($map['token'])) { return array(); } $info = get_token_appinfo($map['token']); $token_status = json_decode($info['addon_status'], true); // 等级权限 if ($info['group_id']) { $map2['id'] = $info['group_id']; $addon_ids = M('public_group')->where($map2)->getField('addon_status'); if ($addon_ids) { $map3['id'] = array('in', $addon_ids); $addons = M('addons')->where($map3)->field('`name`')->select(); foreach ($addons as $a) { $token_status[$a['name']] = '-1'; } } } // 对当前用户的权限进行判断 if ($is_admin) { unset($map); $map['uid'] = get_mid(); $map['mp_id'] = $info['id']; $addon_ids = M('public_link')->where($map)->getField('addon_status'); if ($addon_ids) { $map3['id'] = array('in', $addon_ids); $addons = M('addons')->where($map3)->field('`name`')->select(); foreach ($addons as $a) { $token_status[$a['name']] = '-1'; } } } // dump ( $token_status ); // dump(M ( 'public' )->getLastSql());exit; return $token_status; }
public function lead() { $token = get_token(); if ($token) { $app_info_id = get_token_appinfo($token, 'id'); $this->assign('id', $app_info_id); } $this->display(); }
private function initPublic() { $token = get_token(); if (!$token || $token == -1) { return false; } $info = get_token_appinfo($token); if (!$info) { return false; } // 设置公众号管理者信息 if ($info['uid']) { $manager_id = $info['uid']; session('manager_id', $manager_id); } $manager = get_userinfo($manager_id); // 设置版权信息 $this->assign('system_copy_right', empty($manager['copy_right']) ? C('COPYRIGHT') : $manager['copy_right']); $tongji_code = empty($manager['tongji_code']) ? C('TONGJI_CODE') : $manager['tongji_code']; $param = $_GET; $param['publicid'] = $info['id']; $param['m'] = MODULE_NAME; $param['c'] = CONTROLLER_NAME; $param['a'] = ACTION_NAME; $param['uid'] = intval(session('mid')); $tongji_code .= '<script>$.post("' . SITE_URL . '/log.php?' . http_build_query($param) . '");</script>'; $this->assign('tongji_code', $tongji_code); // 公众号接口权限 $config = S('PUBLIC_AUTH_' . $info['type']); if (!$config) { $config = M('public_auth')->getField('name,type_' . intval($info['type']) . ' as val'); S('PUBLIC_AUTH_' . $info['type'], $config, 86400); } C($config); // 公众号接口权限 // 初始化微信JSAPI需要的参数 Vendor('jssdk.jssdk'); $jssdk = new \JSSDK($info['appid'], $info['secret']); $jsapiParams = $jssdk->GetSignPackage(); $this->assign('jsapiParams', $jsapiParams); $this->assign('page_title', $info['public_name']); // 用公众号名作为默认的页面标题 $this->assign('public_info', $info); // 通用公众号信息 return $info; }
function index() { $id = I('id'); $param['prizeid'] = $id; $info = get_token_appinfo(); $param['publicid'] = $info['id']; $data = D('RealPrize')->getInfo($id); $this->assign('data', $data); // 设置奖品页面领取对应的跳转链接 $prizetype = $data['prize_type']; if ($prizetype == '0') { $url = addons_url("RealPrize://RealPrize/save_address", $param); } else { $url = addons_url("RealPrize://RealPrize/address", $param); } $this->assign('jumpurl', $url); // 获取奖品类型名称,方便显示 $tname = $prizetype == '0' ? '虚拟物品' : '实体物品'; $this->assign('tname', $tname); // 服务号信息 $service_info = get_token_appinfo(); $this->assign('service_info', $service_info); $this->display(); }
function ajax_data() { $public_info = get_token_appinfo(); $this->assign('public_info', $public_info); $id = I('id'); $data = D('Scratch')->getScratchInfo($id); $this->assign('data', $data); // dump($data); // 奖项 $addon = 'Scratch'; $prizes = D('Prize')->getPrizes($id, $addon); $this->assign('prizes', $prizes); // 抽奖记录 // $all_prizes = M ( 'sn_code' )->where ( $map )->order ( 'id desc' )->select (); $all_prizes = D('SnCode')->getSnCodes($id, $addon); // dump ( $all_prizes ); foreach ($all_prizes as $all) { if ($all['prize_id'] > 0) { $has[$all['prize_id']] += 1; // 每个奖项已经中过的次数 $new_prizes[] = $all; // 最新中奖记录 $all['uid'] == $this->mid && ($my_prizes[] = $all); // 我的中奖记录 } else { $no_count += 1; // 没有中奖的次数 } // 记录我已抽奖的次数 $all['uid'] == $this->mid && ($my_count += 1); } $this->assign('new_prizes', $new_prizes); $this->assign('my_prizes', $my_prizes); // dump ( $new_prizes ); // dump ( $my_prizes ); // 权限判断 $follow = get_followinfo($this->mid); $is_admin = is_login(); $error = ''; if ($data['start_time'] > time()) { $error = '活动还没开始'; } if ($data['end_time'] <= time()) { $error = '活动已结束'; } else { if ($data['max_num'] > 0 && $data['max_num'] <= $my_count) { $error = '您的刮卡机会已用完啦'; } else { if ($data['follower_condtion'] > intval($follow['status']) && !$is_admin) { switch ($data['follower_condtion']) { case 1: $error = '关注后才能参与'; break; case 2: $error = '用户绑定后才能参与'; break; case 3: $error = '领取会员卡后才能参与'; break; } } else { if ($data['credit_conditon'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不足'; } else { if ($data['credit_bug'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不够扣除'; } else { if (!empty($data['addon_condition'])) { addon_condition_check($data['addon_condition']) || ($error = '您没权限参与'); } } } } } } $this->assign('error', $error); // 抽奖算法 if (empty($error)) { $prize = D('Scratch')->_lottery($data, $prizes, $new_prizes, $my_count, $has, $no_count); $prizes = D('Prize')->getPrizes($id, $addon); $prize['img'] = get_cover_url($prize['img']); $this->assign('prize', $prize); } $content = $this->fetch(ONETHINK_ADDON_PATH . 'Scratch/View/default/Scratch/data.html'); $returnData = I('callback') . '({"html":"' . rawurlencode($content) . '","prizeJson":"' . rawurlencode(json_encode($prize)) . '"})'; echo $returnData; exit; }
function preview() { $previewUrl = addons_url('Shop://Wap/index', array('shop_id' => $this->shop_id, 'publicid' => get_token_appinfo('', 'id'))); $this->assign('url', $previewUrl); $this->display(SITE_PATH . '/Application/Home/View/default/Addons/preview.html'); }
function getPackageData($id) { $return['public_info'] = $public_info = get_token_appinfo(); $id = $map['target_id'] = I('id'); $return['data'] = $data = M('scratch')->find($id); // dump($data); // 奖项 $map['addon'] = 'Scratch'; $return['prizes'] = $prizes = M('prize')->where($map)->select(); // 抽奖记录 $all_prizes = M('sn_code')->where($map)->order('id desc')->select(); // dump ( $all_prizes ); foreach ($all_prizes as $all) { if ($all['prize_id'] > 0) { $has[$all['prize_id']] += 1; // 每个奖项已经中过的次数 $new_prizes[] = $all; // 最新中奖记录 $all['uid'] == $GLOBALS['mid'] && ($my_prizes[] = $all); // 我的中奖记录 } else { $no_count += 1; // 没有中奖的次数 } // 记录我已抽奖的次数 $all['uid'] == $GLOBALS['mid'] && ($my_count += 1); } $return['new_prizes'] = $new_prizes; $return['my_prizes'] = $my_prizes; // dump ( $new_prizes ); // dump ( $my_prizes ); // 权限判断 unset($map); $follow = get_followinfo($GLOBALS['mid']); $is_admin = is_login(); $error = ''; if ($data['end_time'] <= time()) { $error = '活动已结束'; } else { if ($data['max_num'] > 0 && $data['max_num'] <= $my_count) { $error = '您的刮卡机会已用完啦'; } else { if ($data['follower_condtion'] > intval($follow['status']) && !$is_admin) { switch ($data['follower_condtion']) { case 1: $error = '关注后才能参与'; break; case 2: $error = '用户绑定后才能参与'; break; case 3: $error = '领取会员卡后才能参与'; break; } } else { if ($data['credit_conditon'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不足'; } else { if ($data['credit_bug'] > intval($follow['score']) && !$is_admin) { $error = '您的金币值不够扣除'; } else { if (!empty($data['addon_condition'])) { addon_condition_check($data['addon_condition']) || ($error = '您没权限参与'); } } } } } } $return['error'] = $error; // 抽奖算法 if (empty($error)) { $return['prize'] = $this->_lottery($data, $prizes, $new_prizes, $my_count, $has, $no_count); } // 添加模板目录 $return['template'] = $data['template'] == "" ? "default" : $data['template']; return $return; }
function index() { $xydzp_id = I('id', 0, 'intval'); $openid = get_openid(); $token = get_token(); $this->assign('openid', $openid); $this->assign('token', $token); $this->assign('xydzp_id', $xydzp_id); $xydzp_detail = D('Xydzp')->getXydzpInfo($xydzp_id); $this->assign('data', $xydzp_detail); $public_info = $info = get_token_appinfo(); $param['publicid'] = $info['id']; $param['id'] = $xydzp_id; $jumpUrl = addons_url('Xydzp://Xydzp/show', $param); $this->assign('jumpUrl', $jumpUrl); $this->display(); }
function preview() { $id = I('id', 0, 'intval'); $url = addons_url('Reserve://Wap/index', array('reserve_id' => $id, 'publicid' => get_token_appinfo('', 'id'))); $this->assign('url', $url); $this->display(SITE_PATH . '/Application/Home/View/default/Addons/preview.html'); }