Exemplo n.º 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;
     }
 }
Exemplo n.º 2
0
 function command_active_node_id($app_id = 'ceti_node_id')
 {
     /** 证书获取后激活应用节点 **/
     $config = base_setup_config::deploy_info();
     foreach ($config['package']['app'] as $k => $app) {
         $applist[] = $app['id'];
     }
     foreach ($applist as $str_app_id) {
         $app_xml = kernel::single('base_xml')->xml2array(file_get_contents(app::get($str_app_id)->app_dir . '/app.xml'), 'base_app');
         if (isset($app_xml['node_id']) && $app_xml['node_id'] == "true" && !base_shopnode::node_id($str_app_id)) {
             // 获取节点.
             if (base_shopnode::register($str_app_id)) {
                 kernel::log('Applications info send to center, ok.');
             }
         }
     }
 }