예제 #1
0
파일: service.php 프로젝트: 453111208/bbc
 function __construct()
 {
     if (!kernel::is_online()) {
         die('error');
     }
     cacheobject::init();
     self::$is_start = true;
 }
예제 #2
0
파일: service.php 프로젝트: syjzwjj/quyeba
 private function parse_rpc_request($request)
 {
     $sign = $request['sign'];
     unset($request['sign']);
     $app_id = $request['app_id'];
     if ($app_id) {
         $app_id = substr($app_id, strpos($app_id, '.') + 1, strlen($app_id));
     }
     if ($request["direct"] == 'true') {
         $sign_check = base_certificate::gen_sign($request);
     } else {
         if (!base_shopnode::token($app_id)) {
             $sign_check = base_certificate::gen_sign($request);
         } else {
             $sign_check = base_shopnode::gen_sign($request, $app_id);
         }
     }
     if ($sign != $sign_check) {
         //trigger_error('sign error',E_USER_ERROR);
         $this->send_user_error('4003', 'sign error');
         return false;
     }
     $system_params = array('app_id', 'method', 'date', 'format', 'certi_id', 'v', 'sign', 'node_id');
     foreach ($system_params as $name) {
         $call[$name] = $request[$name];
         unset($request[$name]);
     }
     //api version control 20120627 mabaineng
     $system_params_addon = array('from_node_id', 'from_api_v', 'to_node_id', 'to_api_v');
     foreach ($system_params_addon as $name) {
         if ($request[$name]) {
             self::$api_info[$name] = $request[$name];
             unset($request[$name]);
         }
     }
     //if method request = 'aaa.bbb.ccc.ddd'
     //then: object_service = api.aaa.bbb.ccc, method=ddd
     if (isset($call['method'][2])) {
         if ($p = strrpos($call['method'], '.')) {
             $service = substr($call['method'], 0, $p);
             self::$api_info['api_name'] = $service;
             $service = 'api.' . $service;
             $method = substr($call['method'], $p + 1);
         }
     } else {
         //trigger_error('error method',E_ERROR);
         $this->send_user_error('4001', 'error method');
         return false;
     }
     if ($call['node_id']) {
         self::$node_id = $call['node_id'];
     }
     return array($service, $method, $request);
 }
예제 #3
0
 private function parse_rpc_request($request)
 {
     $sign = $request['sign'];
     unset($request['sign']);
     $sign_check = base_certificate::gen_sign($request);
     if ($sign != $sign_check) {
         //trigger_error('sign error',E_USER_ERROR);
         $this->send_user_error('4003', 'sign error');
         return false;
     }
     $system_params = array('app_id', 'method', 'date', 'format', 'certi_id', 'v', 'sign', 'node_id');
     foreach ($system_params as $name) {
         $call[$name] = $request[$name];
         unset($request[$name]);
     }
     //if method request = 'aaa.bbb.ccc.ddd'
     //then: object_service = api.aaa.bbb.ccc, method=ddd
     if (isset($call['method'][2])) {
         if ($p = strrpos($call['method'], '.')) {
             $service = 'api.' . substr($call['method'], 0, $p);
             $method = substr($call['method'], $p + 1);
         }
     } else {
         //trigger_error('error method',E_ERROR);
         $this->send_user_error('4001', 'error method');
         return false;
     }
     if ($call['node_id']) {
         self::$node_id = $call['node_id'];
     }
     return array($service, $method, $request);
 }
예제 #4
0
 /**
  * 第三方登录
  * @param unknown $data
  */
 public function trust_login($post)
 {
     $userPassport = kernel::single('b2c_user_passport');
     if ($userPassport->userObject->is_login()) {
         $this->rpcService->send_user_error('login_error', '您已经是登录状态,不需要重新登录');
     }
     /*
     openid: "1707357339",
     provider_code: "qzone",
     provider_openid: "ADB189CA2182398213E6FC0905BB0333",
     nickname: "是非亦航",
     realname: "是非亦航",
     avatar: "http://qzapp.qlogo.cn/qzapp/100278270/ADB189CA2182398213E6FC0905BB0333/100",
     email: "",
     gender: "1",
     address: "中国 广东 广州",
     province: "广东",
     city: "广州"
     */
     $data['provider_code'] = $post['provider_code'];
     $data['openid'] = $post['openid'];
     $data['nickname'] = $post['nickname'] ? $post['nickname'] : '';
     $data['realname'] = $post['realname'] ? $post['realname'] : '';
     $data['avatar'] = $post['avatar'] ? $post['avatar'] : '';
     $data['email'] = $post['email'] ? $post['email'] : '';
     $data['gender'] = $post['gender'] ? $post['gender'] : "2";
     $result['data'] = $data;
     $login_name = $this->trust_save_login_data($result, $msg);
     if (!$login_name) {
         $this->rpcService->send_user_error('login_error', $msg);
     }
     $row = app::get('pam')->model('auth')->getList('account_id,module_uid', array('module_uid' => $login_name));
     $member_id = $row[0]['account_id'];
     if (!$member_id) {
         $this->rpcService->send_user_error('login_error', '登录ID错误');
     }
     //记录登录信息
     $b2c_members_model = kernel::single('b2c_mdl_members');
     $member_point_model = kernel::single('b2c_mdl_member_point');
     $member_data = $b2c_members_model->getList('*', array('member_id' => $member_id));
     if (!$member_data) {
         kernel::single('b2c_service_vcode')->set_error_count();
         $data['needVcode'] = kernel::single('b2c_service_vcode')->status();
         //在登录认证表中存在记录,但是在会员信息表中不存在记录
         //$msg = $this->app->_('登录失败:会员数据存在问题,请联系商家或客服');
         //$this->splash('failed',null,$msg,true,$data);exit;
         $data['msg'] = '登录失败:会员数据存在问题,请联系商家或客服';
         $this->rpcService->send_user_error('login_error', $data);
     }
     $member_data = $member_data[0];
     $member_data['order_num'] = kernel::single('b2c_mdl_orders')->count(array('member_id' => $member_id));
     /*
      if($this->app->getConf('site.level_switch')==1)
      {
     $member_data['member_lv_id'] = $b2c_members_model->member_lv_chk($member_data['member_lv_id'],$member_data['experience']);
     }
     if($this->app->getConf('site.level_switch')==0)
     {
     $member_data['member_lv_id'] = $member_point_model->member_lv_chk($member_id,$member_data['member_lv_id'],$member_data['point']);
     }
     */
     $b2c_members_model->update($member_data, array('member_id' => $member_id));
     $this->userObject->set_member_session($member_id);
     $this->bind_member($member_id);
     $this->set_cookie('loginName', $_POST['uname'], time() + 31536000);
     //用于记住密码
     @kernel::single('b2c_mdl_cart_objects')->setCartNum();
     $member_data['session'] = $_SESSION;
     // 微店
     //$member_data['microshop_info']  = array();
     if ($member_data['member_type'] == 2) {
         $mdl = app::get('microshop')->model('shop');
         $filter = array('member_id' => $member_data['member_id']);
         if ($mic_info = $mdl->getDetail($filter)) {
             $member_data['microshop_info'] = $mic_info;
         }
     }
     $member_data['avatar'] = $member_data['avatar'] ? kernel::single('base_storager')->image_path($member_data['avatar']) : $this->app->res_url . '/images/top-bg.png';
     $member_data['cover'] = $member_data['cover'] ? kernel::single('base_storager')->image_path($member_data['cover']) : $this->app->res_url . '/images/top-bg.png';
     return $member_data;
 }