diff --git a/addhost.php b/addhost.php index 56e35765c..975880380 100755 --- a/addhost.php +++ b/addhost.php @@ -192,7 +192,7 @@ if (!empty($argv[1])) } } -print Console_Color::convert("\n" . $config['project_name_version']." Add Host Tool +print $console_color->convert("\n" . $config['project_name_version']." Add Host Tool Usage (SNMPv1/2c): ./addhost.php <%Whostname%n> [community] [v1|v2c] [port] [" . implode("|",$config['snmp']['transports']) . "] Usage (SNMPv3) : Config Defaults : ./addhost.php <%Whostname%n> any v3 [user] [port] [" . implode("|",$config['snmp']['transports']) . "] diff --git a/html/api_v0.php b/html/api_v0.php index cc53e81b7..79c75a5e9 100644 --- a/html/api_v0.php +++ b/html/api_v0.php @@ -16,7 +16,6 @@ include_once("../includes/defaults.inc.php"); include_once("../config.php"); include_once("../includes/definitions.inc.php"); include_once("../includes/common.php"); -include_once("../includes/console_colour.php"); include_once("../includes/dbFacile.php"); include_once("../includes/rewrites.php"); include_once("includes/functions.inc.php"); diff --git a/html/graph.php b/html/graph.php index 8051e01a5..95cf00b21 100755 --- a/html/graph.php +++ b/html/graph.php @@ -54,6 +54,8 @@ include_once("includes/authenticate.inc.php"); include("includes/graphs/graph.inc.php"); +$console_color = new Console_Color2(); + $end = utime(); $run = $end - $start;; if($debug) { echo("
Runtime ".$run." secs"); diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index 2c6aeab54..a8708e7fa 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -547,7 +547,7 @@ function getlocations() $ignore_dev_location[$row['device_id']] = 1; } # We can do this because of the ORDER BY, "bool" will be handled before "string" - elseif ($row['attrib_type'] == 'override_sysLocation_string' && $ignore_dev_location[$row['device_id']] == 1) + elseif ($row['attrib_type'] == 'override_sysLocation_string' && (isset($ignore_dev_location[$row['device_id']]) && $ignore_dev_location[$row['device_id']] == 1)) { if (!in_array($row['attrib_value'],$locations)) { $locations[] = $row['attrib_value']; } } @@ -564,7 +564,7 @@ function getlocations() foreach ($rows as $row) { # Only add it as a location if it wasn't overridden (and not already there) - if ($row['location'] != '' && !$ignore_dev_location[$row['device_id']]) + if ($row['location'] != '' && !isset($ignore_dev_location[$row['device_id']])) { if (!in_array($row['location'],$locations)) { $locations[] = $row['location']; } } diff --git a/html/includes/hostbox.inc.php b/html/includes/hostbox.inc.php index 454039adf..8d3115bb6 100644 --- a/html/includes/hostbox.inc.php +++ b/html/includes/hostbox.inc.php @@ -1,6 +1,6 @@ "); } -echo("".$alert_entry['link'].""); echo("".htmlspecialchars($alert_entry['name']) . " "); diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 4c122bdc3..b7afd9e15 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -165,12 +165,12 @@ if ($_SESSION['userlevel'] >= '10') Errored ('.$ports['errored'].')'); } -if ($ports['ignored']) +if (isset($ports['ignored'])) { echo('
  • Ignored ('.$ports['ignored'].')
  • '); } @@ -254,7 +254,7 @@ if ($menu_sensors) foreach (array('fanspeed','humidity','temperature') as $item) { - if ($menu_sensors[$item]) + if (isset($menu_sensors[$item])) { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; @@ -269,7 +269,7 @@ if ($sep) foreach (array('current','frequency','power','voltage') as $item) { - if ($menu_sensors[$item]) + if (isset($menu_sensors[$item])) { echo('
  • '.nicecase($item).'
  • '); unset($menu_sensors[$item]);$sep++; @@ -306,10 +306,12 @@ if ($_SESSION['userlevel'] >= '5' && ($app_count) > "0") $app_list = dbFetchRows("SELECT `app_type` FROM `applications` GROUP BY `app_type` ORDER BY `app_type`"); foreach ($app_list as $app) { - $image = $config['html_dir']."/images/icons/".$row['app_type'].".png"; - $icon = (file_exists($image) ? $row['app_type'] : "apps"); + if (isset($row['app_type'])) { + $image = $config['html_dir']."/images/icons/".$row['app_type'].".png"; + $icon = (file_exists($image) ? $row['app_type'] : "apps"); echo(' -
  • '.nicecase($app['app_type']).'
  • '); +
  • '.nicecase($app['app_type']).'
  • '); + } } ?> diff --git a/html/index.php b/html/index.php index 353bbc7cc..db8b9807e 100755 --- a/html/index.php +++ b/html/index.php @@ -132,7 +132,7 @@ if (isset($config['branding']) && is_array($config['branding'])) } # page_title_prefix is displayed, unless page_title is set -if ($config['page_title']) { $config['page_title_prefix'] = $config['page_title']; } +if (isset($config['page_title'])) { $config['page_title_prefix'] = $config['page_title']; } ?> @@ -185,7 +185,7 @@ if ($config['favicon']) { echo(' "); print_r($_GET); @@ -284,7 +284,7 @@ if ($config['page_gen']) echo('
    Generated in ' . $gentime . ' seconds.'); } -if (is_array($pagetitle)) +if (isset($pagetitle) && is_array($pagetitle)) { # if prefix is set, put it in front if ($config['page_title_prefix']) { array_unshift($pagetitle,$config['page_title_prefix']); } diff --git a/html/pages/devices.inc.php b/html/pages/devices.inc.php index 1e7af240d..dac40ce07 100644 --- a/html/pages/devices.inc.php +++ b/html/pages/devices.inc.php @@ -17,20 +17,20 @@ if(isset($vars['state'])) } } -if ($vars['hostname']) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } -if ($vars['os']) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } -if ($vars['version']) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } -if ($vars['hardware']) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } -if ($vars['features']) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } -if ($vars['type']) { $where .= " AND type = ?"; $sql_param[] = $vars['type']; } -if ($vars['state']) { +if (isset($vars['hostname'])) { $where .= " AND hostname LIKE ?"; $sql_param[] = "%".$vars['hostname']."%"; } +if (isset($vars['os'])) { $where .= " AND os = ?"; $sql_param[] = $vars['os']; } +if (isset($vars['version'])) { $where .= " AND version = ?"; $sql_param[] = $vars['version']; } +if (isset($vars['hardware'])) { $where .= " AND hardware = ?"; $sql_param[] = $vars['hardware']; } +if (isset($vars['features'])) { $where .= " AND features = ?"; $sql_param[] = $vars['features']; } +if (isset($vars['type'])) { $where .= " AND type = ?"; $sql_param[] = $vars['type']; } +if (isset($vars['state'])) { $where .= " AND status= ?"; $sql_param[] = $state; $where .= " AND disabled='0' AND `ignore`='0'"; $sql_param[] = ''; } -if ($vars['disabled']) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } -if ($vars['ignore']) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } -if ($vars['location'] == "Unset") { $location_filter = ''; } -if ($vars['location']) { $location_filter = $vars['location']; } +if (isset($vars['disabled'])) { $where .= " AND disabled= ?"; $sql_param[] = $vars['disabled']; } +if (isset($vars['ignore'])) { $where .= " AND `ignore`= ?"; $sql_param[] = $vars['ignore']; } +if (isset($vars['location']) && $vars['location'] == "Unset") { $location_filter = ''; } +if (isset($vars['location'])) { $location_filter = $vars['location']; } $pagetitle[] = "Devices"; @@ -94,7 +94,7 @@ foreach ($menu_options as $option => $text) '')).'">Restore Search'); } else { @@ -103,7 +103,7 @@ foreach ($menu_options as $option => $text) echo(" | "); - if ($vars['bare'] == "yes") + if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Restore Header'); } else { @@ -118,7 +118,7 @@ foreach ($menu_options as $option => $text) print_optionbar_end(); print_optionbar_start(); -if($vars['searchbar'] != "hide") +if(isset($vars['searchbar']) && $vars['searchbar'] != "hide") { ?> @@ -235,7 +235,13 @@ foreach (dbFetch('SELECT `type` FROM `devices` AS D WHERE 1 GROUP BY `type` ORDE print_optionbar_end(); -$query = "SELECT * FROM `devices` WHERE 1 ".$where." ORDER BY hostname"; +$query = "SELECT * FROM `devices` WHERE 1 "; + +if (isset($where)) { + $query .= $where; +} + +$query .= " ORDER BY hostname"; list($format, $subformat) = explode("_", $vars['format']); @@ -291,7 +297,7 @@ if($format == "graph") { if (device_permitted($device['device_id'])) { - if (!$location_filter || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) + if (!isset($location_filter) || ((get_dev_attrib($device,'override_sysLocation_bool') && get_dev_attrib($device,'override_sysLocation_string') == $location_filter) || $device['location'] == $location_filter)) { $cell_click = 'onclick="location.href=\'device/device='.$device['device_id'].'/\'" style="cursor: pointer;"'; diff --git a/html/pages/ports.inc.php b/html/pages/ports.inc.php index 2bcda26c0..d82f6a7ff 100644 --- a/html/pages/ports.inc.php +++ b/html/pages/ports.inc.php @@ -63,7 +63,7 @@ echo('
    '); Update URL | '')).'">Search'); } else { @@ -72,7 +72,7 @@ echo('
    '); echo(" | "); - if ($vars['bare'] == "yes") + if (isset($vars['bare']) && $vars['bare'] == "yes") { echo('Header'); } else { @@ -84,7 +84,7 @@ echo('
    '); print_optionbar_end(); print_optionbar_start(); -if($vars['searchbar'] != "hide") +if(isset($vars['searchbar']) && $vars['searchbar'] != "hide") { ?> diff --git a/html/pages/ports/list.inc.php b/html/pages/ports/list.inc.php index 92f3c42e9..8ae9c9df3 100644 --- a/html/pages/ports/list.inc.php +++ b/html/pages/ports/list.inc.php @@ -15,7 +15,7 @@ $cols = array('device' => 'Device', foreach ($cols as $sort => $col) { - if ($vars['sort'] == $sort) + if (isset($vars['sort']) && $vars['sort'] == $sort) { echo(''.$col.' *'); } else { @@ -42,7 +42,7 @@ foreach ($ports as $port) $type = humanmedia($port['ifType']); $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']); - if ($port['in_errors'] > 0 || $port['out_errors'] > 0) + if ((isset($port['in_errors']) && $port['in_errors'] > 0) || (isset($ports['out_errors']) && $port['out_errors'] > 0)) { $error_img = generate_port_link($port,"Interface Errors",errors); } else { $error_img = ""; } diff --git a/includes/common.php b/includes/common.php index bff445574..71da214be 100644 --- a/includes/common.php +++ b/includes/common.php @@ -59,9 +59,10 @@ function isCli() function print_error($text) { + global $console_color; if (isCli()) { - print Console_Color::convert("%r".$text."%n\n", false); + print $console_color->convert("%r".$text."%n\n", false); } else { echo('
    '.$text.'
    '); } @@ -71,7 +72,7 @@ function print_message($text) { if (isCli()) { - print Console_Color::convert("%g".$text."%n\n", false); + print Console_Color2::convert("%g".$text."%n\n", false); } else { echo('
    '.$text.'
    '); } diff --git a/includes/console_colour.php b/includes/console_colour.php index 5dea189ff..c71173937 100644 --- a/includes/console_colour.php +++ b/includes/console_colour.php @@ -2,75 +2,41 @@ /** * Color.php * - * PHP version 4 - * + * PHP version 5 + * * Copyright (c) 2007 Stefan Walk * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to - * deal in the Software without restriction, including without limitation the - * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or - * sell copies of the Software, and to permit persons to whom the Software is + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to + * deal in the Software without restriction, including without limitation the + * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or + * sell copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * - * The above copyright notice and this permission notice shall be included in + * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING - * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. * * @category Console - * @package Console_Color + * @package Console_Color2 * @author Stefan Walk * @license http://www.opensource.org/licenses/mit-license.php MIT License - * @link http://pear.php.net/package/Console_Color + * @link http://pear.php.net/package/Console_Color2 */ -$GLOBALS['_CONSOLE_COLOR_CODES'] = array ( - 'color' => array( - 'black' => 30, - 'red' => 31, - 'green' => 32, - 'brown' => 33, - 'blue' => 34, - 'purple' => 35, - 'cyan' => 36, - 'grey' => 37, - 'yellow' => 33 - ), - 'style' => array( - 'normal' => 0, - 'bold' => 1, - 'light' => 1, - 'underscore' => 4, - 'underline' => 4, - 'blink' => 5, - 'inverse' => 6, - 'hidden' => 8, - 'concealed' => 8 - ), - 'background' => array( - 'black' => 40, - 'red' => 41, - 'green' => 42, - 'brown' => 43, - 'yellow' => 43, - 'blue' => 44, - 'purple' => 45, - 'cyan' => 46, - 'grey' => 47 - ) -); + /** * A simple class to use ANSI Colorcodes. * - * Of all the functions, you probably only want to use convert() and escape(). + * Of all the functions, you probably only want to use convert() and escape(). * They are easier to use. However, if you want to access colorcodes more * directly, look into the other functions. * @@ -80,34 +46,84 @@ $GLOBALS['_CONSOLE_COLOR_CODES'] = array ( * @license http://www.opensource.org/licenses/mit-license.php MIT License * @link http://pear.php.net/package/Console_Color */ -class Console_Color +class Console_Color2 { + protected $color_codes; + + public function __construct() { + $this->setColorCodes(array( + 'color' => array( + 'black' => 30, + 'red' => 31, + 'green' => 32, + 'brown' => 33, + 'blue' => 34, + 'purple' => 35, + 'cyan' => 36, + 'grey' => 37, + 'yellow' => 33 + ), + 'style' => array( + 'normal' => 0, + 'bold' => 1, + 'light' => 1, + 'underscore' => 4, + 'underline' => 4, + 'blink' => 5, + 'inverse' => 6, + 'hidden' => 8, + 'concealed' => 8 + ), + 'background' => array( + 'black' => 40, + 'red' => 41, + 'green' => 42, + 'brown' => 43, + 'yellow' => 43, + 'blue' => 44, + 'purple' => 45, + 'cyan' => 46, + 'grey' => 47 + ) + ) + ); + } + + public function setColorCodes($color_codes) + { + $this->color_codes = $color_codes; + } + + public function getColorCodes() + { + return $this->color_codes; + } + /** * Returns an ANSI-Controlcode - * + * * Takes 1 to 3 Arguments: either 1 to 3 strings containing the name of the * FG Color, style and BG color, or one array with the indices color, style * or background. * * @param mixed $color Optional. * Either a string with the name of the foreground - * color, or an array with the indices 'color', + * color, or an array with the indices 'color', * 'style', 'background' and corresponding names as * values. * @param string $style Optional name of the style * @param string $background Optional name of the background color * - * @access public * @return string */ - function color($color = null, $style = null, $background = null) // {{{ + public function color($color = null, $style = null, $background = null) // {{{ { - $colors = &$GLOBALS['_CONSOLE_COLOR_CODES']; + $colors = $this->getColorCodes(); if (is_array($color)) { - $style = @$color['style']; - $background = @$color['background']; - $color = @$color['color']; + $style = isset($color['style']) ? $color['style'] : null; + $background = isset($color['background']) ? $color['background'] : null; + $color = isset($color['color']) ? $color['color'] : null; } if ($color == 'reset') { @@ -115,14 +131,14 @@ class Console_Color } $code = array(); - if (isset($color)) { - $code[] = $colors['color'][$color]; - } - if (isset($style)) { $code[] = $colors['style'][$style]; } + if (isset($color)) { + $code[] = $colors['color'][$color]; + } + if (isset($background)) { $code[] = $colors['background'][$background]; } @@ -140,40 +156,25 @@ class Console_Color * * @param string $name Name of controlcode * - * @access public * @return string */ - function fgcolor($name) + public function fgcolor($name) { - $colors = &$GLOBALS['_CONSOLE_COLOR_CODES']; + $colors = $this->getColorCodes(); + return "\033[".$colors['color'][$name].'m'; } - + /** * Returns a style controlcode * * @param string $name Name of controlcode * - * @access public - * @return string - */ - function style($name) - { - $colors = &$GLOBALS['_CONSOLE_COLOR_CODES']; - return "\033[".$colors['style'][$name].'m'; - } - - /** - * Returns a BG color controlcode - * - * @param string $name Name of controlcode - * - * @access public * @return string */ function bgcolor($name) { - $colors = &$GLOBALS['_CONSOLE_COLOR_CODES']; + $colors = $this->getColorCodes(); return "\033[".$colors['background'][$name].'m'; } @@ -181,7 +182,7 @@ class Console_Color * Converts colorcodes in the format %y (for yellow) into ansi-control * codes. The conversion table is: ('bold' meaning 'light' on some * terminals). It's almost the same conversion table irssi uses. - *
    +     * 
     
          *                  text      text            background
          *      ------------------------------------------------
          *      %k %K %0    black     dark grey       black
    @@ -209,23 +210,22 @@ class Console_Color
          * @param string $string  String to convert
          * @param bool   $colored Should the string be colored?
          *
    -     * @access public
          * @return string
          */
    -    function convert($string, $colored = true)
    +    public function convert($string, $colored = true)
         {
             static $conversions = array ( // static so the array doesn't get built
                                           // everytime
                 // %y - yellow, and so on... {{{
    -            '%y' => array('color' => 'yellow'),
    -            '%g' => array('color' => 'green' ),
    -            '%b' => array('color' => 'blue'  ),
    -            '%r' => array('color' => 'red'   ),
    -            '%p' => array('color' => 'purple'),
    -            '%m' => array('color' => 'purple'),
    -            '%c' => array('color' => 'cyan'  ),
    -            '%w' => array('color' => 'grey'  ),
    -            '%k' => array('color' => 'black' ),
    +            '%y' => array('color' => 'yellow',  'style' => 'normal'),
    +            '%g' => array('color' => 'green',   'style' => 'normal'),
    +            '%b' => array('color' => 'blue',    'style' => 'normal'),
    +            '%r' => array('color' => 'red',     'style' => 'normal'),
    +            '%p' => array('color' => 'purple',  'style' => 'normal'),
    +            '%m' => array('color' => 'purple',  'style' => 'normal'),
    +            '%c' => array('color' => 'cyan',    'style' => 'normal'),
    +            '%w' => array('color' => 'grey',    'style' => 'normal'),
    +            '%k' => array('color' => 'black',   'style' => 'normal'),
                 '%n' => array('color' => 'reset' ),
                 '%Y' => array('color' => 'yellow',  'style' => 'light'),
                 '%G' => array('color' => 'green',   'style' => 'light'),
    @@ -257,7 +257,7 @@ class Console_Color
             if ($colored) {
                 $string = str_replace('%%', '% ', $string);
                 foreach ($conversions as $key => $value) {
    -                $string = str_replace($key, Console_Color::color($value),
    +                $string = str_replace($key, $this->color($value),
                               $string);
                 }
                 $string = str_replace('% ', '%', $string);
    @@ -271,13 +271,12 @@ class Console_Color
     
         /**
          * Escapes % so they don't get interpreted as color codes
    -     *
    +     * 
          * @param string $string String to escape
          *
    -     * @access public
          * @return string
          */
    -    function escape($string)
    +    public function escape($string) 
         {
             return str_replace('%', '%%', $string);
         }
    @@ -290,10 +289,9 @@ class Console_Color
          * @acess public
          * @return string
          */
    -    function strip($string)
    +    public function strip($string) 
         {
             return preg_replace('/\033\[[\d;]+m/', '', $string);
         }
     
     }
    -?>
    diff --git a/includes/dbFacile.php b/includes/dbFacile.php
    index 42810dcef..9d25c4cad 100644
    --- a/includes/dbFacile.php
    +++ b/includes/dbFacile.php
    @@ -22,16 +22,15 @@ Usage
      * Used by the other _query functions.
      * */
     function dbQuery($sql, $parameters = array()) {
    -	global $fullSql, $debug, $sql_debug;
    +	global $fullSql, $debug, $sql_debug, $console_color;
     	$fullSql = dbMakeQuery($sql, $parameters);
             if($debug) { 
               if(php_sapi_name() == 'cli' && empty($_SERVER['REMOTE_ADDR'])) {
    -            print Console_Color::convert("\nSQL[%y".$fullSql."%n] ");
    +            print $console_color->convert("\nSQL[%y".$fullSql."%n] ");
               } else {
                 $sql_debug[] = $fullSql;
               }
    -          #echo("\nSQL[".$fullSql."] "); 
    -        }
    +	}
     
     	/*
     	if($this->logFile)
    diff --git a/includes/functions.php b/includes/functions.php
    index c2a8eedd4..161757107 100755
    --- a/includes/functions.php
    +++ b/includes/functions.php
    @@ -30,6 +30,8 @@ include_once($config['install_dir'] . "/includes/services.inc.php");
     include_once($config['install_dir'] . "/includes/dbFacile.php");
     include_once($config['install_dir'] . "/includes/console_colour.php");
     
    +$console_color = new Console_Color2();
    +
     if ($config['alerts']['email']['enable'])
     {
       include_once($config['install_dir'] . "/includes/phpmailer/class.phpmailer.php");
    @@ -161,7 +163,7 @@ function getImage($device)
       {
         $image = '';
       }
    -  elseif ($config['os'][$device['os']]['icon'] && file_exists($config['html_dir'] . "/images/os/" . $config['os'][$device['os']]['icon'] . ".png"))
    +  elseif (isset($config['os'][$device['os']]['icon']) && $config['os'][$device['os']]['icon'] && file_exists($config['html_dir'] . "/images/os/" . $config['os'][$device['os']]['icon'] . ".png"))
       {
         $image = '';
       } else {
    diff --git a/includes/rrdtool.inc.php b/includes/rrdtool.inc.php
    index c8f197ee0..3b23be7e9 100644
    --- a/includes/rrdtool.inc.php
    +++ b/includes/rrdtool.inc.php
    @@ -148,7 +148,7 @@ function rrdtool_graph($graph_file, $options)
     
     function rrdtool($command, $filename, $options)
     {
    -  global $config, $debug, $rrd_pipes;
    +  global $config, $debug, $rrd_pipes, $console_color;
     
       $cmd = "$command $filename $options";
       if ($command != "create" && $config['rrdcached'])
    @@ -158,7 +158,7 @@ function rrdtool($command, $filename, $options)
     
       if ($config['norrd'])
       {
    -    print Console_Color::convert("[%rRRD Disabled%n]");
    +    print $console_color->convert("[%rRRD Disabled%n]");
       } else {
         fwrite($rrd_pipes[0], $cmd."\n");
       }
    @@ -166,7 +166,7 @@ function rrdtool($command, $filename, $options)
       {
         echo stream_get_contents($rrd_pipes[1]);
         echo stream_get_contents($rrd_pipes[2]);
    -    print Console_Color::convert("RRD[%g".$cmd."%n] ");
    +    print $console_color->convert("RRD[%g".$cmd."%n] ");
       } else {
         $tmp  = stream_get_contents($rrd_pipes[1]).stream_get_contents($rrd_pipes[2]);
       }
    @@ -182,15 +182,15 @@ function rrdtool($command, $filename, $options)
     
     function rrdtool_create($filename, $options)
     {
    -  global $config, $debug;
    +  global $config, $debug, $console_color;
     
       if ($config['norrd'])
       {
    -    print Console_Color::convert("[%gRRD Disabled%n] ", false);
    +    print $console_color->convert("[%gRRD Disabled%n] ", false);
       } else {
         $command = $config['rrdtool'] . " create $filename $options";
       }
    -  if ($debug) { print Console_Color::convert("RRD[%g".$command."%n] "); }
    +  if ($debug) { print $console_color->convert("RRD[%g".$command."%n] "); }
     
       return shell_exec($command);
     }
    diff --git a/scripts/console-ui.php b/scripts/console-ui.php
    index d4325745a..566b94dd4 100755
    --- a/scripts/console-ui.php
    +++ b/scripts/console-ui.php
    @@ -9,6 +9,8 @@ include_once("../includes/definitions.inc.php");
     include("../includes/functions.php");
     include("../html/includes/functions.inc.php");
     
    +$console_color = new Console_Color2();
    +
     $long_opts = array('list::','device-stats');
     $options = getopt("l:d:",$long_opts);
     
    @@ -36,9 +38,9 @@ while($end == 0)
       // Include the required SQL queries to get our data
       require('../includes/db/status_count.inc.php');
     
    -  $tbl->addRow(array('Devices ('.$devices['count'].')',Console_Color::convert("%g".$devices['up']." Up%n"),Console_Color::convert("%r".$devices['down']." Down%n"),Console_Color::convert("%y".$devices['ignored']." Ignored%n"),Console_Color::convert("%p".$devices['disabled']." Disabled%n")));
    -  $tbl->addRow(array('Ports ('.$ports['count'].')',Console_Color::convert("%g".$ports['up']." Up%n"),Console_Color::convert("%r".$ports['down']." Down%n"),Console_Color::convert("%y".$ports['ignored']." Ignored%n"),Console_Color::convert("%p".$ports['shutdown']." Shutdown%n")));
    -  $tbl->addRow(array('Services ('.$services['count'].')',Console_Color::convert("%g".$services['up']." Up%n"),Console_Color::convert("%r".$services['down']." Down%n"),Console_Color::convert("%y".$services['ignored']." Ignored%n"),Console_Color::convert("%p".$services['disabled']." Shutdown%n")));
    +  $tbl->addRow(array('Devices ('.$devices['count'].')',print $console_color->convert("%g".$devices['up']." Up%n"),print $console_color->convert("%r".$devices['down']." Down%n"),print $console_color->convert("%y".$devices['ignored']." Ignored%n"),print $console_color->convert("%p".$devices['disabled']." Disabled%n")));
    +  $tbl->addRow(array('Ports ('.$ports['count'].')',print $console_color->convert("%g".$ports['up']." Up%n"),print $console_color->convert("%r".$ports['down']." Down%n"),print $console_color->convert("%y".$ports['ignored']." Ignored%n"),print $console_color->convert("%p".$ports['shutdown']." Shutdown%n")));
    +  $tbl->addRow(array('Services ('.$services['count'].')',print $console_color->convert("%g".$services['up']." Up%n"),print $console_color->convert("%r".$services['down']." Down%n"),print $console_color->convert("%y".$services['ignored']." Ignored%n"),print $console_color->convert("%p".$services['disabled']." Shutdown%n")));
     
       echo $tbl->getTable();
     
    @@ -129,7 +131,7 @@ while($end == 0)
     ");
       exit;
       }
    -  echo(Console_Color::convert("%rLast update at ". date("Y-m-d h:i:s")."%n\n\n"));
    +  echo(print $console_color->convert("%rLast update at ". date("Y-m-d h:i:s")."%n\n\n"));
       sleep(5);
     }