Пример #1
0
global $scopeType;
$interface->assign('solrScope', "{$solrScope} - {$scopeType}");
$interface->assign('millenniumScope', $millenniumScope);
//Set that the interface is a single column by default
$interface->assign('page_body_style', 'one_column');
$interface->assign('showPackagingDetailsReport', isset($configArray['EContent']['showPackagingDetailsReport']) && $configArray['EContent']['showPackagingDetailsReport']);
$interface->assign('showFines', $configArray['Catalog']['showFines']);
$interface->assign('activeIp', Location::getActiveIp());
// Check system availability
$mode = checkAvailabilityMode();
if ($mode['online'] === false) {
    // Why are we offline?
    switch ($mode['level']) {
        // Forced Downtime
        case "unavailable":
            $interface->display($mode['template']);
            break;
            // Should never execute. checkAvailabilityMode() would
            //    need to know we are offline, but not why.
        // Should never execute. checkAvailabilityMode() would
        //    need to know we are offline, but not why.
        default:
            $interface->display($mode['template']);
            break;
    }
    exit;
}
$timer->logTime('Checked availability mode');
//Check to see if we have a collection applied.
global $defaultCollection;
if (isset($_GET['collection'])) {
Пример #2
0
/**
 * Handle an error raised by pear
 *
 * @var PEAR_Error $error;
 * @var string $method
 *
 * @return null
 */
function handlePEARError($error, $method = null)
{
    global $errorHandlingEnabled;
    if (isset($errorHandlingEnabled) && $errorHandlingEnabled == false) {
        return;
    }
    global $configArray;
    // It would be really bad if an error got raised from within the error handler;
    // we would go into an infinite loop and run out of memory.  To avoid this,
    // we'll set a static value to indicate that we're inside the error handler.
    // If the error handler gets called again from within itself, it will just
    // return without doing anything to avoid problems.  We know that the top-level
    // call will terminate execution anyway.
    static $errorAlreadyOccurred = false;
    if ($errorAlreadyOccurred) {
        return;
    } else {
        $errorAlreadyOccurred = true;
    }
    //Clear any output that has been generated so far so the user just gets the error message.
    if (!$configArray['System']['debug']) {
        @ob_clean();
        header("Content-Type: text/html");
    }
    // Display an error screen to the user:
    global $interface;
    if (!isset($interface) || $interface == false) {
        $interface = new UInterface();
    }
    global $analytics;
    if ($analytics) {
        $analytics->addEvent('Unexpected Error', 'Unexpected Error', $error, $method);
    }
    $interface->assign('error', $error);
    $interface->assign('debug', $configArray['System']['debug']);
    $interface->setTemplate('../error.tpl');
    $interface->display('layout.tpl');
    // Exceptions we don't want to log
    $doLog = true;
    // Microsoft Web Discussions Toolbar polls the server for these two files
    //    it's not script kiddie hacking, just annoying in logs, ignore them.
    if (strpos($_SERVER['REQUEST_URI'], "cltreq.asp") !== false) {
        $doLog = false;
    }
    if (strpos($_SERVER['REQUEST_URI'], "owssvr.dll") !== false) {
        $doLog = false;
    }
    // If we found any exceptions, finish here
    if (!$doLog) {
        exit;
    }
    // Log the error for administrative purposes -- we need to build a variety
    // of pieces so we can supply information at five different verbosity levels:
    $baseError = $error->toString();
    $basicServer = " (Server: IP = {$_SERVER['REMOTE_ADDR']}, " . "Referer = " . (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '') . ", " . "User Agent = " . (isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : '') . ", " . "Request URI = {$_SERVER['REQUEST_URI']})";
    $detailedServer = "\nServer Context:\n" . print_r($_SERVER, true);
    $basicBacktrace = "\nBacktrace:\n";
    if (is_array($error->backtrace)) {
        foreach ($error->backtrace as $line) {
            $basicBacktrace .= (isset($line['file']) ? $line['file'] : 'none') . "  line " . (isset($line['line']) ? $line['line'] : 'none') . " - " . "class = " . (isset($line['class']) ? $line['class'] : 'none') . ", function = " . (isset($line['function']) ? $line['function'] : 'none') . "\n";
        }
    }
    $detailedBacktrace = "\nBacktrace:\n" . print_r($error->backtrace, true);
    $errorDetails = array(1 => $baseError, 2 => $baseError . $basicServer, 3 => $baseError . $basicServer . $basicBacktrace, 4 => $baseError . $detailedServer . $basicBacktrace, 5 => $baseError . $detailedServer . $detailedBacktrace);
    global $logger;
    $logger->log($errorDetails, PEAR_LOG_ERR);
    exit;
}
Пример #3
0
/**
 * Callback function to handle any PEAR errors that are thrown.
 *
 * @param PEAR_Error $error The error object.
 *
 * @return void
 */
function handlePEARError($error)
{
    global $configArray;
    // It would be really bad if an error got raised from within the error handler;
    // we would go into an infinite loop and run out of memory.  To avoid this,
    // we'll set a static value to indicate that we're inside the error handler.
    // If the error handler gets called again from within itself, it will just
    // return without doing anything to avoid problems.  We know that the top-level
    // call will terminate execution anyway.
    static $errorAlreadyOccurred = false;
    if ($errorAlreadyOccurred) {
        return;
    } else {
        $errorAlreadyOccurred = true;
    }
    // Set appropriate HTTP header based on error (404 for missing record, 500 for
    // other problems):
    $msg = $error->getMessage();
    if ($msg == 'Record Does Not Exist' || stristr($msg, 'cannot access record')) {
        header('HTTP/1.1 404 Not Found');
    } else {
        header('HTTP/1.1 500 Internal Server Error');
    }
    // Display an error screen to the user:
    $interface = new UInterface();
    $interface->assign('error', $error);
    $interface->assign('debug', $configArray['System']['debug']);
    $interface->display('error.tpl');
    // Exceptions we don't want to log
    $doLog = true;
    // Microsoft Web Discussions Toolbar polls the server for these two files
    //    it's not script kiddie hacking, just annoying in logs, ignore them.
    if (strpos($_SERVER['REQUEST_URI'], "cltreq.asp") !== false) {
        $doLog = false;
    }
    if (strpos($_SERVER['REQUEST_URI'], "owssvr.dll") !== false) {
        $doLog = false;
    }
    // If we found any exceptions, finish here
    if (!$doLog) {
        exit;
    }
    // Log the error for administrative purposes -- we need to build a variety
    // of pieces so we can supply information at five different verbosity levels:
    $baseError = $error->toString();
    $referer = isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : 'none';
    $basicServer = " (Server: IP = {$_SERVER['REMOTE_ADDR']}, " . "Referer = {$referer}, " . "User Agent = {$_SERVER['HTTP_USER_AGENT']}, " . "Request URI = {$_SERVER['REQUEST_URI']})";
    $detailedServer = "\nServer Context:\n" . print_r($_SERVER, true);
    $basicBacktrace = "\nBacktrace:\n";
    if (is_array($error->backtrace)) {
        foreach ($error->backtrace as $line) {
            $basicBacktrace .= "{$line['file']} line {$line['line']} - " . "class = {$line['class']}, function = {$line['function']}\n";
        }
    }
    $detailedBacktrace = "\nBacktrace:\n" . print_r($error->backtrace, true);
    $errorDetails = array(1 => $baseError, 2 => $baseError . $basicServer, 3 => $baseError . $basicServer . $basicBacktrace, 4 => $baseError . $detailedServer . $basicBacktrace, 5 => $baseError . $detailedServer . $detailedBacktrace);
    $logger = new Logger();
    $logger->log($errorDetails, PEAR_LOG_ERR);
    exit;
}