2 // +----------------------------------------------------------------------+
3 // | Anuko Time Tracker
4 // +----------------------------------------------------------------------+
5 // | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
6 // +----------------------------------------------------------------------+
7 // | LIBERAL FREEWARE LICENSE: This source code document may be used
8 // | by anyone for any purpose, and freely redistributed alone or in
9 // | combination with other software, provided that the license is obeyed.
11 // | There are only two ways to violate the license:
13 // | 1. To redistribute this code in source form, with the copyright
14 // | notice or license removed or altered. (Distributing in compiled
15 // | forms without embedded copyright notices is permitted).
17 // | 2. To redistribute modified versions of this code in *any* form
18 // | that bears insufficient indications that the modifications are
19 // | not the work of the original author(s).
21 // | This license applies to this document only, not any other software
22 // | that it may be combined with.
24 // +----------------------------------------------------------------------+
26 // | https://www.anuko.com/time_tracker/credits.htm
27 // +----------------------------------------------------------------------+
29 require_once('WEB-INF/config.php');
30 require_once('WEB-INF/lib/common.lib.php');
31 require_once('initialize.php');
33 echo('<h2>Environment check</h2>');
35 // Require the configuration file with application settings.
36 if (file_exists(APP_DIR."/WEB-INF/config.php")) {
37 echo('WEB-INF/config.php file exists.<br>');
39 echo('<font color="red">Error: WEB-INF/config.php file does not exist.</font><br>');
42 // Check whether DSN is defined.
44 echo('DSN is defined as '.DSN.'<br>');
46 echo('<font color="red">Error: DSN value is not defined. Check your config.php file.</font><br>');
49 // Depending on DSN, require either mysqli or mysql extensions.
50 if (strrpos(DSN, 'mysqli://', -strlen(DSN)) !== FALSE) {
51 if (extension_loaded('mysqli')) {
52 echo('mysqli PHP extension is loaded.<br>');
54 echo('<font color="red">Error: mysqli PHP extension is required but is not loaded.</font><br>');
57 if (strrpos(DSN, 'mysql://', -strlen(DSN)) !== FALSE) {
58 if (extension_loaded('mysql')) {
59 echo('mysql PHP extension is loaded.<br>');
61 echo('<font color="red">Error: mysql PHP extension is required but is not loaded.</font><br>');
65 // Check mbstring extension.
66 if (extension_loaded('mbstring')) {
67 echo('mbstring PHP extension is loaded.<br>');
69 echo('<font color="red">Error: mbstring PHP extension is not loaded.</font><br>');
72 // Check gd extension.
73 if (extension_loaded('gd')) {
74 echo('gd PHP extension is loaded.<br>');
76 echo('<font color="red">Error: gd PHP extension is not loaded. It is required for charts plugin.</font><br>');
79 // Check ldap extension.
80 if (AUTH_MODULE == 'ldap') {
81 if (extension_loaded('ldap_')) {
82 echo('ldap PHP extension is loaded.<br>');
84 echo('<font color="red">Error: ldap PHP extension is not loaded. It is required for LDAP authentication.</font><br>');
88 // Check database access.
89 require_once('MDB2.php');
90 $conn = MDB2::connect(DSN);
91 if (!is_a($conn, 'MDB2_Error')) {
92 echo('Connection to database successful.<br>');
94 die('<font color="red">Error: connection to database failed. '.$conn->getMessage().'</font><br>');
97 $conn->setOption('debug', true);
98 $conn->setFetchMode(MDB2_FETCHMODE_ASSOC);
100 $sql = "show tables";
101 $res = $conn->query($sql);
102 if (is_a($res, 'MDB2_Error')) {
103 die('<font color="red">Error: show tables returned an error. '.$res->getMessage().'</font><br>');
106 while ($val = $res->fetchRow()) {
110 echo("There are $tblCnt tables in database.<br>");
112 echo('<font color="red">Error: there are no tables in database. Use dbinstall.php.</font><br>');