Пример #1
0
 static function register($data = null)
 {
     $sys_params = base_setup_config::deploy_info();
     $code = md5(microtime());
     base_kvstore::instance('ecos')->store('net.handshake', $code);
     $app_exclusion = app::get('base')->getConf('system.main_app');
     /** 得到框架的总版本号 **/
     $obj_apps = app::get('base')->model('apps');
     $tmp = $obj_apps->getList('*', array('app_id' => 'base'));
     $app_xml = $tmp[0];
     $app_xml['version'] = $app_xml['local_ver'];
     if (defined('CERTIFICATE_SAS') && constant('CERTIFICATE_SAS')) {
         $data = array('certi_app' => 'open.reg', 'app_id' => 'ecos.' . $app_exclusion['app_id'], 'url' => $data ? $data : kernel::base_url(1), 'result' => $code, 'version' => $app_xml['version']);
     } else {
         $conf = base_setup_config::deploy_info();
         $data = array('certi_app' => 'open.reg', 'identifier' => base_enterprise::ent_id(), 'password' => base_enterprise::ent_ac(), 'product_key' => $conf['product_key'], 'url' => $data ? $data : kernel::base_url(1), 'result' => $code, 'version' => $app_xml['version'], 'api_ver' => '1.3');
     }
     $http = kernel::single('base_httpclient');
     $http->set_timeout(6);
     $result = $http->post(LICENSE_CENTER, $data);
     //todo: 声称获取一个唯一iD,发给飞飞
     $result = json_decode($result, 1);
     if ($result['res'] == 'succ') {
         if ($result['info']) {
             /*
                             if ($result['info']['node_id'])
                             {
                                 $arr_shop_node_id = array(
                                     'node_id' => $result['info']['node_id'],
                                 );
                                 base_shopnode::set_node_id($arr_shop_node_id,$app_exclusion['app_id']);
                                 unset($result['info']['node_id']);
                             }
             */
             //1.3接口不再返回node_id信息
             base_shopnode::register($app_exclusion['app_id']);
             $certificate = $result['info'];
             $flag = self::set_certificate($certificate);
             if ($flag) {
                 app::get('base')->setConf('certificate_code_url', $data['url']);
                 return true;
             } else {
                 return false;
             }
         }
     } else {
         //throw new Exception(LICENSE_CENTER." return ".$result['res']."error is-- ".$result['code'].",".$result['msg']);
         logger::error('create certificate_id faile, reason:' . LICENSE_CENTER . " return " . $result['res'] . "error is " . $result['code'] . "," . $result['msg'], false, LOG_ERR);
         return false;
     }
 }
Пример #2
0
 public function pre_auth_uses()
 {
     if (!base_enterprise::ent_id() || !base_enterprise::ent_ac() || !base_enterprise::ent_email()) {
         //判断数据是否是中心过来的
         return false;
     } else {
         base_enterprise::set_version();
         base_enterprise::set_token();
         if (!base_enterprise::is_valid('json', base_enterprise::ent_id())) {
             return false;
         }
     }
     return true;
 }
Пример #3
0
 function download()
 {
     header("Content-type:application/octet-stream;charset=utf-8");
     header("Content-Type: application/force-download");
     $this->fileName = 'enterprise.CER';
     header("Content-Disposition:filename=" . $this->fileName);
     $this->ent_id = base_enterprise::ent_id();
     $this->ent_ac = base_enterprise::ent_ac();
     $this->ent_email = base_enterprise::ent_email();
     echo $this->ent_id;
     echo '|||';
     echo $this->ent_ac;
     echo '|||';
     echo $this->ent_email;
 }
Пример #4
0
 function saveSmsSign()
 {
     if (mb_strlen(urldecode(trim($_POST['sign'])), 'utf-8') > 8 || mb_strlen(urldecode(trim($_POST['sign'])), 'utf-8') < 2) {
         $this->begin('index.php?app=b2c&ctl=admin_member_messenger&act=setSmsSign');
         $this->end(false, app::get('b2c')->_('签名长度为2到8字'));
     }
     //校验签名
     $this->check_str($_POST['sign']);
     //$sign=$this->checkReg($_POST['sign']);
     $sign = $_POST['sign'];
     $signs = '【' . $sign . '】';
     $entid = base_enterprise::ent_id();
     $passwd = base_enterprise::ent_ac();
     $params = array('shopexid' => $entid, 'content' => $signs, 'passwd' => $passwd);
     $url = 'https://openapi.shopex.cn/api';
     if (defined('SMS_SNDBOX') && SMS_SNDBOX) {
         $url = 'https://openapi.shopex.cn/api-sandbox';
     }
     $core_http = kernel::single('base_prism');
     $core_http->app_key = 'xft7toho';
     $core_http->app_secret = 'zoj66zxqjkq4is3xx762';
     $core_http->base_url = $url;
     //判断是添加还是修改
     $setSmsSign = app::get('b2c')->getConf('setSmsSign');
     //添加签名
     if (empty($setSmsSign['sign'])) {
         $result = $core_http->post('/addcontent/new', $params);
     } else {
         //修改签名
         $params = array('shopexid' => $entid, 'passwd' => $passwd, 'old_content' => '【' . $setSmsSign['sign'] . '】', 'new_content' => $signs);
         $result = $core_http->post('/addcontent/update', $params);
     }
     $response = json_decode($result, true);
     if (!($response['res'] == 'succ')) {
         //兼容目前出现的“签名不存在”问题
         if ($response['code'] == '2010') {
             app::get('b2c')->setConf('setSmsSign', null);
         }
         $this->begin('index.php?app=b2c&ctl=admin_member_messenger&act=setSmsSign');
         $this->end(false, app::get('b2c')->_($response['data']));
     } else {
         $array = array('sign' => trim($sign));
         $this->begin();
         app::get('b2c')->setConf('review', $response['data']['review']);
         app::get('b2c')->setConf('setSmsSign', $array);
         $this->end(true, app::get('b2c')->_('保存成功'));
     }
 }
Пример #5
0
 public function setSmsSign($sign)
 {
     $result = $this->checkSign($sign, $msg);
     if (!$result) {
         throw new \LogicException($msg);
         return false;
     }
     $signs = '【' . $sign . '】';
     $entid = base_enterprise::ent_id();
     $passwd = base_enterprise::ent_ac();
     $params = array('shopexid' => $entid, 'content' => $signs, 'passwd' => $passwd);
     $url = config::get('link.sms_api');
     if (config::get('link.sms_debug')) {
         $url = config::get('link.sms_sandbox_api');
     }
     $core_http = kernel::single('base_prism');
     $core_http->app_key = 'xft7toho';
     $core_http->app_secret = 'zoj66zxqjkq4is3xx762';
     $core_http->base_url = $url;
     //判断是添加还是修改
     $setSmsSign = app::get('system')->getConf('setSmsSign');
     //添加签名
     if (empty($setSmsSign['sign'])) {
         $result = $core_http->post('/addcontent/new', $params);
     } else {
         //修改签名
         $params = array('shopexid' => $entid, 'passwd' => $passwd, 'old_content' => '【' . $setSmsSign['sign'] . '】', 'new_content' => $signs);
         $result = $core_http->post('/addcontent/update', $params);
     }
     $response = json_decode($result, true);
     if ($response['res'] == 'succ') {
         $array = array('sign' => trim($sign));
         app::get('system')->setConf('review', $response['data']['review']);
         app::get('system')->setConf('setSmsSign', $array);
         return true;
     }
     //兼容目前出现的“签名不存在”问题
     if ($response['code'] == '2010') {
         app::get('system')->setConf('setSmsSign', null);
     }
     $msg = $response['data'] ? $response['data'] : "请求设置短信签名出错";
     throw new \LogicException($msg);
     return false;
 }
Пример #6
0
 public function success()
 {
     /** 获取证书,企业号的验证 **/
     $active_url = kernel::base_url(1) . '/index.php/entermembercenter/default/active';
     if ($_GET['ent_id'] && $_GET['ent_ac'] && $_GET['ent_sign'] && $_GET['ent_email']) {
         //判断数据是否是中心过来的
         if (md5($_GET['ent_id'] . $_GET['ent_ac'] . 'ShopEXUser') == $_GET['ent_sign']) {
             //检测企业帐号是否正确
             base_enterprise::set_version();
             base_enterprise::set_token();
             if (!base_enterprise::is_valid('json', $_GET['ent_id'])) {
                 header("Content-type: text/html; charset=utf-8");
                 header('Location:' . $active_url);
                 exit;
             } else {
                 $arr_enterprise = array('ent_id' => $_GET['ent_id'], 'ent_ac' => $_GET['ent_ac'], 'ent_email' => $_GET['ent_email']);
                 base_enterprise::set_enterprise_info($arr_enterprise);
                 if (!base_enterprise::ent_id() || !base_enterprise::ent_email() || !base_enterprise::ent_ac()) {
                     header("Content-type: text/html; charset=utf-8");
                     header('Location:' . $active_url);
                     exit;
                 }
                 base_certificate::register();
                 if (base_certificate::certi_id() && base_certificate::token()) {
                     $this->get_active_node_id();
                 }
             }
         } else {
             // 出现异常的情况
             header("Content-type: text/html; charset=utf-8");
             header('Location:' . $active_url);
             exit;
         }
     } else {
         header("Content-type: text/html; charset=utf-8");
         header('Location:' . $active_url);
         exit;
     }
     $success_url = kernel::base_url(1) . '/index.php/setup/default/success';
     header("Content-type: text/html; charset=utf-8");
     header('Location:' . $success_url);
     exit;
 }
Пример #7
0
 /**
  * @description 获取企业密码
  * @access public
  * @param void
  * @return String
  *
  * 测试企业密码: md5('123jjzh'.'ShopEXUser');
  */
 public function getEntAc()
 {
     if ($this->entac) {
         return $this->entac;
     } else {
         return base_enterprise::ent_ac();
     }
 }
Пример #8
0
 function command_backup_shopex_id()
 {
     $args = func_get_args();
     $options = $this->get_options();
     $this->ent_id = base_enterprise::ent_id();
     $this->ent_ac = base_enterprise::ent_ac();
     $this->ent_email = base_enterprise::ent_email();
     $str_shop = $this->ent_id . "|||" . $this->ent_ac . "|||" . $this->ent_email;
     if ($options['backup_dir']) {
         $backup_dir = $args[0];
         if (!is_dir($backup_dir)) {
             mkdir($backup_dir);
         }
         $file_name = $args[1] . "_shopex_id.log";
         if (!$args[1]) {
             $file_name = "shopex_id_backup.log";
         }
         $backup_file = $backup_dir . "/" . $file_name;
         if (is_file($backup_file)) {
             unlink($backup_file);
         }
         if (!($fp = fopen($backup_file, 'w'))) {
             echo "Can not find file......";
             exit;
         }
         $fw = fwrite($fp, $str_shop);
         if ($fw) {
             echo "the write shopex_id the success of the backup file......";
         } else {
             echo "shopex_id written to the backup file failed......";
         }
     } else {
         echo "缺少参数,使用-d 指定shopex_id要备份到那个目录?使用-n指定要备份的项目名称";
     }
 }
Пример #9
0
 function command_active_cetificate($app_id = 'activeceti')
 {
     /** 安装完成后获取证书 **/
     $args = func_get_args();
     $options = $this->get_options();
     $config = base_setup_config::deploy_info();
     if ($options['options']) {
         parse_str($options['options'], $this->shell->input);
     }
     $install_options = array();
     $tmp_arr_options = array();
     foreach ((array) $config['active_ceti']['active_ceti_info'] as $key => $active_data) {
         $install_options[$key] = $active_data;
     }
     if (is_array($install_options) && count($install_options) > 0 && !$this->shell->input[$app_id]) {
         $this->shell->input_option($install_options, $app_id);
     }
     if ($this->shell->input[$app_id]) {
         logger::info('Active cetificate...');
         $api_data = array('certi_app' => 'ent.reg', 'email' => $this->shell->input[$app_id]['email'], 'password' => $this->shell->input[$app_id]['password'], 'tel' => $this->shell->input[$app_id]['tel'], 'province' => $this->shell->input[$app_id]['province'], 'version' => '1.0', 'format' => 'json');
         ksort($api_data);
         foreach ($api_data as $key => $value) {
             $str .= $value;
         }
         base_enterprise::set_token();
         $api_data['certi_ac'] = md5($str . base_enterprise::$token);
         $http = kernel::single('base_httpclient');
         $http->set_timeout(6);
         $result = $http->post(SHOP_USER_ENTERPRISE_API, $api_data);
         $tmp_res = json_decode($result, 1);
         if ($tmp_res['res'] == 'succ') {
             $arr_enterprise = array('ent_id' => $tmp_res['msg']['entid'], 'ent_ac' => $tmp_res['msg']['password'], 'ent_email' => $tmp_res['msg']['email']);
             base_enterprise::set_enterprise_info($arr_enterprise);
             // 申请证书
             if (base_enterprise::ent_id() && base_enterprise::ent_ac() && base_enterprise::ent_email()) {
                 base_certificate::register();
                 // 申请应用的节点
                 $this->command_active_node_id('ceti_node_id');
             }
             logger::info('Application active cetificate... ok.');
         } else {
             logger::info('Application active cetificate... failed.');
         }
     }
 }