/** * 获取企业信息 * @param string 获取的信息内容 * @return string 相应的内容 */ static function get($code = 'ent_id') { if (self::$enterp === null) { if ($serialize_enterp = app::get('base')->getConf('ecos.enterprise_info')) { $enterprise = unserialize($serialize_enterp); self::$enterp = $enterprise; } } return self::$enterp[$code]; }
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; } }
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; }
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')->_('保存成功')); } }
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; }
function 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"); $active_url = kernel::router()->app->base_url(1) . '/index.php?app=entermembercenter&ctl=register'; 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_certificate::certi_id() || !base_certificate::token()) { $flag = base_certificate::register(); } if (!$flag) { header("Content-type: text/html; charset=utf-8"); $active_url = kernel::router()->app->base_url(1) . '/index.php?app=entermembercenter&ctl=register'; header('Location:' . $active_url); exit; } if (!base_shopnode::node_id() && base_certificate::certi_id() && base_certificate::token()) { $obj_buildin = kernel::single('base_shell_buildin'); $obj_buildin->command_active_node_id('ceti_node_id'); } } } } else { header("Content-type: text/html; charset=utf-8"); $active_url = kernel::router()->app->base_url(1) . '/index.php?app=entermembercenter&ctl=register'; header('Location:' . $active_url); exit; } $url = kernel::router()->gen_url(array(), 1); $url = base64_encode($url); $login_html = 'index.php?ctl=passport&act=index&url=' . $url; header("Content-type: text/html; charset=utf-8"); header('Location:' . $login_html); exit; }
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 clean($type = "clean") { //清除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)) { // 获取节点. base_shopnode::delete_node_id($str_app_id); } } //清除证书 base_certificate::del_certificate(); //清除shopex_id base_enterprise::set_enterprise_info(null); }
/** * @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(); } }
function __construct() { $this->license_id = base_certificate::get('certificate_id'); $this->license_key = base_certificate::get('token'); $this->entid = base_enterprise::ent_id(); }
function command_recover_shopex_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 . "_shopex_id.log"; if (is_file($backup_file)) { if (!($fp = fopen($backup_file, 'r'))) { echo "Failed to read file"; exit; } $content = fgets($fp); list($ent_id, $ent_ac, $ent_email) = explode('|||', $content); $data = array('ent_id' => $ent_id, 'ent_ac' => $ent_ac, 'ent_email' => $ent_email); $result = base_enterprise::set_enterprise_info($data); if (!$result) { echo "failed shopex_id recovery....."; exit; } else { base_certificate::del_certificate(); $obj = kernel::single('base_shell_buildin'); $obj->command_inactive_node_id('ceti_node_id'); echo "success of the shopex_id recovery......"; exit; } } else { echo "File does not exist......"; exit; } } else { echo "缺少参数,使用-d 指定已经备份好的shopex_id存放的目录?使用-n指定要恢复的项目名称"; } }
public function __construct($app) { parent::__construct($app); $this->entid = base_enterprise::ent_id(); }
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.'); } } }
function error_info_view() { $render = app::get('desktop')->render(); $result = $_GET['result']; app::get('desktop')->setConf('activation_code_check', false); $render->pagedata['error_code'] = $result['msg']; $render->pagedata['shopexUrl'] = app::get('base')->getConf('certificate_code_url'); $render->pagedata['shopexId'] = base_enterprise::ent_id(); switch ($result['msg']) { case "invalid_version": $msg = "版本号有误,查看mysql是否运行正常"; break; case "RegUrlError": $msg = "你当前使用的域名与证书所绑定的域名不一致。"; break; case "SessionError": $msg = "中心请求网店API失败!,请联系您的服务商,或找贵公司相关人员检测网络,以确保网络正常"; break; case "license_error": $msg = "证书号错误!"; $Certi = base_certificate::get('certificate_id'); if (!$Certi) { $msg .= "查询不到证书,请确认config/certi.php文件是否存在"; } break; case "method_not_exist": $msg = "接口方法不存在!"; break; case "method_file_not_exist": $msg = "接口文件不存在!"; break; case "NecessaryArgsError": $msg = "缺少必填参数!"; break; case "ProductTypeError": $msg = "产品类型错误!"; break; case "UrlFormatUrl": $msg = "URL格式错误!"; break; case "invalid_sign": $msg = "验签错误!"; break; default: $msg = null; break; } if ($result == null) { $msg = "请检测您的服务器域名解析是否正常!"; $fp = fsockopen("service.shopex.cn", 80, $errno, $errstr, 30); if (!$fp) { $render->pagedata['fsockopen'] = 'fsockopen解析service.shopex.cn错误,请确认是否将fsockopen函数屏蔽</br>错误信息:' . $errstr; } } $url = $this->app->base_url(1); $code_url = $url . 'index.php?app=desktop&ctl=code&act=error_view'; $order_url = $url . 'index.php/shopadmin/#app=b2c&ctl=admin_order&act=index'; $cleanexpired_url = $url . 'index.php/shopadmin/#ctl=adminpanel'; $render->pagedata['msg'] = $msg ? $msg : ""; $render->pagedata['url'] = $url; $render->pagedata['order_url'] = $order_url; $render->pagedata['code_url'] = $code_url; $render->pagedata['cleanexpired_url'] = $cleanexpired_url; echo $render->fetch('codetip.html'); exit; }