/** * 娴嬭瘯parse comments * * @return void */ public function testConfigWrite() { $configWrite = new base_setup_config(); $configWrite->overwrite = true; $configs = ['database.host' => config::get('database.host'), 'database.database' => config::get('database.database'), 'database.username' => config::get('database.username'), 'database.password' => config::get('database.password')]; $configWrite->write($configs); }
public function index() { /** 登录之前的预先验证 **/ if (!defined("STRESS_TESTING")) { $obj_services = kernel::servicelist('app_pre_auth_use'); foreach ($obj_services as $obj) { if (method_exists($obj, 'pre_auth_uses') && method_exists($obj, 'login_verify')) { $pagedata['desktop_login_verify'] = $obj->login_verify(); } } } /** end **/ //检查证书是否合法,从而判定产品功能是否可用。比如b2c功能 $certCheckObj = kernel::service("product_soft_certcheck"); if (is_object($certCheckObj) && method_exists($certCheckObj, "check")) { $certCheckObj->check(); } $pagedata['desktop'] = url::route('shopadmin'); $pagedata['redirect'] = input::get('url'); $pagedata['Commerce'] = 'yes'; $pagedata['img_url'] = app::get('desktop')->res_url . '/images/login.png'; if (pamAccount::isEnableVcode('desktop')) { $pagedata['show_varycode'] = 'true'; } $pagedata['error_info'] = urldecode(input::get('msg')); $conf = base_setup_config::deploy_info(); $pagedata['product_key'] = $conf['product_key']; return view::make('desktop/login.html', $pagedata); }
function advertisement() { $conf = base_setup_config::deploy_info(); $this->pagedata['product_key'] = $conf['product_key']; $this->pagedata['cross_call_url'] = base64_encode(kernel::single('base_component_request')->get_full_http_host() . $this->app->base_url() . 'index.php?ctl=dashboard&act=cross_call'); $this->display('advertisement.html'); }
function advertisement() { $conf = base_setup_config::deploy_info(); $pagedata['product_key'] = $conf['product_key']; $pagedata['cross_call_url'] = base64_encode(url::route('shopadmin', array('ctl' => 'dashboard', 'act' => 'cross_call', 'app' => 'desktop'))); return view::make('desktop/advertisement.html', $pagedata); }
function index() { /** 登录之前的预先验证 **/ $obj_services = kernel::servicelist('app_pre_auth_use'); /*foreach ($obj_services as $obj){ if (method_exists($obj, 'pre_auth_uses') && method_exists($obj, 'login_verify')){ $this->pagedata['desktop_login_verify'] = $obj->login_verify(); } } /** end **/ //检查证书是否合法,从而判定产品功能是否可用。比如b2c功能 /*$certCheckObj = kernel::service("product_soft_certcheck"); if(is_object($certCheckObj) && method_exists($certCheckObj,"check")) $certCheckObj->check();*/ //在登陆页面时,验证码之后,可实现的servicelist $present = kernel::servicelist("passport_index_present"); foreach ($present as $item) { if (is_object($item) && method_exists($item, "handle")) { $item->handle($this); } } $auth = pam_auth::instance(pam_account::get_account_type($this->app->app_id)); $auth->set_appid($this->app->app_id); $auth->set_redirect_url($_GET['url']); $this->pagedata['desktop_url'] = kernel::router()->app->base_url(1); $this->pagedata['cross_call_url'] = base64_encode(kernel::router()->app->base_url(1) . 'index.php?ctl=passport&act=cross_call'); $conf = base_setup_config::deploy_info(); foreach (kernel::servicelist('passport') as $k => $passport) { if ($auth->is_module_valid($k, $this->app->app_id)) { $this->pagedata['passports'][] = array('name' => $auth->get_name($k) ? $auth->get_name($k) : $passport->get_name(), 'html' => $passport->get_login_form($auth, 'desktop', 'basic-login.html', $pagedata)); } } $this->pagedata['product_key'] = $conf['product_key']; $this->display('login.html'); }
public function active() { $this->pagedata['conf'] = base_setup_config::deploy_info(); $this->pagedata['callback_ur'] = base64_encode(kernel::base_url(1) . '/index.php/entermembercenter/default/success'); $this->pagedata['enterprise_url'] = SHOP_USER_ENTERPRISE; $output = $this->fetch('installer-active.html'); echo str_replace('%BASE_URL%', kernel::base_url(1), $output); }
public function active() { $pagedata['conf'] = base_setup_config::deploy_info(); $pagedata['callback_ur'] = base64_encode(kernel::base_url(1) . '/index.php/entermembercenter/default/success'); $pagedata['enterprise_url'] = config::get('link.shop_user_enterprise'); $output = view::make('entermembercenter/installer-active.html', $pagedata)->render(); return str_replace('%BASE_URL%', kernel::base_url(1), $output); }
function index() { $this->pagedata['conf'] = base_setup_config::deploy_info(); $this->pagedata['enterprise_url'] = SHOP_USER_ENTERPRISE; $this->pagedata['callback_url'] = base64_encode(kernel::router()->app->base_url(1) . 'index.php?app=entermembercenter&ctl=register&act=active'); $output = $this->fetch('register.html'); echo str_replace('%BASE_URL%', kernel::base_url(1), $output); }
public function install_queue($config = null) { $config = $config ? $config : base_setup_config::deploy_info(); foreach ($config['package']['app'] as $k => $app) { $applist[] = $app['id']; } return kernel::single('base_application_manage')->install_queue($applist); }
function index() { $pagedata['conf'] = base_setup_config::deploy_info(); $pagedata['enterprise_url'] = config::get('link.shop_user_enterprise'); //$pagedata['callback_url'] = base64_encode(app::get('desktop')->base_url(1).'?app=entermembercenter&ctl=register&act=active'); $pagedata['callback_url'] = base64_encode(url::route('shopadmin', ['app' => 'entermembercenter', 'ctl' => 'register', 'act' => 'active'])); $output = view::make('entermembercenter/register.html', $pagedata)->render(); return str_replace('%BASE_URL%', kernel::base_url(1), $output); }
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 { } }
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; } }
static function register($data = null) { $sys_params = base_setup_config::deploy_info(); $data = array('certi_app' => 'open.reg', 'app_id' => $sys_params['product_name']); $http = kernel::single('base_httpclient'); $http->timeout = 3; $result = $http->post(LICENSE_CENTER, $data); //todo: 声称获取一个唯一iD,发给飞飞 $result = json_decode($result, 1); if ($result['res'] == 'succ') { $certificate = $result['info']; self::set_certificate($certificate); } else { return false; } }
function system_check() { $deploy = base_setup_config::deploy_info(); $check_list = $deploy['installer']['check']; //获取app.xml扩展库 $this->_appcheck($check_list, $deploy['package']); $service = vmc::singleton('base_system_service'); foreach ($check_list as $key => $value) { $show_name = $value['show_name']; unset($value['show_name']); $method = 'check_' . $key; if (is_object($service) && method_exists($service, $method)) { $check_result[$show_name] = $service->{$method}($value, $show_name); } } return $check_result; }
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); }
function index() { /** 登录之前的预先验证 **/ if (!defined("STRESS_TESTING")) { $obj_services = kernel::servicelist('app_pre_auth_use'); foreach ($obj_services as $obj) { if (method_exists($obj, 'pre_auth_uses') && method_exists($obj, 'login_verify')) { $this->pagedata['desktop_login_verify'] = $obj->login_verify(); } } } /** end **/ //在登录页面时,验证码之后,可实现的servicelist $present = kernel::servicelist("passport_index_present"); foreach ($present as $item) { if (is_object($item) && method_exists($item, "handle")) { $item->handle($this); } } $auth = pam_auth::instance(pam_account::get_account_type($this->app->app_id)); $auth->set_appid($this->app->app_id); $auth->set_redirect_url($_GET['url']); $this->pagedata['desktop_url'] = kernel::router()->app->base_url(1); //判断登陆的标志是哪个系统的 $commerce_class = kernel::single('system_commerce'); if (!$commerce_class->get_commerce_version()) { $this->pagedata['cross_call_url'] = base64_encode(kernel::router()->app->base_url(1) . 'index.php?ctl=passport&act=cross_call'); } else { $this->pagedata['Commerce'] = 'yes'; $this->pagedata['img_url'] = app::get('desktop')->res_url . '/login.png'; } $conf = base_setup_config::deploy_info(); foreach (kernel::servicelist('passport') as $k => $passport) { if ($auth->is_module_valid($k, $this->app->app_id)) { $this->pagedata['passports'][] = array('name' => $auth->get_name($k) ? $auth->get_name($k) : $passport->get_name(), 'html' => $passport->get_login_form($auth, 'desktop', 'basic-login.html', $pagedata)); } } $this->pagedata['product_key'] = $conf['product_key']; $this->display('login.html'); }
private function _init_deploy_apps_data() { $deploy_info = base_setup_config::deploy_info(); $apps = is_array($deploy_info['package']['app']) ? $deploy_info['package']['app'] : array(); $hidden_app_ids = array(); $default_app_ids = array(); $locked_app_ids = array(); foreach ($apps as $app) { if ($app['hidden'] === 'true') { array_push($hidden_app_ids, $app['id']); } if ($app['locked'] === 'true') { array_push($locked_app_ids, $app['id']); } if ($app['default'] === 'true') { array_push($default_app_ids, $app['id']); } } $this->_deploy_hidden_app_ids = $hidden_app_ids; $this->_deploy_default_app_ids = $default_app_ids; $this->_deploy_locked_app_ids = $locked_app_ids; }
function post_update($dbinfo) { $dbver = $dbinfo['dbver']; if (empty($dbver) || $dbver < 0.31) { $configWrite = new base_setup_config(); $configWrite->overwrite = true; $configs = ['database.host' => config::get('database.host'), 'database.database' => config::get('database.database'), 'database.username' => config::get('database.username'), 'database.password' => config::get('database.password')]; $configWrite->write($configs); } $rpc_global_server = array('node_id' => base_mdl_network::MATRIX_ASYNC, 'node_url' => config::get('link.matrix_async_url'), 'node_name' => 'Global Matrix', 'node_api' => '', 'link_status' => 'active'); app::get('base')->model('network')->replace($rpc_global_server, array('node_id' => base_mdl_network::MATRIX_ASYNC), true); $rpc_realtime_server = array('node_id' => base_mdl_network::MATRIX_REALTIME, 'node_url' => config::get('link.matrix_realtime_url'), 'node_name' => 'Realtime Matrixi', 'node_api' => '', 'link_status' => 'active'); app::get('base')->model('network')->replace($rpc_realtime_server, array('node_id' => base_mdl_network::MATRIX_REALTIME), true); $rpc_service_server = array('node_id' => base_mdl_network::MATRIX_SERVICE, 'node_url' => config::get('link.matrix_service_url'), 'node_name' => 'Service Matrix', 'node_api' => '', 'link_status' => 'active'); app::get('base')->model('network')->replace($rpc_service_server, array('node_id' => base_mdl_network::MATRIX_SERVICE), true); }
function command_ecos() { //检测php版本 $rst = version_compare(PHP_VERSION, '5.0', '>='); echo $rst ? app::get('dev')->_("php版本是") . PHP_VERSION . app::get('dev')->_('->符合要求...') . "\n" : app::get('dev')->_('php版本是') . PHP_VERSION . app::get('dev')->_('->不符合要求,请安装php5以上的版本...') . "\n"; //检测目录是否可写 $deploy = base_setup_config::deploy_info(); $writeable_dir = $deploy['installer']['writeable_check']['dir']; if (is_array($writeable_dir)) { $unablewrite = array(); foreach ($writeable_dir as $dir) { $file = ROOT_DIR . '/' . $dir . '/test.html'; if ($fp = @fopen($file, 'w')) { @fclose($fp); @unlink($file); } else { $unablewrite[] = $dir; } } if (count($unablewrite)) { echo join(',', $unablewrite) . app::get('dev')->_('目录不可写...') . "\n"; } else { echo app::get('dev')->_('目录可写性检测通过...') . "\n"; } } //检测是否可以解析xml文件 $rst = function_exists('xml_parse_into_struct'); echo $rst ? app::get('dev')->_("php可以解析xml文件...") . "\n" : app::get('dev')->_('php不支持解析xml文件...') . "\n"; //检测是否安装GD库 if (is_callable('imagecreatetruecolor')) { try { $image = imagecreatetruecolor(100, 200); imagedestroy($image); $rst = true; } catch (Exception $e) { $rst = false; } } else { $rst = false; } echo $rst ? app::get('dev')->_("GD库正常...") . "\n" : app::get('dev')->_("GD库不正常 (将影响部分功能)...") . "\n"; //检测kvstore是否可以存取 @$this->app->setConf('dev.test.data', 'testdata'); $s = @$this->app->getConf('dev.test.data'); if (!empty($s)) { $rst = true; @$this->app->setConf('dev.test.data', ''); } else { $rst = false; } echo $rst ? app::get('dev')->_("kvstore存取正常...") . "\n" : app::get('dev')->_("kvstore存取不正常...") . "\n"; //检测mysql函数库是否可用 $rst = function_exists('mysql_connect') && function_exists('mysql_get_server_info'); echo $rst ? app::get('dev')->_("MySQL函数库可用...") . "\n" : app::get('dev')->_('MySQL函数库未安装...') . "\n"; //检测mysql数据库连接 if (!$rst) { echo app::get('dev')->_("MySQL函数库连接出错..."); } else { $rst = false; if (defined('DB_HOST')) { if (defined('DB_PASSWORD')) { $rs = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); } elseif (defined('DB_USER')) { $rs = mysql_connect(DB_HOST, DB_USER); } else { $rs = mysql_connect(DB_HOST); } $db_ver = mysql_get_server_info($rs); } else { $sock = get_cfg_var('mysql.default_socket'); if (PHP_OS != 'WINNT' && file_exists($sock) && is_writable($sock)) { define('DB_HOST', $sock); } else { $host = ini_get('mysql.default_host'); $port = ini_get('mysql.default_port'); if (!$host) { $host = '127.0.0.1'; } if (!$port) { $port = 3306; } define('DB_HOST', $host . ':' . $port); } } if (!$db_ver) { if (substr(DB_HOST, 0, 1) == '/') { $fp = @fsockopen("unix://" . DB_HOST); } else { if ($p = strrpos(DB_HOST, ':')) { $port = substr(DB_HOST, $p + 1); $host = substr(DB_HOST, 0, $p); } else { $port = 3306; $host = DB_HOST; } $fp = @fsockopen("tcp://" . $host, $port, $errno, $errstr, 2); } if (!$fp) { $db_ver = '无法连接'; } else { fwrite($fp, "\n"); $db_ver = fread($fp, 20); fclose($fp); if (preg_match('/([2-8]\\.[0-9\\.]+)/', $db_ver, $match)) { $db_ver = $match[1]; $rst = version_compare($db_ver, '4.0', '>='); } else { $db_ver = '无法识别'; } } } else { $rst = version_compare($db_ver, '4.1', '>='); } if ($db_ver == '无法连接') { $error_msg = 'Mysql数据库无法连接...'; } elseif ($db_ver == '无法识别') { $error_msg = 'Mysql数据库版本无法识别...'; } else { $error_msg = 'Mysql数据库版本是' . $db_ver . ',如果版本过低,请使用高于4.1的版本...'; } echo app::get('dev')->_($error_msg) . "\n"; } //检测mysql数据库是否可写可读 $db = kernel::database(); $db->exec('drop table if exists sdb_test') . "\n"; $sql_c = "CREATE TABLE `sdb_test` (`id` int(10) unsigned NOT NULL AUTO_INCREMENT,`test` char(10) NOT NULL,PRIMARY KEY (`id`)) ENGINE=InnoDB DEFAULT CHARSET=utf8"; if (@$db->exec($sql_c)) { echo app::get('dev')->_("Mysql创建测试表正常...") . "\n"; } else { echo app::get('dev')->_("Mysql创建测试表不正常...") . "\n"; } $sql_i = "insert into `sdb_test`(`id`,`test`) values (1,'test')"; if (@$db->exec($sql_i)) { echo app::get('dev')->_("Mysql插入数据正常...") . "\n"; } else { echo app::get('dev')->_("Mysql插入数据不正常...") . "\n"; } $sql_s = "select * from sdb_test"; if (@$db->exec($sql_s)) { echo app::get('dev')->_("Mysql读取数据正常...") . "\n"; } else { echo app::get('dev')->_("Mysql读取数据不正常...") . "\n"; } $db->exec('drop table if exists sdb_test') . "\n"; //检测常用service是否注册成功 $service_common_arr = array('base_storage_filesystem' => 'file_storage', 'base_view_compiler' => 'view_compile_helper', 'base_view_helper' => 'view_helper', 'base_view_input' => 'html_input', 'base_rpc_service' => 'openapi.rpc_callback', 'base_misc_task' => 'autotask', 'base_rpc_check' => 'openapi.check', 'base_service_queue' => 'openapi.queue', 'base_service_cachevary' => 'cachemgr_global_vary', 'base_service_render' => 'base_render_pre_display', 'base_charset_default' => 'base_charset', 'base_status_system' => 'status', 'dbeav_filter' => 'dbeav_filter', 'pam_passport_basic' => 'passport', 'pam_callback' => 'openapi.pam_callback', 'pam_trust_tao' => 'login_trust', 'desktop_sidepanel_dashboard' => 'desktop_sidepanel.desktop_ctl_dashboard', 'desktop_finder_apps' => 'desktop_finder.base_mdl_apps', 'desktop_application_menu' => 'app_content_detector', 'desktop_application_workground' => 'app_content_detector', 'desktop_application_permission' => 'app_content_detector', 'desktop_application_panelgroup' => 'app_content_detector', 'desktop_application_adminpanel' => 'app_content_detector', 'desktop_application_theme' => 'app_content_detector', 'desktop_application_widgets' => 'app_content_detector', 'desktop_view_input' => 'html_input', 'desktop_view_helper' => 'view_helper', 'desktop_finder_users' => 'desktop_finder.desktop_mdl_users', 'desktop_finder_roles' => 'desktop_finder.desktop_mdl_roles', 'desktop_io_type_csv' => 'desktop_io', 'desktop_finder_pam' => 'desktop_finder.desktop_mdl_pam', 'desktop_finder_tag' => 'desktop_finder.desktop_mdl_tag', 'desktop_service_view_menu' => 'desktop_menu', 'desktop_finder_colset' => 'desktop_task.finder_colset', 'desktop_finder_favstar' => 'desktop_task.finder_favstar', 'desktop_finder_recycle' => 'desktop_finder.desktop_mdl_recycle', 'desktop_finder_magicvars' => 'desktop_finder.desktop_mdl_magicvars', 'desktop_keyboard_initdata' => 'desktop_keyboard_setting', 'desktop_service_login' => 'pam_login_listener', 'desktop_cert_certcheck' => 'product_soft_certcheck', 'image_finder_image' => 'desktop_finder.image_mdl_image', 'site_finder_explorers' => 'desktop_finder.site_mdl_explorers', 'site_finder_link' => 'desktop_finder.site_mdl_link', 'site_finder_modules' => 'desktop_finder.site_mdl_modules', 'site_finder_seo' => 'desktop_finder.site_mdl_seo', 'site_finder_menus' => 'desktop_finder.site_mdl_menus', 'site_finder_theme' => 'desktop_finder.site_mdl_themes', 'site_finder_route_static' => 'desktop_finder.site_mdl_route_statics', 'site_finder_widgets_proinstance' => 'desktop_finder.site_mdl_widgets_proinstance', 'site_finder_callback_modules' => 'desktop_finder_callback.site_mdl_modules', 'site_application_explorer' => 'app_content_detector', 'site_application_module' => 'app_content_detector', 'site_application_widgets' => 'app_content_detector', 'site_view_compiler' => 'view_compile_helper', 'site_view_helper' => 'view_helper', 'site_service_view_helper' => 'site_view_helper', 'site_service_cachevary' => 'cachemgr_global_vary', 'site_service_seo' => 'site_service_seo', 'site_misc_task' => 'autotask', 'site_service_view_menu' => 'desktop_menu', 'site_devtpl_widget' => 'dev.project_type', 'site_devtpl_theme' => 'dev.project_type', 'site_application_themewidgets' => 'site_theme_content_detector', 'site_service_tplsource' => 'tpl_source.site_proinstance', 'site_service_tpltheme' => 'tpl_source.theme', 'site_errorpage_display' => 'site_display_errorpage.conf', 'site_keyboard_initdata' => 'desktop_keyboard_setting'); $sql = 'select app_id,content_name,content_path from sdb_base_app_content where content_type="service" and disabled!="true"'; $fsql = $sql . ' AND app_id IN ("base","dbeav","desktop","image","pam","site")'; $rs = $db->select($fsql); $service_local_arr = array(); foreach ($rs as $data) { $service_local_arr[$data['content_path']] = $data['content_name']; } $unservice = array_diff_key($service_common_arr, $service_local_arr); if (count($unservice)) { $unservice_output = array(); foreach ($unservice as $key => $data1) { $app_ids = explode('_', $key); $app_id = $app_ids[0]; $unservice_output = $data1 . "({$app_id})"; echo "service { " . $unservice_output . app::get('dev')->_(' }未注册...') . "\n"; } } else { echo app::get('dev')->_('常用service存在,但仍可能有service未注册...') . "\n"; } //end }
public function install($app_id, $options = null, $auto_enable = 1) { $app = app::get($app_id); if (!file_exists(APP_DIR . '/' . $app_id . '/app.xml')) { if (!$this->download($app_id)) { logger::info('Application package can not be download.'); return false; } } $rows = kernel::database()->select('select * from sdb_base_apps where app_id="' . $app_id . '"'); if (isset($rows[0]) && $rows[0]['status'] != "uninstalled") { logger::info('Application package Already installed'); return false; } $app_info = $app->define('main_app'); $app_exclusion = app::get('base')->getConf('system.main_app'); if ($app_info['value'] == 'true') { if ($app_info['exclusion'] == 'true') { if ($app_exclusion['value'] == 'true' && $app_exclusion['exclusion'] == 'true' && $app_exclusion['app_id'] != $app_id) { logger::info('Application ' . $app_id . ' exclusioned ' . $app_exclusion['app_id'] . '.'); return false; } } $app_info['app_id'] = $app_id; $app_exclusion = app::get('base')->setConf('system.main_app', $app_info); } $app_self_detector = null; kernel::database()->exec('update sdb_base_apps set status="installing" where app_id="' . $app_id . '" and status="uninstalled" '); $app->runtask('pre_install', $options); kernel::single('base_application_dbtable')->clear_by_app($app_id); //清除冗余表信息 foreach ($this->content_detector($app_id) as $detector) { foreach ($detector->detect($app) as $name => $item) { $item->install(); } kernel::set_online(true); base_kvstore::instance('system')->store('service_last_modified.' . get_class($detector) . '.' . $app_id, $detector->last_modified($app_id)); } //todo:clear service cache... 如果以后做了缓存的话... //用自己新安装的资源探测器,安装自己的资源 foreach (kernel::servicelist('app_content_detector') as $k => $detector) { if ($detector->app->app_id == $app_id) { //遍历所有已经安装的app foreach ($detector->detect($app) as $name => $item) { $item->install(); } base_kvstore::instance('system')->store('service_last_modified.' . get_class($detector) . '.' . $app_id, $detector->last_modified($app_id)); } } app::get('base')->model('apps')->replace(array('status' => 'installed', 'app_id' => $app_id, 'dbver' => $app->define('version')), array('app_id' => $app_id)); $deploy_info = base_setup_config::deploy_info(); foreach ((array) $deploy_info['setting'] as $set) { if ($set['app'] == $app_id) { $app->setConf($set['key'], $set['value']); } } $app->runtask('post_install', $options); if ($auto_enable) { $this->enable($app_id); } //app submit servicelist $params['certificate_id'] = $app_id; $params['app_id'] = $app_id; // $rst = app::get($app_id)->matrix()->set_callback('dev_sandbox','show',array(1,2,3,'aa'=>time())) // ->call('node.addshop',$app_id); logger::info('Application ' . $app_id . ' installed... ok.'); }
function wpermissions() { //检测ecstore系统目录是否可写 $deploy = base_setup_config::deploy_info(); $writeable_dir = $deploy['installer']['writeable_check']['dir']; $unablewrite = array(); if (is_array($writeable_dir)) { foreach ($writeable_dir as $dir) { $file = ROOT_DIR . '/' . $dir . '/test.html'; if ($fp = @fopen($file, 'w')) { @fclose($fp); @unlink($file); } else { $unablewrite[] = $dir; } } } //检测系统tmp目录是否可写 $tmpfile = "/tmp/test.html"; if ($tmpfp = @fopen($tmpfile, 'w')) { @fclose($tmpfp); @unlink($tmpfile); } else { $unablewrite[] = "/tmp"; } if (count($unablewrite)) { echo " " . join(',', $unablewrite) . app::get('dev')->_(' 目录不可写,请检测硬盘空间是否足够或者目录权限web是否用户可以写入...') . "\n"; } else { echo app::get('dev')->_(' 目录可写性检测通过...') . "\n"; } //检测kvstore的存取权限 @$this->app->setConf('dev.test.data', 'testdata'); $s = @$this->app->getConf('dev.test.data'); if (!empty($s)) { $rst = true; @$this->app->setConf('dev.test.data', ''); } else { $rst = false; } echo $rst ? app::get('dev')->_(" kvstore存取正常...") . "\n" : app::get('dev')->_(" kvstore存取不正常,请检测data/kvstore目录中的权限...") . "\n"; }
function test_server_req(&$score) { $rst = version_compare(PHP_VERSION, '5.0', '>='); $items['PHP5以上'] = array('value' => $rst ? '您的php版本是' . PHP_VERSION : '您的php版本是' . PHP_VERSION . '不符合要求,请安装php5以上的版本', 'result' => $rst); if (!$rst) { $allow_install = false; } $rst = !get_cfg_var('zend.ze1_compatibility_mode'); $items['zend.ze1_compatibility_mode 关闭'] = array('value' => $rst ? 'zend.ze1_compatibility_mode 已关闭' : '您的zend.ze1_compatibility_mode 需关闭', 'result' => $rst); if (!$rst) { $allow_install = false; } $deploy = base_setup_config::deploy_info(); $writeable_dir = $deploy['installer']['check']['writeable']['dir']; if (is_array($writeable_dir)) { $unablewrite = array(); foreach ($writeable_dir as $dir) { $file = ROOT_DIR . '/' . $dir . '/test.html'; if ($fp = @fopen($file, 'w')) { @fclose($fp); @unlink($file); } else { $unablewrite[] = $dir; } } if (count($unablewrite)) { $items['目录可写性检测'] = array('value' => join(',', $unablewrite) . '目录不可写', 'result' => false); $allow_install = false; } else { $items['目录检测'] = array('value' => '全部检测通过', 'result' => true); } } $tmpfname = tempnam(TMP_DIR, "foo"); $handle = fopen($tmpfname, "w"); $rst = flock($handle, LOCK_EX); fclose($handle); $items['支持文件锁(flock)'] = array('value' => $rst ? '支持文件锁(flock)' : '您不支持文件锁(flock),' . TMP_DIR . '可能没权限', 'result' => $rst); if (!$rst) { $allow_install = false; } $rst = function_exists('xml_parse_into_struct'); $items['php可以解析xml文件'] = array('value' => $rst ? 'php可以解析xml文件' : '您的php不支持解析xml文件', 'result' => $rst); if (!$rst) { $allow_install = false; } $rst = function_exists('mysql_connect') && function_exists('mysql_get_server_info'); $items['MySQL函数库可用'] = array('value' => $rst ? '您的MySQL函数库是' . mysql_get_client_info() : '您的MySQL函数库未安装', 'result' => $rst); if (!$rst) { $allow_install = false; } else { $rst = false; if (isset($this->check_params['mysql_host'])) { define('DB_HOST', $this->check_params['mysql_host']); } elseif (defined('DB_HOST')) { if (defined('DB_PASSWORD')) { $rs = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD); } elseif (defined('DB_USER')) { $rs = mysql_connect(DB_HOST, DB_USER); } else { $rs = mysql_connect(DB_HOST); } $db_ver = mysql_get_server_info($rs); } elseif ($db_ver = @mysql_get_server_info()) { define('DB_HOST', ''); } else { $sock = get_cfg_var('mysql.default_socket'); if (PHP_OS != 'WINNT' && file_exists($sock) && is_writable($sock)) { define('DB_HOST', $sock); } else { $host = ini_get('mysql.default_host'); $port = ini_get('mysql.default_port'); if (!$host) { $host = '127.0.0.1'; } if (!$port) { $port = 3306; } define('DB_HOST', $host . ':' . $port); } } if (!$db_ver) { if (substr(DB_HOST, 0, 1) == '/') { $fp = @fsockopen("unix://" . DB_HOST); } else { if ($p = strrpos(DB_HOST, ':')) { $port = substr(DB_HOST, $p + 1); $host = substr(DB_HOST, 0, $p); } else { $port = 3306; $host = DB_HOST; } $fp = @fsockopen("tcp://" . $host, $port, $errno, $errstr, 2); } if (!$fp) { $db_ver = '无法连接'; } else { fwrite($fp, "\n"); $db_ver = fread($fp, 20); fclose($fp); if (preg_match('/([2-8]\\.[0-9\\.]+)/', $db_ver, $match)) { $db_ver = $match[1]; $rst = version_compare($db_ver, '4.0', '>='); } else { $db_ver = '无法识别'; } } } else { $rst = version_compare($db_ver, '4.1', '>='); } $this->db_ver = $db_ver; $mysql_key = '数据库Mysql 4.1以上 <i style="color:#060">' . DB_HOST . '</i>'; if ($this->allow_change_db) { $mysql_key .= '<form method="get" action="" style="margin:0;padding:0"><table><tr><td><label for="db_host">MySQL主机</label></td><td> </td></tr><tr><td><input id="db_host" value="' . DB_HOST . '" name="db_host" style="width:100px;" type="text" /></td><td><input type="submit" value="连接"></td></tr></table></form>'; } if ($db_ver == '无法连接') { $error_msg = '您的Mysql数据库无法连接'; } elseif ($db_ver == '无法连接') { $error_msg = '您的Mysql数据库版本无法识别'; } else { $error_msg = '您的Mysql数据库版本是' . $db_ver . ',版本过低请使用高于4.1的版本.'; } $items[$mysql_key] = array('value' => $rst ? '您的Mysql数据库版本是' . $db_ver : $error_msg . '<br>自定义MySQL地址:<input type="text" name="installer_check[mysql_host]" value="" />', 'result' => $rst); if (!$rst) { $allow_install = false; } } /* if(ini_get('safe_mode')){ $rst = is_callable('ftp_connect'); if(!$rst){ $allow_install = false; } $items['当安全模式开启时,ftp函数可用'] = array( 'value'=>$rst?'可用':'不可用', 'result'=>$rst, ); } */ if (is_callable('imagecreatetruecolor')) { try { $image = imagecreatetruecolor(100, 200); imagedestroy($image); $rst = true; } catch (Exception $e) { $rst = false; } } else { $rst = false; } $items['是否正常安装GD库'] = array('value' => $rst ? '成功' : '失败 (将影响部分功能)', 'result' => $rst); $rst = preg_match('/[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+/', gethostbyname('www.example.com')); $items['DNS配置完成,本机上能通过域名访问网络'] = array('value' => $rst ? '成功' : '失败 (将影响部分功能)', 'result' => $rst); return array('group' => '基本需求', 'key' => 'require', 'items' => $items, 'type' => 'require', 'allow_install' => $allow_install); }
function command_inactive_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)) { // 获取节点. base_shopnode::delete_node_id($str_app_id); } } }
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指定要恢复的项目名称"; } }
/** * µÃµ½deploy²¿ÊðµÄdemo dataÑ¡ÔñÏîÄ¿ * @param null * @return array */ private function install_demodata_options($config = null) { $config = $config ? $config : base_setup_config::deploy_info(); $install_options = array(); $tmp_arr_options = array(); foreach ((array) $config['demodatas'] as $key => $demo_data) { foreach ((array) $demo_data['options'] as $arr_options) { $tmp_arr_options[$arr_options['key']] = $arr_options['value']; } unset($demo_data['options']); $demo_data['options'] = $tmp_arr_options; $install_options[$key] = $demo_data; } return $install_options; }
static function node_id($app_id) { if (!$app_id) { $config = base_setup_config::deploy_info(); foreach ($config['package']['app'] as $k => $app) { $app_xml = kernel::single('base_xml')->xml2array(file_get_contents(app::get($app['id'])->app_dir . '/app.xml'), 'base_app'); if (isset($app_xml['node_id']) && $app_xml['node_id'] == "true" && !self::node_id($app['id'])) { // 获取节点. if ($node_id = self::node_id($app['id'])) { return $node_id; } } } return false; } else { return self::get('node_id', $app_id); } }