new pisilinux web sites
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php namespace ZN\ErrorHandling;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
use ZN\Lang;
|
||||
use ZN\ErrorHandling\Exceptions;
|
||||
|
||||
class DebugException
|
||||
{
|
||||
/**
|
||||
* Magic constructor
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $message = NULL
|
||||
* @param mixed $changed = NULL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct(string $file, ?string $message = NULL, $changed = NULL)
|
||||
{
|
||||
if( $data = Lang::default('ZN\CoreDefaultLanguage')::select($file, $message, $changed) )
|
||||
{
|
||||
$message = $data;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = $file;
|
||||
}
|
||||
|
||||
$debug = (object) debug_backtrace(2)[1];
|
||||
|
||||
echo Exceptions::continue($message, $debug->file, $debug->line);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<?php namespace ZN\ErrorHandling;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Configuration
|
||||
*
|
||||
* Enabled when the configuration file can not be accessed.
|
||||
*/
|
||||
class ErrorHandlingDefaultConfiguration
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Error Reporting
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Includes error reporting settings.
|
||||
|
|
||||
*/
|
||||
|
||||
public $errorReporting = E_ALL;
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Escape Errors
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| Error numbers for which the error indication is to be prevented.
|
||||
|
|
||||
*/
|
||||
|
||||
public $escapeErrors = [];
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Exit Errors
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| It is specified which error numbers will stop the code stream.
|
||||
|
|
||||
*/
|
||||
|
||||
public $exitErrors = [0, 2];
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?php namespace ZN\ErrorHandling;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default Configuration
|
||||
*
|
||||
* Provides predefined language content for core classes.
|
||||
*/
|
||||
class ErrorHandlingDefaultLanguage
|
||||
{
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Butcher
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The language of the Core structures.
|
||||
|
|
||||
*/
|
||||
|
||||
public $en =
|
||||
[
|
||||
'type' => 'Type',
|
||||
'line' => 'Line',
|
||||
'message' => 'Error',
|
||||
'file' => 'File',
|
||||
'trace' => 'Trace'
|
||||
];
|
||||
|
||||
public $tr =
|
||||
[
|
||||
'type' => 'Tür',
|
||||
'line' => 'Satır',
|
||||
'message' => 'Hata',
|
||||
'file' => 'Dosya',
|
||||
'trace' => 'İz'
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,159 @@
|
||||
<?php namespace ZN\ErrorHandling;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
use ZN\Lang;
|
||||
|
||||
class Errors
|
||||
{
|
||||
/**
|
||||
* Get error message
|
||||
*
|
||||
* @param string $langFile
|
||||
* @param string $errorMsg = NULL
|
||||
* @param mixed $ex = NULL
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function message(string $langFile, ?string $errorMsg = NULL, $ex = NULL) : string
|
||||
{
|
||||
$style = 'border:solid 1px #E1E4E5;';
|
||||
$style .= 'background:#FEFEFE;';
|
||||
$style .= 'padding:10px;';
|
||||
$style .= 'margin-bottom:10px;';
|
||||
$style .= 'font-family:Calibri, Ebrima, Century Gothic, Consolas, Courier New, Courier, monospace, Tahoma, Arial;';
|
||||
$style .= 'color:#666;';
|
||||
$style .= 'text-align:left;';
|
||||
$style .= 'font-size:14px;';
|
||||
|
||||
$exStyle = 'color:#900;';
|
||||
|
||||
if( ! is_array($ex) )
|
||||
{
|
||||
$ex = '<span style="'.$exStyle .'">'.$ex.'</span>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$newArray = [];
|
||||
|
||||
if( ! empty($ex) ) foreach( $ex as $k => $v )
|
||||
{
|
||||
$newArray[$k] = $v;
|
||||
}
|
||||
|
||||
$ex = $newArray;
|
||||
}
|
||||
|
||||
$str = "<div style=\"$style\">";
|
||||
|
||||
if( $errorMsg !== NULL )
|
||||
{
|
||||
$str .= Lang::default('ZN\CoreDefaultLanguage')::select($langFile, $errorMsg, $ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
$str .= $langFile;
|
||||
}
|
||||
|
||||
$str .= '</div><br>';
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get last error
|
||||
*
|
||||
* @param string $type = NULL
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public static function last(?string $type = NULL)
|
||||
{
|
||||
$result = error_get_last();
|
||||
|
||||
if( $type === NULL )
|
||||
{
|
||||
return $result;
|
||||
}
|
||||
else
|
||||
{
|
||||
return $result[$type] ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Error log
|
||||
*
|
||||
* @param string $message
|
||||
* @param int $type = 0
|
||||
* @param string $destination = NULL
|
||||
* @param string $header = NULL
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function log(string $message, int $type = 0, ?string $destination = NULL, ?string $header = NULL) : bool
|
||||
{
|
||||
return error_log($message, $type, $destination, $header);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get error report
|
||||
*
|
||||
* @param int $level = NULL
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function report(?int $level = NULL) : int
|
||||
{
|
||||
if( ! empty($level) )
|
||||
{
|
||||
return error_reporting($level);
|
||||
}
|
||||
|
||||
return error_reporting();
|
||||
}
|
||||
|
||||
/**
|
||||
* Exception handler
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function handler(int $errorTypes = E_ALL | E_STRICT)
|
||||
{
|
||||
set_error_handler([new Exceptions, 'table'], $errorTypes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger error
|
||||
*
|
||||
* @param string $msg
|
||||
* @param int $errorType = E_USER_NOTICE
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function trigger(string $msg, int $errorType = E_USER_NOTICE) : bool
|
||||
{
|
||||
return trigger_error($msg, $errorType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore handler
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function restore()
|
||||
{
|
||||
restore_error_handler();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
<?php namespace ZN\ErrorHandling;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
use ZN\Base;
|
||||
use ZN\Lang;
|
||||
use ZN\Config;
|
||||
use ZN\Helper;
|
||||
use ZN\Datatype;
|
||||
use ZN\Inclusion;
|
||||
|
||||
class Exceptions extends \Exception implements ExceptionsInterface
|
||||
{
|
||||
/**
|
||||
* Error codes
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $errorCodes =
|
||||
[
|
||||
1 => 'ERROR',
|
||||
2 => 'WARNING',
|
||||
4 => 'PARSE',
|
||||
8 => 'NOTICE',
|
||||
16 => 'CORE_ERROR',
|
||||
32 => 'CORE_WARNING',
|
||||
64 => 'COMPILE_ERROR',
|
||||
128 => 'COMPILE_WARNING',
|
||||
256 => 'USER_ERROR',
|
||||
512 => 'USER_WARNING',
|
||||
1024 => 'USER_NOTICE',
|
||||
2048 => 'STRICT',
|
||||
4096 => 'RECOVERABLE_ERROR',
|
||||
8192 => 'DEPRECATED',
|
||||
16384 => 'USER_DEPRECATED',
|
||||
32767 => 'ALL'
|
||||
];
|
||||
|
||||
/**
|
||||
* Magic to string
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return $this->importExceptionTemplate($this->getMessage(), $this->getFile(), $this->getLine(), $this->getTrace());
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw exception
|
||||
*
|
||||
* @param string $message = NULL
|
||||
* @param string $key = NULL
|
||||
* @param mixed $send = NULL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function throws(?string $message = NULL, ?string $key = NULL, $send = NULL)
|
||||
{
|
||||
$debug = self::throwFinder(debug_backtrace(2), 0, 2);
|
||||
|
||||
if( $lang = Lang::default('ZN\CoreDefaultLanguage')::select($message, $key, $send) )
|
||||
{
|
||||
$message = '['.self::cleanInternalPrefixFromClassName($debug['class']).'::'.$debug['function'].'()] '.$lang;
|
||||
}
|
||||
|
||||
self::table('self', $message, $debug['file'], $debug['line']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get exception table
|
||||
*
|
||||
* @param mixed $no = NULL
|
||||
* @param string $msg = NULL
|
||||
* @param string $file = NULL
|
||||
* @param string $line = NULL
|
||||
* @param array $trace = NULL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function table($no = NULL, ?string $msg = NULL, ?string $file = NULL, ?string $line = NULL, ?array $trace = NULL)
|
||||
{
|
||||
if( is_object($no) )
|
||||
{
|
||||
$msg = $no->getMessage();
|
||||
$file = $no->getFile();
|
||||
$line = $no->getLine();
|
||||
$trace = $no->getTrace();
|
||||
|
||||
$no = 'NULL';
|
||||
}
|
||||
|
||||
$lang = Lang::default('ZN\ErrorHandling\ErrorHandlingDefaultLanguage')::select('Templates');
|
||||
$message = $lang['line'].':'.$line.', '.$lang['file'].':'.$file.', '.$lang['message'].':'.$msg;
|
||||
|
||||
Helper::report('ExceptionError', $message, 'ExceptionError');
|
||||
|
||||
$table = self::importExceptionTemplate($msg, $file, $line, $no, $trace);
|
||||
|
||||
$projectError = Config::default('ZN\ErrorHandling\ErrorHandlingDefaultConfiguration')::get('Project');
|
||||
|
||||
if
|
||||
(
|
||||
in_array($no, $projectError['exitErrors'] ?? [], true) ||
|
||||
in_array(self::$errorCodes[$no] ?? NULL, $projectError['exitErrors'] ?? [], true)
|
||||
)
|
||||
{
|
||||
defined('ZN_REDIRECT_NOEXIT') || exit($table); // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
echo $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Continue exception
|
||||
*
|
||||
* @param string $msg
|
||||
* @param string $file
|
||||
* @param string $line
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function continue($msg, $file, $line)
|
||||
{
|
||||
return self::importExceptionTemplate($msg, $file, $line, NULL, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* Restore exception
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function restore() : bool
|
||||
{
|
||||
return restore_exception_handler();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set exception handler
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function handler()
|
||||
{
|
||||
set_exception_handler([__CLASS__, 'table']);
|
||||
}
|
||||
|
||||
/**
|
||||
* protected exception template
|
||||
*
|
||||
* @param string $msg
|
||||
* @param string $file
|
||||
* @param string $line
|
||||
* @param string $no
|
||||
* @param array $trace
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private static function importExceptionTemplate($msg, $file, $line, $no, $trace)
|
||||
{
|
||||
$projects = Config::default('ZN\ErrorHandling\ErrorHandlingDefaultConfiguration')::get('Project');
|
||||
|
||||
if( ! $projects['errorReporting'] )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( in_array($no, $projects['escapeErrors'], true) || in_array(self::$errorCodes[$no] ?? NULL, $projects['escapeErrors'], true) )
|
||||
{
|
||||
return false; // @codeCoverageIgnore
|
||||
}
|
||||
|
||||
$wizardErrorData = self::getTemplateWizardErrorData($file, $line);
|
||||
|
||||
$exceptionData =
|
||||
[
|
||||
'type' => self::$errorCodes[$no] ?? 'ERROR',
|
||||
'msg' => $msg,
|
||||
'file' => $wizardErrorData->file,
|
||||
'line' => $wizardErrorData->line,
|
||||
'trace' => $trace
|
||||
];
|
||||
|
||||
ob_end_clean();
|
||||
|
||||
return Inclusion\View::use('Table', $exceptionData, true, __DIR__ . '/Resources/');
|
||||
}
|
||||
|
||||
/**
|
||||
* protected clean class name
|
||||
*
|
||||
* @param string $class
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected static function cleanInternalPrefixFromClassName($class)
|
||||
{
|
||||
return str_ireplace(INTERNAL_ACCESS, '', Datatype::divide($class, '\\', -1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Throw finder
|
||||
*
|
||||
* @param array $trace
|
||||
* @param int $p1 = 2
|
||||
* @param int $p2 = 0
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected static function throwFinder($trace, $p1 = 3, $p2 = 5)
|
||||
{
|
||||
$classInfo = $trace[$p1];
|
||||
$fileInfo = $trace[$p2];
|
||||
|
||||
// @codeCoverageIgnoreStart
|
||||
if( ! isset($classInfo['class']) && isset($classInfo['function']) )
|
||||
{
|
||||
$classInfo['class'] = $classInfo['function'];
|
||||
$fileInfo['file'] = $classInfo['file'];
|
||||
$fileInfo['line'] = $classInfo['line'];
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
|
||||
return
|
||||
[
|
||||
'class' => self::cleanInternalPrefixFromClassName($classInfo['class']),
|
||||
'function' => $classInfo['function'],
|
||||
'file' => $fileInfo['file'],
|
||||
'line' => $fileInfo['line'],
|
||||
'trace' => $trace
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle template wizard
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return string|null
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected static function getTemplateWizardErrorData($file, $line)
|
||||
{
|
||||
if( strstr($file, DS . 'Buffering.php') )
|
||||
{
|
||||
$trace = debug_backtrace()[6]['args'] ?? [NULL];
|
||||
$args = debug_backtrace()[1]['args'][4] ?? [];
|
||||
|
||||
self::searchErrorWizardFile($args, $file, $line);
|
||||
|
||||
self::isWizardOrStandartFileExists($file, $trace);
|
||||
}
|
||||
|
||||
return (object)
|
||||
[
|
||||
'file' => $file,
|
||||
'line' => $line
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected search error wizard file
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected static function searchErrorWizardFile($args, &$file, &$line)
|
||||
{
|
||||
foreach( $args as $key => $value )
|
||||
{
|
||||
if( is_array($value) )
|
||||
{
|
||||
if( ! isset($line) && isset($value['file']) && stristr($value['file'], DS . 'Buffering.php') )
|
||||
{
|
||||
$line = $value['line'] ?? NULL;
|
||||
}
|
||||
|
||||
$find = $value['args'][0] ?? NULL;
|
||||
|
||||
if( is_string($find) && preg_match('/(Views\/)*.*?\.\wizard(\.php)*/', $find) )
|
||||
{
|
||||
$file = $find;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected is wizard or standart file exists
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
protected static function isWizardOrStandartFileExists(&$file, $trace)
|
||||
{
|
||||
if( ! is_file($file) )
|
||||
{
|
||||
$file = Base::prefix($file, VIEWS_DIR);
|
||||
|
||||
if( ! is_file($file) )
|
||||
{
|
||||
if( ! is_file($rfile = $file . '.php') )
|
||||
{
|
||||
if( ! is_file($rfile = $file . '.wizard.php') )
|
||||
{
|
||||
if( isset($trace[0]) && is_file($rfile = Base::suffix(Base::prefix($trace[0], VIEWS_DIR), '.php')) )
|
||||
{
|
||||
$file = $rfile;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ! is_file($rfile) )
|
||||
{
|
||||
$file = VIEWS_DIR . CURRENT_CONTROLLER . '/' . CURRENT_CFUNCTION . '.wizard.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = $rfile;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$file = $rfile;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display exception table
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $line
|
||||
* @param string $key
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function display($file, $line, $key)
|
||||
{
|
||||
?>
|
||||
<a href="#openExceptionMessage<?php echo $key?>" class="list-group-item panel-header" style="color:#999;" data-toggle="collapse">
|
||||
<span><i class="fa fa-angle-down fa-fw panel-text"></i>
|
||||
<?php echo $file ?? NULL; ?></span>
|
||||
</a>
|
||||
<div id="openExceptionMessage<?php echo $key?>" class="collapse<?php echo $key !== 0 ? '' : ' in'?>">
|
||||
<pre style="color:#ccc; background:#222; margin-top:-20px; border:0px">
|
||||
<?php
|
||||
|
||||
$content = is_file($file) ? file($file) : NULL;
|
||||
$newdata = '<?PHP' . EOL;
|
||||
$intline = $line;
|
||||
|
||||
for( $i = (($startLine = ($intline - 10)) < 0 ? 0 : $startLine); $i < ($intcount = $intline + 10); $i++ )
|
||||
{
|
||||
if( ! isset($content[$i]) )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
$index = $i + 1;
|
||||
$line = $content[$i];
|
||||
|
||||
if( $index == $intline )
|
||||
{
|
||||
$problem = ' {!!!!}';
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$problem = ' ';
|
||||
}
|
||||
|
||||
$newdata .= $index.'.' . $problem .
|
||||
str_repeat(' ', strlen($intcount) - strlen($i + 1)) .
|
||||
$line;
|
||||
}
|
||||
|
||||
echo self::displayHighlightErrorContent($newdata)
|
||||
|
||||
?></pre></div><?php
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected convert php tag to wizard tag
|
||||
*/
|
||||
protected static function convertPHPTagToWizardTag(&$content)
|
||||
{
|
||||
$content = str_replace(['<?php', '?>', '<?='], ['{[', ']}', '{[='], $content ?? '');
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected important fields
|
||||
*/
|
||||
protected static function hiddenImportantFields(&$content)
|
||||
{
|
||||
$content = preg_replace('/\'(user|password|port|database|host|dsn|key)\'(\s+=>\s+)\'(.*?)\'(,*\s*(\n\r|\n))/', '\'$1\'$2\'********\'$4', $content);
|
||||
}
|
||||
|
||||
/**
|
||||
* Protected display highlight error content
|
||||
*/
|
||||
protected static function displayHighlightErrorContent($content)
|
||||
{
|
||||
self::convertPHPTagToWizardTag($content);
|
||||
self::hiddenImportantFields($content);
|
||||
|
||||
$errorBlock = '<div class="error-block col-lg-12"></div>';
|
||||
|
||||
return preg_replace('/(<br\s\/>|'.CRLF.'|'.CR.'|'.LF.')+/', EOL, str_replace(['<?PHP', '{!!!!}'], [NULL, $errorBlock], Helper::highlight($content,
|
||||
[
|
||||
'default:color' => '#ccc',
|
||||
'keyword:color' => '#00BFFF',
|
||||
'string:color' => '#fff'
|
||||
])));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php namespace ZN\ErrorHandling;
|
||||
/**
|
||||
* ZN PHP Web Framework
|
||||
*
|
||||
* "Simplicity is the ultimate sophistication." ~ Da Vinci
|
||||
*
|
||||
* @package ZN
|
||||
* @license MIT [http://opensource.org/licenses/MIT]
|
||||
* @author Ozan UYKUN [ozan@znframework.com]
|
||||
*/
|
||||
|
||||
interface ExceptionsInterface
|
||||
{
|
||||
/**
|
||||
* Throw exception
|
||||
*
|
||||
* @param string $message = NULL
|
||||
* @param string $key = NULL
|
||||
* @param mixed $send = NULL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function throws(?string $message = NULL, ?string $key = NULL, $send = NULL);
|
||||
|
||||
/**
|
||||
* Get exception table
|
||||
*
|
||||
* @param mixed $no = NULL
|
||||
* @param string $msg = NULL
|
||||
* @param string $file = NULL
|
||||
* @param string $line = NULL
|
||||
* @param array $trace = NULL
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function table($no = NULL, ?string $msg = NULL, ?string $file = NULL, ?string $line = NULL, ?array $trace = NULL);
|
||||
|
||||
/**
|
||||
* Restore exception
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public static function restore() : bool;
|
||||
|
||||
/**
|
||||
* Set exception handler
|
||||
*
|
||||
* @param void
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function handler();
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
<?php unset($trace['params']); ?>
|
||||
|
||||
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
|
||||
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="https://code.jquery.com/jquery-latest.js"></script>
|
||||
<script type="text/javascript" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||
<style>
|
||||
code{
|
||||
background:none;
|
||||
}
|
||||
.pointer
|
||||
{
|
||||
cursor:pointer;
|
||||
}
|
||||
.text-color
|
||||
{
|
||||
color:#00BFFF
|
||||
}
|
||||
.panel-header
|
||||
{
|
||||
background-color: #1b1717;
|
||||
border: 1px solid #222;
|
||||
}
|
||||
.panel-top-header
|
||||
{
|
||||
background-color: #333;
|
||||
border:solid 1px #222;
|
||||
}
|
||||
.panel-text
|
||||
{
|
||||
color:#ccc;
|
||||
}
|
||||
.h-panel-header
|
||||
{
|
||||
margin-top: 15px;
|
||||
margin-bottom: 15px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.error-block
|
||||
{
|
||||
position:absolute;
|
||||
margin-top:-19px;
|
||||
margin-left:-10px;
|
||||
margin-right:-100px;
|
||||
width:96.37%;
|
||||
height:20px;
|
||||
background:white;
|
||||
opacity:.1
|
||||
}
|
||||
</style>
|
||||
|
||||
<div class="col-lg-12" style="z-index:1000000; margin-top:15px">
|
||||
<div class="panel panel-default panel-top-header">
|
||||
|
||||
<div class="panel-heading" style="background:#222; border:none;">
|
||||
<h3 class="panel-title panel-text h-panel-header">
|
||||
<i class="fa fa-exclamation-triangle fa-fw"></i>
|
||||
<?php echo '<span class="text-color">'.($type ?? 'ERROR').'</span> » ' ?>
|
||||
<?php echo $msg ?? NULL; ?></h3>
|
||||
</div>
|
||||
|
||||
<div class="panel-body" style="margin-bottom:-17px;">
|
||||
<div class="list-group">
|
||||
<?php
|
||||
$i = 0;
|
||||
if( is_array($trace) ) foreach( $trace as $key => $debug )
|
||||
{
|
||||
if
|
||||
(
|
||||
is_array($debug) &&
|
||||
! empty($debug['file']) &&
|
||||
! strstr($debug['file'], DIRECTORY_INDEX) &&
|
||||
! strstr($debug['file'], 'Facade.php') &&
|
||||
! strstr($debug['file'], 'Buffering.php') &&
|
||||
! strstr($debug['file'], 'ZN.php') &&
|
||||
! strstr($debug['file'], 'Singleton.php') &&
|
||||
! strstr($debug['file'], 'Kernel.php') &&
|
||||
! strstr($debug['file'], 'Wizard.php') &&
|
||||
! strstr($debug['file'], 'View.php') &&
|
||||
! strstr($debug['file'], 'In.php') &&
|
||||
! strstr($debug['file'], 'Factory.php') &&
|
||||
$debug['file'] !== $file
|
||||
)
|
||||
{
|
||||
ZN\ErrorHandling\Exceptions::display($debug['file'], $debug['line'], $i);
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
ZN\ErrorHandling\Exceptions::display($file, $line, $i === 0 ? $i : count($trace));
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php defined('ZN_REDIRECT_NOEXIT') || exit;
|
||||
Reference in New Issue
Block a user