1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
<?php
/**
* Horde test script.
*
* Parameters:
* -----------
* - app: (string) The app to test.
* DEFAULT: horde
* - mode: (string) TODO
* - url: (string) TODO
*
* Copyright 1999-2014 Horde LLC (http://www.horde.org/)
*
* See the enclosed file COPYING for license information (LGPL-2). If you
* did not receive this file, see http://www.horde.org/licenses/lgpl.
*
* @author Brent J. Nordquist <bjn@horde.org>
* @author Chuck Hagenbuch <chuck@horde.org>
* @author Michael Slusarz <slusarz@horde.org>
* @category Horde
* @license http://www.horde.org/licenses/lgpl LGPL-2
* @package Horde
*/
/* Function to output fatal error message. */
function _hordeTestError($msg)
{
exit('<html><head><title>ERROR</title></head><body><h3 style="color:red">' . htmlspecialchars($msg) . '</h3></body></html>');
}
/* If we can't find the Autoloader, then the framework is not setup. A user
* must at least correctly install the framework. */
ini_set('include_path', __DIR__ . '/lib' . PATH_SEPARATOR . ini_get('include_path'));
if (file_exists(__DIR__ . '/config/horde.local.php')) {
include __DIR__ . '/config/horde.local.php';
}
if (!@include_once 'Horde/Autoloader.php') {
_hordeTestError(sprintf('Could not find Horde\'s framework libraries in the following path(s): %s. Please read horde/docs/INSTALL for information on how to install these libraries.', get_include_path()));
}
/* Similarly, registry.php needs to exist. */
if (!file_exists(__DIR__ . '/config/registry.php')) {
_hordeTestError('Could not find horde/config/registry.php. Please make sure this file exists. Read horde/docs/INSTALL for further information.');
}
require_once __DIR__ . '/lib/Application.php';
try {
Horde_Registry::appInit('horde', array(
'authentication' => 'none',
'test' => true
));
$init_exception = null;
} catch (Exception $e) {
define('HORDE_TEMPLATES', __DIR__ . '/templates');
$init_exception = $e;
}
if (!empty($conf['testdisable'])) {
_hordeTestError('Horde test scripts have been disabled in the local configuration. To enable, change the \'testdisable\' setting in horde/config/conf.php to false.');
}
/* We should have loaded the String class, from the Horde_Util package. If it
* isn't defined, then we're not finding some critical libraries. */
if (!class_exists('Horde_String')) {
_hordeTestError('Required Horde libraries were not found. If PHP\'s error_reporting setting is high enough and display_errors is on, there should be error messages printed above that may help you in debugging the problem. If you are simply missing these files, then you need to install the framework module.');
}
/* Initialize the Horde_Test:: class. */
if (!class_exists('Horde_Test')) {
/* Try and provide enough information to debug the missing file. */
_hordeTestError('Unable to find the Horde_Test library. Your Horde installation may be missing critical files, or PHP may not have sufficient permissions to include files. There may be error messages printed above this message that will help you in debugging the problem.');
}
/* Load the application. */
$app = Horde_Util::getFormData('app', 'horde');
$app_name = $registry->get('name', $app);
$app_version = $registry->getVersion($app);
/* If we've gotten this far, we should have found enough of Horde to run
* tests. Create the testing object. */
if ($app != 'horde') {
try {
$registry->pushApp($app, array('check_perms' => false));
} catch (Exception $e) {
_hordeTestError($e->getMessage());
}
}
$classname = ucfirst($app) . '_Test';
if (!class_exists($classname)) {
_hordeTestError('No tests found for ' . ucfirst($app) . ' [' . $app_name . '].');
}
$test_ob = new $classname();
/* Register a session. */
if ($session && !$session->exists('horde', 'test_count')) {
$session->set('horde', 'test_count', 0);
}
/* Template location. */
$test_templates = HORDE_TEMPLATES . '/test';
/* Self URL. */
$url = Horde::url('test.php', false, array('app' => 'horde'));
$self_url = $url->copy()->add('app', $app);
/* Handle special modes. */
switch (Horde_Util::getGet('mode')) {
case 'extensions':
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">';
$ext_get = Horde_Util::getGet('ext');
require $test_templates . '/extensions.inc';
exit;
case 'phpinfo':
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">';
echo '<a href="' . htmlspecialchars($self_url) . '"><< Back to test.php</a>';
phpinfo();
exit;
case 'unregister':
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">';
$session->remove('horde', 'test_count');
?>
<html>
<body>
The test session has been unregistered.<br />
<a href="<?php echo $self_url ?>">Go back</a> to the test.php page.<br />
</body>
</html>
<?php
exit;
}
/* Get the status output now. */
$pear_output = $test_ob->pearModuleCheck();
Horde::startBuffer();
require $test_templates . '/header.inc';
require $test_templates . '/version.inc';
if ($app == 'horde') {
?>
<h1>Horde Applications</h1>
<ul>
<?php
/* Get Horde module version information. */
if (!$init_exception) {
try {
$app_list = array_diff($registry->listAllApps(), array($app));
sort($app_list);
foreach ($app_list as $val) {
echo '<li>' . ucfirst($val);
if ($name = $registry->get('name', $val)) {
echo ' [' . $name . ']';
}
echo ': ' . $registry->getVersion($val);
if (file_exists($registry->get('fileroot', $val) . '/lib/Test.php')) {
echo ' (<a href="' . $url->copy()->add('app', $val) . '">run tests</a>)</li>';
}
echo "\n";
}
} catch (Exception $e) {
$init_exception = $e;
}
}
if ($init_exception) {
echo '<li style="color:red"><strong>Horde is not correctly configured so no application information can be displayed. Please follow the instructions in horde/docs/INSTALL and ensure horde/config/conf.php and horde/config/registry.php are correctly configured.</strong></li>' .
'<li><strong>Error:</strong> ' . $e->getMessage() . '</li>';
}
?>
</ul>
<?php
} elseif ($output = $test_ob->requiredAppCheck()) {
?>
<h1>Other Horde Applications</h1>
<ul>
<?php echo $output ?>
</ul>
<?php
}
/* Display PHP Version information. */
$php_info = $test_ob->getPhpVersionInformation();
require $test_templates . '/php_version.inc';
if ($module_output = $test_ob->phpModuleCheck()) {
?>
<h1>PHP Module Capabilities</h1>
<ul>
<?php echo $module_output ?>
</ul>
<?php
}
if ($setting_output = $test_ob->phpSettingCheck()) {
?>
<h1>Miscellaneous PHP Settings</h1>
<ul>
<?php echo $setting_output ?>
</ul>
<?php
}
if ($config_output = $test_ob->requiredFileCheck()) {
?>
<h1>Required Configuration Files</h1>
<ul>
<?php echo $config_output ?>
</ul>
<?php
}
?>
<h1>PHP Sessions</h1>
<ul>
<?php if (!$init_exception): ?>
<li>Session counter: <?php $tc = $session->get('horde', 'test_count'); echo ++$tc; $session->set('horde', 'test_count', $tc); ?> [refresh the page to increment the counter]</li>
<li>To unregister the session: <a href="<?php echo $self_url->copy()->add('mode', 'unregister') ?>">click here</a></li>
<?php else: ?>
<li style="color:red"><strong>The PHP session test is disabled until Horde is correctly configured.</strong></li>
<?php endif; ?>
</ul>
<h1>PEAR</h1>
<ul>
<?php echo $pear_output ?>
</ul>
<?php
/* Do application specifc tests now. */
echo $test_ob->appTests();
require $test_templates . '/footer.inc';
echo Horde::endBuffer();
|