Commit 766fa983 authored by Taylor Otwell's avatar Taylor Otwell

tweaking code and adding comments.

parent 1c9798e9
......@@ -3,7 +3,7 @@
<head>
<meta charset="utf-8">
<title>Laravel - Uncaught Exception</title>
<title>Laravel - <?php echo $severity; ?></title>
<style>
@import url(http://fonts.googleapis.com/css?family=Ubuntu);
......@@ -48,16 +48,6 @@
line-height: 25px;
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>
</head>
<body>
......@@ -71,19 +61,6 @@
<h3>Stack Trace</h3>
<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>
</body>
</html>
\ No newline at end of file
......@@ -83,7 +83,9 @@ class Cookie {
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);
}
......
......@@ -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 $path
* @param array $files
* @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);
}
/**
* 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 $default
* @return string
......@@ -137,6 +147,14 @@ class 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 string $path
* @return bool
......@@ -155,27 +173,4 @@ class File {
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);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment