Example #1
0
File: fcms.php Project: lmcro/fcms
/**
 * fcmsErrorHandler 
 * 
 * @param string $errno   PHP error number
 * @param string $errstr  description of error
 * @param string $errfile file path
 * @param string $errline line number
 *
 * @return boolean
 */
function fcmsErrorHandler($errno, $errstr, $errfile, $errline)
{
    $trace = array_reverse(debug_backtrace());
    $stack = '';
    $logStack = '';
    for ($i = 0; $i < count($trace); $i++) {
        $function = '???';
        $file = '???';
        $line = '???';
        if (isset($trace[$i])) {
            $function = isset($trace[$i]['function']) ? $trace[$i]['function'] : $function;
            $file = isset($trace[$i]['file']) ? $trace[$i]['file'] : $file;
            $line = isset($trace[$i]['line']) ? $trace[$i]['line'] : $line;
        }
        $stack .= '#' . $i . ' ' . $function . ' called at [' . $file . ':' . $line . ']<br/>';
        $logStack .= '    #' . $i . ' ' . $function . ' called at [' . $file . ':' . $line . "]\n";
    }
    switch ($errno) {
        case E_USER_ERROR:
            echo '
            <div class="error-alert">
                <p><b>Fatal Error</b></p>
                <p><b>File</b>: ' . $errfile . '</p>
                <p><b>Line</b>: ' . $errline . '</p>
                <p><b>Stack</b>:<br/><small>' . $stack . '</small></p>
                <p><b>PHP</b>: ' . PHP_VERSION . ' (' . PHP_OS . ')</p>
            </div>';
            exit(1);
            break;
        case E_USER_WARNING:
            $errno = 'PHP Warning';
            break;
        case E_USER_NOTICE:
            $errno = 'PHP Notice';
            break;
        default:
            $errno = 'PHP Error';
            break;
    }
    echo '<div class="error-alert"><p><b>' . $errno . '</b></p><p><b>' . $errstr . '</b></p>';
    if (debugOn()) {
        echo '<p><b>File</b>: ' . $errfile . '</p>';
        echo '<p><b>Line</b>: ' . $errline . '</p>';
        echo '<p><b>Stack</b>:<br/><small>' . $stack . '</small></p>';
        echo '<p><b>PHP</b>: ' . PHP_VERSION . ' (' . PHP_OS . ')</p>';
    }
    echo '</div>';
    $log = $errstr . "\n";
    $log .= '  FILE  - ' . $errfile . ' [' . $errline . "]\n";
    $log .= '  PHP   - ' . PHP_VERSION . ' (' . PHP_OS . ")\n";
    $log .= "  STACK\n" . $logStack . "\n";
    logError($log);
    // Don't execute PHP internal error handler
    return true;
}
Example #2
0
    ?>
</table><?php 
    if ($o) {
        $r = ob_get_contents();
        ob_end_clean();
        return $r;
    }
}
$_ = $_POST ?: $_GET;
if (!$_) {
    agent();
    return;
}
extract($_);
if ($debug === true) {
    debugOn();
}
$ip = ip();
switch ($mode) {
    case "write":
        $today = getdate()[0];
        $f = fopen("archive/index-{$today}-{$ip}.html", "w+");
        chmod($handle, 0777);
        fwrite($f, $content);
        fwrite($f, agent(true));
        fclose($f);
        $f = fopen($handle, "w+");
        chmod($handle, 0777);
        fwrite($f, $content);
        fclose($f);
        break;
Example #3
0
File: Error.php Project: lmcro/fcms
 /**
  * displayError 
  * 
  * Prints out the error.
  * 
  * @return void
  */
 public function displayError()
 {
     if (!$this->hasAnyError()) {
         return;
     }
     if ($this->type == 'user') {
         if (isset($_SESSION['user_error'])) {
             unset($_SESSION['user_error']);
         }
         $this->displayUserError();
         return;
     }
     echo '<div class="error-alert"><p><b>' . $this->message . '</b></p>';
     if (debugOn()) {
         echo '<p>' . $this->error . '</p>';
         echo '<p><b>File</b>: ' . $this->file . '</p>';
         echo '<p><b>Line</b>: ' . $this->line . '</p>';
         if (!is_null($this->sql)) {
             echo '<p><b>SQL</b>:<br/>' . $this->sql . '</p>';
         }
         echo '<p><b>Stack</b>:<br/><small>' . $this->stack . '</small></p>';
         echo '<p><b>PHP</b>: ' . PHP_VERSION . ' (' . PHP_OS . ')</p>';
     }
     echo '</div>';
 }