* @copyright 2014 Christian Weiske * @license http://www.gnu.org/licenses/agpl.html GNU AGPL v3 * @link http://cweiske.de/phancap.htm */ namespace phancap; header('HTTP/1.0 500 Internal Server Error'); if (file_exists(__DIR__ . '/../src/phancap/Autoloader.php')) { include_once __DIR__ . '/../src/phancap/Autoloader.php'; Autoloader::register(); } else { include_once 'phancap/Autoloader.php'; } $messages = array(); $config = new Config(); try { $config->load(); if ($config->disableSetup) { header('HTTP/1.0 403 Forbidden'); header('Content-type: text/plain'); echo "Setup check is disabled.\n"; exit(1); } $messages[][] = array('ok', 'Base configuration is ok'); if ($config->access === true) { $messages[][] = array('ok', 'Everyone may access the API'); } else if ($config->access === false) { $messages[][] = array('err', 'API access is disabled'); } else { $messages[][] = array( 'ok', count($config->access) . ' users may access the API' ); } foreach ($config->cfgFiles as $cfgFile) { $messages[][] = array( 'info', 'Possible config file: ' . $cfgFile ); } if ($config->cfgFileExists) { $messages[][] = array( 'ok', 'Configuration file loaded' ); } else { $messages[][] = array( 'info', 'No configuration file found' ); } } catch (\Exception $e) { $messages[][] = array('err', $e->getMessage()); } $adapter = array( 'Cutycapt' ); foreach ($adapter as $classpart) { $class = '\\phancap\\Adapter_' . $classpart; $adapter = new $class(); $adapter->setConfig($config); $errors = $adapter->isAvailable(); if ($errors === true) { $messages[][] = array( 'ok', 'Adapter ' . $classpart . ' is available' ); } else { foreach ($errors as $msg) { $messages['Adapter: '. $classpart][] = array('err', $msg); } } } $out = << phancap setup check
    HTM; $stateMap = array( 'ok' => 'success', 'info' => 'info', 'err' => 'danger' ); foreach ($messages as $key => $messages) { if (!is_numeric($key)) { $out .= '
  • ' . htmlspecialchars($key) . '
      '; } foreach ($messages as $data) { list($state, $message) = $data; $out .= '
    • '; $out .= htmlspecialchars($message); $out .= '
    • ' . "\n"; } if (!is_numeric($key)) { $out .= '
  • ' . "\n"; } } $out .= <<

    back to the index

HTM; header('HTTP/1.0 200 OK'); echo $out; ?>