PageRenderTime 47ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/administrator/components/com_admin/models/sysinfo.php

https://github.com/joebushi/joomla
PHP | 217 lines | 141 code | 13 blank | 63 comment | 14 complexity | 2465283754c987c7f3e30cac727a7b74 MD5 | raw file
Possible License(s): LGPL-2.1, Apache-2.0
  1. <?php
  2. /**
  3. * @version $Id$
  4. * @copyright Copyright (C) 2005 - 2010 Open Source Matters, Inc. All rights reserved.
  5. * @license GNU General Public License version 2 or later; see LICENSE.txt
  6. */
  7. // no direct access
  8. defined('_JEXEC') or die;
  9. jimport('joomla.application.component.model');
  10. /**
  11. * @package Joomla.Administrator
  12. * @subpackage com_admin
  13. * @since 1.6
  14. */
  15. class AdminModelSysInfo extends JModel
  16. {
  17. /**
  18. * @var array some php settings
  19. */
  20. protected $php_settings = null;
  21. /**
  22. * @var array config values
  23. */
  24. protected $config = null;
  25. /**
  26. * @var array somme system values
  27. */
  28. protected $info = null;
  29. /**
  30. * @var string php info
  31. */
  32. protected $php_info = null;
  33. /**
  34. * @var array informations about writable state of directories
  35. */
  36. protected $directory = null;
  37. /**
  38. * @var string The current editor.
  39. */
  40. protected $editor = null;
  41. /**
  42. * Method to get the ChangeLog
  43. *
  44. * @return array some php settings
  45. */
  46. function &getPhpSettings()
  47. {
  48. if (is_null($this->php_settings))
  49. {
  50. $this->php_settings = array();
  51. $this->php_settings['safe_mode'] = ini_get('safe_mode') == '1';
  52. $this->php_settings['display_errors'] = ini_get('display_errors') == '1';
  53. $this->php_settings['short_open_tag'] = ini_get('short_open_tag') == '1';
  54. $this->php_settings['file_uploads'] = ini_get('file_uploads') == '1';
  55. $this->php_settings['magic_quotes_gpc'] = ini_get('magic_quotes_gpc') == '1';
  56. $this->php_settings['register_globals'] = ini_get('register_globals') == '1';
  57. $this->php_settings['output_buffering'] = (bool) ini_get('output_buffering');
  58. $this->php_settings['open_basedir'] = ini_get('open_basedir');
  59. $this->php_settings['session.save_path'] = ini_get('session.save_path');
  60. $this->php_settings['session.auto_start'] = ini_get('session.auto_start');
  61. $this->php_settings['disable_functions'] = ini_get('disable_functions');
  62. $this->php_settings['xml'] = extension_loaded('xml');
  63. $this->php_settings['zlib'] = extension_loaded('zlib');
  64. $this->php_settings['mbstring'] = extension_loaded('mbstring');
  65. $this->php_settings['iconv'] = function_exists('iconv');
  66. }
  67. return $this->php_settings;
  68. }
  69. /**
  70. * method to get the config
  71. *
  72. * @return array config values
  73. */
  74. function &getConfig()
  75. {
  76. if (is_null($this->config))
  77. {
  78. $registry = & JFactory::getConfig();
  79. $this->config = $registry->toArray();
  80. $hidden = array('host', 'user', 'password', 'ftp_user', 'ftp_pass', 'smtpuser', 'smtppass');
  81. foreach($hidden as $key) {
  82. $this->config[$key] = 'xxxxxx';
  83. }
  84. }
  85. return $this->config;
  86. }
  87. /**
  88. * method to get the system information
  89. *
  90. * @return array system information values
  91. */
  92. function &getInfo()
  93. {
  94. if (is_null($this->info))
  95. {
  96. $this->info = array();
  97. $version = new JVersion();
  98. $db = & JFactory::getDBO();
  99. if (isset($_SERVER['SERVER_SOFTWARE'])) {
  100. $sf = $_SERVER['SERVER_SOFTWARE'];
  101. }
  102. else {
  103. $sf = getenv('SERVER_SOFTWARE');
  104. }
  105. $this->info['php'] = php_uname();
  106. $this->info['dbversion'] = $db->getVersion();
  107. $this->info['dbcollation'] = $db->getCollation();
  108. $this->info['phpversion'] = phpversion();
  109. $this->info['server'] = $sf;
  110. $this->info['sapi_name'] = php_sapi_name();
  111. $this->info['version'] = $version->getLongVersion();
  112. $this->info['useragent'] = phpversion() <= '4.2.1' ? getenv("HTTP_USER_AGENT") : $_SERVER['HTTP_USER_AGENT'];
  113. }
  114. return $this->info;
  115. }
  116. /**
  117. * method to get the PHP info
  118. *
  119. * @return string PHP info
  120. */
  121. function &getPHPInfo()
  122. {
  123. if (is_null($this->php_info))
  124. {
  125. ob_start();
  126. phpinfo(INFO_GENERAL | INFO_CONFIGURATION | INFO_MODULES);
  127. $phpinfo = ob_get_contents();
  128. ob_end_clean();
  129. preg_match_all('#<body[^>]*>(.*)</body>#siU', $phpinfo, $output);
  130. $output = preg_replace('#<table#', '<table class="adminlist" ', $output[1][0]);
  131. $output = preg_replace('#(\w),(\w)#', '\1, \2', $output);
  132. $output = preg_replace('#border="0" cellpadding="3" width="600"#', 'border="0" cellspacing="1" cellpadding="4" width="95%"', $output);
  133. $output = preg_replace('#<hr />#', '', $output);
  134. $output = str_replace('<div class="center">', '', $output);
  135. $output = str_replace('</div>', '', $output);
  136. $this->php_info = $output;
  137. }
  138. return $this->php_info;
  139. }
  140. /**
  141. * method to get the directory states
  142. *
  143. * @return array states of directories
  144. */
  145. function &getDirectory()
  146. {
  147. if (is_null($this->directory))
  148. {
  149. $registry = & JFactory::getConfig();
  150. jimport('joomla.filesystem.folder');
  151. $cparams = & JComponentHelper::getParams('com_media');
  152. $this->directory = array();
  153. $this->directory['administrator'.DS.'components'] = array('writable' => is_writable(JPATH_SITE.DS.'administrator'.DS.'components'), 'message' => '');
  154. $this->directory['administrator'.DS.'language'] = array('writable' => is_writable(JPATH_SITE.DS.'administrator'.DS.'language'), 'message' => '');
  155. // List all admin languages
  156. $admin_langs = JFolder::folders(JPATH_ADMINISTRATOR.DS.'language');
  157. foreach($admin_langs as $alang) {
  158. $this->directory['administrator'.DS.'language'.DS.$alang] = array('writable' => is_writable(JPATH_SITE.DS.'administrator'.DS.'language'.DS.$alang), 'message' => '');
  159. }
  160. $this->directory['administrator'.DS.'modules'] = array('writable' => is_writable(JPATH_SITE.DS.'administrator'.DS.'modules'), 'message' => '');
  161. $this->directory['administrator'.DS.'templates'] = array('writable' => is_writable(JPATH_SITE.DS.'administrator'.DS.'templates'), 'message' => '');
  162. $this->directory['components'] = array('writable' => is_writable(JPATH_SITE.DS.'components'), 'message' => '');
  163. $this->directory['images'] = array('writable' => is_writable(JPATH_SITE.DS.'images'), 'message' => '');
  164. $this->directory['images'.DS.'banners'] = array('writable' => is_writable(JPATH_SITE.DS.'images'.DS.'banners'), 'message' => '');
  165. $this->directory[$cparams->get('image_path') ] = array('writable' => is_writable(JPATH_SITE.DS.$cparams->get('image_path')), 'message' => '');
  166. $this->directory['language'] = array('writable' => is_writable(JPATH_SITE.DS.'language'), 'message' => '');
  167. // List all site languages
  168. $site_langs = JFolder::folders(JPATH_SITE.DS.'language');
  169. foreach ($site_langs as $slang) {
  170. $this->directory['language'.DS.$slang] = array('writable' => is_writable(JPATH_SITE.DS.'language'.DS.$slang), 'message' => '');
  171. }
  172. $this->directory['media'] = array('writable' => is_writable(JPATH_SITE.DS.'media'), 'message' => '');
  173. $this->directory['modules'] = array('writable' => is_writable(JPATH_SITE.DS.'modules'), 'message' => '');
  174. $this->directory['plugins'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'), 'message' => '');
  175. $this->directory['plugins'.DS.'content'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'.DS.'content'), 'message' => '');
  176. $this->directory['plugins'.DS.'editors'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'.DS.'editors'), 'message' => '');
  177. $this->directory['plugins'.DS.'editors-xtd'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'.DS.'editors-xtd'), 'message' => '');
  178. $this->directory['plugins'.DS.'search'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'.DS.'search'), 'message' => '');
  179. $this->directory['plugins'.DS.'system'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'.DS.'system'), 'message' => '');
  180. $this->directory['plugins'.DS.'user'] = array('writable' => is_writable(JPATH_SITE.DS.'plugins'.DS.'user'), 'message' => '');
  181. $this->directory['cache'] = array('writable' => is_writable(JPATH_SITE.DS.'cache'), 'message' => 'Admin_Cache_Directory');
  182. $this->directory['administrator'.DS.'cache'] = array('writable' => is_writable(JPATH_SITE.DS.'administrator'.DS.'cache'), 'message' => 'Admin_Cache_Directory');
  183. $this->directory[$registry->getValue('config.log_path', JPATH_ROOT.DS.'log') ] = array('writable' => is_writable($registry->getValue('config.log_path', JPATH_ROOT.DS.'log')), 'message' => 'Admin_Log_Directory');
  184. $this->directory[$registry->getValue('config.tmp_path', JPATH_ROOT.DS.'log') ] = array('writable' => is_writable($registry->getValue('config.tmp_path', JPATH_ROOT.DS.'tmp')), 'message' => 'Admin_Temp_Directory');
  185. }
  186. return $this->directory;
  187. }
  188. /**
  189. * method to get the editor
  190. *
  191. * @return string the default editor
  192. *
  193. * has to be removed (it is present in the config...)
  194. */
  195. function &getEditor()
  196. {
  197. if (is_null($this->editor))
  198. {
  199. $config = &JFactory::getConfig();
  200. $this->editor = $config->getValue('config.editor');
  201. }
  202. return $this->editor;
  203. }
  204. }