diagnoser.lib.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Class Diagnoser
  5. * Class that is responsible for generating diagnostic information about the system
  6. *
  7. * @package chamilo.diagnoser
  8. * @author Ivan Tcholakov, 2008, initiall proposal and sample code.
  9. * @author spou595, 2009, implementation for Chamilo 2.x
  10. * @author Julio Montoya <gugli100@gmail.com>, 2010, port to chamilo 1.8.7, Some fixes
  11. *
  12. */
  13. class Diagnoser
  14. {
  15. const STATUS_OK = 1;
  16. const STATUS_WARNING = 2;
  17. const STATUS_ERROR = 3;
  18. const STATUS_INFORMATION = 4;
  19. /**
  20. * Contructor
  21. */
  22. public function __construct()
  23. {
  24. }
  25. /**
  26. * Show html table
  27. */
  28. public function show_html()
  29. {
  30. $sections = array('chamilo', 'php', 'database', 'webserver');
  31. $currentSection = isset($_GET['section']) ? $_GET['section'] : '';
  32. if (!in_array(trim($currentSection), $sections)) {
  33. $currentSection = 'chamilo';
  34. }
  35. $html = '<div class="tabbable"><ul class="nav nav-tabs">';
  36. foreach ($sections as $section) {
  37. if ($currentSection === $section) {
  38. $html .= '<li class="active">';
  39. } else {
  40. $html .= '<li>';
  41. }
  42. $params['section'] = $section;
  43. $html .= '<a href="system_status.php?section='.$section.'">'.get_lang($section).'</a></li>';
  44. }
  45. $html .= '</ul><div class="tab-pane">';
  46. $data = call_user_func(array($this, 'get_'.$currentSection.'_data'));
  47. echo $html;
  48. if ($currentSection != 'paths') {
  49. $table = new SortableTableFromArray($data, 1, 100);
  50. $table->set_header(0, '', false);
  51. $table->set_header(1, get_lang('Section'), false);
  52. $table->set_header(2, get_lang('Setting'), false);
  53. $table->set_header(3, get_lang('Current'), false);
  54. $table->set_header(4, get_lang('Expected'), false);
  55. $table->set_header(5, get_lang('Comment'), false);
  56. $table->display();
  57. } else {
  58. $headers = $data['headers'];
  59. $results = $data['data'];
  60. $table = new HTML_Table(array('class' => 'data_table'));
  61. $column = 0;
  62. foreach ($headers as $header) {
  63. $table->setHeaderContents(0, $column, $header);
  64. $column++;
  65. }
  66. $row = 1;
  67. foreach ($results as $index => $rowData) {
  68. $table->setCellContents(
  69. $row,
  70. 0,
  71. $rowData
  72. );
  73. $table->setCellContents(
  74. $row,
  75. 1,
  76. $index
  77. );
  78. $row++;
  79. }
  80. echo $table->display();
  81. }
  82. echo '</div></div>';
  83. }
  84. /**
  85. * @return array
  86. */
  87. public function get_paths_data()
  88. {
  89. global $paths;
  90. $list = $paths[api_get_path(WEB_PATH)];
  91. $list['url_append'] = api_get_configuration_value('url_append');
  92. asort($list);
  93. return [
  94. 'headers' => ['Path', 'constant'],
  95. 'data' => $list
  96. ];
  97. }
  98. /**
  99. * Functions to get the data for the chamilo diagnostics
  100. * @return array of data
  101. */
  102. public function get_chamilo_data()
  103. {
  104. $array = array();
  105. $writable_folders = array(
  106. api_get_path(SYS_APP_PATH).'cache',
  107. api_get_path(SYS_COURSE_PATH),
  108. api_get_path(SYS_APP_PATH).'home',
  109. api_get_path(SYS_APP_PATH).'upload/users/',
  110. api_get_path(SYS_PATH).'main/default_course_document/images/',
  111. );
  112. foreach ($writable_folders as $index => $folder) {
  113. $writable = is_writable($folder);
  114. $status = $writable ? self::STATUS_OK : self::STATUS_ERROR;
  115. $array[] = $this->build_setting(
  116. $status,
  117. '[FILES]',
  118. get_lang('IsWritable').': '.$folder,
  119. 'http://be2.php.net/manual/en/function.is-writable.php',
  120. $writable,
  121. 1,
  122. 'yes_no',
  123. get_lang('DirectoryMustBeWritable')
  124. );
  125. }
  126. $exists = file_exists(api_get_path(SYS_CODE_PATH).'install');
  127. $status = $exists ? self::STATUS_WARNING : self::STATUS_OK;
  128. $array[] = $this->build_setting($status, '[FILES]', get_lang('DirectoryExists').': /install', 'http://be2.php.net/file_exists', $exists, 0, 'yes_no', get_lang('DirectoryShouldBeRemoved'));
  129. $app_version = api_get_setting('chamilo_database_version');
  130. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[DB]', 'chamilo_database_version', '#', $app_version, 0, null, 'Chamilo DB version');
  131. $access_url_id = api_get_current_access_url_id();
  132. if ($access_url_id === 1) {
  133. global $_configuration;
  134. $message2 = '';
  135. if ($access_url_id === 1) {
  136. if (api_is_windows_os()) {
  137. $message2 .= get_lang('SpaceUsedOnSystemCannotBeMeasuredOnWindows');
  138. } else {
  139. $dir = api_get_path(SYS_PATH);
  140. $du = exec('du -sh '.$dir, $err);
  141. list($size, $none) = explode("\t", $du);
  142. $limit = $_configuration[$access_url_id]['hosting_limit_disk_space'];
  143. $message2 .= sprintf(get_lang('TotalSpaceUsedByPortalXLimitIsYMB'), $size, $limit);
  144. }
  145. }
  146. $array[] = $this->build_setting(
  147. self::STATUS_OK,
  148. '[FILES]',
  149. 'hosting_limit_disk_space',
  150. '#',
  151. $size,
  152. 0,
  153. null,
  154. $message2
  155. );
  156. }
  157. return $array;
  158. }
  159. /**
  160. * Functions to get the data for the php diagnostics
  161. * @return array of data
  162. */
  163. public function get_php_data()
  164. {
  165. $array = array();
  166. // General Functions
  167. $version = phpversion();
  168. $status = $version > REQUIRED_PHP_VERSION ? self::STATUS_OK : self::STATUS_ERROR;
  169. $array[] = $this->build_setting($status, '[PHP]', 'phpversion()', 'http://www.php.net/manual/en/function.phpversion.php', phpversion(), '>= '.REQUIRED_PHP_VERSION, null, get_lang('PHPVersionInfo'));
  170. $setting = ini_get('output_buffering');
  171. $req_setting = 1;
  172. $status = $setting >= $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  173. $array[] = $this->build_setting($status, '[INI]', 'output_buffering', 'http://www.php.net/manual/en/outcontrol.configuration.php#ini.output-buffering', $setting, $req_setting, 'on_off', get_lang('OutputBufferingInfo'));
  174. $setting = ini_get('file_uploads');
  175. $req_setting = 1;
  176. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  177. $array[] = $this->build_setting($status, '[INI]', 'file_uploads', 'http://www.php.net/manual/en/ini.core.php#ini.file-uploads', $setting, $req_setting, 'on_off', get_lang('FileUploadsInfo'));
  178. $setting = ini_get('magic_quotes_runtime');
  179. $req_setting = 0;
  180. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  181. $array[] = $this->build_setting($status, '[INI]', 'magic_quotes_runtime', 'http://www.php.net/manual/en/ini.core.php#ini.magic-quotes-runtime', $setting, $req_setting, 'on_off', get_lang('MagicQuotesRuntimeInfo'));
  182. $setting = ini_get('safe_mode');
  183. $req_setting = 0;
  184. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
  185. $array[] = $this->build_setting($status, '[INI]', 'safe_mode', 'http://www.php.net/manual/en/ini.core.php#ini.safe-mode', $setting, $req_setting, 'on_off', get_lang('SafeModeInfo'));
  186. $setting = ini_get('register_globals');
  187. $req_setting = 0;
  188. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  189. $array[] = $this->build_setting($status, '[INI]', 'register_globals', 'http://www.php.net/manual/en/ini.core.php#ini.register-globals', $setting, $req_setting, 'on_off', get_lang('RegisterGlobalsInfo'));
  190. $setting = ini_get('short_open_tag');
  191. $req_setting = 0;
  192. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
  193. $array[] = $this->build_setting($status, '[INI]', 'short_open_tag', 'http://www.php.net/manual/en/ini.core.php#ini.short-open-tag', $setting, $req_setting, 'on_off', get_lang('ShortOpenTagInfo'));
  194. $setting = ini_get('magic_quotes_gpc');
  195. $req_setting = 0;
  196. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  197. $array[] = $this->build_setting($status, '[INI]', 'magic_quotes_gpc', 'http://www.php.net/manual/en/ini.core.php#ini.magic_quotes_gpc', $setting, $req_setting, 'on_off', get_lang('MagicQuotesGpcInfo'));
  198. $setting = ini_get('display_errors');
  199. $req_setting = 0;
  200. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
  201. $array[] = $this->build_setting($status, '[INI]', 'display_errors', 'http://www.php.net/manual/en/ini.core.php#ini.display_errors', $setting, $req_setting, 'on_off', get_lang('DisplayErrorsInfo'));
  202. $setting = ini_get('default_charset');
  203. if ($setting == '')
  204. $setting = null;
  205. $req_setting = null;
  206. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  207. $array[] = $this->build_setting($status, '[INI]', 'default_charset', 'http://www.php.net/manual/en/ini.core.php#ini.default-charset', $setting, $req_setting, null, get_lang('DefaultCharsetInfo'));
  208. $setting = ini_get('max_execution_time');
  209. $req_setting = '300 ('.get_lang('Minimum').')';
  210. $status = $setting >= 300 ? self::STATUS_OK : self::STATUS_WARNING;
  211. $array[] = $this->build_setting($status, '[INI]', 'max_execution_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-execution-time', $setting, $req_setting, null, get_lang('MaxExecutionTimeInfo'));
  212. $setting = ini_get('max_input_time');
  213. $req_setting = '300 ('.get_lang('Minimum').')';
  214. $status = $setting >= 300 ? self::STATUS_OK : self::STATUS_WARNING;
  215. $array[] = $this->build_setting($status, '[INI]', 'max_input_time', 'http://www.php.net/manual/en/ini.core.php#ini.max-input-time', $setting, $req_setting, null, get_lang('MaxInputTimeInfo'));
  216. $setting = ini_get('memory_limit');
  217. $req_setting = '>= '.REQUIRED_MIN_MEMORY_LIMIT.'M';
  218. $status = self::STATUS_ERROR;
  219. if ((float) $setting >= REQUIRED_MIN_MEMORY_LIMIT)
  220. $status = self::STATUS_OK;
  221. $array[] = $this->build_setting($status, '[INI]', 'memory_limit', 'http://www.php.net/manual/en/ini.core.php#ini.memory-limit', $setting, $req_setting, null, get_lang('MemoryLimitInfo'));
  222. $setting = ini_get('post_max_size');
  223. $req_setting = '>= '.REQUIRED_MIN_POST_MAX_SIZE.'M';
  224. $status = self::STATUS_ERROR;
  225. if ((float) $setting >= REQUIRED_MIN_POST_MAX_SIZE)
  226. $status = self::STATUS_OK;
  227. $array[] = $this->build_setting($status, '[INI]', 'post_max_size', 'http://www.php.net/manual/en/ini.core.php#ini.post-max-size', $setting, $req_setting, null, get_lang('PostMaxSizeInfo'));
  228. $setting = ini_get('upload_max_filesize');
  229. $req_setting = '>= '.REQUIRED_MIN_UPLOAD_MAX_FILESIZE.'M';
  230. $status = self::STATUS_ERROR;
  231. if ((float) $setting >= REQUIRED_MIN_UPLOAD_MAX_FILESIZE)
  232. $status = self::STATUS_OK;
  233. $array[] = $this->build_setting($status, '[INI]', 'upload_max_filesize', 'http://www.php.net/manual/en/ini.core.php#ini.upload_max_filesize', $setting, $req_setting, null, get_lang('UploadMaxFilesizeInfo'));
  234. $setting = ini_get('variables_order');
  235. $req_setting = 'GPCS';
  236. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_ERROR;
  237. $array[] = $this->build_setting($status, '[INI]', 'variables_order', 'http://www.php.net/manual/en/ini.core.php#ini.variables-order', $setting, $req_setting, null, get_lang('VariablesOrderInfo'));
  238. $setting = ini_get('session.gc_maxlifetime');
  239. $req_setting = '4320';
  240. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
  241. $array[] = $this->build_setting($status, '[SESSION]', 'session.gc_maxlifetime', 'http://www.php.net/manual/en/ini.core.php#session.gc-maxlifetime', $setting, $req_setting, null, get_lang('SessionGCMaxLifetimeInfo'));
  242. if (api_check_browscap()) {$setting = true; } else {$setting = false; }
  243. $req_setting = true;
  244. $status = $setting == $req_setting ? self::STATUS_OK : self::STATUS_WARNING;
  245. $array[] = $this->build_setting($status, '[INI]', 'browscap', 'http://www.php.net/manual/en/misc.configuration.php#ini.browscap', $setting, $req_setting, 'on_off', get_lang('BrowscapInfo'));
  246. // Extensions
  247. $extensions = array(
  248. 'gd' => array(
  249. 'link' => 'http://www.php.net/gd',
  250. 'expected' => 1,
  251. 'comment' => get_lang('ExtensionMustBeLoaded'),
  252. ),
  253. 'pdo_mysql' => array(
  254. 'link' => 'http://php.net/manual/en/ref.pdo-mysql.php',
  255. 'expected' => 1,
  256. 'comment' => get_lang('ExtensionMustBeLoaded'),
  257. ),
  258. 'pcre' => array(
  259. 'link' => 'http://www.php.net/pcre',
  260. 'expected' => 1,
  261. 'comment' => get_lang('ExtensionMustBeLoaded'),
  262. ),
  263. 'session' => array(
  264. 'link' => 'http://www.php.net/session',
  265. 'expected' => 1,
  266. 'comment' => get_lang('ExtensionMustBeLoaded'),
  267. ),
  268. 'standard' => array(
  269. 'link' => 'http://www.php.net/spl',
  270. 'expected' => 1,
  271. 'comment' => get_lang('ExtensionMustBeLoaded'),
  272. ),
  273. 'zlib' => array(
  274. 'link' => 'http://www.php.net/zlib',
  275. 'expected' => 1,
  276. 'comment' => get_lang('ExtensionMustBeLoaded'),
  277. ),
  278. 'xsl' => array(
  279. 'link' => 'http://be2.php.net/xsl',
  280. 'expected' => 2,
  281. 'comment' => get_lang('ExtensionShouldBeLoaded'),
  282. ),
  283. 'curl' => array(
  284. 'link' => 'http://www.php.net/curl',
  285. 'expected' => 2,
  286. 'comment' => get_lang('ExtensionShouldBeLoaded'),
  287. ),
  288. 'Zend OPcache' => array(
  289. 'link' => 'http://www.php.net/opcache',
  290. 'expected' => 2,
  291. 'comment' => get_lang('ExtensionShouldBeLoaded'),
  292. ),
  293. 'apcu' => array(
  294. 'link' => 'http://www.php.net/apcu',
  295. 'expected' => 2,
  296. 'comment' => get_lang('ExtensionShouldBeLoaded'),
  297. ),
  298. );
  299. foreach ($extensions as $extension => $data) {
  300. $url = $data['link'];
  301. $expected_value = $data['expected'];
  302. $comment = $data['comment'];
  303. $loaded = extension_loaded($extension);
  304. $status = $loaded ? self::STATUS_OK : self::STATUS_ERROR;
  305. $array[] = $this->build_setting($status, '[EXTENSION]', get_lang('LoadedExtension').': '.$extension, $url, $loaded, $expected_value, 'yes_no_optional', $comment);
  306. }
  307. return $array;
  308. }
  309. /**
  310. * Functions to get the data for the mysql diagnostics
  311. * @return array of data
  312. */
  313. public function get_database_data()
  314. {
  315. $array = array();
  316. $em = Database::getManager();
  317. $connection = $em->getConnection();
  318. $host = $connection->getHost();
  319. $db = $connection->getDatabase();
  320. $port = $connection->getPort();
  321. $driver = $connection->getDriver()->getName();
  322. $array[] = $this->build_setting(
  323. self::STATUS_INFORMATION,
  324. '[Database]',
  325. 'driver',
  326. '',
  327. $driver, null, null, get_lang('Driver')
  328. );
  329. $array[] = $this->build_setting(
  330. self::STATUS_INFORMATION,
  331. '[Database]',
  332. 'host',
  333. '',
  334. $host, null, null, get_lang('MysqlHostInfo')
  335. );
  336. $array[] = $this->build_setting(
  337. self::STATUS_INFORMATION,
  338. '[Database]',
  339. 'port',
  340. '',
  341. $port, null, null, get_lang('Port')
  342. );
  343. $array[] = $this->build_setting(
  344. self::STATUS_INFORMATION,
  345. '[Database]',
  346. 'Database name',
  347. '',
  348. $db, null, null, get_lang('Name')
  349. );
  350. return $array;
  351. }
  352. /**
  353. * Functions to get the data for the webserver diagnostics
  354. * @return array of data
  355. */
  356. public function get_webserver_data()
  357. {
  358. $array = array();
  359. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_NAME"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_NAME"], null, null, get_lang('ServerNameInfo'));
  360. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_ADDR"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_ADDR"], null, null, get_lang('ServerAddessInfo'));
  361. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_PORT"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_PORT"], null, null, get_lang('ServerPortInfo'));
  362. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_SOFTWARE"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_SOFTWARE"], null, null, get_lang('ServerSoftwareInfo'));
  363. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["REMOTE_ADDR"]', 'http://be.php.net/reserved.variables.server', $_SERVER["REMOTE_ADDR"], null, null, get_lang('ServerRemoteInfo'));
  364. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["HTTP_USER_AGENT"]', 'http://be.php.net/reserved.variables.server', $_SERVER["HTTP_USER_AGENT"], null, null, get_lang('ServerUserAgentInfo'));
  365. /*$path = $this->manager->get_url(array('section' => Request::get('section')));
  366. $request = $_SERVER["REQUEST_URI"];
  367. $status = $request != $path ? self::STATUS_ERROR : self::STATUS_OK;
  368. $array[] = $this->build_setting($status, '[SERVER]', '$_SERVER["REQUEST_URI"]', 'http://be.php.net/reserved.variables.server', $request, $path, null, get_lang('RequestURIInfo'));
  369. */
  370. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["SERVER_PROTOCOL"]', 'http://be.php.net/reserved.variables.server', $_SERVER["SERVER_PROTOCOL"], null, null, get_lang('ServerProtocolInfo'));
  371. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', 'php_uname()', 'http://be2.php.net/php_uname', php_uname(), null, null, get_lang('UnameInfo'));
  372. $array[] = $this->build_setting(self::STATUS_INFORMATION, '[SERVER]', '$_SERVER["HTTP_X_FORWARDED_FOR"]', 'http://be.php.net/reserved.variables.server', (!empty($_SERVER["HTTP_X_FORWARDED_FOR"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : ''), null, null, get_lang('ServerXForwardedForInfo'));
  373. return $array;
  374. }
  375. /**
  376. * Additional functions needed for fast integration
  377. */
  378. public function build_setting(
  379. $status,
  380. $section,
  381. $title,
  382. $url,
  383. $current_value,
  384. $expected_value,
  385. $formatter,
  386. $comment
  387. ) {
  388. switch ($status) {
  389. case self::STATUS_OK :
  390. $img = 'bullet_green.png';
  391. break;
  392. case self::STATUS_WARNING :
  393. $img = 'bullet_orange.png';
  394. break;
  395. case self::STATUS_ERROR :
  396. $img = 'bullet_red.png';
  397. break;
  398. case self::STATUS_INFORMATION :
  399. $img = 'bullet_blue.png';
  400. break;
  401. }
  402. $image = Display::return_icon($img, $status);
  403. $url = $this->get_link($title, $url);
  404. $formatted_current_value = $current_value;
  405. $formatted_expected_value = $expected_value;
  406. if ($formatter) {
  407. if (method_exists($this, 'format_'.$formatter)) {
  408. $formatted_current_value = call_user_func(array($this, 'format_'.$formatter), $current_value);
  409. $formatted_expected_value = call_user_func(array($this, 'format_'.$formatter), $expected_value);
  410. }
  411. }
  412. return array($image, $section, $url, $formatted_current_value, $formatted_expected_value, $comment);
  413. }
  414. /**
  415. * Create a link with a url and a title
  416. * @param $title
  417. * @param $url
  418. * @return string the url
  419. */
  420. public function get_link($title, $url)
  421. {
  422. return '<a href="'.$url.'" target="about:bank">'.$title.'</a>';
  423. }
  424. public function format_yes_no_optional($value)
  425. {
  426. $return = '';
  427. switch ($value) {
  428. case 0:
  429. $return = get_lang('No');
  430. break;
  431. case 1:
  432. $return = get_lang('Yes');
  433. break;
  434. case 2:
  435. $return = get_lang('Optional');
  436. break;
  437. }
  438. return $return;
  439. }
  440. function format_yes_no($value)
  441. {
  442. return $value ? get_lang('Yes') : get_lang('No');
  443. }
  444. function format_on_off($value)
  445. {
  446. $value = intval($value);
  447. if ($value > 1) {
  448. // Greater than 1 values are shown "as-is", they may be interpreted as "On" later.
  449. return $value;
  450. }
  451. // These are the values 'On' and 'Off' used in the php-ini file. Translation (get_lang()) is not needed here.
  452. return $value ? 'On' : 'Off';
  453. }
  454. }