* @copyright 2013 Horde LLC * @license http://www.fsf.org/copyleft/gpl.html GPL */ require 'vendor/autoload.php'; require 'lib/HordeInstaller.php'; $c = new Horde_Cli(); $c->writeln($c->bold('----------------------')); $c->writeln($c->bold('Horde installer script')); $c->writeln($c->bold('----------------------')); $argv = new Horde_Argv_Parser(); $argv->addOption('-i', '--install-dir', array('action' => 'store', 'dest' => 'horde_dir', 'help' => 'Horde install directory')); $argv->addOption('-l', '--log', array('action' => 'store', 'dest' => 'log', 'help' => 'Log filename')); list($values, ) = $argv->parseArgs(); $version = phpversion(); if (version_compare($version, '5.3.0') === -1) { $c->fatal('You need at least PHP version 5.3.0 to run Horde.'); } $c->writeln(); $c->message('PHP version: ' . $version, 'cli.message'); exec('which pear', $pear_output); if (empty($pear_output)) { $c->fatal('Could not find PEAR script in your include path.'); } $c->message('PEAR location: ' . $pear_output[0], 'cli.message'); while (!strlen($values->horde_dir)) { $values->horde_dir = $c->prompt('The directory to install Horde into:'); } $hi = new HordeInstaller(); $logfile = isset($values->log) ? realpath($values->log) : dirname(Phar::running(false)) . '/horde-installer.log'; $c->writeln(); try {
/** * Aborts with a fatal error, displaying debug information to the user. * * @param mixed $error Either a string or an object with a getMessage() * method (e.g. PEAR_Error, Exception). */ public static function fatal($error) { global $registry; if (is_object($error)) { switch (get_class($error)) { case 'Horde_Exception_AuthenticationFailure': $auth_app = !$registry->clearAuthApp($error->application); if ($auth_app && $registry->isAuthenticated(array('app' => $error->application, 'notransparent' => true))) { break; } try { Horde::log($error, 'NOTICE'); } catch (Exception $e) { } if (Horde_Cli::runningFromCLI()) { $cli = new Horde_Cli(); $cli->fatal($error); } $params = array(); if ($registry->getAuth()) { $params['app'] = $error->application; } switch ($error->getCode()) { case Horde_Auth::REASON_MESSAGE: $params['msg'] = $error->getMessage(); $params['reason'] = $error->getCode(); break; } $logout_url = $registry->getLogoutUrl($params); /* Clear authentication here. Otherwise, there might be * issues on the login page since we would otherwise need * to do session token checking (which might not be * available, so logout won't happen, etc...) */ if ($auth_app && array_key_exists('app', $params)) { $registry->clearAuth(); } $logout_url->redirect(); } } try { Horde::log($error, 'EMERG'); } catch (Exception $e) { } try { $cli = Horde_Cli::runningFromCLI(); } catch (Exception $e) { die($e); } if ($cli) { $cli = new Horde_Cli(); $cli->fatal($error); } if (!headers_sent()) { header('Content-type: text/html; charset=UTF-8'); } echo <<<HTML <html> <head><title>Horde :: Fatal Error</title></head> <body style="background:#fff; color:#000"> HTML; ob_start(); try { $admin = isset($registry) && $registry->isAdmin(); echo '<h1>' . Horde_Core_Translation::t("A fatal error has occurred") . '</h1>'; if (is_object($error) && method_exists($error, 'getMessage')) { echo '<h3>' . htmlspecialchars($error->getMessage()) . '</h3>'; } elseif (is_string($error)) { echo '<h3>' . htmlspecialchars($error) . '</h3>'; } if ($admin) { $trace = $error instanceof Exception ? $error : debug_backtrace(); echo '<div id="backtrace"><pre>' . strval(new Horde_Support_Backtrace($trace)) . '</pre></div>'; if (is_object($error)) { echo '<h3>' . Horde_Core_Translation::t("Details") . '</h3>'; echo '<h4>' . Horde_Core_Translation::t("The full error message is logged in Horde's log file, and is shown below only to administrators. Non-administrative users will not see error details.") . '</h4>'; ob_flush(); flush(); echo '<div id="details"><pre>' . htmlspecialchars(print_r($error, true)) . '</pre></div>'; } } else { echo '<h3>' . Horde_Core_Translation::t("Details have been logged for the administrator.") . '</h3>'; } } catch (Exception $e) { die($e); } ob_end_flush(); echo '</body></html>'; exit(1); }
public function fail($text) { $this->_cli->fatal($text); }