Exemple #1
0
 function upLicense()
 {
     $content = file_get_contents($_FILES['license']['tmp_name']);
     list($certificate_id, $token) = explode('|||', $content);
     $result = base_certificate::set_certificate(array('certificate_id' => $certificate_id, 'token' => $token));
     if (!$result) {
         echo "<script>parent.MessageBox.success('证书重置失败,请先上传文件');</script>";
     } else {
         echo "<script>parent.MessageBox.error('证书上传成功');</script>";
     }
 }
Exemple #2
0
 function upLicense()
 {
     if ($_FILES) {
         if ($_FILES['license']['name']) {
             $fileName = explode('.', $_FILES['license']['name']);
             if ('CER' != $fileName['1']) {
                 $this->begin();
                 $this->end(false, app::get('desktop')->_("证书格式不对"));
             } else {
                 $content = file_get_contents($_FILES['license']['tmp_name']);
                 list($certificate_id, $token) = explode('|||', $content);
                 /** 验证证书是否合法 **/
                 $sys_params = base_setup_config::deploy_info();
                 $code = md5(microtime());
                 base_kvstore::instance('ecos')->store('net.login_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'];
                 $conf = base_setup_config::deploy_info();
                 $data = array('certi_app' => 'open.login', 'certificate_id' => $certificate_id, 'url' => kernel::base_url(1), 'version' => '0.14', 'ver_detail' => $app_xml['version'], 'result' => $code, 'format' => 'json');
                 ksort($data);
                 foreach ($data as $key => $value) {
                     $str .= $value;
                 }
                 $data['certi_ac'] = md5($str . $token);
                 $http = kernel::single('base_httpclient');
                 $http->set_timeout(6);
                 $result = $http->post(LICENSE_CENTER, $data);
                 $result = json_decode($result, 1);
                 if ($result['res'] != 'succ') {
                     $this->begin();
                     $this->end(false, app::get('desktop')->_("上传证书无效"));
                 }
                 $result = base_certificate::set_certificate(array('certificate_id' => $certificate_id, 'token' => $token));
                 if (!$result) {
                     $this->begin();
                     $this->end(false, app::get('desktop')->_("证书重置失败,请先上传文件"));
                 } else {
                     $this->begin();
                     $this->end(true, app::get('desktop')->_("证书上传成功"));
                 }
             }
         } else {
             $this->begin();
             $this->end(false, app::get('desktop')->_("请选择要上传的文件"));
         }
     } else {
     }
 }
Exemple #3
0
 function command_recover_certificate_id()
 {
     $args = func_get_args();
     $options = $this->get_options();
     if ($options['backup_dir']) {
         $file_name = $args[1];
         $backup_dir = $args[0];
         $backup_file = $backup_dir . "/" . $file_name . "_certificate_id.log";
         if (is_file($backup_file)) {
             if (!($fp = fopen($backup_file, 'r'))) {
                 echo "Failed to read file";
                 exit;
             }
             $content = fgets($fp);
             list($certificate_id, $token) = explode('|||', $content);
             $sys_params = base_setup_config::deploy_info();
             $code = md5(microtime());
             base_kvstore::instance('ecos')->store('net.login_handshake', $code);
             $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'];
             $conf = base_setup_config::deploy_info();
             $data = array('certi_app' => 'open.login', 'certificate_id' => $certificate_id, 'url' => kernel::base_url(1), 'version' => '0.14', 'ver_detail' => $app_xml['version'], 'result' => $code, 'format' => 'json');
             ksort($data);
             foreach ($data as $key => $value) {
                 $str .= $value;
             }
             $data['certi_ac'] = md5($str . $token);
             $http = kernel::single('base_httpclient');
             $http->set_timeout(6);
             $result = $http->post(LICENSE_CENTER, $data);
             $result = json_decode($result, 1);
             if ($result['res'] != 'succ') {
                 echo "Certificate restore fails......";
             }
             $result = base_certificate::set_certificate(array('certificate_id' => $certificate_id, 'token' => $token));
             if ($result) {
                 echo "Certificate recovery success......";
             } else {
                 echo "Certificate restore fails.....";
             }
         } else {
             echo "File does not exist......";
             exit;
         }
     } else {
         echo "缺少参数,使用-d 指定已经备份好的'证书'存放的目录?使用-n指定要恢复的项目名称";
     }
 }