[ Index ]
 

Code source de vtiger CRM 5.0.2

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/modules/System/ -> systemconfig.php (source)

   1  <?php 
   2  // phpSysInfo - A PHP System Information Script
   3  // http://phpsysinfo.sourceforge.net/
   4  // This program is free software; you can redistribute it and/or
   5  // modify it under the terms of the GNU General Public License
   6  // as published by the Free Software Foundation; either version 2
   7  // of the License, or (at your option) any later version.
   8  // This program is distributed in the hope that it will be useful,
   9  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11  // GNU General Public License for more details.
  12  // You should have received a copy of the GNU General Public License
  13  // along with this program; if not, write to the Free Software
  14  // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  15  // $Id: index.php,v 1.113 2006/04/17 15:24:46 bigmichi1 Exp $
  16  // phpsysinfo release version number
  17  $VERSION = "2.5.2_rc2";
  18  $startTime = array_sum( explode( " ", microtime() ) );
  19  
  20  
  21  define('IN_PHPSYSINFO', true);
  22  
  23  ini_set('magic_quotes_runtime', 'off');
  24  ini_set('register_globals', 'off');
  25  // ini_set('display_errors','on');
  26  define('APP_ROOT', getcwd().'/modules/System');
  27  require_once (APP_ROOT . '/includes/class.error.inc.php');
  28  $error = new Error;
  29  
  30  // Figure out which OS where running on, and detect support
  31  if ( file_exists( APP_ROOT . '/includes/os/class.' . PHP_OS . '.inc.php' ) ) {
  32  } else {
  33    $error->addError('include(class.' . PHP_OS . '.php.inc)' , PHP_OS . ' is not currently supported', __LINE__, __FILE__ );
  34  }
  35  
  36  if (!extension_loaded('xml')) {
  37    $error->addError('extension_loaded(xml)', 'phpsysinfo requires the xml module for php to work', __LINE__, __FILE__);
  38  } 
  39  if (!extension_loaded('pcre')) {
  40    $error->addError('extension_loaded(pcre)', 'phpsysinfo requires the pcre module for php to work', __LINE__, __FILE__);
  41  } 
  42  
  43  if (!file_exists(APP_ROOT . '/config.php')) {
  44    $error->addError('file_exists(config.php)', 'config.php does not exist in the phpsysinfo directory.', __LINE__, __FILE__);
  45  } else { 
  46    require_once (APP_ROOT . '/config.php');             // get the config file
  47  }
  48  
  49  if ( !empty( $sensor_program ) ) {
  50    $sensor_program = basename( $sensor_program );
  51    if( !file_exists( APP_ROOT . '/includes/mb/class.' . $sensor_program . '.inc.php' ) ) {
  52      $error->addError('include(class.' . htmlspecialchars($sensor_program, ENT_QUOTES) . '.inc.php)', 'specified sensor programm is not supported', __LINE__, __FILE__ );
  53    } 
  54  } 
  55  
  56  if ( !empty( $hddtemp_avail ) && $hddtemp_avail != "tcp" && $hddtemp_avail != "suid" ) {
  57    $error->addError('include(class.hddtemp.inc.php)', 'bad configuration in config.php for $hddtemp_avail', __LINE__, __FILE__ );
  58  }
  59  
  60  if( $error->ErrorsExist() ) {
  61    echo $error->ErrorsAsHTML();
  62    exit;
  63  }
  64  
  65  require_once (APP_ROOT . '/includes/common_functions.php');     // Set of common functions used through out the app
  66  
  67  // commented for security
  68  // Check to see if where running inside of phpGroupWare
  69  //if (file_exists("../header.inc.php") && isset($_REQUEST['sessionid']) && $_REQUEST['sessionid'] && $_REQUEST['kp3'] && $_REQUEST['domain']) {
  70  //  define('PHPGROUPWARE', 1);
  71  //  $phpgw_info['flags'] = array('currentapp' => 'phpsysinfo-dev');
  72  //  include('../header.inc.php');
  73  //} else {
  74  //  define('PHPGROUPWARE', 0);
  75  //}
  76  
  77  // DEFINE TEMPLATE_SET
  78  if (isset($_POST['template'])) {
  79    $template = $_POST['template'];
  80  } elseif (isset($_GET['template'])) {
  81    $template = $_GET['template'];
  82  } elseif (isset($_COOKIE['template'])) {
  83    $template = $_COOKIE['template'];
  84  } else {
  85    $template = $default_template; 
  86  }
  87  
  88  // check to see if we have a random
  89  if ($template == 'random') {
  90    $buf = gdc( APP_ROOT . "/templates/" );
  91    $template = $buf[array_rand($buf, 1)];
  92  }
  93  
  94  if ($template != 'xml' && $template != 'wml') {
  95    // figure out if the template exists
  96   $template = basename(APP_ROOT .'/templates/' . $template);
  97    if (!file_exists(APP_ROOT . "/templates/" . $template)) {
  98      // use default if not exists.
  99      $template = $default_template;
 100    }
 101    // Store the current template name in a cookie, set expire date to 30 days later
 102    // if template is xml then skip
 103    @setcookie("template", $template, (time() + 60 * 60 * 24 * 30));
 104    $_COOKIE['template'] = $template; //update COOKIE Var
 105  }
 106  
 107  // get our current language
 108  // default to english, but this is negotiable.
 109  if ($template == "wml") {
 110    $lng = "en";
 111  } elseif (isset($_POST['lng'])) {
 112    $lng = $_POST['lng'];
 113  } elseif (isset($_GET['lng'])) {
 114    $lng = $_GET['lng'];
 115  } elseif (isset($_COOKIE['lng'])) {
 116    $lng = $_COOKIE['lng'];
 117  } else {
 118    $lng = $default_lng;
 119  } 
 120  
 121  if ($lng == 'browser') {
 122    // see if the browser knows the right languange.
 123    if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
 124      $plng = split(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
 125      if (count($plng) > 0) {
 126        while (list($k, $v) = each($plng)) {
 127          $k = split(';', $v, 1);
 128          $k = split('-', $k[0]);
 129          if (file_exists(APP_ROOT . '/includes/lang/' . $k[0] . '.php')) {
 130            $lng = $k[0];
 131            break;
 132          }
 133        }
 134      }
 135    }
 136  }
 137  
 138  $lng = basename($lng);
 139  if (file_exists(APP_ROOT . '/includes/lang/' . $lng . '.php')) {
 140    $charset = 'iso-8859-1';
 141    require_once(APP_ROOT . '/includes/lang/' . $lng . '.php'); // get our language include
 142    // Store the current language selection in a cookie, set expire date to 30 days later
 143   @setcookie("lng", $lng, (time() + 60 * 60 * 24 * 30));
 144    $_COOKIE['lng'] = $lng; //update COOKIE Var
 145  } else {
 146    $error->addError('include(' . $lng . ')', 'we do not support this language', __LINE__, __FILE__ );
 147    $lng = $default_lng;
 148  }
 149  
 150  // include the files and create the instances
 151  define('TEMPLATE_SET', $template);
 152  require_once( APP_ROOT . '/includes/os/class.' . PHP_OS . '.inc.php' );
 153  $sysinfo = new sysinfo;
 154  if( !empty( $sensor_program ) ) {
 155    require_once(APP_ROOT . '/includes/mb/class.' . $sensor_program . '.inc.php');
 156    $mbinfo = new mbinfo;
 157  }
 158  if ( !empty($hddtemp_avail ) ) {
 159    require_once(APP_ROOT . '/includes/mb/class.hddtemp.inc.php');
 160  }
 161  
 162  require_once (APP_ROOT . '/includes/xml/vitals.php');
 163  require_once (APP_ROOT . '/includes/xml/network.php');
 164  require_once (APP_ROOT . '/includes/xml/hardware.php');
 165  require_once (APP_ROOT . '/includes/xml/memory.php');
 166  require_once (APP_ROOT . '/includes/xml/filesystems.php');
 167  require_once (APP_ROOT . '/includes/xml/mbinfo.php');
 168  require_once (APP_ROOT . '/includes/xml/hddtemp.php');
 169  
 170  // build the xml
 171  $xml = "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n";
 172  $xml .= "<!DOCTYPE phpsysinfo SYSTEM \"phpsysinfo.dtd\">\n\n";
 173  $xml .= created_by();
 174  $xml .= "<phpsysinfo>\n";
 175  $xml .= "  <Generation version=\"$VERSION\" timestamp=\"" . time() . "\"/>\n";
 176  $xml .= xml_vitals();
 177  $xml .= xml_network();
 178  $xml .= xml_hardware($hddtemp_devices);
 179  $xml .= xml_memory();
 180  $xml .= xml_filesystems();
 181  if ( !empty( $sensor_program ) ) {
 182    $xml .= xml_mbtemp();
 183    $xml .= xml_mbfans();
 184    $xml .= xml_mbvoltage();
 185  };
 186  if ( !empty($hddtemp_avail ) ) {
 187    $hddtemp = new hddtemp($hddtemp_devices);
 188    $xml .= xml_hddtemp($hddtemp);
 189  }
 190  $xml .= "</phpsysinfo>";
 191  replace_specialchars($xml);
 192  
 193  // output
 194  if (TEMPLATE_SET == 'xml') {
 195    // just printout the XML and exit
 196    header("Content-Type: text/xml\n\n");
 197    print $xml;
 198  } elseif (TEMPLATE_SET == 'wml') {
 199    require_once (APP_ROOT . '/includes/XPath.class.php');
 200    $XPath = new XPath();
 201    $XPath->importFromString($xml); 
 202  
 203    header("Content-type: text/vnd.wap.wml; charset=iso-8859-1");
 204    header("");
 205    header("Cache-Control: no-cache, must-revalidate");
 206    header("Pragma: no-cache");
 207  
 208    echo "<?xml version='1.0' encoding='iso-8859-1'?>\n";
 209    echo "<!DOCTYPE wml PUBLIC \"-//WAPFORUM//DTD WML 1.1//EN\" \"http://www.wapforum.org/DTD/wml_1.1.xml\" >\n";
 210    echo "<wml>\n";
 211    echo "<card id=\"start\" title=\"phpSysInfo - Menu\">\n";
 212    echo "<p><a href=\"#vitals\">" . $text['vitals'] . "</a></p>\n";
 213    echo "<p><a href=\"#network\">" . $text['netusage'] . "</a></p>\n";
 214    echo "<p><a href=\"#memory\">" . $text['memusage'] . "</a></p>\n";
 215    echo "<p><a href=\"#filesystem\">" . $text['fs'] . "</a></p>\n";
 216    if (!empty($sensor_program) || (isset($hddtemp_avail) && $hddtemp_avail)) {
 217      echo "<p><a href=\"#temp\">" . $text['temperature'] . "</a></p>\n";
 218    }
 219    if (!empty($sensor_program)) {
 220      echo "<p><a href=\"#fans\">" . $text['fans'] . "</a></p>\n";
 221      echo "<p><a href=\"#volt\">" . $text['voltage'] . "</a></p>\n";
 222    }
 223    echo "</card>\n";
 224    echo wml_vitals();
 225    echo wml_network();
 226    echo wml_memory();
 227    echo wml_filesystem();
 228    
 229    $temp = "";
 230    if (!empty($sensor_program)) {
 231      echo wml_mbfans();
 232      echo wml_mbvoltage();
 233      $temp .= wml_mbtemp();
 234    }
 235    if (isset($hddtemp_avail) && $hddtemp_avail)
 236      if ($XPath->match("/phpsysinfo/HDDTemp/Item"))
 237        $temp .= wml_hddtemp();
 238    if(strlen($temp) > 0)
 239      echo "<card id=\"temp\" title=\"" . $text['temperature'] . "\">" . $temp . "</card>";
 240    echo "</wml>\n";
 241  
 242  } else {
 243    $image_height = get_gif_image_height(APP_ROOT . '/templates/' . TEMPLATE_SET . '/images/bar_middle.gif');
 244    define('BAR_HEIGHT', $image_height);
 245  
 246  //  if (PHPGROUPWARE != 1) {
 247      require_once (APP_ROOT . '/includes/class.Template.inc.php'); // template library
 248  //  } 
 249    // fire up the template engine
 250    $tpl = new Template(APP_ROOT . '/templates/' . TEMPLATE_SET);
 251    $tpl->set_file(array('form' => 'form.tpl')); 
 252    // print out a box of information
 253    function makebox ($title, $content)
 254    {
 255      if (empty($content)) {
 256        return "";
 257      } else {
 258        global $webpath;
 259        $textdir = direction();
 260        $t = new Template(APP_ROOT . '/templates/' . TEMPLATE_SET);
 261        $t->set_file(array('box' => 'box.tpl'));
 262        $t->set_var('title', $title);
 263        $t->set_var('content', $content);
 264        $t->set_var('webpath', $webpath);
 265        $t->set_var('text_dir', $textdir['direction']);
 266        return $t->parse('out', 'box');
 267      } 
 268    } 
 269    // Fire off the XPath class
 270    require_once (APP_ROOT . '/includes/XPath.class.php');
 271    $XPath = new XPath();
 272    $XPath->importFromString($xml); 
 273    // let the page begin.
 274    require_once (APP_ROOT . '/includes/system_header.php');
 275  
 276    if ( $error->ErrorsExist() && isset($showerrors) && $showerrors ) {
 277      $tpl->set_var('errors', makebox("ERRORS", $error->ErrorsAsHTML() ));
 278    }
 279  
 280    $tpl->set_var('title', $text['title'] . ': ' . $XPath->getData('/phpsysinfo/Vitals/Hostname') . ' (' . $XPath->getData('/phpsysinfo/Vitals/IPAddr') . ')');
 281    $tpl->set_var('vitals', makebox($text['vitals'], html_vitals()));
 282    $tpl->set_var('network', makebox($text['netusage'], html_network()));
 283    $tpl->set_var('hardware', makebox($text['hardware'], html_hardware()));
 284    $tpl->set_var('memory', makebox($text['memusage'], html_memory()));
 285    $tpl->set_var('filesystems', makebox($text['fs'], html_filesystems()));
 286    // Timo van Roermund: change the condition for showing the temperature, voltage and fans section
 287    $html_temp = "";
 288    if (!empty($sensor_program)) {
 289      if ($XPath->match("/phpsysinfo/MBinfo/Temperature/Item")) {
 290        $html_temp = html_mbtemp();
 291      }
 292      if ($XPath->match("/phpsysinfo/MBinfo/Fans/Item")) {
 293        $tpl->set_var('mbfans', makebox($text['fans'], html_mbfans()));
 294      } else {
 295        $tpl->set_var('mbfans', '');
 296      };
 297      if ($XPath->match("/phpsysinfo/MBinfo/Voltage/Item")) {
 298        $tpl->set_var('mbvoltage', makebox($text['voltage'], html_mbvoltage()));
 299      } else {
 300        $tpl->set_var('mbvoltage', '');
 301      };
 302    }
 303    if (isset($hddtemp_avail) && $hddtemp_avail) {
 304      if ($XPath->match("/phpsysinfo/HDDTemp/Item")) {
 305        $html_temp .= html_hddtemp();
 306      };
 307    }
 308    if (strlen($html_temp) > 0) {
 309      $tpl->set_var('mbtemp', makebox($text['temperature'], "\n<table width=\"100%\">\n" . $html_temp . "</table>\n"));
 310    }
 311    
 312    // parse our the template
 313    $tpl->pfp('out', 'form'); 
 314   
 315    // finally our print our footer
 316  //  if (PHPGROUPWARE == 1) {
 317  //    $phpgw->common->phpgw_footer();
 318  //  } else {
 319    require_once (APP_ROOT . '/includes/system_footer.php');
 320  //  } 
 321  } 
 322  
 323  ?>


Généré le : Sun Feb 25 10:22:19 2007 par Balluche grâce à PHPXref 0.7