PageRenderTime 46ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/installer/checkSystem.php

https://bitbucket.org/wildanm/orangehrm
PHP | 298 lines | 237 code | 43 blank | 18 comment | 39 complexity | 54d7eb212f88d4b950063b3a8ede1266 MD5 | raw file
Possible License(s): CC-BY-SA-3.0, AGPL-3.0, BSD-3-Clause, AGPL-1.0, GPL-2.0, LGPL-2.1, LGPL-3.0
  1. <?php
  2. /**
  3. * OrangeHRM is a comprehensive Human Resource Management (HRM) System that captures
  4. * all the essential functionalities required for any enterprise.
  5. * Copyright (C) 2006 OrangeHRM Inc., http://www.orangehrm.com
  6. *
  7. * OrangeHRM is free software; you can redistribute it and/or modify it under the terms of
  8. * the GNU General Public License as published by the Free Software Foundation; either
  9. * version 2 of the License, or (at your option) any later version.
  10. *
  11. * OrangeHRM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  12. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License along with this program;
  16. * if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  17. * Boston, MA 02110-1301, USA
  18. *
  19. */
  20. require(ROOT_PATH . '/lib/utils/installUtil.php');
  21. function checkMemory() {
  22. $limit = 9;
  23. $recommended = 16;
  24. $maxMemory = null;
  25. $msg = '';
  26. $cssClass = '';
  27. $result = checkPHPMemory($limit, $recommended, $maxMemory);
  28. switch ($result) {
  29. case INSTALLUTIL_MEMORY_NO_LIMIT:
  30. $msg = "OK (No Limit)";
  31. $cssClass = "done";
  32. break;
  33. case INSTALLUTIL_MEMORY_UNLIMITED:
  34. $msg = "OK (Unlimited)";
  35. $cssClass = "done";
  36. break;
  37. case INSTALLUTIL_MEMORY_HARD_LIMIT_FAIL:
  38. $msg = "Warning at least ${limit}M required (${maxMemory} available, Recommended ${recommended}M)";
  39. $cssClass = "error";
  40. break;
  41. case INSTALLUTIL_MEMORY_SOFT_LIMIT_FAIL:
  42. $msg = "OK (Recommended ${recommended}M)";
  43. $cssClass = "pending";
  44. break;
  45. case INSTALLUTIL_MEMORY_OK:
  46. $msg = "OK";
  47. $cssClass = "done";
  48. break;
  49. }
  50. $msg = "<b class='$cssClass'>".$msg."</b>";
  51. return $msg;
  52. }
  53. ?>
  54. <script language="JavaScript">
  55. function sysCheckPassed() {
  56. document.frmInstall.actionResponse.value = 'SYSCHECKOK';
  57. document.frmInstall.submit();
  58. }
  59. </script>
  60. <link href="style.css" rel="stylesheet" type="text/css" />
  61. <div id="content">
  62. <h2>Step 3: System Check</h2>
  63. <p>In order for your OrangeHRM installation to function properly,
  64. please ensure that all of the system check items listed below are green. If
  65. any are red, please take the necessary steps to fix them.</p>
  66. <table cellpadding="0" cellspacing="0" border="0" class="table">
  67. <tr>
  68. <th align="left" class="th">Component</th>
  69. <th class="th" style="text-align: right;">Status</th>
  70. </tr>
  71. <tr>
  72. <td class="tdComponent">PHP version</td>
  73. <td align="right" class="tdValues"><strong>
  74. <?php
  75. $error_found = false;
  76. $minVersion = '5.1.2';
  77. $supportedVersions = array (
  78. '5.0.1', '5.0.2', '5.0.3', '5.0.4',
  79. '5.1.0', '5.1.1', '5.1.2', '5.1.3',
  80. '5.1.4', '5.1.5', '5.1.6', '5.1.7',
  81. '5.2.0', '5.2.1', '5.2.2'
  82. );
  83. $invalidVersions = array('5.0.0', '5.0.5');
  84. $php_version = constant('PHP_VERSION');
  85. $check_php_version_result = checkPHPVersion($minVersion, $supportedVersions, $invalidVersions, $php_version);
  86. switch($check_php_version_result)
  87. {
  88. case INSTALLUTIL_VERSION_INVALID:
  89. echo "<b><font color='red'>Invalid version, ($php_version) Installed</font></b>";
  90. $error_found = true;
  91. break;
  92. case INSTALLUTIL_VERSION_UNSUPPORTED:
  93. echo "<b><font color='red'>Unsupported (ver $php_version)</font></b>";
  94. break;
  95. case INSTALLUTIL_VERSION_SUPPORTED:
  96. echo "<b><font color='green'>OK (ver $php_version)</font></b>";
  97. break;
  98. }
  99. ?>
  100. </strong></td>
  101. </tr>
  102. <tr>
  103. <td class="tdComponent">MySQL Client</td>
  104. <td align="right" class="tdValues"><strong>
  105. <?php
  106. if(function_exists('mysql_connect')) {
  107. $mysqlClient = mysql_get_client_info();
  108. if(intval(substr($mysqlClient,0,1)) < 4 || substr($mysqlClient,0,3) == '4.0') {
  109. echo "<b><font color='#C4C781'>ver 4.1.x or later recommended (reported ver " .$mysqlClient. ')</font></b>';
  110. } else echo "<b><font color='green'>OK (ver " .$mysqlClient. ')</font></b>';
  111. } else {
  112. echo "<b><font color='red'>MySQL support not available in PHP settings</font></b>";
  113. $error_found = true;
  114. }
  115. ?>
  116. </strong></td>
  117. </tr>
  118. <tr>
  119. <td class="tdComponent">MySQL Server</td>
  120. <td align="right" class="tdValues"><strong>
  121. <?php
  122. $dbInfo = $_SESSION['dbInfo'];
  123. if(function_exists('mysql_connect') && (@mysql_connect($dbInfo['dbHostName'].':'.$dbInfo['dbHostPort'], $dbInfo['dbUserName'], $dbInfo['dbPassword']))) {
  124. $mysqlServer = mysql_get_server_info();
  125. if(version_compare($mysqlServer, "5.0.12") >= 0) {
  126. echo "<b><font color='green'>OK (ver " .$mysqlServer. ')</font></b>';
  127. } else {
  128. echo "<b><font color='#C4C781'>ver 5.0.12 or later recommended (reported ver " .$mysqlServer. ')</font></b>';
  129. }
  130. } else {
  131. echo "<b><font color='red'>Not Available</font></b>";
  132. $error_found = true;
  133. }
  134. ?>
  135. </strong></td>
  136. </tr>
  137. <tr>
  138. <td class="tdComponent">MySQL InnoDB Support</td>
  139. <td align="right" class="tdValues"><strong>
  140. <?php
  141. if(function_exists('mysql_connect') && (@mysql_connect($dbInfo['dbHostName'].':'.$dbInfo['dbHostPort'], $dbInfo['dbUserName'], $dbInfo['dbPassword']))) {
  142. $mysqlServer = mysql_query("show engines");
  143. while ($engines = mysql_fetch_assoc($mysqlServer)) {
  144. if ($engines['Engine'] == 'InnoDB') {
  145. if ($engines['Support'] == 'DISABLED') {
  146. echo "<b><font color='red'>Disabled!</font></b>";
  147. $error_found = true;
  148. } elseif ($engines['Support'] == 'DEFAULT') {
  149. echo "<b><font color='green'>Default</font></b>";
  150. } elseif ($engines['Support'] == 'YES') {
  151. echo "<b><font color='green'>Enabled</font></b>";
  152. } elseif ($engines['Support'] == 'NO') {
  153. echo "<b><font color='red'>Not available!</font></b>";
  154. $error_found = true;
  155. } else {
  156. echo "<b><font color='red'>Unknown Error!</font></b>";
  157. $error_found = true;
  158. }
  159. }
  160. }
  161. } else {
  162. echo "<b><font color='red'>Cannot connect to the database</font></b>";
  163. $error_found = true;
  164. }
  165. ?>
  166. </strong></td>
  167. </tr>
  168. <tr>
  169. <td class="tdComponent">OrangeHRM Configuration File Writable (lib/confs)</td>
  170. <td align="right" class="tdValues"><strong>
  171. <?php
  172. if(is_writable(ROOT_PATH . '/lib/confs')) {
  173. echo "<b><font color='green'>OK</font></b>";
  174. } else {
  175. echo "<b><font color='red'>Not Writeable</font>";
  176. echo "<b><font color='red'><sup>*</sup></font></b>";
  177. $error_found = true;
  178. }
  179. ?>
  180. </strong></td>
  181. </tr>
  182. <tr>
  183. <td class="tdComponent">OrangeHRM Email Log File Writable (lib/logs)</td>
  184. <td align="right" class="tdValues"><strong>
  185. <?php
  186. if(is_writable(ROOT_PATH . '/lib/logs')) {
  187. echo "<b><font color='green'>OK</font></b>";
  188. } else {
  189. echo "<b><font color='red'>Not Writeable</font>";
  190. echo "<b><font color='red'><sup>*</sup></font></b>";
  191. $error_found = true;
  192. }
  193. ?>
  194. </strong></td>
  195. </tr>
  196. <tr>
  197. <td class="tdComponent">Maximum Session Idle Time before Timeout</td>
  198. <td align="right" class="tdValues"><strong>
  199. <?php
  200. $gc_maxlifetime_min = floor(ini_get("session.gc_maxlifetime")/60);
  201. $gc_maxlifetime_sec = ini_get("session.gc_maxlifetime") % 60;
  202. if ($gc_maxlifetime_min > 15) {
  203. echo "<b><font color='green'>OK</font></b>";
  204. } else if ($gc_maxlifetime_min > 2){
  205. echo "<b><font color='#C4C781'>Short ($gc_maxlifetime_min minutes and $gc_maxlifetime_sec seconds)</font></b>";
  206. } else {
  207. echo "<b><font color='red'>Too short ($gc_maxlifetime_min minutes and $gc_maxlifetime_sec seconds)</font></b>";
  208. $error_found = true;
  209. }
  210. ?>
  211. </strong></td>
  212. </tr>
  213. <tr>
  214. <td class="tdComponent">Register Globals turned-off</td>
  215. <td align="right" class="tdValues"><strong>
  216. <?php
  217. $registerGlobalsValue = (bool) ini_get("register_globals");
  218. if ($registerGlobalsValue) {
  219. echo "<font color='red'>On <sup>#</sup></font>";
  220. $error_found = true;
  221. } else {
  222. echo "<font color='green'>OK</font>";
  223. }
  224. ?>
  225. </strong></td>
  226. </tr>
  227. <tr>
  228. <td class="tdComponent">Memory allocated for PHP script</td>
  229. <td align="right" class="tdValues"><?php echo checkMemory()?></td>
  230. </tr>
  231. <?php
  232. $printMoreInfoLink = false;
  233. if(!(is_writable(ROOT_PATH . '/lib/confs'))){
  234. echo "<tr> <td colspan='2'> ";
  235. echo "<font color='red'>* Web server requires write privilege to the following directory</font> ";
  236. print_r(ROOT_PATH .'/lib/confs');
  237. echo "</td> </tr>";
  238. $printMoreInfoLink = true;
  239. }
  240. if ($registerGlobalsValue) {
  241. echo "<tr> <td colspan='2'> ";
  242. echo "<font color='red'><sup>#</sup> The value of <strong>register_globals</strong> should be <strong>Off</strong> in php.ini file</font> ";
  243. echo "</td> </tr>";
  244. $printMoreInfoLink = true;
  245. }
  246. if ($printMoreInfoLink) {
  247. print ' <a href="./guide/#systemChk" id="help" target="_blank">[ For More Information ?]</a>';
  248. }
  249. ?>
  250. </table>
  251. <br />
  252. <input class="button" type="button" value="Back" onclick="back();" tabindex="4">
  253. <input class="button" type="button" name="Re-check" value="Re-check" onclick="document.frmInstall.submit();" tabindex="3">
  254. <input class="button" type="button" value="Next" onclick="sysCheckPassed();" <?php echo ($error_found) ? 'disabled' : '' ?> tabindex="2">
  255. </div>