From e0c298d958468039b7797453c8fe17a7ee0b9fdb Mon Sep 17 00:00:00 2001 From: ngleader Date: Fri, 8 Jul 2011 07:45:51 +0000 Subject: [PATCH] issue 72 Sending server environment information after agreement of xe admin user. git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@8581 201d5d3c-b55e-5fd7-737f-ddc643e51545 --- modules/addon/addon.admin.model.php | 5 ++- modules/admin/admin.admin.model.php | 60 +++++++++++++++++++++++++- modules/admin/admin.admin.view.php | 28 +++++++++++- modules/install/install.controller.php | 14 ++++-- modules/install/install.model.php | 2 - modules/install/tpl/introduce.html | 4 +- modules/module/module.model.php | 4 +- 7 files changed, 104 insertions(+), 13 deletions(-) diff --git a/modules/addon/addon.admin.model.php b/modules/addon/addon.admin.model.php index e066f28a9..f3032b4ee 100644 --- a/modules/addon/addon.admin.model.php +++ b/modules/addon/addon.admin.model.php @@ -29,11 +29,13 @@ // Wanted to add a list of activated $inserted_addons = $this->getInsertedAddons($site_srl); // Downloaded and installed add-on to the list of Wanted - $searched_list = FileHandler::readDir('./addons'); + $searched_list = FileHandler::readDir('./addons','/^([a-zA-Z0-9-_]+)$/'); $searched_count = count($searched_list); if(!$searched_count) return; sort($searched_list); + $oAddonAdminController = &getAdminController('addon'); + for($i=0;$i<$searched_count;$i++) { // Add the name of $addon_name = $searched_list[$i]; @@ -51,7 +53,6 @@ // Check if a permossion is granted entered in DB if(!in_array($addon_name, array_keys($inserted_addons))) { // If not, type in the DB type (model, perhaps because of the hate doing this haneungeo .. ㅡ. ㅜ) - $oAddonAdminController = &getAdminController('addon'); $oAddonAdminController->doInsert($addon_name, $site_srl); // Is activated } else { diff --git a/modules/admin/admin.admin.model.php b/modules/admin/admin.admin.model.php index ce181e86f..cfbbd9cbd 100644 --- a/modules/admin/admin.admin.model.php +++ b/modules/admin/admin.admin.model.php @@ -87,5 +87,61 @@ } $this->add('list', $list); } - } -?> + + function getEnv($type='WORKING') { + + $skip = array( + 'ext' => array('pcre','json','hash','dom','session','spl','standard','date','ctype','tokenizer','apache2handler','filter','posix','reflection','pdo') + ,'module' => array('addon','admin','autoinstall', 'comment', 'communication', 'counter', 'document', 'editor', 'file', 'importer', 'install', 'integration_search', 'layout', 'member', 'menu', 'message', 'module', 'opage', 'page', 'point', 'poll', 'rss', 'session', 'spamfilter', 'tag', 'trackback', 'trash', 'widget') + ,'addon' => array('autolink', 'blogapi', 'captcha', 'counter', 'member_communication', 'member_extra_info', 'mobile', 'openid_delegation_id', 'point_level_icon', 'resize_image' ) + ); + + $info = array(); + $info['type'] = ($type !='INSTALL' ? 'WORKING' : 'INSTALL'); + $info['location'] = _XE_LOCATION_; + $info['package'] = _XE_PACKAGE_; + $info['host'] = $db_type->default_url ? $db_type->default_url : getFullUrl(); + $info['app'] = $_SERVER['SERVER_SOFTWARE']; + $info['php'] = phpversion(); + + $db_info = Context::getDBInfo(); + $info['db_type'] = $db_info->db_type; + $info['use_rewrite'] = $db_info->use_rewrite; + $info['use_db_session'] = $db_info->use_db_session == 'Y' ?'Y':'N'; + $info['use_ssl'] = $db_info->use_ssl; + + $info['phpext'] = ''; + foreach (get_loaded_extensions() as $ext) { + $ext = strtolower($ext); + if(in_array($ext, $skip['ext'])) continue; + $info['phpext'] .= '|'. $ext; + } + $info['phpext'] = substr($info['phpext'],1); + + $info['module'] = ''; + $oModuleModel = &getModel('module'); + $module_list = $oModuleModel->getModuleList(); + foreach($module_list as $module){ + if(in_array($module->module, $skip['module'])) continue; + $info['module'] .= '|'.$module->module; + } + $info['module'] = substr($info['module'],1); + + $info['addon'] = ''; + $oAddonAdminModel = &getAdminModel('addon'); + $addon_list = $oAddonAdminModel->getAddonList(); + foreach($addon_list as $addon){ + if(in_array($addon->addon, $skip['addon'])) continue; + $info['addon'] .= '|'.$addon->addon; + } + $info['addon'] = substr($info['addon'],1); + + $param = ''; + foreach($info as $k => $v){ + if($v) $param .= sprintf('&%s=%s',$k,urlencode($v)); + } + $param = substr($param, 1); + + return $param; + } + } diff --git a/modules/admin/admin.admin.view.php b/modules/admin/admin.admin.view.php index 0779501ec..d490a90f7 100644 --- a/modules/admin/admin.admin.view.php +++ b/modules/admin/admin.admin.view.php @@ -42,6 +42,8 @@ if($db_info->http_port) Context::set('http_port', $db_info->http_port); if($db_info->https_port) Context::set('https_port', $db_info->https_port); + $this->showSendEnv(); + } function loadSideBar() @@ -353,5 +355,29 @@ Context::set('layout','none'); $this->setTemplateFile('config'); } + + function showSendEnv() { + if(Context::getResponseMethod() != 'HTML' && $_SESSION['agree_send_env'] != 'Y') return; + + $server = 'http://collect.xpressengine.com/env/img.php?'; + $path = './files/env/'; + $install_env = $path . 'install'; + if(file_exists(FileHandler::getRealPath($install_env))) { + $oAdminAdminModel = &getAdminModel('admin'); + $params = $oAdminAdminModel->getEnv('INSTALL'); + $img = sprintf('', $server.$params); + Context::addHtmlFooter($img); + + FileHandler::removeFile($install_env_send); + FileHandler::writeFile($path.__ZBXE_VERSION__,'1'); + } else if(!file_exists($path.__ZBXE_VERSION__)) { + $oAdminAdminModel = &getAdminModel('admin'); + $params = $oAdminAdminModel->getEnv(); + $img = sprintf('', $server.$params); + Context::addHtmlFooter($img); + + FileHandler::removeDir($path); + FileHandler::writeFile($path.__ZBXE_VERSION__,'1'); + } + } } -?> diff --git a/modules/install/install.controller.php b/modules/install/install.controller.php index 2ce37d4ad..3e8a11669 100644 --- a/modules/install/install.controller.php +++ b/modules/install/install.controller.php @@ -29,11 +29,14 @@ { global $lang; $requestVars = Context::gets('lgpl_agree', 'enviroment_gather'); - if($requestVars->lgpl_agree != 'on') + if($requestVars->lgpl_agree != 'Y') { return new Object('-1', $lang->msg_license_agreement_alert); + } $_SESSION['lgpl_agree'] = $requestVars->lgpl_agree; - $_SESSION['enviroment_gather'] = $requestVars->enviroment_gather; + if($requestVars->enviroment_gather=='Y') { + FileHandler::writeFile('./files/env/install','1'); + } $url = getNotEncodedUrl('', 'act', 'dispInstallCheckEnv'); header('location:'.$url); @@ -183,6 +186,12 @@ // Display a message that installation is completed $this->setMessage('msg_install_completed'); + if($_SESSION['enviroment_gather'] == 'Y'){ + $oAdminAdminController = &getAdminController('admin'); + $oAdminAdminController->_sendServerEnv(); + unset($_SESSION['enviroment_gather']); + } + if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) { $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl(''); header('location:'.$returnUrl); @@ -517,4 +526,3 @@ } } -?> diff --git a/modules/install/install.model.php b/modules/install/install.model.php index f03118dff..e2e72b1b3 100644 --- a/modules/install/install.model.php +++ b/modules/install/install.model.php @@ -1,8 +1,6 @@
-

- {$lang->read_all}

+

- {$lang->read_all}

{$lang->license_agreement_desc}

-

+

{$lang->intall_env_agreement_desc}

diff --git a/modules/module/module.model.php b/modules/module/module.model.php index 217b7cad8..55f4f2a66 100644 --- a/modules/module/module.model.php +++ b/modules/module/module.model.php @@ -983,7 +983,7 @@ // Create DB Object $oDB = &DB::getInstance(); // Get a list of downloaded and installed modules - $searched_list = FileHandler::readDir('./modules'); + $searched_list = FileHandler::readDir('./modules', '/^([a-zA-Z0-9_-]+)$/'); sort($searched_list); $searched_count = count($searched_list); @@ -994,6 +994,8 @@ $module_name = $searched_list[$i]; $path = ModuleHandler::getModulePath($module_name); + if(!is_dir(FileHandler::getRealPath($path))) continue; + // Get the number of xml files to create a table in schemas $tmp_files = FileHandler::readDir($path."schemas", '/(\.xml)$/'); $table_count = count($tmp_files);