Source for file config-test.php

Documentation is available at config-test.php

  1. <?php
  2. if (! exec ('which which'))
  3. {
  4. die("The 'which' utility cannot be found. It is required for configuration-testing. Aborting.");
  5. }
  6. ?>
  7. <html>
  8. <head><title>MidCOM Configuration Test</title></head>
  9. <body>
  10.  
  11. <h1>MidCOM Configuration Test</h1>
  12.  
  13. <p>This page test the MidCOM configuration for validity.</p>
  14.  
  15. <table border="1" cellspacing="0" cellpadding="3">
  16. <tr>
  17. <th>Test</th>
  18. <th>Result</th>
  19. <th>Recommendations</th>
  20. </tr>
  21. <?php
  22.  
  23. define('OK', 0);
  24. define('WARNING', 1);
  25. define('ERROR', 2);
  26.  
  27. function println($testname, $result_code, $recommendations = '&nbsp;')
  28. {
  29. echo " <tr>\n";
  30. echo " <td>{$testname}</td>\n";
  31. switch ($result_code)
  32. {
  33. case OK:
  34. echo " <td style='color: green;'>OK</td>\n";
  35. break;
  36. case WARNING:
  37. echo " <td style='color: orange;'>WARNING</td>\n";
  38. break;
  39. case ERROR:
  40. echo " <td style='color: red;'>ERROR</td>\n";
  41. break;
  42. default:
  43. die ("Unknown error code {$result_code}. Aborting.");
  44. }
  45. echo " <td>{$recommendations}</td>\n";
  46. echo " </tr>\n";
  47. }
  48.  
  49. function ini_get_filesize($setting)
  50. {
  51. $result = ini_get($setting);
  52. $last_char = substr($result, -1);
  53. if ($last_char == 'M')
  54. {
  55. $result = substr($result, 0, -1) * 1024 * 1024;
  56. }
  57. else if ($last_char == 'K')
  58. {
  59. $result = substr($result, 0, -1) * 1024;
  60. }
  61. else if ($last_char == 'G')
  62. {
  63. $result = substr($result, 0, -1) * 1024 * 1024 * 1024;
  64. }
  65. return $result;
  66. }
  67.  
  68. function ini_get_boolean($setting)
  69. {
  70. $result = ini_get($setting);
  71. if ($result == false || $result == "Off" || $result == "off" || $result == "" || $result == "0")
  72. {
  73. return false;
  74. }
  75. else
  76. {
  77. return true;
  78. }
  79. }
  80.  
  81. function check_for_include_file($filename)
  82. {
  83. return midcom_file_exists_incpath($filename);
  84. }
  85.  
  86. function println_check_for_include_file($filename, $testname, $fail_code, $fail_recommendations)
  87. {
  88. if (check_for_include_file($filename))
  89. {
  90. println($testname, OK);
  91. }
  92. else
  93. {
  94. println($testname, $fail_code, $fail_recommendations);
  95. }
  96. }
  97.  
  98. function check_for_utility ($name, $testname, $fail_code, $fail_recommendations)
  99. {
  100. $executable = $GLOBALS['midcom_config']["utility_{$name}"];
  101. $testname = "External Utility: {$testname}";
  102. if (is_null($executable))
  103. {
  104. println($testname, $fail_code, "The path to the utility {$name} is not configured. {$fail_recommendations}");
  105. }
  106. else
  107. {
  108. exec ("which {$executable}", $output, $exitcode);
  109. if ($exitcode == 0)
  110. {
  111. println($testname, OK);
  112. }
  113. else
  114. {
  115. println($testname, $fail_code, "The utility {$name} is not correctly configured: File ({$executable}) not found. {$fail_recommendations}");
  116. }
  117. }
  118. }
  119.  
  120. // Some helpers
  121. $i18n =& $GLOBALS['midcom']->get_service('i18n');
  122.  
  123. // Check the PHP Version and PHP_Compat availability
  124.  
  125. $version = phpversion();
  126. if (version_compare($version, '4.1.0', '<'))
  127. {
  128. println('PHP Version', ERROR, 'PHP 4.1.0 or greater is required for MidCOM, 4.3.0 or greater is recommended.');
  129. }
  130. else if (version_compare($version, '4.3.0', '<'))
  131. {
  132. println('PHP Version', WARNING, 'PHP 4.3.0 or greater is recommended for MidCOM.');
  133. println_check_for_include_file('PHP/Compat.php', 'PEAR Package: PHP_Compat',
  134. ERROR, 'The PEAR Package PHP_Compat is required for pre-4.3.0 installations.');
  135. }
  136. else
  137. {
  138. println('PHP Version', OK);
  139. }
  140.  
  141. // Available Memory for PHP
  142.  
  143. $cur_limit = ini_get_filesize('memory_limit');
  144. if ($cur_limit >= (20 * 1024 * 1024))
  145. {
  146. println('PHP Setting: memory_limit', OK);
  147. }
  148. else
  149. {
  150. println('PHP Setting: memory_limit', ERROR, "MidCOM requires a minimum memory limit of 20 MB to operate correctly. Smaller amounts will lead to PHP Errors. Detected limit was {$cur_limit}.");
  151. }
  152.  
  153. // Register Globals
  154. if (array_key_exists('midcom_site', $GLOBALS))
  155. {
  156. if (ini_get_boolean('register_globals'))
  157. {
  158. println('PHP Setting: register_globals', OK);
  159. }
  160. else
  161. {
  162. println('PHP Setting: register_globals', ERROR, 'register_globals is required for MidCOM-Template usage, which depends on NemeinAuthentication.');
  163. }
  164. }
  165. else
  166. {
  167. if (ini_get_boolean('register_globals'))
  168. {
  169. println('PHP Setting: register_globals', WARNING, 'register_globals is enabled, it is recommended to turn this off for security reasons (unless you rely on Nemein Authentication somewhere).');
  170. }
  171. else
  172. {
  173. println('PHP Setting: register_globals', OK);
  174. }
  175. }
  176.  
  177. // Upload File Size
  178. $upload_limit = ini_get_filesize('upload_max_filesize');
  179. if ($upload_limit >= (50 * 1024 * 1024))
  180. {
  181. println('PHP Setting: upload_max_filesize', OK);
  182. }
  183. else
  184. {
  185. println('PHP Setting: upload_max_filesize',
  186. WARNING, "To make bulk uploads (for exampe in the Image Gallery) useful, you should increase the Upload limit to something above 50 MB. (Current setting: {$upload_limit})");
  187. }
  188.  
  189. $post_limit = ini_get_filesize('post_max_size');
  190. if ($post_limit >= $upload_limit)
  191. {
  192. println('PHP Setting: post_max_size', OK);
  193. }
  194. else
  195. {
  196. println('PHP Setting: post_max_size', WARNING, 'post_max_size should be larger then upload_max_filesize, as both limits apply during uploads.');
  197. }
  198.  
  199. // Magic Quotes
  200. if (! ini_get_boolean('magic_quotes_gpc'))
  201. {
  202. println('PHP Setting: magic_quotes_gpc', OK);
  203. }
  204. else
  205. {
  206. println('PHP Setting: magic_quotes_gpc', ERROR, 'Magic Quotes must be turned off, Midgard/MidCOM does this explicitly where required.');
  207. }
  208. if (! ini_get_boolean('magic_quotes_runtime'))
  209. {
  210. println('PHP Setting: magic_quotes_runtime', OK);
  211. }
  212. else
  213. {
  214. println('PHP Setting: magic_quotes_runtime', ERROR, 'Magic Quotes must be turned off, Midgard/MidCOM does this explicitly where required.');
  215. }
  216.  
  217.  
  218. // iconv must be available.
  219. if (! function_exists('iconv'))
  220. {
  221. println('iconv', ERROR, 'The PHP iconv module is required for MidCOM operation.');
  222. }
  223. else
  224. {
  225. println('iconv', OK);
  226. }
  227.  
  228. // dba with db[234] is recommended.
  229.  
  230. if (! function_exists('dba_open'))
  231. {
  232. println('Simple Database functions (dbm-style abstraction)', ERROR,
  233. 'The dba module with support for BerkleyDB must be available for proper operation of the caching engine.');
  234. }
  235. else
  236. {
  237. if (! function_exists('dba_handlers'))
  238. {
  239. println('Simple Database functions (dbm-style abstraction)', WARNING,
  240. 'The dba module is available, but the available modules cannot be listed. Ensure that BerkleyDB is available and configure MidCOM accordingly.');
  241. }
  242. else
  243. {
  244. $handlers = dba_handlers();
  245. if ( in_array('db2', $handlers)
  246. || in_array('db3', $handlers)
  247. || in_array('db4', $handlers))
  248. {
  249. println('Simple Database functions (dbm-style abstraction)', OK);
  250. }
  251. else
  252. {
  253. $tmp = implode($handlers, ", ");
  254. println('Simple Database functions (dbm-style abstraction)', WARNING,
  255. "The dba module is available, but the BerkleyDB handlers are not supported. They are recommeded for their stability. Available handlers: {$tmp}");
  256. }
  257. }
  258. }
  259.  
  260. // Multibyte String Functions
  261.  
  262. if (! function_exists('mb_strlen'))
  263. {
  264. println('Multi-Byte String functions', ERROR, 'The Multi-Byte String functions are unavailable, they are required for MidCOM operation.');
  265. }
  266. else
  267. {
  268. if ($i18n->get_current_charset() == 'UTF-8')
  269. {
  270. $overload = ini_get('mbstring.func_overload');
  271. if ($overload != '7')
  272. {
  273. println('Multi-Byte String functions', WARNING, 'The Multi-Byte String functions are available, but this is an UTF-8 site and Function overloading is disabled, this is not recommended since string operations are erronous then.');
  274. }
  275. else
  276. {
  277. println('Multi-Byte String functions', OK);
  278. }
  279. }
  280. else
  281. {
  282. println('Multi-Byte String functions', OK);
  283. }
  284. }
  285.  
  286. // EXIF Reading
  287.  
  288. $have_jhead = ! is_null($GLOBALS['midcom_config']['utility_jhead']);
  289.  
  290. if (! function_exists('read_exif_data'))
  291. {
  292. if (! $have_jhead)
  293. {
  294. println('EXIF reader', WARNING, 'Neither PHP-EXIF nor JHead is available. They are required for proper operation of the Image Gallery components. PHP Exif is recommended for PHP 4.2+, JHEAD for older versions.');
  295. }
  296. else
  297. {
  298. if (version_compare($version, '4.2.0', '<'))
  299. {
  300. println('EXIF reader', OK);
  301. check_for_utility('jhead', 'jhead', ERROR, 'JHead is required to read the EXIF information from images.');
  302. }
  303. else
  304. {
  305. println('EXIF reader', WARNING, 'PHP-EXIF is unavailable, but JHead was found. For PHP 4.2+ PHP Exif is the recommended way of processing EXIF information due to JHeads limited Featureset.');
  306. check_for_utility('jhead', 'jhead', ERROR, 'JHead is required to read the EXIF information from images.');
  307. }
  308. }
  309. }
  310. else
  311. {
  312. if (version_compare($version, '4.2.0', '<'))
  313. {
  314. if (! $have_jhead)
  315. {
  316. println('EXIF reader', WARNING, 'PHP EXIF is available, but on a pre 4.2 installations. This may cause segfaults. You should either upgrade PHP or install JHead.');
  317. }
  318. else
  319. {
  320. println('EXIF reader', WARNING, 'PHP EXIF is available, but on a pre 4.2 installations. This may cause segfaults. JHead can be used instead, but with a reduced feature set.');
  321. check_for_utility('jhead', 'jhead', ERROR, 'JHead is required to read the EXIF information from images.');
  322. }
  323. }
  324. else
  325. {
  326. println('EXIF reader', OK);
  327. }
  328. }
  329.  
  330. // Mail and Mail_Mime PEAR packages for the Mailtemplate interface
  331. println_check_for_include_file('Mail.php', 'PEAR Package: Mail',
  332. WARNING, 'The Mail package is required to use the Mailtemplate system used by various components with auto-mailing support (like n.n.orders).');
  333. println_check_for_include_file('Mail/mime.php', 'PEAR Package: Mail_Mime',
  334. WARNING, 'The Mail_Mime package is required to use the Mailtemplate system used by various components with auto-mailing support (like n.n.orders).');
  335.  
  336. // HTML_Quickform for Datamanager validation support
  337. println_check_for_include_file('HTML/QuickForm/RuleRegistry.php', 'PEAR Package: HTML_QuickForm',
  338. WARNING, 'The HTML_QuickForm pacakge is required for the Datamanger Form Validation code. If you use more then is_empty checks you should install it.');
  339.  
  340. // HTML_Treemenu
  341. println_check_for_include_file('HTML/TreeMenu.php', 'PEAR Package: HTML_TreeMenu',
  342. WARNING, 'The HTML_TreeMenu package is required for the JS TreeMenu Navigation in AIS (disabled by default). You have to install it if you want to use the new navigation.');
  343.  
  344. // ImageMagick
  345. $cmd = "{$GLOBALS['midcom_config']['utility_imagemagick_base']}identify -version";
  346. exec ($cmd, $output, $result);
  347. if ($result != 0)
  348. {
  349. println('External Utility: ImageMagick', ERROR, 'The existance ImageMagick toolkit could not be verified, it is required for all kinds of image processing in MidCOM.');
  350. }
  351. else
  352. {
  353. println('External Utility: ImageMagick', OK);
  354. }
  355.  
  356. // Other utilities
  357. check_for_utility('find', 'find', WARNING, 'The find utility is required for bulk upload processing in the image galleries, you should install it if you plan to deploy Image Galleries.');
  358. check_for_utility('file', 'file', ERROR, 'The file utility is required for all kindes of Mime-Type identifications. You have to install it for proper MidCOM operations.');
  359. check_for_utility('unzip', 'unzip', WARNING, 'The unzip utility is required for bulk upload processing in the image galleries, you should install it if you plan to deploy Image Galleries.');
  360. check_for_utility('tar', 'tar', WARNING, 'The tar utility is required for bulk upload processing in the image galleries, you should install it if you plan to deploy Image Galleries.');
  361. check_for_utility('gzip', 'gzip', WARNING, 'The gzip utility is required for bulk upload processing in the image galleries, you should install it if you plan to deploy Image Galleries.');
  362. check_for_utility('jpegtran', 'jpegtran', WARNING, 'The jpegtran utility is used for lossless JPEG operations, even though ImageMagick can do the same conversions, the lossless features provided by this utility are used where appropriate, so its installation is strongly recommended.');
  363. if ($GLOBALS['midcom_config']['indexer_backend'])
  364. {
  365. check_for_utility('catdoc', 'catdoc', ERROR, 'Catdoc is required to properly index Microsoft Word documents. It is strongly recommended to install it, otherwise Word documents will be indexed as binary files.');
  366. check_for_utility('pdftotext', 'pdftotext', ERROR, 'pdftotext is required to properly index Adobe PDF documents. It is strongly recommended to install it, otherwise PDF documents will be indexed as binary files.');
  367. check_for_utility('unrtf', 'unrtf', ERROR, 'unrtf is required to properly index Rich Text Format documents. It is strongly recommended to install it, otherwise RTF documents will be indexed as binary files.');
  368. }
  369.  
  370. // Validate the Cache Base Directory.
  371. if (! is_dir($GLOBALS['midcom_config']['cache_base_directory']))
  372. {
  373. println('MidCOM cache base directory', ERROR, "The configured MidCOM cache base directory ({$GLOBALS['midcom_config']['cache_base_directory']}) does not exist or is not a directory. You have to create it as a directory writable by the Apache user.");
  374. }
  375. else if (! is_writable($GLOBALS['midcom_config']['cache_base_directory']))
  376. {
  377. println('MidCOM cache base directory', ERROR, "The configured MidCOM cache base directory ({$GLOBALS['midcom_config']['cache_base_directory']}) is not writable by the Apache user. You have to create it as a directory writable by the Apache user.");
  378. }
  379. else
  380. {
  381. println('MidCOM cache base directory', OK);
  382. }
  383.  
  384.  
  385. ?>
  386. </table>
  387. </body>

Documentation generated on Mon, 21 Nov 2005 18:12:42 +0100 by phpDocumentor 1.3.0RC3