tweaking code and adding comments.
This commit is contained in:
@@ -3,7 +3,7 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
|
|
||||||
<title>Laravel - Uncaught Exception</title>
|
<title>Laravel - <?php echo $severity; ?></title>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
|
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
|
||||||
@@ -48,16 +48,6 @@
|
|||||||
line-height: 25px;
|
line-height: 25px;
|
||||||
margin: 10px 0;
|
margin: 10px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#main pre {
|
|
||||||
font-size: 12px;
|
|
||||||
background-color: #f0f0f0;
|
|
||||||
border-left: 1px solid #d8d8d8;
|
|
||||||
border-top: 1px solid #d8d8d8;
|
|
||||||
border-radius: 5px;
|
|
||||||
padding: 10px;
|
|
||||||
white-space: pre-wrap;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@@ -71,19 +61,6 @@
|
|||||||
<h3>Stack Trace</h3>
|
<h3>Stack Trace</h3>
|
||||||
|
|
||||||
<pre><?php echo $exception->getTraceAsString(); ?></pre>
|
<pre><?php echo $exception->getTraceAsString(); ?></pre>
|
||||||
|
|
||||||
<h3>Snapshot</h3>
|
|
||||||
|
|
||||||
<?php
|
|
||||||
$lines = array();
|
|
||||||
|
|
||||||
foreach (File::snapshot($exception->getFile(), $exception->getLine()) as $num => $context)
|
|
||||||
{
|
|
||||||
$lines[] = $num.': '.$context;
|
|
||||||
}
|
|
||||||
?>
|
|
||||||
|
|
||||||
<pre><?php echo htmlentities(implode("\n", $lines)); ?></pre>
|
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@@ -83,7 +83,9 @@ class Cookie {
|
|||||||
|
|
||||||
if ($minutes < 0) unset($_COOKIE[$name]);
|
if ($minutes < 0) unset($_COOKIE[$name]);
|
||||||
|
|
||||||
$time = ($minutes != 0) ? time() + ($minutes * 60) : 0;
|
// Since PHP needs the cookie lifetime in seconds, we will calculate it here.
|
||||||
|
// A "0" lifetime means the cookie expires when the browser closes.
|
||||||
|
$time = ($minutes !== 0) ? time() + ($minutes * 60) : 0;
|
||||||
|
|
||||||
return setcookie($name, $value, $time, $path, $domain, $secure, $http_only);
|
return setcookie($name, $value, $time, $path, $domain, $secure, $http_only);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,21 +104,31 @@ class File {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Move an uploaded file to permanenet storage.
|
* Move an uploaded file to permanent storage.
|
||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @param array $files
|
* @param array $files
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function upload($key, $path, $files)
|
public static function upload($key, $path, $files = null)
|
||||||
{
|
{
|
||||||
|
if (is_null($files)) $files = $_FILES;
|
||||||
|
|
||||||
return move_uploaded_file($files[$key]['tmp_name'], $path);
|
return move_uploaded_file($files[$key]['tmp_name'], $path);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a file MIME type by extension.
|
* Get a file MIME type by extension.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Determine the MIME type for the .tar extension
|
||||||
|
* $mime = File::mime('tar');
|
||||||
|
*
|
||||||
|
* // Return a default value if the MIME can't be determined
|
||||||
|
* $mime = File::mime('ext', 'application/octet-stream');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param string $extension
|
* @param string $extension
|
||||||
* @param string $default
|
* @param string $default
|
||||||
* @return string
|
* @return string
|
||||||
@@ -137,6 +147,14 @@ class File {
|
|||||||
*
|
*
|
||||||
* The Fileinfo PHP extension will be used to determine the MIME type of the file.
|
* The Fileinfo PHP extension will be used to determine the MIME type of the file.
|
||||||
*
|
*
|
||||||
|
* <code>
|
||||||
|
* // Determine if a file is a JPG image
|
||||||
|
* $jpg = File::is('jpg', 'path/to/file.jpg');
|
||||||
|
*
|
||||||
|
* // Determine if a file is one of a given list of types
|
||||||
|
* $image = File::is(array('jpg', 'png', 'gif'), 'path/to/file');
|
||||||
|
* </code>
|
||||||
|
*
|
||||||
* @param array|string $extension
|
* @param array|string $extension
|
||||||
* @param string $path
|
* @param string $path
|
||||||
* @return bool
|
* @return bool
|
||||||
@@ -155,27 +173,4 @@ class File {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the lines surrounding a given line in a file.
|
|
||||||
*
|
|
||||||
* @param string $path
|
|
||||||
* @param int $line
|
|
||||||
* @param int $padding
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
public static function snapshot($path, $line, $padding = 5)
|
|
||||||
{
|
|
||||||
if ( ! file_exists($path)) return array();
|
|
||||||
|
|
||||||
$file = file($path, FILE_IGNORE_NEW_LINES);
|
|
||||||
|
|
||||||
array_unshift($file, '');
|
|
||||||
|
|
||||||
if (($start = $line - $padding) < 0) $start = 0;
|
|
||||||
|
|
||||||
if (($length = ($line - $start) + $padding + 1) < 0) $length = 0;
|
|
||||||
|
|
||||||
return array_slice($file, $start, $length, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user