Ejemplo n.º 1
0
function finalOutput($error, $from)
{
    // For use by Email and database.log
    // Turn the error message into just plane text with LF at end of each line where a BR was.
    // and remove the "ERROR" header and any blank lines.
    $err = preg_replace("/<br>/", "\n", $error);
    $err = htmlspecialchars_decode(preg_replace("/<.*?>/", '', $err));
    $err = preg_replace("/^\\s*?\n/m", '', $err);
    // Callback to get the user ID if the callback exists
    $userId = '';
    $agent = $_SERVER['HTTP_USER_AGENT'] . "\n";
    if (function_exists('ErrorGetId')) {
        $userId = "User: "******"{$userId}\n";
    }
    // Email error information to webmaster
    // During debug set the Error class's $noEmailErrs to ture
    if (Error::getNoEmailErrs() !== true && defined(EMAILADDRESS)) {
        mail(EMAILADDRESS, $from, "{$err}{$userId}", "From: " . EMAILFROM, "-f " . EMAILRETURN);
    }
    if (!file_exists(LOGFILE)) {
        // create it and change the permisions
        touch(LOGFILE);
        chmod(LOGFILE, 0666);
    }
    date_default_timezone_set('America/New_York');
    file_put_contents(LOGFILE, date("Y-m-d h:m:s") . "\n{$from}: {$err}{$userId}{$agent}*****\n", FILE_APPEND);
    if (Error::getDevelopment() !== true) {
        // Minimal error message
        $error = <<<EOF
<p>The webmaster has been notified of this error and it should be fixed shortly. Please try again in
a couple of hours.</p>

EOF;
        $err = " The webmaster has been notified of this error and it should be fixed shortly." . " Please try again in a couple of hours.";
    }
    if (Error::getNohtml() === true) {
        $error = "<pre><b>{$from}:</b>{$err}</pre>";
    } else {
        $error = <<<EOF
<div style="text-align: center; background-color: white; border: 1px solid black; width: 85%; margin: auto auto; padding: 10px;">
<h1 style="color: red">{$from}</h1>
{$error}
</div>
EOF;
    }
    if (Error::getNoOutput() !== true) {
        echo $error;
    }
}
Ejemplo n.º 2
0
function finalOutput($error, $from)
{
    // For use by Email and database.log
    // Turn the error message into just plane text with LF at end of each line where a BR was.
    // and remove the "ERROR" header and any blank lines.
    $err = html_entity_decode(preg_replace("/<.*?>/", '', $error));
    $err = preg_replace("/^\\s*\$/", '', $err);
    // Callback to get the user ID if the callback exists
    $userId = '';
    if (function_exists('ErrorGetId')) {
        $userId = "User: "******"agent: " . $_SERVER['HTTP_USER_AGENT'] . "\n";
    }
    // Email error information to webmaster
    // During debug set the Error class's $noEmailErrs to ture
    if (ErrorClass::getNoEmailErrs() !== true) {
        $S = $GLOBALS["S"];
        if (!$S || empty($S->EMAILADDRESS)) {
            $S->EMAILADDRESS = $S->EMAILRETURN = $S->EMAILFROM = "*****@*****.**";
        }
        mail($S->EMAILADDRESS, $from, "{$err}{$userId}", "From: " . $S->EMAILFROM, "-f " . $S->EMAILRETURN);
    }
    // Log the raw error info.
    date_default_timezone_set('America/Los_Angeles');
    error_log("ErrorClass, finalOutput: {$from}\n{$err}{$userId}");
    if (ErrorClass::getDevelopment() !== true) {
        // Minimal error message
        $error = <<<EOF
<p>The webmaster has been notified of this error and it should be fixed shortly. Please try again in
a couple of hours.</p>

EOF;
        $err = " The webmaster has been notified of this error and it should be fixed shortly." . " Please try again in a couple of hours.";
    }
    if (ErrorClass::getNohtml() === true) {
        $error = "{$from}: {$err}";
    } else {
        $error = <<<EOF
<div style="text-align: center; background-color: white; border: 1px solid black; width: 85%; margin: auto auto; padding: 10px;">
<h1 style="color: red">{$from}</h1>
{$error}
</div>
EOF;
    }
    if (ErrorClass::getNoOutput() !== true) {
        echo $error;
    }
}