Skip to content
This repository
Browse code

initial commit of laravel!

  • Loading branch information...
commit a188d62105532fcf2a2839309fb71b862d904612 0 parents
Taylor Otwell authored June 08, 2011

Showing 70 changed files with 6,942 additions and 0 deletions. Show diff stats Hide diff stats

  1. 0  .gitignore b/application/db/.gitignore
  2. 0  application/cache/.gitignore
  3. 98  application/config/application.php
  4. 32  application/config/auth.php
  5. 52  application/config/cache.php
  6. 60  application/config/db.php
  7. 34  application/config/error.php
  8. 89  application/config/session.php
  9. 41  application/filters.php
  10. 0  application/lang/en/.gitignore
  11. 0  application/logs/.gitignore
  12. 0  application/models/.gitignore
  13. 0  application/packages/.gitignore
  14. 25  application/routes.php
  15. 0  application/sessions/.gitignore
  16. 56  application/views/error/404.php
  17. 56  application/views/error/500.php
  18. 77  application/views/home/index.php
  19. 19  license.txt
  20. 5  public/.htaccess
  21. BIN  public/favicon.ico
  22. 133  public/index.php
  23. 135  system/auth.php
  24. 49  system/benchmark.php
  25. 47  system/cache.php
  26. 40  system/cache/driver.php
  27. 95  system/cache/driver/file.php
  28. 80  system/cache/driver/memcached.php
  29. 26  system/cache/factory.php
  30. 118  system/config.php
  31. 78  system/cookie.php
  32. 132  system/crypt.php
  33. 111  system/db.php
  34. 58  system/db/connector.php
  35. 353  system/db/eloquent.php
  36. 26  system/db/eloquent/factory.php
  37. 272  system/db/eloquent/hydrate.php
  38. 24  system/db/eloquent/meta.php
  39. 132  system/db/eloquent/relate.php
  40. 66  system/db/eloquent/warehouse.php
  41. 593  system/db/query.php
  42. 116  system/db/query/compiler.php
  43. 145  system/download.php
  44. 156  system/error.php
  45. 51  system/filter.php
  46. 327  system/form.php
  47. 52  system/hash.php
  48. 275  system/html.php
  49. 230  system/inflector.php
  50. 135  system/input.php
  51. 178  system/lang.php
  52. 50  system/loader.php
  53. 102  system/log.php
  54. 56  system/memcached.php
  55. 66  system/redirect.php
  56. 136  system/request.php
  57. 252  system/response.php
  58. 85  system/route.php
  59. 148  system/router.php
  60. 281  system/session.php
  61. 37  system/session/driver.php
  62. 78  system/session/driver/db.php
  63. 64  system/session/driver/file.php
  64. 49  system/session/driver/memcached.php
  65. 29  system/session/factory.php
  66. 85  system/str.php
  67. 146  system/text.php
  68. 132  system/url.php
  69. 191  system/view.php
  70. 78  system/views/error/exception.php
0  .gitignore b/application/db/.gitignore
No changes.
0  application/cache/.gitignore
No changes.
98  application/config/application.php
... ...
@@ -0,0 +1,98 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Application URL
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| The URL used to access your application. The trailing slash is optional.
  11
+	|
  12
+	| Note: Remove "index.php" from this URL when using mod_rewrite.
  13
+	|
  14
+	*/
  15
+
  16
+	'url' => 'http://localhost/index.php',
  17
+
  18
+	/*
  19
+	|--------------------------------------------------------------------------
  20
+	| Application Language
  21
+	|--------------------------------------------------------------------------
  22
+	|
  23
+	| The default language of your application. This language will be used by
  24
+	| default by the Lang library when doing string localization.
  25
+	|
  26
+	| If you are not using the Lang library, this option isn't really important.
  27
+	|
  28
+	*/
  29
+
  30
+	'language' => 'en',
  31
+
  32
+	/*
  33
+	|--------------------------------------------------------------------------
  34
+	| Application Timezone
  35
+	|--------------------------------------------------------------------------
  36
+	|
  37
+	| The default timezone of your application. This timezone will be used when
  38
+	| Laravel needs a date, such as when writing to a log file.
  39
+	|
  40
+	*/
  41
+
  42
+	'timezone' => 'UTC',
  43
+
  44
+	/*
  45
+	|--------------------------------------------------------------------------
  46
+	| Application Key
  47
+	|--------------------------------------------------------------------------
  48
+	|
  49
+	| Your application key should be a 32 character string that is totally
  50
+	| random and secret. This key is used by the encryption class to generate
  51
+	| secure, encrypted strings.
  52
+	|
  53
+	| If you will not be using the encryption class, this doesn't matter.
  54
+	|
  55
+	*/
  56
+
  57
+	'key' => '',
  58
+
  59
+	/*
  60
+	|--------------------------------------------------------------------------
  61
+	| Class Aliases
  62
+	|--------------------------------------------------------------------------
  63
+	|
  64
+	| Here, you can specify any class aliases that you would like registered
  65
+	| when Laravel loads. Aliases are lazy-loaded, so add as many as you want.
  66
+	|
  67
+	| We have already setup a few to make your life easier.
  68
+	|
  69
+	*/
  70
+
  71
+	'aliases' => array(
  72
+		'Auth' => 'System\\Auth',
  73
+		'Benchmark' => 'System\\Benchmark',
  74
+		'Cache' => 'System\\Cache',
  75
+		'Config' => 'System\\Config',
  76
+		'Cookie' => 'System\\Cookie',
  77
+		'Crypt' => 'System\\Crypt',
  78
+		'Date' => 'System\\Date',
  79
+		'DB' => 'System\\DB',
  80
+		'Download' => 'System\\Download',
  81
+		'Eloquent' => 'System\\DB\\Eloquent',
  82
+		'Form' => 'System\\Form',
  83
+		'Hash' => 'System\\Hash',
  84
+		'HTML' => 'System\\HTML',
  85
+		'Inflector' => 'System\\Inflector',
  86
+		'Input' => 'System\\Input',
  87
+		'Lang' => 'System\\Lang',
  88
+		'URL' => 'System\\URL',
  89
+		'Redirect' => 'System\\Redirect',
  90
+		'Request' => 'System\\Request',
  91
+		'Response' => 'System\\Response',
  92
+		'Session' => 'System\\Session',
  93
+		'Str' => 'System\\Str',
  94
+		'Text' => 'System\\Text',
  95
+		'View' => 'System\View',
  96
+	),
  97
+
  98
+);
32  application/config/auth.php
... ...
@@ -0,0 +1,32 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Authentication Model
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| This model will be used by the Auth class when retrieving the users of
  11
+	| your application. Feel free to change it to the name of your user model.
  12
+	|
  13
+	| Note: The authentication model must be an Eloquent model.
  14
+	|
  15
+	*/
  16
+
  17
+	'model' => 'User',
  18
+
  19
+	/*
  20
+	|--------------------------------------------------------------------------
  21
+	| Authentication Username
  22
+	|--------------------------------------------------------------------------
  23
+	|
  24
+	| The authentication username is the column on your users table that
  25
+	| is considered the username of the user. Typically, this is either "email"
  26
+	| or "username". However, you are free to make it whatever you wish.
  27
+	|
  28
+	*/
  29
+
  30
+	'username' => 'email',
  31
+
  32
+);
52  application/config/cache.php
... ...
@@ -0,0 +1,52 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Cache Driver
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| The name of the default cache driver for your application.
  11
+	|
  12
+	| Caching can be used to increase the performance of your application
  13
+	| by storing commonly accessed data in memory or in a file.
  14
+	|
  15
+	| Supported Drivers: 'file', 'memcached'.
  16
+	|
  17
+	*/
  18
+
  19
+	'driver' => 'file',
  20
+
  21
+	/*
  22
+	|--------------------------------------------------------------------------
  23
+	| Memcached Servers
  24
+	|--------------------------------------------------------------------------
  25
+	|
  26
+	| Here you can define the Memcached servers used by your application.
  27
+	|
  28
+	| Memcached is a free and open source, high-performance, distributed memory
  29
+	| object caching system, generic in nature, but intended for use in speeding
  30
+	| up dynamic web applications by alleviating database load.
  31
+	|
  32
+	| For more information about Memcached, check out: http://memcached.org
  33
+	|
  34
+	*/
  35
+
  36
+	'servers' => array(
  37
+		array('host' => '127.0.0.1', 'port' => 11211, 'weight' => 100),
  38
+	),
  39
+
  40
+	/*
  41
+	|--------------------------------------------------------------------------
  42
+	| Memcached Key
  43
+	|--------------------------------------------------------------------------
  44
+	|
  45
+	| This key will be prepended to items stored using Memcached to avoid
  46
+	| collisions with other applications on the server.
  47
+	|
  48
+	*/
  49
+
  50
+	'key' => 'laravel',	
  51
+
  52
+);
60  application/config/db.php
... ...
@@ -0,0 +1,60 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Default Database Connection
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| The name of your default database connection.
  11
+	|
  12
+	| This connection will be used by default for all database operations
  13
+	| unless a different connection is specified when performing the operation.
  14
+	|
  15
+	*/
  16
+
  17
+	'default' => 'sqlite',
  18
+
  19
+	/*
  20
+	|--------------------------------------------------------------------------
  21
+	| Database Connections
  22
+	|--------------------------------------------------------------------------
  23
+	|
  24
+	| Here you can define all of the databases used by your application.
  25
+	|
  26
+	| Supported Drivers: 'mysql', 'pgsql', 'sqlite'.
  27
+	|
  28
+	| Note: When using the SQLite driver, the path and "sqlite" extention will
  29
+	|       be added automatically. You only need to specify the database name.
  30
+	|
  31
+	*/
  32
+
  33
+	'connections' => array(
  34
+
  35
+		'sqlite' => array(
  36
+			'driver'   => 'sqlite',
  37
+			'database' => 'application',
  38
+		),
  39
+
  40
+		'mysql' => array(
  41
+			'driver'   => 'mysql',
  42
+			'host'     => 'localhost',
  43
+			'database' => 'database',
  44
+			'username' => 'root',
  45
+			'password' => 'password',
  46
+			'charset'  => 'utf8',
  47
+		),
  48
+
  49
+		'pgsql' => array(
  50
+			'driver'   => 'pgsql',
  51
+			'host'     => 'localhost',
  52
+			'database' => 'database',
  53
+			'username' => 'root',
  54
+			'password' => 'password',
  55
+			'charset'  => 'utf8',
  56
+		),
  57
+
  58
+	),
  59
+
  60
+);
34  application/config/error.php
... ...
@@ -0,0 +1,34 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Error Detail
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| Would you like detailed error messages?
  11
+	|
  12
+	| If your application is in production, consider turning off error details
  13
+	| for enhanced security and user experience.
  14
+	|
  15
+	*/
  16
+
  17
+	'detail' => true,
  18
+
  19
+	/*
  20
+	|--------------------------------------------------------------------------
  21
+	| Error Logging
  22
+	|--------------------------------------------------------------------------
  23
+	|
  24
+	| Would you like errors to be logged? Error logging can be extremely
  25
+	| helpful when debugging a production application.
  26
+	|
  27
+	| Note: When error logging is enabled, errors will be logged even when
  28
+	|       error detail is disabled.
  29
+	|
  30
+	*/
  31
+
  32
+	'log' => false,
  33
+
  34
+);
89  application/config/session.php
... ...
@@ -0,0 +1,89 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Session Driver
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| The name of the session driver for your application.
  11
+	|
  12
+	| Since HTTP is stateless, sessions are used to maintain "state" across
  13
+	| multiple requests from the same user of your application.
  14
+	|
  15
+	| Supported Drivers: 'file', 'db', 'memcached'.
  16
+	|
  17
+	*/
  18
+
  19
+	'driver' => '',
  20
+
  21
+	/*
  22
+	|--------------------------------------------------------------------------
  23
+	| Session Database
  24
+	|--------------------------------------------------------------------------
  25
+	|
  26
+	| The database table on which the session should be stored. 
  27
+	|
  28
+	| If you are not using database based sessions, don't worry about this.
  29
+	|
  30
+	*/
  31
+
  32
+	'table' => 'sessions',
  33
+
  34
+	/*
  35
+	|--------------------------------------------------------------------------
  36
+	| Session Lifetime
  37
+	|--------------------------------------------------------------------------
  38
+	|
  39
+	| How many minutes can a session be idle before expiring?
  40
+	|
  41
+	*/
  42
+
  43
+	'lifetime' => 60,
  44
+
  45
+	/*
  46
+	|--------------------------------------------------------------------------
  47
+	| Session Expiration On Close
  48
+	|--------------------------------------------------------------------------
  49
+	|
  50
+	| Should the session expire when the user's web browser closes?
  51
+	|
  52
+	*/
  53
+
  54
+	'expire_on_close' => false,
  55
+
  56
+	/*
  57
+	|--------------------------------------------------------------------------
  58
+	| Session Cookie Path
  59
+	|--------------------------------------------------------------------------
  60
+	|
  61
+	| The path for which the session cookie is available.
  62
+	|
  63
+	*/
  64
+
  65
+	'path' => '/',
  66
+
  67
+	/*
  68
+	|--------------------------------------------------------------------------
  69
+	| Session Cookie Domain
  70
+	|--------------------------------------------------------------------------
  71
+	|
  72
+	| The domain for which the session cookie is available.
  73
+	|
  74
+	*/
  75
+
  76
+	'domain' => null,
  77
+
  78
+	/*
  79
+	|--------------------------------------------------------------------------
  80
+	| Session Cookie HTTPS
  81
+	|--------------------------------------------------------------------------
  82
+	|
  83
+	| Should the session cookie only be transported over HTTPS?
  84
+	|
  85
+	*/
  86
+
  87
+	'https' => false,
  88
+
  89
+);
41  application/filters.php
... ...
@@ -0,0 +1,41 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Filters
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| Filters provide a convenient method for filtering access to your route
  11
+	| functions. To make your life easier, we have already setup basic filters
  12
+	| for authentication and CSRF protection.
  13
+	|
  14
+	| For more information, check out: http://laravel.com/docs/basics/routes#filters
  15
+	|
  16
+	*/
  17
+
  18
+	'before' => function()
  19
+	{
  20
+		// Do stuff before every request is executed.	
  21
+	},
  22
+
  23
+
  24
+	'after' => function($response)
  25
+	{
  26
+		// Do stuff after every request is executed.
  27
+	},
  28
+
  29
+
  30
+	'auth' => function()
  31
+	{
  32
+		return ( ! Auth::check()) ? Redirect::to_login() : null;
  33
+	},
  34
+
  35
+
  36
+	'csrf' => function()
  37
+	{
  38
+		return (Input::get('csrf_token') !== Form::raw_token()) ? Response::view('error/500', 500) : null;
  39
+	},
  40
+
  41
+);
0  application/lang/en/.gitignore
No changes.
0  application/logs/.gitignore
No changes.
0  application/models/.gitignore
No changes.
0  application/packages/.gitignore
No changes.
25  application/routes.php
... ...
@@ -0,0 +1,25 @@
  1
+<?php
  2
+
  3
+return array(
  4
+
  5
+	/*
  6
+	|--------------------------------------------------------------------------
  7
+	| Application Routes
  8
+	|--------------------------------------------------------------------------
  9
+	|
  10
+	| Here is the "definition", or the public API, of your application.
  11
+	|
  12
+	| To add functionality to your application, you add to the array located
  13
+	| in this file. It's a breeze. Just tell Laravel the request method and
  14
+	| URI a function should respond to.
  15
+	|
  16
+	| To learn more, check out: http://laravel.com/docs/basics/routes
  17
+	|
  18
+	*/
  19
+
  20
+	'GET /' => function()
  21
+	{
  22
+		return View::make('home/index');
  23
+	},
  24
+
  25
+);
0  application/sessions/.gitignore
No changes.
56  application/views/error/404.php
... ...
@@ -0,0 +1,56 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+<head>
  4
+	<meta charset="utf-8">
  5
+	<title>404 - Not Found</title>
  6
+
  7
+	<link href='http://fonts.googleapis.com/css?family=Ubuntu&amp;subset=latin' rel='stylesheet' type='text/css'>
  8
+
  9
+	<style type="text/css">
  10
+		body {
  11
+			background-color: #fff;
  12
+			margin: 45px 0 0 0;
  13
+			font-family: 'Ubuntu', sans-serif;
  14
+			font-size: 16px;
  15
+			color: #3f3f3f;
  16
+		}
  17
+
  18
+		h1 {
  19
+			font-size: 40px;
  20
+			margin: 0 0 10px 0;
  21
+		}
  22
+
  23
+		a {
  24
+			color: #000;
  25
+		}
  26
+
  27
+		#wrapper {
  28
+			width: 740px;
  29
+			margin: 0 auto;
  30
+		}
  31
+
  32
+		#content {
  33
+			padding: 10px 10px 10px 10px;
  34
+			background-color: #ffebe8;
  35
+			border: 1px solid #dd3c10;
  36
+			border-radius: 10px;
  37
+		}
  38
+	</style>
  39
+</head>
  40
+<body>
  41
+	<div id="wrapper">
  42
+		<?php
  43
+			$messages = array('Should we ask for directions?', 'This doesn\'t look familiar.', 'We need a map.');
  44
+			$message = $messages[mt_rand(0, 2)];
  45
+		?>
  46
+
  47
+		<h1><?php echo $message; ?></h1>
  48
+
  49
+		<div id="content">
  50
+			The resource you requested was not found.
  51
+			<br /><br />
  52
+			Would you like go to our <a href="<?php echo System\Config::get('application.url'); ?>">home page</a> instead?
  53
+		</div>
  54
+	</div>
  55
+</body>
  56
+</html>
56  application/views/error/500.php
... ...
@@ -0,0 +1,56 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+<head>
  4
+	<meta charset="utf-8">
  5
+	<title>500 - Internal Server Error</title>
  6
+
  7
+	<link href='http://fonts.googleapis.com/css?family=Ubuntu&amp;subset=latin' rel='stylesheet' type='text/css'>
  8
+
  9
+	<style type="text/css">
  10
+		body {
  11
+			background-color: #fff;
  12
+			margin: 45px 0 0 0;
  13
+			font-family: 'Ubuntu', sans-serif;
  14
+			font-size: 16px;
  15
+			color: #3f3f3f;
  16
+		}
  17
+
  18
+		h1 {
  19
+			font-size: 40px;
  20
+			margin: 0 0 10px 0;
  21
+		}
  22
+
  23
+		a {
  24
+			color: #000;
  25
+		}
  26
+
  27
+		#wrapper {
  28
+			width: 740px;
  29
+			margin: 0 auto;
  30
+		}
  31
+
  32
+		#content {
  33
+			padding: 10px 10px 10px 10px;
  34
+			background-color: #ffebe8;
  35
+			border: 1px solid #dd3c10;
  36
+			border-radius: 10px;
  37
+		}
  38
+	</style>
  39
+</head>
  40
+<body>
  41
+	<div id="wrapper">
  42
+		<?php
  43
+			$messages = array('Whoops!', 'Oh no!', 'Ouch!');
  44
+			$message = $messages[mt_rand(0, 2)];
  45
+		?>
  46
+
  47
+		<h1><?php echo $message; ?></h1>
  48
+
  49
+		<div id="content">
  50
+			An error occured while we were processing your request.
  51
+			<br /><br />
  52
+			Would you like go to our <a href="<?php echo System\Config::get('application.url'); ?>">home page</a> instead?
  53
+		</div>
  54
+	</div>
  55
+</body>
  56
+</html>
77  application/views/home/index.php
... ...
@@ -0,0 +1,77 @@
  1
+<!DOCTYPE html>
  2
+<html>
  3
+<head>
  4
+	<meta charset="utf-8"> 
  5
+	<title>Welcome To Laravel!</title> 
  6
+ 
  7
+	<link href="http://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet" type="text/css" media="all" /> 
  8
+	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
  9
+
  10
+	<style type="text/css">
  11
+		body {
  12
+			background-color: #fff; 
  13
+			font-family: 'Ubuntu', sans-serif; 
  14
+			font-size: 16px;
  15
+			color: #3f3f3f;
  16
+		}
  17
+ 
  18
+		h1 {
  19
+			font-size: 40px;
  20
+			color: #6d6d6d;
  21
+			margin: 0 0 10px 0;
  22
+			text-shadow: 1px 1px #000;
  23
+		}		
  24
+ 
  25
+		a {
  26
+			color: #000; 
  27
+		}
  28
+ 
  29
+		#wrapper {
  30
+			width: 740px;
  31
+		}
  32
+ 
  33
+		#content {
  34
+			padding: 10px 10px 10px 10px;
  35
+			background-color: #eee;
  36
+			border-radius: 10px;
  37
+		}
  38
+
  39
+		#footer {
  40
+			font-size: 12px;
  41
+			padding-top: 10px;
  42
+			text-align: right;
  43
+		}
  44
+	</style>
  45
+
  46
+	<script type="text/javascript"> 
  47
+		$(document).ready(function(){
  48
+			$(window).resize(function(){
  49
+				$('#wrapper').css({
  50
+					position:'absolute', 
  51
+					left: ($(window).width() - $('#wrapper').outerWidth()) / 2, 
  52
+					top: ($(window).height() - $('#wrapper').outerHeight()) / 3
  53
+				});
  54
+		 	});
  55
+		 
  56
+			$(window).resize();
  57
+		});		
  58
+	</script>
  59
+</head> 
  60
+<body>
  61
+	<div id="wrapper">
  62
+		<h1>Laravel</h1> 
  63
+ 
  64
+		<div id="content"> 
  65
+			You have successfully installed Laravel.
  66
+
  67
+			<br /><br />
  68
+
  69
+			Perhaps you would like to <a href="http://laravel.com/docs">peruse the documentation</a> or <a href="http://github.com/taylorotwell/laravel">contribute on GitHub</a>?
  70
+		</div>
  71
+
  72
+		<div id="footer">
  73
+			<?php echo Benchmark::memory(); ?>mb &middot; <?php echo Benchmark::check('laravel'); ?>ms
  74
+		</div>
  75
+	</div> 
  76
+</body> 
  77
+</html>
19  license.txt
... ...
@@ -0,0 +1,19 @@
  1
+Copyright (c) 2011 Taylor Otwell - taylorotwell@gmail.com
  2
+
  3
+Permission is hereby granted, free of charge, to any person obtaining a copy
  4
+of this software and associated documentation files (the "Software"), to deal
  5
+in the Software without restriction, including without limitation the rights
  6
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7
+copies of the Software, and to permit persons to whom the Software is
  8
+furnished to do so, subject to the following conditions:
  9
+
  10
+The above copyright notice and this permission notice shall be included in
  11
+all copies or substantial portions of the Software.
  12
+
  13
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  14
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  15
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  16
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  17
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  18
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  19
+THE SOFTWARE.
5  public/.htaccess
... ...
@@ -0,0 +1,5 @@
  1
+Options +FollowSymLinks
  2
+RewriteEngine on
  3
+RewriteCond %{REQUEST_FILENAME} !-f
  4
+RewriteCond %{REQUEST_FILENAME} !-d
  5
+RewriteRule . /index.php [L]
BIN  public/favicon.ico
Binary file not shown
133  public/index.php
... ...
@@ -0,0 +1,133 @@
  1
+<?php
  2
+/**
  3
+ * Laravel - A clean and classy framework for PHP web development.
  4
+ *
  5
+ * @package  Laravel
  6
+ * @version  1.0.0 Beta 1
  7
+ * @author   Taylor Otwell
  8
+ * @license  MIT License
  9
+ * @link     http://laravel.com 
  10
+ */
  11
+
  12
+// --------------------------------------------------------------
  13
+// Set the framework starting time.
  14
+// --------------------------------------------------------------
  15
+define('LARAVEL_START', microtime(true));
  16
+
  17
+// --------------------------------------------------------------
  18
+// Define the framework paths.
  19
+// --------------------------------------------------------------
  20
+define('APP_PATH', realpath('../application').'/');
  21
+define('SYS_PATH', realpath('../system').'/');
  22
+define('BASE_PATH', realpath('../').'/');
  23
+
  24
+// --------------------------------------------------------------
  25
+// Define the PHP file extension.
  26
+// --------------------------------------------------------------
  27
+define('EXT', '.php');
  28
+
  29
+// --------------------------------------------------------------
  30
+// Load the configuration and string classes.
  31
+// --------------------------------------------------------------
  32
+require SYS_PATH.'config'.EXT;
  33
+require SYS_PATH.'str'.EXT;
  34
+
  35
+// --------------------------------------------------------------
  36
+// Register the auto-loader.
  37
+// --------------------------------------------------------------
  38
+spl_autoload_register(require SYS_PATH.'loader'.EXT);
  39
+
  40
+// --------------------------------------------------------------
  41
+// Set the Laravel starting time in the Benchmark class.
  42
+// --------------------------------------------------------------
  43
+System\Benchmark::$marks['laravel'] = LARAVEL_START;
  44
+
  45
+// --------------------------------------------------------------
  46
+// Set the error reporting level.
  47
+// --------------------------------------------------------------
  48
+error_reporting((System\Config::get('error.detail')) ? E_ALL | E_STRICT : 0);
  49
+
  50
+// --------------------------------------------------------------
  51
+// Register the error handlers.
  52
+// --------------------------------------------------------------
  53
+set_exception_handler(function($e)
  54
+{
  55
+	System\Error::handle($e);	
  56
+});
  57
+
  58
+set_error_handler(function($number, $error, $file, $line) 
  59
+{
  60
+	System\Error::handle(new ErrorException($error, 0, $number, $file, $line));
  61
+});
  62
+
  63
+register_shutdown_function(function()
  64
+{
  65
+	if ( ! is_null($error = error_get_last()))
  66
+	{
  67
+		System\Error::handle(new ErrorException($error['message'], 0, $error['type'], $error['file'], $error['line']));
  68
+	}	
  69
+});
  70
+
  71
+// --------------------------------------------------------------
  72
+// Set the default timezone.
  73
+// --------------------------------------------------------------
  74
+date_default_timezone_set(System\Config::get('application.timezone'));
  75
+
  76
+// --------------------------------------------------------------
  77
+// Load the session.
  78
+// --------------------------------------------------------------
  79
+if (System\Config::get('session.driver') != '')
  80
+{
  81
+	System\Session::load();
  82
+}
  83
+
  84
+// --------------------------------------------------------------
  85
+// Execute the global "before" filter.
  86
+// --------------------------------------------------------------
  87
+$response = System\Filter::call('before');
  88
+
  89
+// --------------------------------------------------------------
  90
+// Only execute the route function if the "before" filter did
  91
+// not override by sending a response.
  92
+// --------------------------------------------------------------
  93
+if (is_null($response))
  94
+{
  95
+	// ----------------------------------------------------------
  96
+	// Route the request to the proper route.
  97
+	// ----------------------------------------------------------
  98
+	$route = System\Router::route(Request::method(), Request::uri());
  99
+
  100
+	// ----------------------------------------------------------
  101
+	// Execute the route function.
  102
+	// ----------------------------------------------------------
  103
+	if ( ! is_null($route))
  104
+	{
  105
+		$response = $route->call();	
  106
+	}
  107
+	else
  108
+	{
  109
+		$response = System\Response::view('error/404', 404);
  110
+	}
  111
+}
  112
+else
  113
+{
  114
+	$response = ( ! $response instanceof System\Response) ? new System\Response($response) : $response;
  115
+}
  116
+
  117
+// ----------------------------------------------------------
  118
+// Execute the global "after" filter.
  119
+// ----------------------------------------------------------
  120
+System\Filter::call('after', array($response));
  121
+
  122
+// --------------------------------------------------------------
  123
+// Close the session.
  124
+// --------------------------------------------------------------
  125
+if (System\Config::get('session.driver') != '')
  126
+{
  127
+	System\Session::close();
  128
+}
  129
+
  130
+// --------------------------------------------------------------
  131
+// Send the response to the browser.
  132
+// --------------------------------------------------------------
  133
+$response->send();
135  system/auth.php
... ...
@@ -0,0 +1,135 @@
  1
+<?php namespace System;
  2
+
  3
+class Auth {
  4
+
  5
+	/**
  6
+	 * The current user of the application.
  7
+	 *
  8
+	 * @var object
  9
+	 */
  10
+	public static $user;
  11
+
  12
+	/**
  13
+	 * The key used to store the user ID in the session.
  14
+	 *
  15
+	 * @var string
  16
+	 */
  17
+	private static $key = 'laravel_user_id';
  18
+
  19
+	/**
  20
+	 * Determine if the current user of the application is authenticated.
  21
+	 *
  22
+	 * @return bool
  23
+	 */
  24
+	public static function check()
  25
+	{
  26
+		return ( ! is_null(static::user()));
  27
+	}
  28
+
  29
+	/**
  30
+	 * Get the current user of the application.
  31
+	 *
  32
+	 * @return object
  33
+	 */
  34
+	public static function user()
  35
+	{
  36
+		// -----------------------------------------------------
  37
+		// Verify that sessions are enabled.
  38
+		// -----------------------------------------------------
  39
+		if (Config::get('session.driver') == '')
  40
+		{
  41
+			throw new \Exception("You must specify a session driver before using the Auth class.");
  42
+		}
  43
+
  44
+		// -----------------------------------------------------
  45
+		// Get the authentication model.
  46
+		// -----------------------------------------------------
  47
+		$model = static::model();
  48
+
  49
+		// -----------------------------------------------------
  50
+		// Load the user using the ID stored in the session.
  51
+		// -----------------------------------------------------
  52
+		if (is_null(static::$user) and Session::has(static::$key))
  53
+		{
  54
+			static::$user = $model::find(Session::get(static::$key));
  55
+		}
  56
+
  57
+		return static::$user;
  58
+	}
  59
+
  60
+	/**
  61
+	 * Attempt to login a user.
  62
+	 *
  63
+	 * @param  string  $username
  64
+	 * @param  string  $password
  65
+	 */
  66
+	public static function login($username, $password)
  67
+	{
  68
+		// -----------------------------------------------------
  69
+		// Get the authentication model.
  70
+		// -----------------------------------------------------
  71
+		$model = static::model();
  72
+
  73
+		// -----------------------------------------------------
  74
+		// Get the user by username.
  75
+		// -----------------------------------------------------
  76
+		$user = $model::where(Config::get('auth.username'), '=', $username)->first();
  77
+
  78
+		if ( ! is_null($user))
  79
+		{
  80
+			// -----------------------------------------------------
  81
+			// Hash the password.
  82
+			// -----------------------------------------------------
  83
+			$password = (isset($user->salt)) ? Hash::make($password, $user->salt)->value : sha1($password);
  84
+
  85
+			// -----------------------------------------------------
  86
+			// Verify that the passwords match.
  87
+			// -----------------------------------------------------
  88
+			if ($user->password == $password)
  89
+			{
  90
+				// -----------------------------------------------------
  91
+				// Set the user property.
  92
+				// -----------------------------------------------------
  93
+				static::$user = $user;
  94
+
  95
+				// -----------------------------------------------------
  96
+				// Store the user ID in the session.
  97
+				// -----------------------------------------------------
  98
+				Session::put(static::$key, $user->id);
  99
+
  100
+				return true;
  101
+			}
  102
+		}
  103
+
  104
+		return false;
  105
+	}
  106
+
  107
+	/**
  108
+	 * Logout the current user of the application.
  109
+	 *
  110
+	 * @return void
  111
+	 */
  112
+	public static function logout()
  113
+	{
  114
+		// -----------------------------------------------------
  115
+		// Remove the user ID from the session.
  116
+		// -----------------------------------------------------
  117
+		Session::forget(static::$key);
  118
+
  119
+		// -----------------------------------------------------
  120
+		// Clear the current user variable.
  121
+		// -----------------------------------------------------
  122
+		static::$user = null;
  123
+	}
  124
+
  125
+	/**
  126
+	 * Get the authentication model.
  127
+	 *
  128
+	 * @return string
  129
+	 */
  130
+	private static function model()
  131
+	{
  132
+		return '\\'.Config::get('auth.model');
  133
+	}
  134
+
  135
+}
49  system/benchmark.php
... ...
@@ -0,0 +1,49 @@
  1
+<?php namespace System;
  2
+
  3
+class Benchmark {
  4
+
  5
+	/**
  6
+	 * Benchmark starting times.
  7
+	 *
  8
+	 * @var array
  9
+	 */
  10
+	public static $marks = array();
  11
+
  12
+	/**
  13
+	 * Start a benchmark.
  14
+	 *
  15
+	 * @param  string  $name
  16
+	 * @return void
  17
+	 */
  18
+	public static function start($name)
  19
+	{
  20
+		static::$marks[$name] = microtime(true);
  21
+	}
  22
+
  23
+	/**
  24
+	 * Get the elapsed time in milliseconds since starting a benchmark.
  25
+	 *
  26
+	 * @param  string  $name
  27
+	 * @return float
  28
+	 */
  29
+	public static function check($name)
  30
+	{
  31
+		if (array_key_exists($name, static::$marks))
  32
+		{
  33
+			return number_format((microtime(true) - static::$marks[$name]) * 1000, 2);
  34
+		}
  35
+
  36
+		return 0.0;
  37
+	}
  38
+
  39
+	/**
  40
+	 * Get the total memory usage in megabytes.
  41
+	 *
  42
+	 * @return float
  43
+	 */
  44
+	public static function memory()
  45
+	{
  46
+		return number_format(memory_get_usage() / 1024 / 1024, 2);
  47
+	}
  48
+
  49
+}
47  system/cache.php
... ...
@@ -0,0 +1,47 @@
  1
+<?php namespace System;
  2
+
  3
+class Cache {
  4
+
  5
+	/**
  6
+	 * The active cache drivers.
  7
+	 *
  8
+	 * @var Cache\Driver
  9
+	 */
  10
+	private static $drivers = array();
  11
+
  12
+	/**
  13
+	 * Get the cache driver instance.
  14
+	 *
  15
+	 * @param  string  $driver
  16
+	 * @return Cache\Driver
  17
+	 */
  18
+	public static function driver($driver = null)
  19
+	{
  20
+		if ( ! array_key_exists($driver, static::$drivers))
  21
+		{
  22
+			// --------------------------------------------------
  23
+			// If no driver was specified, use the default.
  24
+			// --------------------------------------------------
  25
+			if (is_null($driver))
  26
+			{
  27
+				$driver = Config::get('cache.driver');
  28
+			}
  29
+
  30
+			// --------------------------------------------------
  31
+			// Create the cache driver.
  32
+			// --------------------------------------------------
  33
+			static::$drivers[$driver] = Cache\Factory::make($driver);
  34
+		}
  35
+
  36
+		return static::$drivers[$driver];
  37
+	}
  38
+
  39
+	/**
  40
+	 * Pass all other methods to the default driver.
  41
+	 */
  42
+	public static function __callStatic($method, $parameters)
  43
+	{
  44
+		return call_user_func_array(array(static::driver(), $method), $parameters);
  45
+	}
  46
+
  47
+}
40  system/cache/driver.php
... ...
@@ -0,0 +1,40 @@
  1
+<?php namespace System\Cache;
  2
+
  3
+interface Driver {
  4
+
  5
+	/**
  6
+	 * Determine if an item exists in the cache.
  7
+	 *
  8
+	 * @param  string  $key
  9
+	 * @return bool
  10
+	 */
  11
+	public function has($key);
  12
+
  13
+	/**
  14
+	 * Get an item from the cache.
  15
+	 *
  16
+	 * @param  string  $key
  17
+	 * @param  mixed   $default
  18
+	 * @return mixed
  19
+	 */	
  20
+	public function get($key, $default = null);
  21
+
  22
+	/**
  23
+	 * Write an item to the cache.
  24
+	 *
  25
+	 * @param  string  $key
  26
+	 * @param  mixed   $value
  27
+	 * @param  int     $minutes
  28
+	 * @return void
  29
+	 */
  30
+	public function put($key, $value, $minutes);
  31
+
  32
+	/**
  33
+	 * Delete an item from the cache.
  34
+	 *
  35
+	 * @param  string  $key
  36
+	 * @return void
  37
+	 */
  38
+	public function forget($key);
  39
+
  40
+}
95  system/cache/driver/file.php
... ...
@@ -0,0 +1,95 @@
  1
+<?php namespace System\Cache\Driver;
  2
+
  3
+class File implements \System\Cache\Driver {
  4
+
  5
+	/**
  6
+	 * All of the loaded cache items.
  7
+	 *
  8
+	 * @var array
  9
+	 */
  10
+	private $items = array();
  11
+
  12
+	/**
  13
+	 * Determine if an item exists in the cache.
  14
+	 *
  15
+	 * @param  string  $key
  16
+	 * @return bool
  17
+	 */
  18
+	public function has($key)
  19
+	{
  20
+		return ( ! is_null($this->get($key)));
  21
+	}
  22
+
  23
+	/**
  24
+	 * Get an item from the cache.
  25
+	 *
  26
+	 * @param  string  $key
  27
+	 * @param  mixed   $default
  28
+	 * @return mixed
  29
+	 */	
  30
+	public function get($key, $default = null)
  31
+	{
  32
+		// --------------------------------------------------
  33
+		// If the item has already been loaded, return it.
  34
+		// --------------------------------------------------
  35
+		if (array_key_exists($key, $this->items))
  36
+		{
  37
+			return $this->items[$key];
  38
+		}
  39
+
  40
+		// --------------------------------------------------
  41
+		// Verify that the cache file exists.
  42
+		// --------------------------------------------------
  43
+		if ( ! file_exists(APP_PATH.'cache/'.$key))
  44
+		{
  45
+			return $default;
  46
+		}
  47
+
  48
+		// --------------------------------------------------
  49
+		// Read the contents of the cache file.
  50
+		// --------------------------------------------------
  51
+		$cache = file_get_contents(APP_PATH.'cache/'.$key);
  52
+
  53
+		// --------------------------------------------------
  54
+		// Has the cache expired? The UNIX expiration time
  55
+		// is stored at the beginning of the file.
  56
+		// --------------------------------------------------
  57
+		if (time() >= substr($cache, 0, 10))
  58
+		{
  59
+			$this->forget($key);
  60
+
  61
+			return $default;
  62
+		}
  63
+
  64
+		return $this->items[$key] = unserialize(substr($cache, 10));
  65
+	}
  66