<?php
/*
Plugin Name: System Overview
Plugin URI: http://markratledge.com
Description: System Overview
Version: 1
Author: Mark Ratledge
Author URI: http://markratledge.com
*/

if (!function_exists('add_action')) {
    header('Status 403 Forbidden');
    header('HTTP/1.0 403 Forbidden');
    header('HTTP/1.1 403 Forbidden');
    exit();
}
?>

<?php
if (is_admin()) {
    class wp_overview_lite
    {
        var $memory = false;
        function wpo()
        {
            return $this->__construct();
        }
        function __construct()
        {
            add_action('init', array(
                &$this,
                'wpo_limit'
            ));
            add_action('wp_dashboard_setup', array(
                &$this,
                'wpo_dashboard'
            ));
        }
        function wpo_limit()
        {
            $this->memory['wpo-limit'] = (int) ini_get('memory_limit');
        }
        function wpo_load()
        {
            $this->memory['wpo-load'] = function_exists('memory_get_usage') ? round(memory_get_usage() / 1024 / 1024, 2) : 0;
        }
        function wpo_consumption()
        {
            $this->memory['wpo-consumption'] = round($this->memory['wpo-load'] / $this->memory['wpo-limit'] * 100, 0);
        }
        function wpo_output()
        {
            $this->wpo_load();
            $this->wpo_consumption();
            $this->memory['wpo-load'] = empty($this->memory['wpo-load']) ? __('0') : $this->memory['wpo-load'] . __('M')?>

<?php
            global $wpdb, $wp_version, $wpmu_version;
            $cur_locale   = get_locale();
            $mysql_status = array();
            $mysql_vars   = array();
            foreach ($wpdb->get_results('SHOW GLOBAL STATUS') as $result) {
                $mysql_status[$result->Variable_name] = $result->Value;
            }
            foreach ($wpdb->get_results('SHOW GLOBAL VARIABLES') as $result) {
                $mysql_vars[$result->Variable_name] = $result->Value;
            }
            $uptime_days    = $mysql_status['Uptime'] / 86400;
            $uptime_hours   = ($uptime_days - (int) $uptime_days) * 24;
            $uptime_minutes = ($uptime_hours - (int) $uptime_hours) * 60;
            $uptime_seconds = ($uptime_minutes - (int) $uptime_minutes) * 60;
            $uptime_string  = (int) $uptime_days . ' days, ' . (int) $uptime_hours . ' hours, ' . (int) $uptime_minutes . ' minutes, ' . (int) $uptime_seconds . ' seconds'?>

<ul>
	<li><strong>IP</strong>:<span> 
<?php
            echo $_SERVER['SERVER_ADDR'];
?>
	</span></li>
	<li><strong>OS</strong>: <span>
<?php
            echo php_uname();
?>
	</span> </li>
	<li><strong>HTTP</strong>: <span>
<?php
            echo $_SERVER['SERVER_SOFTWARE'];
?>
	</span> <span>
<?php
            echo (PHP_INT_SIZE * 8) . __('Bit');
?>
	</span></li>
	<li><strong>PHP</strong>: <span>
<?php
            echo PHP_VERSION;
?>
	</span> Zend: <span>
<?php
            echo zend_version();
?>
	</span> Max Post:<span> 
<?php
            echo _e(ini_get('post_max_size'));
?>
	</span> Upload:<span> 
<?php
            echo _e(ini_get('upload_max_filesize'));
?>
	</span> Input:</strong> <span>
<?php
            echo ini_get('max_input_time');
?>
	s</span> Exec<span>: 
<?php
            $et = ini_get('max_execution_time');
            if ($et > 1000)
                $et /= 1000;
            echo $et;
?>
	s</span></li>
	<li><strong>MySQL </strong>: <span>
<?php
            echo $mysql_vars['version'];
?>
	</span> 
	<li><strong>Uptime</strong>: <span>
<?php
            echo $uptime_string;
?>
	</span></li>
	<li><strong>RAM</strong>: <span>
<?php
            echo WP_MEMORY_LIMIT;
?>
	</span> Usage: <span>
<?php
            echo $this->memory['wpo-consumption'] . '%' . ' ' . $this->memory['wpo-load'];
?>
	</span> of <span>
<?php
            echo $this->memory['wpo-limit'] . 'M';
?>
	</span></li>
</ul>
<?php
        }
        function wpo_dashboard()
        {
            wp_add_dashboard_widget('wp_overview_lite_dashboard_widget', 'System Overview', array(
                &$this,
                'wpo_output'
            ));
        }
    }
    
    add_action('plugins_loaded', create_function('', '$memory=new wp_overview_lite();'));
}

?>