EPESI BIM • Business Information Manager • Cloud CRM/ERP http://epe.si/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

check.php 9.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. <?php
  2. /**
  3. * EPESI Compatibility check.
  4. * @author Arkadiusz Bisaga <abisaga@telaxus.com>
  5. * @version 1.0
  6. * @copyright Copyright &copy; 2007, Telaxus LLC
  7. * @license MIT
  8. * @package epesi-base
  9. */
  10. $fullscreen = !defined("_VALID_ACCESS");
  11. !$fullscreen || define("_VALID_ACCESS", true);
  12. define('CID', false);
  13. require_once('include/data_dir.php');
  14. $config = file_exists(DATA_DIR . '/config.php');
  15. if ($config) {
  16. include_once('include.php');
  17. ModuleManager::load_modules();
  18. }
  19. if ($config && class_exists('Base_AclCommon')) {
  20. if (Base_AclCommon::i_am_user()) {
  21. if (!Base_AclCommon::i_am_sa()) {
  22. die('Only super admin can access this page');
  23. }
  24. } else {
  25. $auth = SimpleLogin::form();
  26. if ($auth) {
  27. print($auth);
  28. die();
  29. }
  30. }
  31. }
  32. if (class_exists('Base_LangCommon'))
  33. Base_LangCommon::update_translations();
  34. if (class_exists('Base_ThemeCommon'))
  35. Base_ThemeCommon::create_cache();
  36. if (class_exists('ModuleManager'))
  37. ModuleManager::create_load_priority_array();
  38. $html = '';
  39. $checks = array();
  40. // checking:
  41. // DB - creating tables, selects, locking tables
  42. // Strict Standards
  43. // error display
  44. // file_get_contents() [function.file-get-contents]: URL file-access is disabled in the server configuration
  45. // memory check
  46. // max_execution_time setting (safe mode)
  47. // upload_max_filesize
  48. // Libs: ZIP, curl
  49. // ********************* DATABASE ***********************
  50. if ($config) {
  51. ob_start();
  52. $exists = @DB::GetOne('SELECT 1 FROM modules WHERE NOT EXISTS (SELECT 1 FROM test WHERE 1=2)');
  53. if (!$exists) {
  54. $create = @DB::CreateTable('test', 'id I4 AUTO KEY', array('constraints'=>''));
  55. $alter = @DB::Execute('ALTER TABLE test ADD COLUMN field_name INTEGER');
  56. } else $alter = $create = null;
  57. $insert = @DB::Execute('INSERT INTO test (id) VALUES (1)');
  58. $update = @DB::Execute('UPDATE test SET id=1 WHERE id=1');
  59. if(DB::is_mysql()) {
  60. $lock = DB::GetOne('SELECT GET_LOCK(%s,%d)',array('test',ini_get('max_execution_time')));
  61. $lock &= !DB::GetOne('SELECT IS_FREE_LOCK(%s)',array('test'));
  62. $end_lock = DB::GetOne('SELECT RELEASE_LOCK(%s)',array('test'));
  63. }
  64. $delete = @DB::Execute('DELETE FROM test');
  65. $drop = @DB::DropTable('test');
  66. ob_end_clean();
  67. $db_tests = array();
  68. if ($create===null)
  69. $db_tests[] = array('label'=>'CREATE permission', 'status'=>'Unknown', 'severity'=>1);
  70. else
  71. $db_tests[] = array('label'=>'CREATE permission', 'status'=>$create?'OK':'Failed', 'severity'=>$create?0:2);
  72. if ($alter===null)
  73. $db_tests[] = array('label'=>'ALTER permission', 'status'=>'Unknown', 'severity'=>1);
  74. else
  75. $db_tests[] = array('label'=>'ALTER permission', 'status'=>$alter?'OK':'Failed', 'severity'=>$alter?0:2);
  76. $db_tests[] = array('label'=>'INSERT permission', 'status'=>$insert?'OK':'Failed', 'severity'=>$insert?0:2);
  77. $db_tests[] = array('label'=>'UPDATE permission', 'status'=>$update?'OK':'Failed', 'severity'=>$update?0:2);
  78. if(DB::is_mysql())
  79. $db_tests[] = array('label'=>'LOCK permission', 'status'=>$lock?'OK':'Failed', 'severity'=>$lock?0:2);
  80. $db_tests[] = array('label'=>'DELETE permission', 'status'=>$delete?'OK':'Failed', 'severity'=>$delete?0:2);
  81. $db_tests[] = array('label'=>'DROP permission', 'status'=>$drop?'OK':'Failed', 'severity'=>$drop?0:2);
  82. $checks[] = array('label'=>'Database permissions', 'tests'=>$db_tests, 'solution'=>'http://forum.epesibim.com');
  83. } else {
  84. }
  85. // ********************* DATABASE ***********************
  86. // ********************* SYSTEM ***********************
  87. $system_tests = array();
  88. $php_version = phpversion();
  89. $desired_version = '5.4';
  90. $php_version_ok = version_compare($php_version, $desired_version, '>=');
  91. $status = $php_version_ok ? $php_version : $php_version . ' - EPESI requires at least ' . $desired_version;
  92. $system_tests[] = array('label' => 'PHP version', 'status' => $status, 'severity' => $php_version_ok ? 0 : 2);
  93. $checks[] = array('label' => 'System', 'tests' => $system_tests, 'solution' => 'http://forum.epesibim.com');
  94. // ********************* SYSTEM ***********************
  95. // ********************* ERRORS ***********************
  96. $err = error_reporting();
  97. $strict = (($err | E_STRICT) == $err);
  98. $display = ini_get('display_errors');
  99. $error_tests = array();
  100. $error_tests[] = array('label'=>'Strict errors reporting', 'status'=>!$strict?'Disabled':'Enabled', 'severity'=>!$strict?0:2);
  101. $error_tests[] = array('label'=>'Error display', 'status'=>$display?'On':'Off', 'severity'=>$display?0:1);
  102. $checks[] = array('label'=>'Error reporting', 'tests'=>$error_tests, 'solution'=>'http://forum.epesibim.com');
  103. // ********************* ERRORS ***********************
  104. // ********************* EXECUTION SETTINGS ***********************
  105. $mem = ini_get('memory_limit');
  106. if (strpos($mem, 'M')===false) $mem_s = 2;
  107. else {
  108. $mem = str_replace('M', '', $mem);
  109. if ($mem<32) $mem_s = 2;
  110. elseif ($mem==32) $mem_s = 1;
  111. else $mem_s = 0;
  112. $mem .= ' MB';
  113. }
  114. $upload_size = ini_get('upload_max_filesize');
  115. if (strpos($upload_size, 'M')===false) $upload_size_s = 2;
  116. else {
  117. $upload_size = str_replace('M', '', $upload_size);
  118. if ($upload_size<8) $upload_size_s = 2;
  119. elseif ($upload_size==8) $upload_size_s = 1;
  120. else $upload_size_s = 0;
  121. $upload_size .= ' MB';
  122. }
  123. $post_size = ini_get('post_max_size');
  124. if (strpos($post_size, 'M')===false) $post_size_s = 2;
  125. else {
  126. $post_size = str_replace('M', '', $post_size);
  127. if ($post_size<16) $post_size_s = 2;
  128. elseif ($post_size==16) $post_size_s = 1;
  129. else $post_size_s = 0;
  130. $post_size .= ' MB';
  131. }
  132. if (version_compare(PHP_VERSION, '5.4') >= 0)
  133. $safe_mode = false;
  134. else
  135. $safe_mode = ini_get('safe_mode');
  136. $lang_code = 'pl';
  137. setlocale(LC_ALL,$lang_code.'_'.strtoupper($lang_code).'.utf8',
  138. $lang_code.'_'.strtoupper($lang_code).'.UTF-8',
  139. $lang_code.'.utf8',
  140. $lang_code.'.UTF-8','polish');
  141. setlocale(LC_NUMERIC,'en_EN.utf8','en_EN.UTF-8','en_US.utf8','en_US.UTF-8','C','POSIX','en_EN','en_US','en','en.utf8','en.UTF-8','english');
  142. $str = print_r(1.1,true);
  143. if (strpos($str,'.') === false) {
  144. $loc = 'ERROR';
  145. $loc_s = 1;
  146. } else {
  147. $loc = 'OK';
  148. $loc_s = 0;
  149. }
  150. if (extension_loaded('openssl')) {
  151. $ssl = 'OK';
  152. $ssl_s = 0;
  153. } else {
  154. $ssl = "ERROR";
  155. $ssl_s = 1;
  156. }
  157. $tests = array();
  158. $tests[] = array('label'=>'Safe mode', 'status'=>!$safe_mode?'Disabled':'Enabled', 'severity'=>!$safe_mode?0:2);
  159. $tests[] = array('label'=>'Memory limit', 'status'=>$mem, 'severity'=>$mem_s);
  160. $tests[] = array('label'=>'Upload file size', 'status'=>$upload_size, 'severity'=>$upload_size_s);
  161. $tests[] = array('label'=>'POST max size', 'status'=>$post_size, 'severity'=>$post_size_s);
  162. $tests[] = array('label'=>'Locale settings', 'status'=>$loc, 'severity'=>$loc_s);
  163. $tests[] = array('label'=>'SSL enabled', 'status'=>$ssl, 'severity'=>$ssl_s);
  164. $checks[] = array('label'=>'Script execution', 'tests'=>$tests, 'solution'=>'http://forum.epesibim.com');
  165. // ********************* EXECUTION SETTINGS ***********************
  166. // ********************* FEATURES ***********************
  167. $zip = class_exists('ZipArchive');
  168. $curl = extension_loaded('curl');
  169. $remote_fgc = ini_get('allow_url_fopen');
  170. $modules_writable = is_writable('modules');
  171. $imagegd = function_exists('imagecreatefromjpeg');
  172. $error_tests = array();
  173. $error_tests[] = array('label'=>'Remote file_get_contents()', 'status'=>$remote_fgc?'Enabled':'Disabled', 'severity'=>$remote_fgc?0:2);
  174. $error_tests[] = array('label'=>'ZIPArchive library loaded', 'status'=>$zip?'Loaded':'Not found', 'severity'=>$zip?0:2);
  175. $error_tests[] = array('label'=>'cURL library loaded', 'status'=>$curl?'Loaded':'Not found', 'severity'=>$curl?0:1);
  176. $error_tests[] = array('label'=>'Modules directory writable', 'status'=>$modules_writable?'Yes':'No', 'severity'=>$modules_writable?0:1);
  177. $error_tests[] = array('label'=>'PHP GD extension - image processing', 'status'=>$imagegd?'Yes':'No', 'severity'=>$imagegd?0:2);
  178. $checks[] = array('label'=>'Features', 'tests'=>$error_tests, 'solution'=>'http://forum.epesibim.com');
  179. // ********************* FEATURES ***********************
  180. foreach ($checks as $c) {
  181. $html .= '<strong>'.$c['label'].'</strong><br>';
  182. $solution = false;
  183. foreach ($c['tests'] as $t) {
  184. switch ($t['severity']) {
  185. case 0: $color = '#00CC00'; break;
  186. case 1: $color = '#CCAA00'; $solution = true; break;
  187. case 2: $color = 'red'; $solution = true; break;
  188. }
  189. $html .= '<span style="font-weight:bold;float:right;margin-right:100px;color:'.$color.'">'.$t['status'].'</span>';
  190. $html .= '<span style="margin-left:40px;">'.$t['label'].'</span>';
  191. $html .= '<br>';
  192. }
  193. if ($solution) {
  194. //$html .= 'Solution available here: <a target="_blank" href="'.$c['solution'].'">'.$c['solution'].'</a>';
  195. //$html .= '<br>';
  196. }
  197. $html .= '<br>';
  198. }
  199. $html .= '<br><br>';
  200. $html .= '<font size=-2>';
  201. $html .= 'Legend:<br>';
  202. $html .= '<span style="color:#00CC00;">Green</span> - matches EPESI requirements<br>';
  203. $html .= '<span style="color:#CCAA00;">Yellow</span> - shouldn\'t prevent EPESI from running, but it\'s recommended to change the settings<br>';
  204. $html .= '<span style="color:red;">Red</span> - check failed, it\'s necessary to change the settings<br>';
  205. $html .= '</font>';
  206. if ($fullscreen) {
  207. if (class_exists('Utils_FrontPageCommon'))
  208. Utils_FrontPageCommon::display('EPESI Compatibility check', $html);
  209. else
  210. print('<div style="width:600px;margin:0 auto;">'.$html.'</div>');
  211. } else {
  212. print($html);
  213. }
  214. ?>