Source for file libTest.php
Documentation is available at libTest.php
/* Store the PHP version information. */
/* We want to be as verbose as possible here. */
/* Set character encoding. */
header('Content-type: text/html; charset=utf-8');
header('Vary: Accept-Language');
/* First pick off major version, and lower-case the rest. */
if ((strlen($version) >= 3) && ($version[1] == '.')) {
$phpver['major'] = substr($version, 0, 3);
$phpver['major'] = $version;
$phpver['class'] = 'unknown';
if ($version[0] == '.') {
$version = substr($version, 1);
/* Next, determine if this is 4.0b or 4.0rc; if so, there is no
minor, the rest is the subminor, and class is set to beta. */
$s = strspn($version, '0123456789');
$phpver['subminor'] = $version;
$phpver['class'] = 'beta';
/* Otherwise, this is non-beta; the numeric part is the minor,
the rest is either a classification (dev, cvs) or a subminor
version (rc<x>, pl<x>). */
$phpver['minor'] = substr($version, 0, $s);
if ((strlen($version) > $s) && (($version[$s] == '.') || ($version[$s] == '-'))) {
$phpver['subminor'] = substr($version, $s);
if (($phpver['subminor'] == 'cvs') || ($phpver['subminor'] == 'dev') || (substr($phpver['subminor'], 0, 2) == 'rc')) {
unset ($phpver['subminor']);
$phpver['class'] = 'dev';
if (!$phpver['subminor']) {
unset ($phpver['subminor']);
$phpver['class'] = 'release';
$output_array = array ();
foreach ($modlist as $key => $val) {
$error_msg = $mod_test = $status_out = $fatal = null;
$descrip = $val['descrip'];
$fatal = !empty ($val['fatal']);
if (isset ($val['error'])) {
$error_msg = $val['error'];
$status_out = $this->_status($mod_test, $fatal);
if (!is_null($error_msg) && !$mod_test) {
if ($fatal && !$mod_test) {
/* Turn tracking of errors on. */
/* Print the include_path. */
$output .= $this->_outputLine(array("<strong>PEAR Search Path (PHP's include_path)</strong>", ' <tt>' . ini_get('include_path') . '</tt>'));
/* Go through module list. */
foreach ($pear_list as $key => $val) {
/* If this module depends on another module that we
* haven't succesfully found, fail the test. */
if (!empty($val['depends']) && empty($succeeded[$val['depends']])) {
$result = @include_once $val['path'];
$error_msg = $val['error'];
if ($result && isset ($val['function'])) {
$error_msg = $func_output;
$entry[] = $this->_status($result, !empty($val['required']));
if (!empty($val['required'])) {
$error_msg .= ' THIS IS A REQUIRED MODULE!';
if (empty($val['required'])) {
/* Restore previous value of 'track_errors'. */
foreach ($file_list as $key => $val) {
$entry[] = $this->_status($result);
$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.';
/* Try to load a basic framework if we're testing an app other than
* the Horde base files. */
$GLOBALS['registry'] = & Registry :: singleton();
$GLOBALS['registry']->pushApp('phpUserTrack', false);
/* Try to auto-create missing .dist files. */
foreach ($indices as $index) {
if (is_readable($appBase . '/config/' . $files[$index])) {
if (file_exists($appBase . '/config/' . $files[$index] . '.dist') && @ copy($appBase . '/config/' . $files[$index] . '.dist', $appBase . '/config/' . $files[$index])) {
/* Return if we have no missing files left. */
$output = & new stdClass;
$testscript = '.' . '/test.php';
$output->phpinfo = $testscript . '?mode=phpinfo&url=' . $url;
$output->extensions = $testscript . '?mode=extensions&url=' . $url;
$output->major = $this->_phpver['major'];
if (isset ($this->_phpver['minor'])) {
$output->minor = $this->_phpver['minor'];
if (isset ($this->_phpver['subminor'])) {
$output->subminor = $this->_phpver['subminor'];
$output->class = $this->_phpver['class'];
$output->status_color = 'red';
if ($output->major < '5.0') {
$output->status = 'This version of PHP is not supported. You need to upgrade to at least PHP 5.0';
elseif (($output->major == '5.0') || ($output->major == '5.1')) {
$output->status = 'You are running a supported version of PHP.';
$output->status_color = 'green';
$output->status = 'Wow, a mystical version of PHP from the future. Let <a href="mailto:mini@chatetheory.com">mini@chatetheory.com</a> know what version you have so we can fix this script.';
$output->status_color = 'orange';
$output->version_check = 'Horde requires PHP 4.3.0 or greater.';
function _status($bool, $required = true) {
return '<span class="supported">Yes</span>';
return '<span class="notsupported">No</span>';
return '<span class="notrequired">No</span>';
$output .= '<br /><span class="' . (empty ($entry) || !array_shift($entry) ? 'notsupported' : 'notrequired') . '">' . $msg . '</span>' . "\n";
$output .= '</li>' . "\n";
|