[ Index ]

PHP Cross Reference of Joomla 2.5.4 DE

title

Body

[close]

/administrator/components/com_admin/models/ -> sysinfo.php (source)

   1  <?php
   2  /**
   3   * @copyright    Copyright (C) 2005 - 2012 Open Source Matters, Inc. All rights reserved.
   4   * @license        GNU General Public License version 2 or later; see LICENSE.txt
   5   */
   6  
   7  // no direct access
   8  defined('_JEXEC') or die;
   9  
  10  jimport('joomla.application.component.model');
  11  
  12  /**
  13   * @package        Joomla.Administrator
  14   * @subpackage    com_admin
  15   * @since        1.6
  16   */
  17  class AdminModelSysInfo extends JModel
  18  {
  19      /**
  20       * @var array some php settings
  21       */
  22      protected $php_settings = null;
  23  
  24      /**
  25       * @var array config values
  26       */
  27      protected $config = null;
  28  
  29      /**
  30       * @var array somme system values
  31       */
  32      protected $info = null;
  33  
  34      /**
  35       * @var string php info
  36       */
  37      protected $php_info = null;
  38  
  39      /**
  40       * @var array informations about writable state of directories
  41       */
  42      protected $directories = null;
  43  
  44      /**
  45       * @var string The current editor.
  46       */
  47      protected $editor = null;
  48  
  49      /**
  50       * Method to get the ChangeLog
  51       *
  52       * @return array some php settings
  53       */
  54      function &getPhpSettings()
  55      {
  56          if (is_null($this->php_settings))
  57          {
  58              $this->php_settings = array();
  59              $this->php_settings['safe_mode']            = ini_get('safe_mode') == '1';
  60              $this->php_settings['display_errors']        = ini_get('display_errors') == '1';
  61              $this->php_settings['short_open_tag']        = ini_get('short_open_tag') == '1';
  62              $this->php_settings['file_uploads']            = ini_get('file_uploads') == '1';
  63              $this->php_settings['magic_quotes_gpc']        = ini_get('magic_quotes_gpc') == '1';
  64              $this->php_settings['register_globals']        = ini_get('register_globals') == '1';
  65              $this->php_settings['output_buffering']        = (bool) ini_get('output_buffering');
  66              $this->php_settings['open_basedir']            = ini_get('open_basedir');
  67              $this->php_settings['session.save_path']    = ini_get('session.save_path');
  68              $this->php_settings['session.auto_start']    = ini_get('session.auto_start');
  69              $this->php_settings['disable_functions']    = ini_get('disable_functions');
  70              $this->php_settings['xml']                    = extension_loaded('xml');
  71              $this->php_settings['zlib']                    = extension_loaded('zlib');
  72              $this->php_settings['zip']                    = function_exists('zip_open') && function_exists('zip_read');
  73              $this->php_settings['mbstring']                = extension_loaded('mbstring');
  74              $this->php_settings['iconv']                = function_exists('iconv');
  75          }
  76          return $this->php_settings;
  77      }
  78      /**
  79       * method to get the config
  80       *
  81       * @return array config values
  82       */
  83      function &getConfig()
  84      {
  85          if (is_null($this->config))
  86          {
  87              $registry = new JRegistry(new JConfig);
  88              $this->config = $registry->toArray();
  89              $hidden = array('host', 'user', 'password', 'ftp_user', 'ftp_pass', 'smtpuser', 'smtppass');
  90              foreach($hidden as $key) {
  91                  $this->config[$key] = 'xxxxxx';
  92              }
  93          }
  94          return $this->config;
  95      }
  96      /**
  97       * method to get the system information
  98       *
  99       * @return array system information values
 100       */
 101      function &getInfo()
 102      {
 103          if (is_null($this->info))
 104          {
 105              $this->info = array();
 106              $version = new JVersion();
 107              $platform = new JPlatform();
 108              $db = JFactory::getDBO();
 109              if (isset($_SERVER['SERVER_SOFTWARE'])) {
 110                  $sf = $_SERVER['SERVER_SOFTWARE'];
 111              }
 112              else {
 113                  $sf = getenv('SERVER_SOFTWARE');
 114              }
 115              $this->info['php']            = php_uname();
 116              $this->info['dbversion']    = $db->getVersion();
 117              $this->info['dbcollation']    = $db->getCollation();
 118              $this->info['phpversion']    = phpversion();
 119              $this->info['server']        = $sf;
 120              $this->info['sapi_name']    = php_sapi_name();
 121              $this->info['version']        = $version->getLongVersion();
 122              $this->info['platform']        = $platform->getLongVersion();
 123              $this->info['useragent']    = $_SERVER['HTTP_USER_AGENT'];
 124          }
 125          return $this->info;
 126      }
 127      /**
 128       * method to get the PHP info
 129       *
 130       * @return string PHP info
 131       */
 132      function &getPHPInfo()
 133      {
 134          if (is_null($this->php_info))
 135          {
 136              ob_start();
 137              date_default_timezone_set('UTC');
 138              phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
 139              $phpinfo = ob_get_contents();
 140              ob_end_clean();
 141              preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
 142              $output = preg_replace('#<table[^>]*>#', '<table class="adminlist">', $output[1][0]);
 143              $output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
 144              $output = preg_replace('#<hr />#', '', $output);
 145              $output = str_replace('<div class="center">', '', $output);
 146              $output = preg_replace('#<tr class="h">(.*)<\/tr>#', '<thead><tr class="h">$1</tr></thead><tbody>', $output);
 147              $output = str_replace('</table>', '</tbody></table>', $output);
 148              $output = str_replace('</div>', '', $output);
 149              $this->php_info = $output;
 150          }
 151          return $this->php_info;
 152      }
 153      /**
 154       * method to get the directory states
 155       *
 156       * @return array states of directories
 157       */
 158  	public function getDirectory() {
 159          if (is_null($this->directories))
 160          {
 161              $this->directories = array();
 162  
 163              $registry = JFactory::getConfig();
 164              jimport('joomla.filesystem.folder');
 165              $cparams = JComponentHelper::getParams('com_media');
 166  
 167              $this->_addDirectory('administrator/components', JPATH_ADMINISTRATOR.'/components');
 168              $this->_addDirectory('administrator/language', JPATH_ADMINISTRATOR.'/language');
 169  
 170              // List all admin languages
 171              $admin_langs = JFolder::folders(JPATH_ADMINISTRATOR.'/language');
 172              foreach($admin_langs as $alang) {
 173                  $this->_addDirectory('administrator/language/' . $alang, JPATH_ADMINISTRATOR.'/language/'.$alang);
 174              }
 175  
 176              // List all manifests folders
 177              $manifests = JFolder::folders(JPATH_ADMINISTRATOR.'/manifests');
 178              foreach($manifests as $_manifest) {
 179                  $this->_addDirectory('administrator/manifests/' . $_manifest, JPATH_ADMINISTRATOR.'/manifests/'.$_manifest);
 180              }
 181  
 182              $this->_addDirectory('administrator/modules', JPATH_ADMINISTRATOR.'/modules');
 183              $this->_addDirectory('administrator/templates', JPATH_THEMES);
 184  
 185              $this->_addDirectory('components', JPATH_SITE.'/components');
 186  
 187              $this->_addDirectory($cparams->get('image_path'), JPATH_SITE.'/'.$cparams->get('image_path'));
 188  
 189              $image_folders = JFolder::folders(JPATH_SITE.'/'.$cparams->get('image_path'));
 190              // List all images folders
 191              foreach ($image_folders as $folder) {
 192                  $this->_addDirectory('images/' . $folder, JPATH_SITE.'/'.$cparams->get('image_path').'/'.$folder);
 193              }
 194  
 195              $this->_addDirectory('language', JPATH_SITE.'/language');
 196              // List all site languages
 197              $site_langs = JFolder::folders(JPATH_SITE . '/language');
 198              foreach ($site_langs as $slang) {
 199                  $this->_addDirectory('language/' . $slang, JPATH_SITE.'/language/'.$slang);
 200              }
 201  
 202              $this->_addDirectory('libraries', JPATH_LIBRARIES);
 203  
 204              $this->_addDirectory('media', JPATH_SITE.'/media');
 205              $this->_addDirectory('modules', JPATH_SITE.'/modules');
 206              $this->_addDirectory('plugins', JPATH_PLUGINS);
 207  
 208              $plugin_groups = JFolder::folders(JPATH_PLUGINS);
 209              foreach ($plugin_groups as $folder) {
 210                  $this->_addDirectory('plugins/' . $folder, JPATH_PLUGINS.'/'.$folder);
 211              }
 212  
 213              $this->_addDirectory('templates', JPATH_SITE.'/templates');
 214              $this->_addDirectory('configuration.php', JPATH_CONFIGURATION.'/configuration.php');
 215              $this->_addDirectory('cache', JPATH_SITE.'/cache', 'COM_ADMIN_CACHE_DIRECTORY');
 216              $this->_addDirectory('administrator/cache', JPATH_CACHE, 'COM_ADMIN_CACHE_DIRECTORY');
 217  
 218              $this->_addDirectory($registry->get('log_path', JPATH_ROOT . '/log'), $registry->get('log_path', JPATH_ROOT.'/log'), 'COM_ADMIN_LOG_DIRECTORY');
 219              $this->_addDirectory($registry->get('tmp_path', JPATH_ROOT . '/tmp'), $registry->get('tmp_path', JPATH_ROOT.'/tmp'), 'COM_ADMIN_TEMP_DIRECTORY');
 220          }
 221          return $this->directories;
 222      }
 223  
 224  	private function _addDirectory($name, $path, $message = '') {
 225          $this->directories[$name] = array('writable' => is_writable($path), 'message' => $message);
 226      }
 227  
 228      /**
 229       * method to get the editor
 230       *
 231       * @return string the default editor
 232       *
 233       * has to be removed (it is present in the config...)
 234       */
 235      function &getEditor()
 236      {
 237          if (is_null($this->editor))
 238          {
 239              $config = JFactory::getConfig();
 240              $this->editor = $config->get('editor');
 241          }
 242          return $this->editor;
 243      }
 244  }


Generated: Tue Apr 3 11:40:28 2012 Cross-referenced by PHPXref 0.7.1