diff options
author | xue <> | 2005-12-03 16:19:08 +0000 |
---|---|---|
committer | xue <> | 2005-12-03 16:19:08 +0000 |
commit | 3ea63072225a473239227facfabde294bb58ed1d (patch) | |
tree | 2716662f13c184f31281bab45871c3ad3c9634b4 /framework/Exceptions/TErrorHandler.php | |
parent | bdd139266bbd71b828394a1500551254fc42a819 (diff) |
Diffstat (limited to 'framework/Exceptions/TErrorHandler.php')
-rw-r--r-- | framework/Exceptions/TErrorHandler.php | 48 |
1 files changed, 16 insertions, 32 deletions
diff --git a/framework/Exceptions/TErrorHandler.php b/framework/Exceptions/TErrorHandler.php index e9f48a2b..7d914fca 100644 --- a/framework/Exceptions/TErrorHandler.php +++ b/framework/Exceptions/TErrorHandler.php @@ -190,21 +190,14 @@ class TErrorHandler extends TComponent implements IModule die("Unable to open error template file '$errorFile'.");
$serverAdmin=isset($_SERVER['SERVER_ADMIN'])?$_SERVER['SERVER_ADMIN']:'';
- $fields=array(
- '%%StatusCode%%',
- '%%ErrorMessage%%',
- '%%ServerAdmin%%',
- '%%Version%%',
- '%%Time%%'
+ $tokens=array(
+ '%%StatusCode%%' => "$statusCode",
+ '%%ErrorMessage%%' => htmlspecialchars($exception->getMessage()),
+ '%%ServerAdmin%%' => $serverAdmin,
+ '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion(),
+ '%%Time%%' => strftime('%Y-%m-%d %H:%m',time())
);
- $values=array(
- "$statusCode",
- htmlspecialchars($exception->getMessage()),
- $serverAdmin,
- $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion(),
- strftime('%Y-%m-%d %H:%m',time())
- );
- echo str_replace($fields,$values,$content);
+ echo strtr($content,$tokens);
}
/**
@@ -257,23 +250,14 @@ class TErrorHandler extends TComponent implements IModule $source.=htmlspecialchars(sprintf("%04d: %s",$i+1,str_replace("\t",' ',$lines[$i])));
}
- $fields=array(
- '%%ErrorType%%',
- '%%ErrorMessage%%',
- '%%SourceFile%%',
- '%%SourceCode%%',
- '%%StackTrace%%',
- '%%Version%%',
- '%%Time%%'
- );
- $values=array(
- get_class($exception),
- htmlspecialchars($exception->getMessage()),
- htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')',
- $source,
- htmlspecialchars($exception->getTraceAsString()),
- $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion(),
- strftime('%Y-%m-%d %H:%m',time())
+ $tokens=array(
+ '%%ErrorType%%' => get_class($exception),
+ '%%ErrorMessage%%' => htmlspecialchars($exception->getMessage()),
+ '%%SourceFile%%' => htmlspecialchars($exception->getFile()).' ('.$exception->getLine().')',
+ '%%SourceCode%%' => $source,
+ '%%StackTrace%%' => htmlspecialchars($exception->getTraceAsString()),
+ '%%Version%%' => $_SERVER['SERVER_SOFTWARE'].' <a href="http://www.pradosoft.com/">PRADO</a>/'.Prado::getVersion(),
+ '%%Time%%' => strftime('%Y-%m-%d %H:%m',time())
);
$lang=Prado::getPreferredLanguage();
$exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'-'.$lang.'.html';
@@ -281,7 +265,7 @@ class TErrorHandler extends TComponent implements IModule $exceptionFile=Prado::getFrameworkPath().'/Exceptions/templates/'.self::EXCEPTION_FILE_NAME.'.html';
if(($content=@file_get_contents($exceptionFile))===false)
die("Unable to open exception template file '$exceptionFile'.");
- echo str_replace($fields,$values,$content);
+ echo strtr($content,$tokens);
}
}
|