~ubuntu-branches/ubuntu/saucy/horde3/saucy

« back to all changes in this revision

Viewing changes to lib/Test.php

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2005-05-04 23:08:08 UTC
  • Revision ID: james.westby@ubuntu.com-20050504230808-p4hf3hk28o3v7wir
Tags: upstream-3.0.4
ImportĀ upstreamĀ versionĀ 3.0.4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
/**
 
4
 * Define HORDE_BASE, if it is not already set, and include the main
 
5
 * Horde library, since we require it for this package to function.
 
6
 */
 
7
if (!defined('HORDE_BASE')) {
 
8
    define('HORDE_BASE', dirname(__FILE__) . '/..');
 
9
}
 
10
require_once HORDE_BASE . '/lib/core.php';
 
11
 
 
12
/**
 
13
 * Set the path to the templates needed for testing output.
 
14
 */
 
15
define('TEST_TEMPLATES', HORDE_BASE . '/templates/test/');
 
16
 
 
17
/* If gettext is not loaded, define a dummy _() function so that
 
18
 * including any file with gettext strings won't cause a fatal error,
 
19
 * causing test.php to return a blank page. */
 
20
if (!function_exists('_')) {
 
21
    function _($s) { return $s; }
 
22
}
 
23
 
 
24
/**
 
25
 * The Horde_Test:: class provides functions used in the test scripts
 
26
 * used in the various applications (test.php).
 
27
 *
 
28
 * $Horde: horde/lib/Test.php,v 1.31.4.4 2005/03/05 20:21:15 chuck Exp $
 
29
 *
 
30
 * Copyright 1999-2005 Charles J. Hagenbuch <chuck@horde.org>
 
31
 * Copyright 1999-2005 Jon Parise <jon@horde.org>
 
32
 * Copyright 2002-2005 Brent J. Nordquist <bjn@horde.org>
 
33
 * Copyright 2003-2005 Michael Slusarz <slusarz@bigworm.colorado.edu>
 
34
 *
 
35
 * See the enclosed file COPYING for license information (LGPL).  If you
 
36
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 
37
 *
 
38
 * @author  Chuck Hagenbuch <chuck@horde.org>
 
39
 * @author  Jon Parise <jon@horde.org>
 
40
 * @author  Brent J. Nordquist <bjn@horde.org>
 
41
 * @author  Michael Slusarz <slusarz@bigworm.colorado.edu>
 
42
 * @since   Horde 3.0
 
43
 * @package Horde_Test
 
44
 */
 
45
class Horde_Test {
 
46
 
 
47
    /**
 
48
     * Array that holds the list of Horde applications.
 
49
     * (Loaded from config/registry.php)
 
50
     *
 
51
     * @var array $applications
 
52
     */
 
53
    var $applications = array();
 
54
 
 
55
    /**
 
56
     * Cached results of getApplications().
 
57
     *
 
58
     * @var array $_appoutput
 
59
     */
 
60
    var $_appoutput = array();
 
61
 
 
62
    /**
 
63
     * The PHP version of the system.
 
64
     *
 
65
     * @var array $_phpver
 
66
     */
 
67
    var $_phpver;
 
68
 
 
69
    /**
 
70
     * Location of the base Horde test script.
 
71
     *
 
72
     * @var string $_testscript
 
73
     */
 
74
    var $_testscript;
 
75
 
 
76
    /**
 
77
     * Constructor.
 
78
     *
 
79
     * @access public
 
80
     */
 
81
    function Horde_Test()
 
82
    {
 
83
        include_once HORDE_BASE . '/config/registry.php';
 
84
        ksort($this->applications);
 
85
 
 
86
        /* Set the location of the base test script. */
 
87
        $this->_testscript = $_SERVER['PHP_SELF'];
 
88
 
 
89
        /* Store the PHP version information. */
 
90
        $this->_phpver = $this->splitPHPVersion(phpversion());
 
91
 
 
92
        /* We want to be as verbose as possible here. */
 
93
        error_reporting(E_ALL);
 
94
 
 
95
        /* Set character encoding. */
 
96
        header('Content-type: text/html; charset=utf-8');
 
97
        header('Vary: Accept-Language');
 
98
    }
 
99
 
 
100
    /**
 
101
     * Parse PHP version.
 
102
     *
 
103
     * @access public
 
104
     *
 
105
     * @param string $version  A PHP-style version string (X.X.X).
 
106
     *
 
107
     * @param array  The parsed string.
 
108
     *               Keys: 'major', 'minor', 'subminor', 'class'
 
109
     */
 
110
    function splitPHPVersion($version)
 
111
    {
 
112
        /* First pick off major version, and lower-case the rest. */
 
113
        if ((strlen($version) >= 3) && ($version[1] == '.')) {
 
114
            $phpver['major'] = substr($version, 0, 3);
 
115
            $version = substr(strtolower($version), 3);
 
116
        } else {
 
117
            $phpver['major'] = $version;
 
118
            $phpver['class'] = 'unknown';
 
119
            return $phpver;
 
120
        }
 
121
 
 
122
        if ($version[0] == '.') {
 
123
            $version = substr($version, 1);
 
124
        }
 
125
 
 
126
        /* Next, determine if this is 4.0b or 4.0rc; if so, there is no
 
127
           minor, the rest is the subminor, and class is set to beta. */
 
128
        $s = strspn($version, '0123456789');
 
129
        if ($s == 0) {
 
130
            $phpver['subminor'] = $version;
 
131
            $phpver['class'] = 'beta';
 
132
            return $phpver;
 
133
        }
 
134
 
 
135
        /* Otherwise, this is non-beta;  the numeric part is the minor,
 
136
           the rest is either a classification (dev, cvs) or a subminor
 
137
           version (rc<x>, pl<x>). */
 
138
        $phpver['minor'] = substr($version, 0, $s);
 
139
        if ((strlen($version) > $s) &&
 
140
            (($version[$s] == '.') || ($version[$s] == '-'))) {
 
141
            $s++;
 
142
        }
 
143
        $phpver['subminor'] = substr($version, $s);
 
144
        if (($phpver['subminor'] == 'cvs') ||
 
145
            ($phpver['subminor'] == 'dev') ||
 
146
            (substr($phpver['subminor'], 0, 2) == 'rc')) {
 
147
            unset($phpver['subminor']);
 
148
            $phpver['class'] = 'dev';
 
149
        } else {
 
150
            if (!$phpver['subminor']) {
 
151
                unset($phpver['subminor']);
 
152
            }
 
153
            $phpver['class'] = 'release';
 
154
        }
 
155
 
 
156
        return $phpver;
 
157
    }
 
158
 
 
159
    /**
 
160
     * Check the list of PHP modules.
 
161
     *
 
162
     * @access public
 
163
     *
 
164
     * @param array $modlist  The module list.
 
165
     * <pre>
 
166
     * KEY:   module name
 
167
     * VALUE: Either the description or an array with the following entries:
 
168
     *        'descrip'  --  Module Description
 
169
     *        'error'    --  Error Message
 
170
     *        'phpver'   --  The PHP version above which to do the test
 
171
     * </pre>
 
172
     *
 
173
     * @return string  The HTML output.
 
174
     */
 
175
    function phpModuleCheck($modlist)
 
176
    {
 
177
        $output = '';
 
178
        $output_array = array();
 
179
 
 
180
        foreach ($modlist as $key => $val) {
 
181
            $error_msg = $mod_test = $status_out = $fatal = null;
 
182
            $entry = array();
 
183
 
 
184
            if (is_array($val)) {
 
185
                $descrip = $val['descrip'];
 
186
                $fatal = !empty($val['fatal']);
 
187
                if (isset($val['phpver']) &&
 
188
                    (version_compare(phpversion(), $val['phpver']) == -1)) {
 
189
                    $mod_test = true;
 
190
                    $status_out = 'N/A';
 
191
                }
 
192
                if (isset($val['error'])) {
 
193
                    $error_msg = $val['error'];
 
194
                }
 
195
            } else {
 
196
                $descrip = $val;
 
197
            }
 
198
 
 
199
            if (is_null($status_out)) {
 
200
                $mod_test = extension_loaded($key);
 
201
                $status_out = $this->_status($mod_test, $fatal);
 
202
            }
 
203
 
 
204
            $entry[] = $descrip;
 
205
            $entry[] = $status_out;
 
206
 
 
207
            if (!is_null($error_msg) && !$mod_test) {
 
208
                $entry[] = $error_msg;
 
209
                if (!$fatal) {
 
210
                    $entry[] = 1;
 
211
                }
 
212
            }
 
213
 
 
214
            $output .= $this->_outputLine($entry);
 
215
 
 
216
            if ($fatal && !$mod_test) {
 
217
                echo $output;
 
218
                exit;
 
219
            }
 
220
        }
 
221
 
 
222
        return $output;
 
223
    }
 
224
 
 
225
    /**
 
226
     * Checks the list of PHP settings.
 
227
     *
 
228
     * @access public
 
229
     *
 
230
     * @param array $modlist  The settings list.
 
231
     * <code>
 
232
     * KEY:   setting name
 
233
     * VALUE: An array with the following entries:
 
234
     *        'error'    --  Error Message
 
235
     *        'setting'  --  Boolean - should the setting be on or off
 
236
     * </code>
 
237
     *
 
238
     * @return string  The HTML output.
 
239
     */
 
240
    function phpSettingCheck($settings_list)
 
241
    {
 
242
        $output = '';
 
243
 
 
244
        foreach ($settings_list as $key => $val) {
 
245
            $entry = array();
 
246
            $result = (ini_get($key) == $val['setting']);
 
247
 
 
248
            $entry[] = $key . ' ' . (($val['setting'] === true) ? 'enabled' : 'disabled');
 
249
            $entry[] = $this->_status($result);
 
250
 
 
251
            if (!$result) {
 
252
                $entry[] = $val['error'];
 
253
            }
 
254
 
 
255
            $output .= $this->_outputLine($entry);
 
256
        }
 
257
 
 
258
        return $output;
 
259
    }
 
260
 
 
261
    /**
 
262
     * Check the list of PEAR modules.
 
263
     *
 
264
     * @access public
 
265
     *
 
266
     * @param array $pear_list  The PEAR module list.
 
267
     * <pre>
 
268
     * KEY:   PEAR class name
 
269
     * VALUE: An array with the following entries:
 
270
     *        'depends'   --  This module depends on another module
 
271
     *        'error'     --  Error Message
 
272
     *        'function'  --  Reference to function to run if module is found
 
273
     *        'path'      --  The path to the PEAR module
 
274
     *        'required'  --  Is this PEAR module required? (boolean)
 
275
     * </pre>
 
276
     *
 
277
     * @return string  The HTML output.
 
278
     */
 
279
    function PEARModuleCheck($pear_list)
 
280
    {
 
281
        $output = '';
 
282
 
 
283
        /* Turn tracking of errors on. */
 
284
        ini_set('track_errors', 1);
 
285
 
 
286
        /* Print the include_path. */
 
287
        $output .= $this->_outputLine(array("<b>PEAR Search Path (PHP's include_path)</b>", '&nbsp;<tt>' . ini_get('include_path') . '</tt>'));
 
288
 
 
289
        /* Check for PEAR in general. */
 
290
        {
 
291
            $entry = array();
 
292
            $entry[] = 'PEAR';
 
293
            @include_once 'PEAR.php';
 
294
            $entry[] = $this->_status(!isset($php_errormsg));
 
295
            if (isset($php_errormsg)) {
 
296
                $entry[] = 'Check your PHP include_path setting to make sure it has the PEAR library directory.';
 
297
                $output .= $this->_outputLine($entry);
 
298
                ini_restore('track_errors');
 
299
                return $output;
 
300
            }
 
301
            $output .= $this->_outputLine($entry);
 
302
        }
 
303
 
 
304
        /* Check for a recent PEAR version. */
 
305
        $entry = array();
 
306
        $newpear = $this->isRecentPEAR();
 
307
        $entry[] = 'Recent PEAR';
 
308
        $entry[] = $this->_status($newpear);
 
309
        if (!$newpear) {
 
310
            $entry[] = 'This version of PEAR is not recent enough. See the <a href="http://www.horde.org/pear/">Horde PEAR page</a> for details.';
 
311
        }
 
312
        $output .= $this->_outputLine($entry);
 
313
 
 
314
        /* Go through module list. */
 
315
        $succeeded = array();
 
316
        foreach ($pear_list as $key => $val) {
 
317
            $entry = array();
 
318
 
 
319
            /* If this module depends on another module that we
 
320
             * haven't succesfully found, fail the test. */
 
321
            if (!empty($val['depends']) && empty($succeeded[$val['depends']])) {
 
322
                $result = false;
 
323
            } else {
 
324
                $result = @include_once $val['path'];
 
325
            }
 
326
            $error_msg = $val['error'];
 
327
            if ($result && isset($val['function'])) {
 
328
                $func_output = call_user_func($val['function']);
 
329
                if ($func_output) {
 
330
                    $result = false;
 
331
                    $error_msg = $func_output;
 
332
                }
 
333
            }
 
334
            $entry[] = $key;
 
335
            $entry[] = $this->_status($result, !empty($val['required']));
 
336
 
 
337
            if ($result) {
 
338
                $succeeded[$key] = true;
 
339
            } else {
 
340
                if (!empty($val['required'])) {
 
341
                    $error_msg .= ' THIS IS A REQUIRED MODULE!';
 
342
                }
 
343
                $entry[] = $error_msg;
 
344
                if (empty($val['required'])) {
 
345
                    $entry[] = 1;
 
346
                }
 
347
            }
 
348
 
 
349
            $output .= $this->_outputLine($entry);
 
350
        }
 
351
 
 
352
        /* Restore previous value of 'track_errors'. */
 
353
        ini_restore('track_errors');
 
354
 
 
355
        return $output;
 
356
    }
 
357
 
 
358
    /**
 
359
     * Check the list of required files
 
360
     *
 
361
     * @access public
 
362
     *
 
363
     * @param array $file_list  The file list.
 
364
     * <pre>
 
365
     * KEY:   file path
 
366
     * VALUE: The error message to use (null to use default message)
 
367
     * </pre>
 
368
     *
 
369
     * @return string  The HTML output.
 
370
     */
 
371
    function requiredFileCheck($file_list)
 
372
    {
 
373
        $output = '';
 
374
 
 
375
        foreach ($file_list as $key => $val) {
 
376
            $entry = array();
 
377
            $result = file_exists('./' . $key);
 
378
 
 
379
            $entry[] = $key;
 
380
            $entry[] = $this->_status($result);
 
381
 
 
382
            if (!$result) {
 
383
                if (empty($val)) {
 
384
                    $entry[] = 'The file <code>' . $key . '</code> appears to be missing. You probably just forgot to copy <code>' . $key . '.dist</code> over. While you do that, take a look at the settings and make sure they are appropriate for your site.';
 
385
                } else {
 
386
                    $entry[] = $val;
 
387
                }
 
388
            }
 
389
 
 
390
            $output .= $this->_outputLine($entry);
 
391
        }
 
392
 
 
393
        return $output;
 
394
    }
 
395
 
 
396
    /**
 
397
     * Displays an error screen with a list of all configuration files
 
398
     * that are missing, together with a description what they do and
 
399
     * how they are created. If a file can be automatically created
 
400
     * from the defaults, then we do that instead and don't display an
 
401
     * error.
 
402
     *
 
403
     * @param string $app        The application name
 
404
     * @param string $appBase    The path to the application
 
405
     * @param array  $files      An array with the "standard" configuration files
 
406
     *                           that should be checked. Currently supported:
 
407
     *                           - conf.php
 
408
     *                           - prefs.php
 
409
     *                           - mime_drivers.php
 
410
     * @param array $additional  (optional) An associative array containing
 
411
     *                           more files (as keys) and error message (as
 
412
     *                           values) if they don't exist.
 
413
     */
 
414
    function configFilesMissing($app, $appBase, $files, $additional = array())
 
415
    {
 
416
        if (!is_array($files)) {
 
417
            $files = array($files);
 
418
        }
 
419
        $files = array_merge($files, array_keys($additional));
 
420
 
 
421
        /* Try to auto-create missing .dist files. */
 
422
        $indices = array_keys($files);
 
423
        foreach ($indices as $index) {
 
424
            if (is_readable($appBase . '/config/' . $files[$index])) {
 
425
                unset($files[$index]);
 
426
            } else {
 
427
                if (@file_exists($appBase . '/config/' . $files[$index] . '.dist') &&
 
428
                    @copy($appBase . '/config/' . $files[$index] . '.dist', $appBase . '/config/' . $files[$index])) {
 
429
                    unset($files[$index]);
 
430
                }
 
431
            }
 
432
        }
 
433
 
 
434
        /* Return if we have no missing files left. */
 
435
        if (!count($files)) {
 
436
            return;
 
437
        }
 
438
 
 
439
        $descriptions = array_merge(array(
 
440
            'conf.php' => sprintf('This is the main %s configuration file. ' .
 
441
                                  'It contains paths and options for the %s ' .
 
442
                                  'scripts. You need to login as an ' .
 
443
                                  'administrator and create the file with ' .
 
444
                                  'the web frontend under "Administration => ' .
 
445
                                  'Configuration".',
 
446
                                  $app, $app, $appBase . '/config'),
 
447
            'prefs.php' => sprintf('This file controls the default preferences ' .
 
448
                                   'for %s, and also controls which preferences ' .
 
449
                                   'users can alter.', $app),
 
450
            'mime_drivers.php' => sprintf('This file controls local MIME ' .
 
451
                                          'drivers for %s, specifically what ' .
 
452
                                          'kinds of files are viewable and/or ' .
 
453
                                          'downloadable.', $app),
 
454
            'backends.php' => sprintf('This file controls what backends are ' .
 
455
                                      'available from %s.', $app),
 
456
            'sources.php' => sprintf('This file defines the list of available ' .
 
457
                                     'sources for %s.', $app)
 
458
        ), $additional);
 
459
        $title = sprintf('%s is not properly configured', $app);
 
460
        $header = sprintf('Some of %s\'s configuration files are missing or unreadable', $app);
 
461
        $footer = sprintf('Create these files from their .dist versions in %s and change them according to your needs.', $appBase . '/config');
 
462
 
 
463
        echo <<< HEADER
 
464
<html>
 
465
<head><title>$title</title></head>
 
466
<body style="background-color: white; color: black;">
 
467
<h1>$header</h1>
 
468
HEADER;
 
469
 
 
470
        foreach ($files as $file) {
 
471
            $description = $descriptions[$file];
 
472
            echo <<< FILE
 
473
    <h3>$file</h3><p>$description</p>
 
474
FILE;
 
475
        }
 
476
 
 
477
        echo <<< FOOTER
 
478
 
 
479
<h2>$footer</h2>
 
480
</body>
 
481
</html>
 
482
FOOTER;
 
483
        exit;
 
484
    }
 
485
 
 
486
    /**
 
487
     * Check the list of required Horde applications.
 
488
     *
 
489
     * @access public
 
490
     *
 
491
     * @param array $app_list  The application list.
 
492
     * <pre>
 
493
     * KEY:   application name
 
494
     * VALUE: An array with the following entries:
 
495
     *        'error'    --  Error Message
 
496
     *        'version'  --  The minimum version required
 
497
     * </pre>
 
498
     *
 
499
     * @return string  The HTML output.
 
500
     */
 
501
    function requiredAppCheck($app_list)
 
502
    {
 
503
        $output = '';
 
504
 
 
505
        $apps = $this->applicationList();
 
506
 
 
507
        foreach ($app_list as $key => $val) {
 
508
            $entry = array();
 
509
            $entry[] = $key;
 
510
 
 
511
            if (!isset($apps[$key])) {
 
512
                $entry[] = $this->_status(false);
 
513
                $entry[] = $val['error'];
 
514
            } else {
 
515
                /* Strip '-cvs' and H3 (ver) from version string. */
 
516
                $appver = str_replace('-cvs', '', $apps[$key]->version);
 
517
                $appver = preg_replace('/H3 \((.*)\)/', '$1', $appver);
 
518
                if (version_compare($val['version'], $appver) === 1) {
 
519
                    $entry[] = $this->_status(false) . ' (Have version: ' . $apps[$key]->version . '; Need version: ' . $val['version'] . ')';
 
520
                    $entry[] = $val['error'];
 
521
                } else {
 
522
                    $entry[] = $this->_status(true) . ' (Version: ' . $apps[$key]->version . ')';
 
523
                }
 
524
            }
 
525
            $output .= $this->_outputLine($entry);
 
526
        }
 
527
 
 
528
        return $output;
 
529
    }
 
530
 
 
531
    /**
 
532
     * Is this a 'recent' version of PEAR?
 
533
     *
 
534
     * @access public
 
535
     *
 
536
     * @param boolean  True if a recent version of PEAR.
 
537
     */
 
538
    function isRecentPEAR()
 
539
    {
 
540
        @include_once 'PEAR.php';
 
541
        $pear_methods = get_class_methods('PEAR');
 
542
        return (is_array($pear_methods) &&
 
543
                (in_array('registershutdownfunc', $pear_methods) ||
 
544
                 in_array('registerShutdownFunc', $pear_methods)));
 
545
    }
 
546
 
 
547
    /**
 
548
     * Obtain information on the PHP version.
 
549
     *
 
550
     * @access public
 
551
     *
 
552
     * @return object stdClass  TODO
 
553
     */
 
554
    function getPhpVersionInformation()
 
555
    {
 
556
        $output = &new stdClass;
 
557
        $url = urlencode($_SERVER['PHP_SELF']);
 
558
        $vers_check = true;
 
559
 
 
560
        $output->phpinfo = $this->_testscript . '?mode=phpinfo&url=' . $url;
 
561
        $output->extensions = $this->_testscript . '?mode=extensions&url=' . $url;
 
562
        $output->version = phpversion();
 
563
        $output->major = $this->_phpver['major'];
 
564
        if (isset($this->_phpver['minor'])) {
 
565
            $output->minor = $this->_phpver['minor'];
 
566
        }
 
567
        if (isset($this->_phpver['subminor'])) {
 
568
            $output->subminor = $this->_phpver['subminor'];
 
569
        }
 
570
        $output->class = $this->_phpver['class'];
 
571
 
 
572
        $output->status_color = 'red';
 
573
        if ($output->major < '4.3') {
 
574
            $output->status = 'This version of PHP is not supported. You need to upgrade to a more recent version.';
 
575
            $vers_check = false;
 
576
        } elseif (($output->major == '4.3') || ($output->major == '4.4')) {
 
577
            $output->status = 'You are running a supported version of PHP.';
 
578
            $output->status_color = 'green';
 
579
        } elseif ($output->major == '5.0') {
 
580
            $output->status = 'PHP 5 is supported experimentally. You may not see any error messages, but the changed behaviour of objects in PHP 5 has unpredictable side effects.';
 
581
            $ouput->status_color = 'orange';
 
582
        } else {
 
583
            $output->status = 'Wow, a mystical version of PHP from the future. Let <a href="mailto:dev@lists.horde.org">dev@lists.horde.org</a> know what version you have so we can fix this script.';
 
584
            $output->status_color = 'orange';
 
585
        }
 
586
 
 
587
        if (!$vers_check) {
 
588
            $output->version_check = 'Horde requires PHP 4.3.0 or greater.';
 
589
        }
 
590
 
 
591
        return $output;
 
592
    }
 
593
 
 
594
    /**
 
595
     * Get the application list.
 
596
     *
 
597
     * @access public
 
598
     *
 
599
     * @return array  List of stdClass objects.
 
600
     *                KEY: application name
 
601
     *                ELEMENT 'version': Version of application
 
602
     *                ELEMENT 'test': The location of the test script (if any)
 
603
     */
 
604
    function applicationList()
 
605
    {
 
606
        if (!empty($this->_appoutput)) {
 
607
            return $this->_appoutput;
 
608
        }
 
609
 
 
610
        foreach ($this->applications as $mod => $det) {
 
611
            if (($det['status'] != 'heading') &&
 
612
                ($det['status'] != 'block') &&
 
613
                is_readable($det['fileroot'] . '/lib/version.php')) {
 
614
                require_once $det['fileroot'] . '/lib/version.php';
 
615
                eval('$defined = defined(\'' . strtoupper($mod) . '_VERSION\');');
 
616
                if ($defined) {
 
617
                    eval('$ver = ' . strtoupper($mod) . '_VERSION;');
 
618
                    $this->_appoutput[$mod] = &new stdClass;
 
619
                    $this->_appoutput[$mod]->version = $ver;
 
620
                    if (($mod != 'horde') &&
 
621
                        @is_readable($det['fileroot'] . '/test.php')) {
 
622
                        $this->_appoutput[$mod]->test = $det['webroot'] . '/test.php';
 
623
                    }
 
624
                }
 
625
            }
 
626
        }
 
627
 
 
628
        return $this->_appoutput;
 
629
    }
 
630
 
 
631
    /**
 
632
     * Output the results of a status check.
 
633
     *
 
634
     * @access private
 
635
     *
 
636
     * @param boolean $bool      The result of the status check.
 
637
     * @param boolean $required  Whether the checked item is required.
 
638
     *
 
639
     * @return string  The HTML of the result of the status check.
 
640
     */
 
641
    function _status($bool, $required = true)
 
642
    {
 
643
        if ($bool) {
 
644
            return '<font color="green"><b>Yes</b></font>';
 
645
        } elseif ($required) {
 
646
            return '<font color="red"><b>No</b></font>';
 
647
        } else {
 
648
            return '<font color="orange"><b>No</b></font>';
 
649
        }
 
650
    }
 
651
 
 
652
    /**
 
653
     * Internal output function.
 
654
     *
 
655
     * @access private
 
656
     *
 
657
     * @param array $entry  3 element array.
 
658
     * <pre>
 
659
     * 1st value: Header
 
660
     * 2nd value: Test Result
 
661
     * 3rd value: Error message (if present)
 
662
     * 4th value: Error level (if present): 0 = error, 1 = warning
 
663
     * </pre>
 
664
     *
 
665
     * @return string  HTML output.
 
666
     */
 
667
    function _outputLine($entry)
 
668
    {
 
669
        $output = '<li>' . array_shift($entry) . ': ' . array_shift($entry);
 
670
        if (!empty($entry)) {
 
671
            $msg = array_shift($entry);
 
672
            $output .= '<br /><font color="' . (empty($entry) || !array_shift($entry) ? 'red' : 'orange') . '"><b>' . $msg . '</b></font>' . "\n";
 
673
        }
 
674
        $output .= '</li>' . "\n";
 
675
 
 
676
        return $output;
 
677
    }
 
678
 
 
679
}