public function index()
 {
     $map['id'] = I('id');
     $params['mp_id'] = $map['mp_id'] = get_mpid();
     hook('init_ucuser', $params);
     //把消息分发到addons/ucuser/init_ucuser的方法中,初始化公众号粉丝信息
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $info = get_mpid_appinfo($params['mp_id']);
     $options['appid'] = $info['appid'];
     //初始化options信息
     $options['appsecret'] = $info['secret'];
     $options['encodingaeskey'] = $info['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $info = M('weicj')->where($map)->find();
     $info['pic1'] = get_cover_url($info['pic1']);
     $info['pic2'] = get_cover_url($info['pic2']);
     $info['pic3'] = get_cover_url($info['pic3']);
     $info['pic4'] = get_cover_url($info['pic4']);
     $info['pic5'] = get_cover_url($info['pic5']);
     $info['pic6'] = get_cover_url($info['pic6']);
     $info['clickpic'] = get_cover_url($info['clickpic']);
     if ($info['andio']) {
         $file = M('file')->where('id=' . $info['andio'])->find();
         $filename = 'http://' . $_SERVER['HTTP_HOST'] . '/Uploads/Download/' . $file['savepath'] . $file['savename'];
         $info['trueaudio'] = $filename;
     } else {
         $info['trueaudio'] = $info['audio2'];
     }
     $this->assign('info', $info);
     //$templateFile = $this->model ['template_list'] ? $this->model ['template_list'] : '';
     $this->display();
 }
Exemple #2
0
    $v_friend = ckfriend($value['uid'], $value['friend']);
    if (!$v_friend) {
        $space[$value['subtype']] = '';
    }
}
@(include_once S_ROOT . './data/data_usergroup.php');
//ᄏ�위
$space['star'] = getstar($space['experience']);
//ᅮ￲ᅢ
$space['domainurl'] = space_domain($space);
//ᄌ￶￈ᅨᄊᆵᅩᆲ
$feedlist = array();
if ($_SGLOBAL['mygroupid'] == 3 || ckprivacy('feed')) {
    $query = $_SGLOBAL['db']->query("SELECT * FROM " . tname('feed') . " WHERE uid='{$space['uid']}' AND isdeleted=0 ORDER BY top DESC,dateline DESC  LIMIT 0,20 ");
    while ($value = $_SGLOBAL['db']->fetch_array($query)) {
        $value['share_url'] = get_shareurl($value['idtype'], $value['id']);
        if (ckfriend($value['uid'], $value['friend'], $value['target_ids'])) {
            realname_set($value['uid'], $value['username']);
            $value['num'] = get_commentnum($value['idtype'], $value['id']);
            $feedlist[] = $value;
        }
    }
    $feednum = count($feedlist);
}
//채ᅮ￑￁￐ᄆ■
$oluids = array();
$friendlist = array();
$friendnum = 0;
if ($space[groupid] == 3) {
    $friendfans = '我的粉丝';
    $friendnumquery = $_SGLOBAL['db']->query("SELECT count(x.uid) FROM " . tname('friend') . " x , " . tname('space') . " y WHERE x.uid='{$space['uid']}' AND x.fuid = y.uid AND y.groupid != 3 AND x.status='1' ORDER BY x.num DESC, x.dateline DESC");
 /**
  * 活动详情
  * @param int $id
  * autor:xjw129xjt
  */
 public function detail($id = 0)
 {
     $check_isSign = D('event_attend')->where(array('uid' => is_login(), 'event_id' => $id))->select();
     $this->assign('check_isSign', $check_isSign);
     $event_content = D('Event')->where(array('status' => 1, 'id' => $id))->find();
     if (!$event_content) {
         $this->error('404 not found');
     }
     D('Event')->where(array('id' => $id))->setInc('view_count');
     $event_content['user'] = query_user(array('id', 'username', 'nickname', 'space_url', 'space_link', 'avatar64', 'rank_html', 'signature'), $event_content['uid']);
     $event_content['type'] = $this->getType($event_content['type_id']);
     $menber = D('event_attend')->where(array('event_id' => $id, 'status' => 1))->select();
     foreach ($menber as $k => $v) {
         $event_content['member'][$k] = query_user(array('id', 'username', 'nickname', 'space_url', 'space_link', 'avatar64', 'rank_html', 'signature'), $v['uid']);
     }
     $params['mp_id'] = $map['mp_id'] = get_mpid();
     $this->assign('mp_id', $params['mp_id']);
     $uid = get_ucuser_uid();
     //获取粉丝用户uid,一个神奇的函数,没初始化过就初始化一个粉丝
     if ($uid === false) {
         $this->error('只可在微信中访问');
     }
     $user = get_uid_ucuser($uid);
     //获取公众号粉丝用户信息
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $appinfo = get_mpid_appinfo($params['mp_id']);
     //获取公众号信息
     $this->assign('appinfo', $appinfo);
     $options['appid'] = $appinfo['appid'];
     //初始化options信息
     $options['appsecret'] = $appinfo['secret'];
     $options['encodingaeskey'] = $appinfo['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $this->assign('user', $user);
     $this->assign('content', $event_content);
     $this->setTitle('{$content.title|op_t}' . '——活动');
     $this->setKeywords('{$content.title|op_t}' . ',活动');
     $this->getRecommend();
     $this->display();
 }
 public function index()
 {
     //JSSDK 初始部分
     $param['mp_id'] = I('mp_id');
     //$param ['id'] = I('id');                                          //如有插件中数据id,分享url中应加入id参数
     //$url = addons_url ( 'Jssdk://Jssdk/index', $param );  //分享的url需要和自定义回复入口url保持相同
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $info = get_mpid_appinfo($param['mp_id']);
     $options['appid'] = $info['appid'];
     //初始化options信息
     $options['appsecret'] = $info['secret'];
     $options['encodingaeskey'] = $info['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $addon_config = get_addon_config('Jssdk');
     $this->assign('addon_config', $addon_config);
     //微信支付部分
     //此处可以动态获取数据库中的MCHID和KEY
     $jssdkpay = new JsSdkPay($options);
     $jssdkpay->MCHID = "";
     // 动态MCHID;微信支付分配的商户号
     $jssdkpay->KEY = "";
     // 动态KEY;
     //=========步骤2:使用统一支付接口,获取prepay_id============
     //使用统一支付接口
     $jssdkpay->parameters['openid'] = get_openid();
     //trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识。
     $jssdkpay->parameters['body'] = "订单支付";
     //商品或支付单简要描述
     $jssdkpay->parameters['out_trade_no'] = "outtradeno" . time();
     //商户系统内部的订单号,32个字符内、可包含字母,不可重复
     $jssdkpay->parameters['total_fee'] = 100;
     //收款金额,此处单位为分 出现小数点接口报错必须是整数
     $jssdkpay->parameters['notify_url'] = 'http://test.uctoo.com/index.php/addon/Jssdk/Jssdk/alarmnotify';
     //接收微信支付异步通知回调地址
     $jssdkpay->parameters['trade_type'] = "JSAPI";
     //取值如下:JSAPI,NATIVE,APP
     $jssdkpay->parameters['spbill_create_ip'] = get_client_ip();
     //APP和网页支付提交用户端ip,Native支付填调用微信支付API的机器IP。
     //以下非必填参数根据需要添加
     //$jssdkpay->parameters['device_info'] = "013467007045764";            //微信支付分配的终端设备号,商户自定义
     //$jssdkpay->parameters['detail'] = "UCToo   蓝色";                     //商品名称明细列表
     //$jssdkpay->parameters['attach'] = "说明";                             //附加数据,在查询API和支付通知中原样返回,该字段主要用于商户携带订单的自定义数据
     //$jssdkpay->parameters['fee_type'] = "CNY";                           //符合ISO 4217标准的三位字母代码,默认人民币:CNY
     //$jssdkpay->parameters['time_start'] = "20091225091010";              //订单生成时间,格式为yyyyMMddHHmmss
     //$jssdkpay->parameters['time_expire'] = "20091227091010";             //订单失效时间,格式为yyyyMMddHHmmss
     //$jssdkpay->parameters['goods_tag'] = "WXG";                          //商品标记,代金券或立减优惠功能的参数
     //$jssdkpay->parameters['product_id'] = "12235413214070356458058";     //trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。
     $jssdkpay->prepay_id = $jssdkpay->getPrepayId();
     //微信生成的预支付回话标识,用于后续接口调用中使用,该值有效期为2小时
     //=========步骤3:使用jsapi调起支付============
     $jsApiParameters = $jssdkpay->getParameters();
     //JSSDK 用户支付完成后的一些系统操作
     $param1['dcnum'] = $jssdkpay->parameters['out_trade_no'];
     $param1['openid'] = $jssdkpay->parameters['openid'];
     $ajaxurl = addons_url('Jssdk://Jssdk/orderpaid', $param1);
     //用户支付完成后,在微信支付返回alarmnotify之前(不保证时序),可以通过ajax调用,进行一些预处理操作
     $jsApiParameters = substr($jsApiParameters, 1, -1) . ",success: function (res) {\n                // 支付成功后的js回调函数\n               \n                }";
     $this->assign("jsApiParameters", $jsApiParameters);
     //向页面传整理好的调起支付参数
     $this->display();
 }
 public function profile()
 {
     $params['mp_id'] = $map['mp_id'] = get_mpid();
     $this->assign('mp_id', $params['mp_id']);
     $map['id'] = I('id');
     $uid = get_ucuser_uid();
     //获取粉丝用户uid,一个神奇的函数,没初始化过就初始化一个粉丝
     if ($uid === false) {
         $this->error('只可在微信中访问');
     }
     $user = get_uid_ucuser($uid);
     //获取公众号粉丝用户信息
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     $appinfo = get_mpid_appinfo($params['mp_id']);
     //获取公众号信息
     $this->assign('appinfo', $appinfo);
     $options['appid'] = $appinfo['appid'];
     //初始化options信息
     $options['appsecret'] = $appinfo['secret'];
     $options['encodingaeskey'] = $appinfo['encodingaeskey'];
     $weObj = new TPWechat($options);
     $auth = $weObj->checkAuth();
     $js_ticket = $weObj->getJsTicket();
     if (!$js_ticket) {
         $this->error('获取js_ticket失败!错误码:' . $weObj->errCode . ' 错误原因:' . ErrCode::getErrText($weObj->errCode));
     }
     $js_sign = $weObj->getJsSign($url);
     $this->assign('js_sign', $js_sign);
     $fans = $weObj->getUserInfo($user['openid']);
     $this->assign('user', $user);
     if (IS_POST) {
         $data['uid'] = $uid;
         $data['nickname'] = I('post.nickname', '', 'op_t');
         $data['mobile'] = I('post.mobile', '', 'op_t');
         $data['email'] = I('post.email', '', 'op_t');
         $data['sex'] = I('post.sex', '', 'intval');
         $data['qq'] = I('post.qq', '', 'op_t');
         $data['weibo'] = I('post.weibo', '', 'op_t');
         $data['signature'] = I('post.signature', '', 'op_t');
         $ucuser = D('Common/Ucuser');
         $res = $ucuser->save($data);
         if ($res > 0) {
             $this->success('更新资料成功', addons_url('Ucuser://Ucuser/profile'));
         } else {
             $this->error($ucuser->getError());
         }
     } else {
         //显示资料页面
         if ($user['openid'] != $fans['openid']) {
             //本地保存的openid和公众平台获取的不同,不允许用户自己以外的人访问
             $this->error('无权访问用户资料', addons_url('Ucuser://Ucuser/login'), 5);
         }
         $this->display();
     }
 }
 /**
  *
  * jsApi微信支付示例
  * 注意:
  * 1、微信支付授权目录配置如下  http://test.uctoo.com/addon/Wxpay/Index/jsApiPay/mp_id/
  * 2、支付页面地址需带mp_id参数
  * 3、管理后台-基础设置-公众号管理,微信支付必须配置的参数都需填写正确
  * @param array $mp_id 公众号在系统中的ID
  * @return 将微信支付需要的参数写入支付页面,显示支付页面
  */
 public function jsApiPay($mp_id = 0)
 {
     empty($mp_id) && ($mp_id = get_mpid());
     $params['mp_id'] = $mp_id;
     //系统中公众号ID
     $this->assign('mp_id', $params['mp_id']);
     $uid = get_ucuser_uid();
     //获取粉丝用户uid,一个神奇的函数,没初始化过就初始化一个粉丝
     if ($uid === false) {
         $this->error('只可在微信中访问');
     }
     $user = get_uid_ucuser($uid);
     //获取本地存储公众号粉丝用户信息
     $this->assign('user', $user);
     $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     $surl = get_shareurl();
     if (!empty($surl)) {
         $this->assign('share_url', $surl);
     }
     //odata通用订单数据,订单数据可以从订单页面提交过来
     $odata['uid'] = $uid;
     $odata['mp_id'] = $params['mp_id'];
     // 当前公众号在系统中ID
     $odata['order_id'] = "time" . date("YmdHis");
     //
     $odata['order_status'] = 1;
     //不带该字段-全部状态, 2-待发货, 3-已发货, 5-已完成, 8-维权中
     $odata['order_total_price'] = 1;
     //订单总价,单位:分
     $odata['buyer_openid'] = $user['openid'];
     $odata['buyer_nick'] = $user['nickname'];
     $odata['receiver_mobile'] = $user['mobile'];
     $odata['product_id'] = 1;
     $odata['product_name'] = "UCToo";
     $odata['product_price'] = 100;
     //商品价格,单位:分
     $odata['product_sku'] = "UCToo_Wxpay";
     $odata['product_count'] = 1;
     $odata['module'] = MODULE_NAME;
     $odata['model'] = "order";
     $odata['aim_id'] = 1;
     $order = D("Order");
     // 实例化order对象
     $order->create($odata);
     // 生成数据对象
     $result = $order->add();
     // 写入数据
     if ($result) {
         // 如果主键是自动增长型 成功后返回值就是最新插入的值
     }
     //获取公众号信息,jsApiPay初始化参数
     $info = get_mpid_appinfo($odata['mp_id']);
     $this->options['appid'] = $info['appid'];
     $this->options['mchid'] = $info['mchid'];
     $this->options['mchkey'] = $info['mchkey'];
     $this->options['secret'] = $info['secret'];
     $this->options['notify_url'] = $info['notify_url'];
     $this->wxpaycfg = new WxPayConfig($this->options);
     //①、初始化JsApiPay
     $tools = new JsApiPay($this->wxpaycfg);
     $wxpayapi = new WxPayApi($this->wxpaycfg);
     //②、统一下单
     $input = new WxPayUnifiedOrder($this->wxpaycfg);
     //这里带参数初始化了WxPayDataBase
     //  $input->SetAppid($info['appid']);//公众账号ID
     //  $input->SetMch_id($info['mchid']);//商户号
     $input->SetBody($odata['product_name']);
     $input->SetAttach($odata['product_sku']);
     $input->SetOut_trade_no($odata['order_id']);
     $input->SetTotal_fee($odata['order_total_price']);
     $input->SetTime_start(date("YmdHis"));
     $input->SetTime_expire(date("YmdHis", time() + 600));
     // $input->SetGoods_tag("WXG");                      //商品标记,代金券或立减优惠功能的参数
     //  $input->SetNotify_url($info['notify_url']);       //http://test.uctoo.com/index.php/UShop/Index/notify
     $input->SetTrade_type("JSAPI");
     $input->SetOpenid($user['openid']);
     $order = $wxpayapi->unifiedOrder($input);
     $jsApiParameters = $tools->GetJsApiParameters($order);
     //获取共享收货地址js函数参数
     $editAddress = $tools->GetEditAddressParameters();
     //③、在支持成功回调通知中处理成功之后的事宜,见 notify.php
     /**
      * 注意:
      * 1、当你的回调地址不可访问的时候,回调通知会失败,可以通过查询订单来确认支付是否成功
      * 2、jsapi支付时需要填入用户openid,WxPay.JsApiPay.php中有获取openid流程 (文档可以参考微信公众平台“网页授权接口”,
      * 参考http://mp.weixin.qq.com/wiki/17/c0f37d5704f0b64713d5d2c37b468d75.html)
      */
     $this->assign('order', $odata);
     $this->assign('jsApiParameters', $jsApiParameters);
     $this->assign('editAddress', $editAddress);
     $this->display();
 }