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; }
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; }
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; }
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指定要备份的项目名称"; } }
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.'); } } }