Source for file sysinfo.php

Documentation is available at sysinfo.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Administrator
  4.  * @subpackage  com_admin
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE.txt
  8.  */
  9.  
  10. defined('_JEXEC'or die;
  11.  
  12. /**
  13.  * Model for the display of system information.
  14.  *
  15.  * @package     Joomla.Administrator
  16.  * @subpackage  com_admin
  17.  * @since       1.6
  18.  */
  19. {
  20.     /**
  21.      * @var array Some PHP settings
  22.      * @since  1.6
  23.      */
  24.     protected $php_settings = null;
  25.  
  26.     /**
  27.      * @var array Config values
  28.      * @since  1.6
  29.      */
  30.     protected $config = null;
  31.  
  32.     /**
  33.      * @var array Some system values
  34.      * @since  1.6
  35.      */
  36.     protected $info = null;
  37.  
  38.     /**
  39.      * @var string PHP info
  40.      * @since  1.6
  41.      */
  42.     protected $php_info = null;
  43.  
  44.     /**
  45.      * Information about writable state of directories
  46.      *
  47.      * @var array 
  48.      * @since  1.6
  49.      */
  50.     protected $directories = null;
  51.  
  52.     /**
  53.      * The current editor.
  54.      *
  55.      * @var string 
  56.      * @since  1.6
  57.      */
  58.     protected $editor = null;
  59.  
  60.     /**
  61.      * Method to get the ChangeLog
  62.      *
  63.      * @return array some php settings
  64.      *
  65.      * @since  1.6
  66.      */
  67.     public function &getPhpSettings()
  68.     {
  69.         if (is_null($this->php_settings))
  70.         {
  71.             $this->php_settings = array();
  72.             $this->php_settings['safe_mode']            ini_get('safe_mode'== '1';
  73.             $this->php_settings['display_errors']        ini_get('display_errors'== '1';
  74.             $this->php_settings['short_open_tag']        ini_get('short_open_tag'== '1';
  75.             $this->php_settings['file_uploads']            ini_get('file_uploads'== '1';
  76.             $this->php_settings['magic_quotes_gpc']        ini_get('magic_quotes_gpc'== '1';
  77.             $this->php_settings['register_globals']        ini_get('register_globals'== '1';
  78.             $this->php_settings['output_buffering']        = (bool) ini_get('output_buffering');
  79.             $this->php_settings['open_basedir']            ini_get('open_basedir');
  80.             $this->php_settings['session.save_path']    ini_get('session.save_path');
  81.             $this->php_settings['session.auto_start']    ini_get('session.auto_start');
  82.             $this->php_settings['disable_functions']    ini_get('disable_functions');
  83.             $this->php_settings['xml']                    extension_loaded('xml');
  84.             $this->php_settings['zlib']                    extension_loaded('zlib');
  85.             $this->php_settings['zip']                    function_exists('zip_open'&& function_exists('zip_read');
  86.             $this->php_settings['mbstring']                extension_loaded('mbstring');
  87.             $this->php_settings['iconv']                function_exists('iconv');
  88.         }
  89.  
  90.         return $this->php_settings;
  91.     }
  92.  
  93.     /**
  94.      * Method to get the config
  95.      *
  96.      * @return  array  config values
  97.      *
  98.      * @since  1.6
  99.      */
  100.     public function &getConfig()
  101.     {
  102.         if (is_null($this->config))
  103.         {
  104.             $registry new JRegistry(new JConfig);
  105.             $this->config = $registry->toArray();
  106.             $hidden array('host''user''password''ftp_user''ftp_pass''smtpuser''smtppass');
  107.  
  108.             foreach ($hidden as $key)
  109.             {
  110.                 $this->config[$key'xxxxxx';
  111.             }
  112.         }
  113.  
  114.         return $this->config;
  115.     }
  116.  
  117.     /**
  118.      * Method to get the system information
  119.      *
  120.      * @return  array system information values
  121.      *
  122.      * @since   1.6
  123.      */
  124.     public function &getInfo()
  125.     {
  126.         if (is_null($this->info))
  127.         {
  128.             $this->info = array();
  129.             $version new JVersion;
  130.             $platform new JPlatform;
  131.             $db JFactory::getDbo();
  132.  
  133.             if (isset($_SERVER['SERVER_SOFTWARE']))
  134.             {
  135.                 $sf $_SERVER['SERVER_SOFTWARE'];
  136.             }
  137.             else
  138.             {
  139.                 $sf getenv('SERVER_SOFTWARE');
  140.             }
  141.  
  142.             $this->info['php']            php_uname();
  143.             $this->info['dbversion']    $db->getVersion();
  144.             $this->info['dbcollation']    $db->getCollation();
  145.             $this->info['phpversion']    phpversion();
  146.             $this->info['server']        $sf;
  147.             $this->info['sapi_name']    php_sapi_name();
  148.             $this->info['version']        $version->getLongVersion();
  149.             $this->info['platform']        $platform->getLongVersion();
  150.             $this->info['useragent']    $_SERVER['HTTP_USER_AGENT'];
  151.         }
  152.  
  153.         return $this->info;
  154.     }
  155.  
  156.     /**
  157.      * Method to get the PHP info
  158.      *
  159.      * @return  string PHP info
  160.      *
  161.      * @since  1.6
  162.      */
  163.     public function &getPHPInfo()
  164.     {
  165.         if (is_null($this->php_info))
  166.         {
  167.             ob_start();
  168.             date_default_timezone_set('UTC');
  169.             phpinfo(INFO_GENERAL INFO_CONFIGURATION INFO_MODULES);
  170.             $phpInfo ob_get_contents();
  171.             ob_end_clean();
  172.             preg_match_all('#<body[^>]*>(.*)</body>#siU'$phpInfo$output);
  173.             $output preg_replace('#<table[^>]*>#''<table class="table table-striped adminlist">'$output[1][0]);
  174.             $output preg_replace('#(\w),(\w)#''\1, \2'$output);
  175.             $output preg_replace('#<hr />#'''$output);
  176.             $output str_replace('<div class="center">'''$output);
  177.             $output preg_replace('#<tr class="h">(.*)<\/tr>#''<thead><tr class="h">$1</tr></thead><tbody>'$output);
  178.             $output str_replace('</table>''</tbody></table>'$output);
  179.             $output str_replace('</div>'''$output);
  180.             $this->php_info = $output;
  181.         }
  182.  
  183.         return $this->php_info;
  184.     }
  185.  
  186.     /**
  187.      * Method to get the directory states
  188.      *
  189.      * @return array States of directories
  190.      *
  191.      * @since  1.6
  192.      */
  193.     public function getDirectory()
  194.     {
  195.         if (is_null($this->directories))
  196.         {
  197.             $this->directories = array();
  198.  
  199.             $registry JFactory::getConfig();
  200.             $cparams JComponentHelper::getParams('com_media');
  201.  
  202.             $this->_addDirectory('administrator/components'JPATH_ADMINISTRATOR '/components');
  203.             $this->_addDirectory('administrator/language'JPATH_ADMINISTRATOR '/language');
  204.  
  205.             // List all admin languages
  206.             $admin_langs new DirectoryIterator(JPATH_ADMINISTRATOR '/language');
  207.  
  208.             foreach ($admin_langs as $folder)
  209.             {
  210.                 if (!$folder->isDir(|| $folder->isDot())
  211.                 {
  212.                     continue;
  213.                 }
  214.  
  215.                 $this->_addDirectory('administrator/language/' $folder->getFilename()JPATH_ADMINISTRATOR '/language/' $folder->getFilename());
  216.             }
  217.  
  218.             // List all manifests folders
  219.             $manifests new DirectoryIterator(JPATH_ADMINISTRATOR '/manifests');
  220.  
  221.             foreach ($manifests as $folder)
  222.             {
  223.                 if (!$folder->isDir(|| $folder->isDot())
  224.                 {
  225.                     continue;
  226.                 }
  227.  
  228.                 $this->_addDirectory('administrator/manifests/' $folder->getFilename()JPATH_ADMINISTRATOR '/manifests/' $folder->getFilename());
  229.             }
  230.  
  231.             $this->_addDirectory('administrator/modules'JPATH_ADMINISTRATOR '/modules');
  232.             $this->_addDirectory('administrator/templates'JPATH_THEMES);
  233.  
  234.             $this->_addDirectory('components'JPATH_SITE '/components');
  235.  
  236.             $this->_addDirectory($cparams->get('image_path')JPATH_SITE '/' $cparams->get('image_path'));
  237.  
  238.             // List all images folders
  239.             $image_folders new DirectoryIterator(JPATH_SITE '/' $cparams->get('image_path'));
  240.  
  241.             foreach ($image_folders as $folder)
  242.             {
  243.                 if (!$folder->isDir(|| $folder->isDot())
  244.                 {
  245.                     continue;
  246.                 }
  247.  
  248.                 $this->_addDirectory('images/' $folder->getFilename()JPATH_SITE '/' $cparams->get('image_path''/' $folder->getFilename());
  249.             }
  250.  
  251.             $this->_addDirectory('language'JPATH_SITE '/language');
  252.  
  253.             // List all site languages
  254.             $site_langs new DirectoryIterator(JPATH_SITE '/language');
  255.  
  256.             foreach ($site_langs as $folder)
  257.             {
  258.                 if (!$folder->isDir(|| $folder->isDot())
  259.                 {
  260.                     continue;
  261.                 }
  262.  
  263.                 $this->_addDirectory('language/' $folder->getFilename()JPATH_SITE '/language/' $folder->getFilename());
  264.             }
  265.  
  266.             $this->_addDirectory('libraries'JPATH_LIBRARIES);
  267.  
  268.             $this->_addDirectory('media'JPATH_SITE '/media');
  269.             $this->_addDirectory('modules'JPATH_SITE '/modules');
  270.             $this->_addDirectory('plugins'JPATH_PLUGINS);
  271.  
  272.             $plugin_groups new DirectoryIterator(JPATH_SITE '/plugins');
  273.  
  274.             foreach ($plugin_groups as $folder)
  275.             {
  276.                 if (!$folder->isDir(|| $folder->isDot())
  277.                 {
  278.                     continue;
  279.                 }
  280.  
  281.                 $this->_addDirectory('plugins/' $folder->getFilename()JPATH_PLUGINS '/' $folder->getFilename());
  282.             }
  283.  
  284.             $this->_addDirectory('templates'JPATH_SITE '/templates');
  285.             $this->_addDirectory('configuration.php'JPATH_CONFIGURATION '/configuration.php');
  286.             $this->_addDirectory('cache'JPATH_SITE '/cache''COM_ADMIN_CACHE_DIRECTORY');
  287.             $this->_addDirectory('administrator/cache'JPATH_CACHE'COM_ADMIN_CACHE_DIRECTORY');
  288.  
  289.             $this->_addDirectory($registry->get('log_path'JPATH_ROOT '/log')$registry->get('log_path'JPATH_ROOT '/log')'COM_ADMIN_LOG_DIRECTORY');
  290.             $this->_addDirectory($registry->get('tmp_path'JPATH_ROOT '/tmp')$registry->get('tmp_path'JPATH_ROOT '/tmp')'COM_ADMIN_TEMP_DIRECTORY');
  291.         }
  292.  
  293.         return $this->directories;
  294.     }
  295.  
  296.     /**
  297.      * Method to add a directory
  298.      *
  299.      * @return void 
  300.      * @since  1.6
  301.      */
  302.     /**
  303.      * Method to add a directory
  304.      *
  305.      * @param   string  $name     Directory Name
  306.      * @param   string  $path     Directory path
  307.      * @param   string  $message  Message
  308.      *
  309.      * @return   void 
  310.      */
  311.     private function _addDirectory($name$path$message '')
  312.     {
  313.         $this->directories[$namearray('writable' => is_writable($path)'message' => $message);
  314.     }
  315.  
  316.     /**
  317.      * Method to get the editor
  318.      *
  319.      * @return  string The default editor
  320.      *
  321.      * @note: has to be removed (it is present in the config...)
  322.      *
  323.      * @since  1.6
  324.      */
  325.     public function &getEditor()
  326.     {
  327.         if (is_null($this->editor))
  328.         {
  329.             $config JFactory::getConfig();
  330.             $this->editor = $config->get('editor');
  331.         }
  332.  
  333.         return $this->editor;
  334.     }
  335. }

Documentation generated on Tue, 19 Nov 2013 15:14:46 +0100 by phpDocumentor 1.4.3