Adding system status to settings view

skala
Julio Montoya 16 years ago
parent 5f86b61d3b
commit d90a1a8111
  1. 14
      main/admin/index.php
  2. 8
      main/admin/system_status.php
  3. 45
      main/inc/lib/diagnoser.lib.php

@ -1,10 +1,10 @@
<?php // $Id: index.php 22269 2009-07-21 15:06:15Z juliomontoya $
/* For licensing terms, see /dokeos_license.txt */
/* For licensing terms, see /license.txt */
/**
==============================================================================
* Index of the admin tools
*
* @package dokeos.admin
* @package chamilo.admin
==============================================================================
*/
// name of the language file that needs to be included <br />
@ -14,8 +14,8 @@ $language_file=array('admin','tracking');
$cidReset=true;
// including some necessary chamilo files
require('../inc/global.inc.php');
require_once(api_get_path(LIBRARY_PATH).'security.lib.php');
require_once '../inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'security.lib.php';
// setting the section (for the tabs)
$this_section=SECTION_PLATFORM_ADMIN;
@ -34,8 +34,7 @@ $tool_name=get_lang('PlatformAdmin');
Display::display_header($nameTools);
if(api_is_platform_admin())
{
if(api_is_platform_admin()) {
if(is_dir(api_get_path(SYS_CODE_PATH).'install/') && is_readable(api_get_path(SYS_CODE_PATH).'install/index.php'))
{
Display::display_normal_message(get_lang('InstallDirAccessibleSecurityThreat'));
@ -176,6 +175,9 @@ if(api_is_platform_admin()) {
if (api_get_setting('allow_terms_conditions')=='true') {
echo '<li><a href="legal_add.php">'.get_lang('TermsAndConditions').'</a></li>';
}
echo '<li><a href="system_status.php">'.get_lang('SystemStatus').'</a></li>';
?>
</ul>

@ -11,7 +11,12 @@ $cidReset = true;
require_once '../inc/global.inc.php';
$this_section = SECTION_PLATFORM_ADMIN;
require_once api_get_path(LIBRARY_PATH).'diagnoser.lib.php';
// User permissions
api_protect_admin_script();
$interbreadcrumb[] = array ('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
Display :: display_header(get_lang('SystemStatus'));
/* @todo this will be moved to default.css */
?>
<style>
@ -58,8 +63,7 @@ Display :: display_header(get_lang('SystemStatus'));
color: #4171b5;
}
.tabbed-pane-tabs li a:active,.tabbed-pane-tabs li a.current,.tabbed-pane-tabs li a.current:hover
{
.tabbed-pane-tabs li a:active,.tabbed-pane-tabs li a.current,.tabbed-pane-tabs li a.current:hover {
color: black;
}

@ -1,21 +1,17 @@
<?php
/* For licensing terms, see /license.txt */
/**
* $Id: diagnoser.class.php 128 2009-11-09 13:13:20Z vanpouckesven $
*
* @package chamilo.diagnoser
* @author spou595
* @author Julio Montoya <gugli100@gmail.com> port to chamilo 1.8.7
*
* Class that is responsible for generating diagnostic information about the system
*/
//require_once dirname(__FILE__) . '/diagnoser_cellrenderer.class.php';
class Diagnoser
{
/**
* The manager where this diagnoser runs on
*/
private $manager;
/**
* The status's
*/
@ -24,13 +20,11 @@ class Diagnoser
const STATUS_ERROR = 3;
const STATUS_INFORMATION = 4;
function Diagnoser($manager = null)
{
$this->manager = $manager;
function __construct() {
}
function show_html()
{
function show_html() {
$sections = array('chamilo', 'php', 'mysql', 'webserver');
if (!in_array($_GET['section'], $sections)) {
@ -73,8 +67,7 @@ class Diagnoser
* Functions to get the data for the chamilo diagnostics
* @return array of data
*/
function get_chamilo_data()
{
function get_chamilo_data() {
$array = array();
$writable_folders = array('archive', 'courses', 'home', 'main/upload/users/','main/default_course_document/images/');
foreach ($writable_folders as $index => $folder) {
@ -95,13 +88,11 @@ class Diagnoser
* Functions to get the data for the php diagnostics
* @return array of data
*/
function get_php_data()
{
function get_php_data() {
$array = array();
// General Functions
$version = phpversion();
$status = $version > '5.2' ? self :: STATUS_OK : self :: STATUS_ERROR;
$array[] = $this->build_setting($status, '[PHP]', 'phpversion()', 'http://www.php.net/manual/en/function.phpversion.php', phpversion(), '>= 5.2', null, get_lang('PHPVersionInfo'));
@ -206,12 +197,11 @@ class Diagnoser
//Extensions
$extensions = array('gd' => 'http://www.php.net/gd', 'mysql' => 'http://www.php.net/mysql', 'pcre' => 'http://www.php.net/pcre', 'session' => 'http://www.php.net/session', 'standard' => 'http://www.php.net/spl', 'zlib' => 'http://www.php.net/zlib', 'xsl' => 'http://be2.php.net/xsl');
foreach ($extensions as $extension => $url)
{
foreach ($extensions as $extension => $url) {
$loaded = extension_loaded($extension);
$status = $loaded ? self :: STATUS_OK : self :: STATUS_ERROR;
$array[] = $this->build_setting($status, '[EXTENSION]', get_lang('ExtensionLoaded') . ': ' . $extension, $url, $loaded, 1, 'yes_no', get_lang('ExtensionMustBeLoaded'));
}
}
return $array;
}
@ -220,8 +210,7 @@ class Diagnoser
* Functions to get the data for the mysql diagnostics
* @return array of data
*/
function get_mysql_data()
{
function get_mysql_data() {
$array = array();
$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[MySQL]', 'mysql_get_host_info()', 'http://www.php.net/manual/en/function.mysql-get-host-info.php', mysql_get_host_info(), null, null, get_lang('MysqlHostInfo'));
@ -237,8 +226,7 @@ class Diagnoser
* Functions to get the data for the webserver diagnostics
* @return array of data
*/
function get_webserver_data()
{
function get_webserver_data() {
$array = array();
$array[] = $this->build_setting(self :: STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_ADDR"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_ADDR"], null, null, get_lang('ServerIPInfo'));
@ -267,8 +255,7 @@ class Diagnoser
function build_setting($status, $section, $title, $url, $current_value, $expected_value, $formatter, $comment, $img_path = null)
{
switch ($status)
{
switch ($status) {
case self :: STATUS_OK :
$img = 'bullet_green.gif';
break;
@ -293,10 +280,8 @@ class Diagnoser
$formatted_current_value = $current_value;
$formatted_expected_value = $expected_value;
if ($formatter)
{
if (method_exists($this, 'format_' . $formatter))
{
if ($formatter) {
if (method_exists($this, 'format_' . $formatter)) {
$formatted_current_value = call_user_func(array($this, 'format_' . $formatter), $current_value);
$formatted_expected_value = call_user_func(array($this, 'format_' . $formatter), $expected_value);
}

Loading…
Cancel
Save