Issues (1098)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/diag/index.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
//------------------------------------------------------------------------------
4
//
5
//  eTraxis - Records tracking web-based system
6
//  Copyright (C) 2009-2011  Artem Rodygin
7
//
8
//  This program is free software: you can redistribute it and/or modify
9
//  it under the terms of the GNU General Public License as published by
10
//  the Free Software Foundation, either version 3 of the License, or
11
//  (at your option) any later version.
12
//
13
//  This program is distributed in the hope that it will be useful,
14
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
//  GNU General Public License for more details.
17
//
18
//  You should have received a copy of the GNU General Public License
19
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//------------------------------------------------------------------------------
22
23
/**
24
 * @package eTraxis
25
 * @ignore
26
 */
27
28
/**#@+
29
 * Dependency.
30
 */
31
require_once('../config.php');
32
/**#@-*/
33
34
define('PHP_V4',       4);
35
define('PHP_V5',       5);
36
define('PHP_V6',       6);
37
define('PHP_OBSOLETE', 0);
38
39
define('PHP4_MINIMUM', '4.3.2');
40
define('PHP5_MINIMUM', '5.1.0');
41
42
define('DRIVER_MYSQL50', 1);  // MySQL 5.0 or later
43
define('DRIVER_MSSQL2K', 2);  // Microsoft SQL Server 2000 or later
44
define('DRIVER_ORACLE9', 3);  // Oracle 9i or later
45
define('DRIVER_PGSQL80', 4);  // PostgreSQL 8.0 or later
46
47
if (version_compare(PHP_VERSION, '6.0.0') >= 0)
48
{
49
    $php_version = PHP_V6;
50
}
51
elseif (version_compare(PHP_VERSION, '5.0.0') >= 0)
52
{
53
    $php_version = PHP_V5;
54
}
55
elseif (version_compare(PHP_VERSION, '4.0.0') >= 0)
56
{
57
    $php_version = PHP_V4;
58
}
59
else
60
{
61
    $php_version = PHP_OBSOLETE;
62
}
63
64
// Disable PHP execution timeout.
65
if (!ini_get('safe_mode'))
66
{
67
    set_time_limit(0);
68
}
69
70
?>
71
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
72
<meta name="author" content="Artem Rodygin"/>
73
<meta name="copyright" content="Copyright (C) 2003-2010 by Artem Rodygin"/>
74
<link rel="shortcut icon" type="image/x-icon" href="../favicon.ico"/>
75
<link rel="stylesheet" type="text/css" href="../themes/Emerald/css/etraxis.css"/>
76
<title>eTraxis</title>
77
<body style="margin:10px">
78
<!-- General information ------------------------------------------------------>
79
<fieldset>
80
<legend>General information</legend>
81
<table class="form"><tr>
82
<td class="label">Server OS:</td>
83
<td class="text"><?php echo(php_uname()); ?></td>
84
</tr><tr>
85
<td class="label">Server software:</td>
86
<td class="text"><?php echo($_SERVER['SERVER_SOFTWARE']); ?></td>
87
</tr><tr>
88
<td class="label">User agent:</td>
89
<td class="text"><?php echo($_SERVER['HTTP_USER_AGENT']); ?></td>
90
</tr></table>
91
</fieldset>
92
<!-- PHP configuration -------------------------------------------------------->
93
<fieldset>
94
<legend>PHP configuration</legend>
95
<table class="form"><tr>
96
<?php
97
98
switch ($php_version)
99
{
100
    case PHP_V4:
101
102
        $message = '<a class="fail">FAIL</a> <i>(PHP 4 is discontinued, you need ' . PHP5_MINIMUM . ' at least)</i>';
103
104
        break;
105
106
    case PHP_V5:
107
108
        if (version_compare(PHP_VERSION, PHP5_MINIMUM) >= 0)
109
        {
110
            $message = '<a class="pass">PASS</a> <i>(version ' . PHP_VERSION . ')</i>';
111
        }
112
        else
113
        {
114
            $message = '<a class="fail">FAIL</a> <i>(version ' . PHP_VERSION . ' is not supported, you need ' . PHP5_MINIMUM . ' at least)</i>';
115
        }
116
117
        break;
118
119
    case PHP_V6:
120
121
        $message = '<a class="fail">FAIL</a> <i>(PHP 6 is not production, eTraxis behaviour is unpredictable)</i>';
122
123
        break;
124
125
    default:
126
127
        $message = '<a class="fail">FAIL</a> <i>(version ' . PHP_VERSION . ' is obsolete or not supported)</i>';
128
}
129
130
?>
131
<td class="label">PHP version:</td>
132
<td class="text"><?php echo($message); ?></td>
133
<?php
134
135
if (ini_get('safe_mode'))
136
{
137
    $message = '<a class="fail">FAIL</a> <i>(safe mode is turned on, eTraxis behaviour is unpredictable)</i>';
138
}
139
else
140
{
141
    $message = '<a class="pass">PASS</a> <i>(safe mode is disabled)</i>';
142
}
143
144
?>
145
</tr><tr>
146
<td class="label">safe_mode:</td>
147
<td class="text"><?php echo($message); ?></td>
148
<?php
149
150
if (get_magic_quotes_gpc() == 0)
151
{
152
    $message = '<a class="pass">PASS</a> <i>(magic quotes are disabled)</i>';
153
}
154
else
155
{
156
    $message = '<a class="fail">FAIL</a> <i>(magic quotes for GET/POST/Cookie are turned on, must be disabled)</i>';
157
}
158
159
?>
160
</tr><tr>
161
<td class="label">magic_quotes_gpc:</td>
162
<td class="text"><?php echo($message); ?></td>
163
<?php
164
165
if (get_magic_quotes_runtime() == 0)
166
{
167
    $message = '<a class="pass">PASS</a> <i>(magic quotes are disabled)</i>';
168
}
169
else
170
{
171
    $message = '<a class="fail">FAIL</a> <i>(magic quotes for runtime data are turned on, must be disabled)</i>';
172
}
173
174
?>
175
</tr><tr>
176
<td class="label">magic_quotes_runtime:</td>
177
<td class="text"><?php echo($message); ?></td>
178
<?php
179
180
$default_charset = ini_get('default_charset');
181
182
if (strlen($default_charset) == 0 || strtolower($default_charset) == 'utf-8')
183
{
184
    $message = '<a class="pass">PASS</a> <i>(' . (strlen($default_charset) == 0 ? 'empty' : $default_charset) . ')</i>';
185
}
186
else
187
{
188
    $message = '<a class="fail">FAIL</a> <i>(should be either commented, or set to "UTF-8")</i>';
189
}
190
191
?>
192
</tr><tr>
193
<td class="label">default_charset:</td>
194
<td class="text"><?php echo($message); ?></td>
195
<?php
196
197
if ($php_version == PHP_V5)
198
{
199
    $timezone = ini_get('date.timezone');
200
201
    if (strlen($timezone) == 0)
202
    {
203
        $message = '<a class="fail">FAIL</a> <i>(undefined, should be set to one of <a href="http://www.php.net/manual/timezones.php">available timezones</a>)</i>';
204
    }
205
    else
206
    {
207
        $message = '<a class="pass">PASS</a> <i>("' . $timezone . '")</i>';
208
    }
209
210
?>
211
</tr><tr>
212
<td class="label">date.timezone:</td>
213
<td class="text"><?php echo($message); ?></td>
214
<?php
215
}
216
217
?>
218
</tr></table>
219
</fieldset>
220
<!-- PHP extensions ----------------------------------------------------------->
221
<fieldset>
222
<legend>PHP extensions</legend>
223
<table class="form">
224
<?php
225
226
$extensions = array('bcmath', 'iconv', 'libxml', 'mbstring', 'simplexml', 'xsl');
227
228
switch (DATABASE_DRIVER)
229
{
230
    case DRIVER_MYSQL50:
231
        array_push($extensions, extension_loaded('mysqli') ? 'mysqli' : 'mysql');
232
        break;
233
234
    case DRIVER_MSSQL2K:
235
        array_push($extensions, 'sqlsrv');
236
        break;
237
238
    case DRIVER_ORACLE9:
239
        array_push($extensions, 'dbx');
240
        array_push($extensions, 'oci8');
241
        break;
242
243
    case DRIVER_PGSQL80:
244
        array_push($extensions, 'pgsql');
245
        break;
246
247
    default: ;  // nop
248
}
249
250
if (LDAP_ENABLED)
251
{
252
    array_push($extensions, 'ldap');
253
}
254
255
sort($extensions);
256
257
foreach ($extensions as $extension)
258
{
259
?>
260
<tr><td class="label"><?php echo($extension); ?>:</td>
261
<?php
262
263
    if (extension_loaded($extension))
264
    {
265
        $message = '<a class="pass">PASS</a>';
266
    }
267
    else
268
    {
269
        $message = '<a class="fail">FAIL</a>';
270
    }
271
272
?>
273
<td class="text"><?php echo($message); ?></td>
274
<?php
275
}
276
277
?>
278
</table>
279
</fieldset>
280
<!-- eTraxis configuration ---------------------------------------------------->
281
<fieldset>
282
<legend>eTraxis configuration</legend>
283
<table class="form"><tr>
284
<?php
285
286 View Code Duplication
if (ATTACHMENTS_ENABLED)
287
{
288
    if (!file_exists(ATTACHMENTS_PATH))
289
    {
290
        $message = '<a class="fail">FAIL</a> <i>("' . ATTACHMENTS_PATH . '" is not found)</i>';
291
    }
292
    elseif (!is_dir(ATTACHMENTS_PATH))
293
    {
294
        $message = '<a class="fail">FAIL</a> <i>("' . ATTACHMENTS_PATH . '" is not a directory)</i>';
295
    }
296
    elseif (!is_writable(ATTACHMENTS_PATH))
297
    {
298
        $message = '<a class="fail">FAIL</a> <i>("' . ATTACHMENTS_PATH . '" is not writeable)</i>';
299
    }
300
    elseif (substr(ATTACHMENTS_PATH, -1, 1) != '/')
301
    {
302
        $message = '<a class="fail">FAIL</a> <i>("' . ATTACHMENTS_PATH . '" must be finished with "/" character)</i>';
303
    }
304
    else
305
    {
306
        $message = '<a class="pass">PASS</a> <i>("' . ATTACHMENTS_PATH . '")</i>';
307
    }
308
}
309
else
310
{
311
    $message = '<a class="pass">PASS</a> <i>(disabled)</i>';
312
}
313
314
?>
315
<td class="label">Attachments:</td>
316
<td class="text"><?php echo($message); ?></td>
317
<?php
318
319 View Code Duplication
if (DEBUG_MODE)
320
{
321
    if (!file_exists(DEBUG_LOGS))
322
    {
323
        $message = '<a class="fail">FAIL</a> <i>("' . DEBUG_LOGS . '" is not found)</i>';
324
    }
325
    elseif (!is_dir(DEBUG_LOGS))
326
    {
327
        $message = '<a class="fail">FAIL</a> <i>("' . DEBUG_LOGS . '" is not a directory)</i>';
328
    }
329
    elseif (!is_writable(DEBUG_LOGS))
330
    {
331
        $message = '<a class="fail">FAIL</a> <i>("' . DEBUG_LOGS . '" is not writeable)</i>';
332
    }
333
    elseif (substr(DEBUG_LOGS, -1, 1) != '/')
334
    {
335
        $message = '<a class="fail">FAIL</a> <i>("' . DEBUG_LOGS . '" must be finished with "/" character)</i>';
336
    }
337
    else
338
    {
339
        $message = '<a class="pass">PASS</a> <i>("' . DEBUG_LOGS . '")</i>';
340
    }
341
}
342
else
343
{
344
    $message = '<a class="pass">PASS</a> <i>(disabled)</i>';
345
}
346
347
?>
348
</tr><tr>
349
<td class="label">Debug logs:</td>
350
<td class="text"><?php echo($message); ?></td>
351
<?php
352
353
switch (DATABASE_DRIVER)
354
{
355
    case DRIVER_MYSQL50:
356
357
        if (extension_loaded('mysqli'))
358
        {
359
            $link = mysqli_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_DBNAME);
360
361
            if ($link)
362
            {
363
                mysqli_query($link, 'set names utf8');
364
365
                $res = mysqli_query($link, 'select var_value from tbl_sys_vars where var_name = \'FEATURE_LEVEL\'');
366
367
                if (is_object($res))
368
                {
369
                    $row = mysqli_fetch_array($res, MYSQLI_BOTH);
370
371
                    if (is_array($row))
372
                    {
373
                        mysqli_free_result($res);
374
                        $message = '<a class="pass">PASS</a> <i>(MySQL / feature level ' . $row['var_value'] . ')</i>';
375
                    }
376 View Code Duplication
                    else
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
377
                    {
378
                        $errno = mysqli_errno($link);
379
                        $error = mysqli_error($link);
380
381
                        $message = ($errno == 0 || strlen($error) == 0)
382
                                 ? '<a class="fail">FAIL</a> <i>(unknown MySQL error on fetching data)</i>'
383
                                 : '<a class="fail">FAIL</a> <i>(MySQL error #' . $errno . ' on fetching data - ' . $error . ')</i>';
384
                    }
385
                }
386 View Code Duplication
                else
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
387
                {
388
                    $errno = mysqli_errno($link);
389
                    $error = mysqli_error($link);
390
391
                    $message = ($errno == 0 || strlen($error) == 0)
392
                             ? '<a class="fail">FAIL</a> <i>(unknown MySQL error on query database)</i>'
393
                             : '<a class="fail">FAIL</a> <i>(MySQL error #' . $errno . ' on query database - ' . $error . ')</i>';
394
                }
395
396
                mysqli_close($link);
397
            }
398
            else
399
            {
400
                $message = '<a class="fail">FAIL</a> <i>(MySQL server cannot be connected)</i>';
401
            }
402
        }
403
        else
404
        {
405
            $link = mysql_connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD);
406
407
            if ($link)
408
            {
409
                if (mysql_select_db(DATABASE_DBNAME, $link))
410
                {
411
                    mysql_query('set names utf8', $link);
412
413
                    $res = mysql_query('select var_value from tbl_sys_vars where var_name = \'FEATURE_LEVEL\'', $link);
414
415
                    if (is_resource($res))
416
                    {
417
                        $row = mysql_fetch_array($res, MYSQL_BOTH);
418
419
                        if (is_array($row))
420
                        {
421
                            if (mysql_free_result($res))
422
                            {
423
                                $message = '<a class="pass">PASS</a> <i>(MySQL / feature level ' . $row['var_value'] . ')</i>';
424
                            }
425 View Code Duplication
                            else
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
426
                            {
427
                                $errno = mysql_errno($link);
428
                                $error = mysql_error($link);
429
430
                                $message = ($errno == 0 || strlen($error) == 0)
431
                                         ? '<a class="fail">FAIL</a> <i>(unknown MySQL error on releasing recordset)</i>'
432
                                         : '<a class="fail">FAIL</a> <i>(MySQL error #' . $errno . ' on releasing recordset - ' . $error . ')</i>';
433
                            }
434
                        }
435 View Code Duplication
                        else
436
                        {
437
                            $errno = mysql_errno($link);
438
                            $error = mysql_error($link);
439
440
                            $message = ($errno == 0 || strlen($error) == 0)
441
                                     ? '<a class="fail">FAIL</a> <i>(unknown MySQL error on fetching data)</i>'
442
                                     : '<a class="fail">FAIL</a> <i>(MySQL error #' . $errno . ' on fetching data - ' . $error . ')</i>';
443
                        }
444
                    }
445 View Code Duplication
                    else
446
                    {
447
                        $errno = mysql_errno($link);
448
                        $error = mysql_error($link);
449
450
                        $message = ($errno == 0 || strlen($error) == 0)
451
                                 ? '<a class="fail">FAIL</a> <i>(unknown MySQL error on query database)</i>'
452
                                 : '<a class="fail">FAIL</a> <i>(MySQL error #' . $errno . ' on query database - ' . $error . ')</i>';
453
                    }
454
                }
455 View Code Duplication
                else
456
                {
457
                    $errno = mysql_errno($link);
458
                    $error = mysql_error($link);
459
460
                    $message = ($errno == 0 || strlen($error) == 0)
461
                             ? '<a class="fail">FAIL</a> <i>(unknown MySQL error on selecting database)</i>'
462
                             : '<a class="fail">FAIL</a> <i>(MySQL error #' . $errno . ' on selecting database - ' . $error . ')</i>';
463
                }
464
465
                mysql_close($link);
466
            }
467
            else
468
            {
469
                $message = '<a class="fail">FAIL</a> <i>(MySQL server cannot be connected)</i>';
470
            }
471
        }
472
473
        break;
474
475
    case DRIVER_MSSQL2K:
476
477
        $conn_info = array
478
        (
479
            'APP'          => 'eTraxis',
480
            'CharacterSet' => 'UTF-8',
481
            'Database'     => DATABASE_DBNAME,
482
        );
483
484 View Code Duplication
        if (strlen(trim(DATABASE_USERNAME)) != 0)
485
        {
486
            $conn_info['UID'] = DATABASE_USERNAME;
487
            $conn_info['PWD'] = DATABASE_PASSWORD;
488
        }
489
490
        $link = sqlsrv_connect(DATABASE_HOST, $conn_info);
491
492
        if ($link)
493
        {
494
            $res = sqlsrv_query($link, 'select var_value from tbl_sys_vars where var_name = \'FEATURE_LEVEL\'',
495
                                NULL, array('Scrollable' => SQLSRV_CURSOR_STATIC));
496
497
            if (is_resource($res))
498
            {
499
                $row = sqlsrv_fetch_array($res, SQLSRV_FETCH_BOTH, SQLSRV_SCROLL_NEXT);
500
501
                if (is_array($row))
502
                {
503
                    if (sqlsrv_free_stmt($res))
504
                    {
505
                        $message = '<a class="pass">PASS</a> <i>(Microsoft SQL Server / feature level ' . $row['var_value'] . ')</i>';
506
                    }
507 View Code Duplication
                    else
508
                    {
509
                        $error = sqlsrv_errors(SQLSRV_ERR_ALL);
510
511
                        $message = (is_null($error))
512
                                 ? '<a class="fail">FAIL</a> <i>(unknown Microsoft SQL Server error on releasing recordset)</i>'
513
                                 : sprintf('<a class="fail">FAIL</a> <i>(Microsoft SQL Server error #%d on releasing recordset - %s)</i>',
514
                                           $error[0]['code'],
515
                                           $error[0]['message']);
516
                    }
517
                }
518 View Code Duplication
                else
519
                {
520
                    $error = sqlsrv_errors(SQLSRV_ERR_ALL);
521
522
                    $message = (is_null($error))
523
                             ? '<a class="fail">FAIL</a> <i>(unknown Microsoft SQL Server error on fetching data)</i>'
524
                             : sprintf('<a class="fail">FAIL</a> <i>(Microsoft SQL Server error #%d on fetching data - %s)</i>',
525
                                       $error[0]['code'],
526
                                       $error[0]['message']);
527
                }
528
            }
529 View Code Duplication
            else
530
            {
531
                $error = sqlsrv_errors(SQLSRV_ERR_ALL);
532
533
                $message = (is_null($error))
534
                         ? '<a class="fail">FAIL</a> <i>(unknown Microsoft SQL Server error on query database)</i>'
535
                         : sprintf('<a class="fail">FAIL</a> <i>(Microsoft SQL Server error #%d on query database - %s)</i>',
536
                                   $error[0]['code'],
537
                                   $error[0]['message']);
538
            }
539
540
            sqlsrv_close($link);
541
        }
542
        else
543
        {
544
            $message = '<a class="fail">FAIL</a> <i>(Microsoft SQL Server cannot be connected)</i>';
545
        }
546
547
        break;
548
549
    case DRIVER_ORACLE9:
550
551
        $link = dbx_connect(DBX_OCI8, DATABASE_HOST, DATABASE_DBNAME, DATABASE_USERNAME, DATABASE_PASSWORD);
552
553
        if ($link)
554
        {
555
            $res = dbx_query($link, 'select var_value from tbl_sys_vars where var_name = \'FEATURE_LEVEL\'', DBX_COLNAMES_LOWERCASE);
556
557
            if (is_object($res))
558
            {
559
                $row = $res->data[0];
560
561
                if (is_array($row))
562
                {
563
                    $message = '<a class="pass">PASS</a> <i>(Oracle / feature level ' . $row['var_value'] . ')</i>';
564
                }
565 View Code Duplication
                else
566
                {
567
                    $error = ocierror($link->handle);
568
569
                    $message = (strlen($error) == 0)
570
                             ? '<a class="fail">FAIL</a> <i>(unknown Oracle error on query database)</i>'
571
                             : '<a class="fail">FAIL</a> <i>(Oracle error #' . $error['code'] . ' on fetching data - ' . $error['message'] . ')</i>';
572
                }
573
            }
574 View Code Duplication
            else
575
            {
576
                $error = ocierror($link->handle);
577
578
                $message = (strlen($error) == 0)
579
                         ? '<a class="fail">FAIL</a> <i>(unknown Oracle error on query database)</i>'
580
                         : '<a class="fail">FAIL</a> <i>(Oracle error #' . $error['code'] . ' on query database - ' . $error['message'] . ')</i>';
581
            }
582
583
            dbx_close($link);
584
        }
585
        else
586
        {
587
            $message = '<a class="fail">FAIL</a> <i>(Oracle server cannot be connected)</i>';
588
        }
589
590
        break;
591
592
    case DRIVER_PGSQL80:
593
594
        if (strlen(trim(DATABASE_HOST)) == 0)
595
        {
596
            $link = pg_connect(sprintf('dbname=%s user=%s password=%s', DATABASE_DBNAME, DATABASE_USERNAME, DATABASE_PASSWORD));
597
        }
598 View Code Duplication
        else
599
        {
600
            $link = pg_connect(sprintf('host=%s dbname=%s user=%s password=%s', DATABASE_HOST, DATABASE_DBNAME, DATABASE_USERNAME, DATABASE_PASSWORD));
601
        }
602
603
        if ($link)
604
        {
605
            $res = pg_query($link, 'select var_value from tbl_sys_vars where var_name = \'FEATURE_LEVEL\'');
606
607
            if (is_resource($res))
608
            {
609
                $row = pg_fetch_array($res);
610
611
                if (is_array($row))
612
                {
613
                    if (pg_free_result($res))
614
                    {
615
                        $message = '<a class="pass">PASS</a> <i>(PostgreSQL / feature level ' . $row['var_value'] . ')</i>';
616
                    }
617 View Code Duplication
                    else
618
                    {
619
                        $error = pg_last_error($link);
620
621
                        $message = ($error)
622
                                 ? '<a class="fail">FAIL</a> <i>(PostgreSQL error on releasing recordset - ' . $error . ')</i>'
623
                                 : '<a class="fail">FAIL</a> <i>(unknown PostgreSQL error on releasing recordset)</i>';
624
                    }
625
                }
626 View Code Duplication
                else
627
                {
628
                    $error = pg_last_error($link);
629
630
                    $message = ($error)
631
                             ? '<a class="fail">FAIL</a> <i>(PostgreSQL error on fetching data - ' . $error . ')</i>'
632
                             : '<a class="fail">FAIL</a> <i>(unknown PostgreSQL error on fetching data)</i>';
633
                }
634
            }
635 View Code Duplication
            else
636
            {
637
                $error = pg_last_error($link);
638
639
                $message = ($error)
640
                         ? '<a class="fail">FAIL</a> <i>(PostgreSQL error on query database - ' . $error . ')</i>'
641
                         : '<a class="fail">FAIL</a> <i>(unknown PostgreSQL error on query database)</i>';
642
            }
643
644
            pg_close($link);
645
        }
646
        else
647
        {
648
            $message = '<a class="fail">FAIL</a> <i>(PostgreSQL server cannot be connected)</i>';
649
        }
650
651
        break;
652
653
    default:
654
655
        $message = '<a class="fail">FAIL</a> <i>(unknown database type in "DATABASE_DRIVER")</i>';
656
}
657
658
?>
659
</tr><tr>
660
<td class="label">Database:</td>
661
<td class="text"><?php echo($message); ?></td>
662
<?php
663
664
if (LDAP_ENABLED)
665
{
666
    $link = @ldap_connect(LDAP_HOST, LDAP_PORT);
667
668
    if ($link)
669
    {
670
        if (!@ldap_set_option($link, LDAP_OPT_PROTOCOL_VERSION, 3))
671
        {
672
            $message = '<a class="fail">FAIL</a> <i>(LDAP protocol version cannot be set - ' . ldap_err2str(ldap_errno($link)) . ')</i>';
673
        }
674
        elseif (!@ldap_set_option($link, LDAP_OPT_REFERRALS, 0))
675
        {
676
            $message = '<a class="fail">FAIL</a> <i>(LDAP protocol option cannot be set - ' . ldap_err2str(ldap_errno($link)) . ')</i>';
677
        }
678
        elseif (!@ldap_bind($link, LDAP_USERNAME, LDAP_PASSWORD))
679
        {
680
            $message = '<a class="fail">FAIL</a> <i>(can\'t bind to LDAP server as \'' . (strlen(LDAP_USERNAME) == 0 ? 'anonymous' : LDAP_USERNAME) . '\' - ' . ldap_err2str(ldap_errno($link)) . ')</i>';
681
        }
682
        else
683
        {
684
            $message = '<a class="pass">PASS</a> <i>(enabled)</i>';
685
        }
686
687
        ldap_close($link);
688
    }
689
    else
690
    {
691
        $message = '<a class="fail">FAIL</a> <i>(LDAP server cannot be connected)</i>';
692
    }
693
}
694
else
695
{
696
    $message = '<a class="pass">PASS</a> <i>(disabled)</i>';
697
}
698
699
?>
700
</tr><tr>
701
<td class="label">Active Directory:</td>
702
<td class="text"><?php echo($message); ?></td>
703
</tr></table>
704
</fieldset>
705
<input type="button" class="button" onclick="window.open('../records/index.php','_parent');" value="Back"/>
706
<!----------------------------------------------------------------------------->
707
</body>
708
<?php
709
710
// Restore PHP execution timeout.
711
if (!ini_get('safe_mode'))
712
{
713
    ini_restore('max_execution_time');
714
}
715
716
?>
717