Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
syncEnrollments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Yeray Santana Hualde
syncEnrollments
Commits
47db2ff1
Commit
47db2ff1
authored
Sep 21, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactoring, added uri class.
parent
1463617f
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
509 additions
and
246 deletions
+509
-246
aliases.php
application/config/aliases.php
+1
-0
.gitignore
application/libraries/.gitignore
+0
-0
changelog.md
changelog.md
+8
-0
arr.php
laravel/arr.php
+4
-2
apc.php
laravel/cache/drivers/apc.php
+48
-11
container.php
laravel/config/container.php
+145
-164
core.php
laravel/core.php
+14
-1
facades.php
laravel/facades.php
+1
-0
file.php
laravel/file.php
+1
-1
form.php
laravel/form.php
+1
-1
loader.php
laravel/loader.php
+59
-2
request.php
laravel/request.php
+72
-52
loader.php
laravel/routing/loader.php
+0
-9
route.php
laravel/routing/route.php
+10
-2
manager.php
laravel/session/manager.php
+4
-1
uri.php
laravel/uri.php
+141
-0
No files found.
application/config/aliases.php
View file @
47db2ff1
...
...
@@ -41,6 +41,7 @@ return array(
'Loader'
=>
'Laravel\\Facades\\Loader'
,
'Messages'
=>
'Laravel\\Validation\\Messages'
,
'Package'
=>
'Laravel\\Facades\\Package'
,
'URI'
=>
'Laravel\\Facades\\URI'
,
'URL'
=>
'Laravel\\Facades\\URL'
,
'Redirect'
=>
'Laravel\\Facades\\Redirect'
,
'Request'
=>
'Laravel\\Facades\\Request'
,
...
...
application/libraries/.gitignore
deleted
100644 → 0
View file @
1463617f
changelog.md
View file @
47db2ff1
# Laravel Change Log
## Version 1.5.9
-
Fixed bug in Eloquent relationship loading.
### Upgrading from 1.5.8
-
Replace
**system**
directory.
## Version 1.5.8
-
Fixed bug in form class that prevent name attributes from being set properly.
...
...
laravel/arr.php
View file @
47db2ff1
<?php
namespace
Laravel
;
use
Closure
;
class
Arr
{
/**
...
...
@@ -30,7 +32,7 @@ class Arr {
{
if
(
!
is_array
(
$array
)
or
!
array_key_exists
(
$segment
,
$array
))
{
return
(
$default
instanceof
\
Closure
)
?
call_user_func
(
$default
)
:
$default
;
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
$array
=
$array
[
$segment
];
...
...
@@ -107,7 +109,7 @@ class Arr {
if
(
call_user_func
(
$callback
,
$key
,
$value
))
return
$value
;
}
return
(
$default
instanceof
\
Closure
)
?
call_user_func
(
$default
)
:
$default
;
return
(
$default
instanceof
Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
/**
...
...
laravel/cache/drivers/apc.php
View file @
47db2ff1
<?php
namespace
Laravel\Cache\Drivers
;
use
Laravel\Proxy
;
class
APC_Engine
{
/**
* Retrieve an item from the APC cache.
*
* @param string $key
* @return mixed
*/
public
function
fetch
(
$key
)
{
return
apc_fetch
(
$key
);
}
/**
* Store an item in the APC cache.
*
* @param string $key
* @param mixed $value
* @param int $seconds
* @return void
*/
public
function
store
(
$key
,
$value
,
$seconds
)
{
apc_store
(
$key
,
$value
,
$seconds
);
}
/**
* Delete an item from the APC cache.
*
* @param string $key
* @return void
*/
public
function
delete
(
$key
)
{
apc_delete
(
$key
);
}
}
class
APC
extends
Driver
{
/**
* The
proxy class
instance.
* The
APC engine
instance.
*
* @var
Proxy
* @var
APC_Engine
*/
private
$
proxy
;
private
$
apc
;
/**
* The cache key from the cache configuration file.
...
...
@@ -21,14 +58,14 @@ class APC extends Driver {
/**
* Create a new APC cache driver instance.
*
* @param
Proxy $proxy
* @param
APC_Engine $apc
* @param string $key
* @return void
*/
public
function
__construct
(
Proxy
$proxy
,
$key
)
public
function
__construct
(
APC_Engine
$apc
,
$key
)
{
$this
->
apc
=
$apc
;
$this
->
key
=
$key
;
$this
->
proxy
=
$proxy
;
}
/**
...
...
@@ -50,7 +87,7 @@ class APC extends Driver {
*/
protected
function
retrieve
(
$key
)
{
if
(
!
is_null
(
$cache
=
$this
->
proxy
->
apc_
fetch
(
$this
->
key
.
$key
)))
return
$cache
;
if
(
!
is_null
(
$cache
=
$this
->
apc
->
fetch
(
$this
->
key
.
$key
)))
return
$cache
;
}
/**
...
...
@@ -63,7 +100,7 @@ class APC extends Driver {
*/
public
function
put
(
$key
,
$value
,
$minutes
)
{
$this
->
proxy
->
apc_
store
(
$this
->
key
.
$key
,
$value
,
$minutes
*
60
);
$this
->
apc
->
store
(
$this
->
key
.
$key
,
$value
,
$minutes
*
60
);
}
/**
...
...
@@ -74,7 +111,7 @@ class APC extends Driver {
*/
public
function
forget
(
$key
)
{
$this
->
proxy
->
apc_
delete
(
$this
->
key
.
$key
);
$this
->
apc
->
delete
(
$this
->
key
.
$key
);
}
}
\ No newline at end of file
laravel/config/container.php
View file @
47db2ff1
...
...
@@ -4,23 +4,23 @@ return array(
/*
|--------------------------------------------------------------------------
| Laravel Components
|
Core
Laravel Components
|--------------------------------------------------------------------------
*/
'laravel.asset'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.asset'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Asset
(
$c
ontainer
->
resolve
(
'laravel.html'
));
return
new
Asset
(
$c
->
resolve
(
'laravel.html'
));
}),
'laravel.auth'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.auth'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Security\Auth
(
$c
ontainer
->
resolve
(
'laravel.config'
),
$container
->
resolve
(
'laravel.session'
));
return
new
Security\Auth
(
$c
->
resolve
(
'laravel.config'
),
$c
->
resolve
(
'laravel.session'
));
}),
'laravel.config'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.config'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$paths
=
array
(
SYS_CONFIG_PATH
,
CONFIG_PATH
);
...
...
@@ -33,11 +33,9 @@ return array(
}),
'laravel.crypter'
=>
array
(
'resolver'
=>
function
(
$c
ontainer
)
'laravel.crypter'
=>
array
(
'resolver'
=>
function
(
$c
)
{
$key
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.key'
);
return
new
Security\Crypter
(
MCRYPT_RIJNDAEL_256
,
'cbc'
,
$key
);
return
new
Security\Crypter
(
MCRYPT_RIJNDAEL_256
,
'cbc'
,
$c
->
resolve
(
'laravel.config'
)
->
get
(
'application.key'
));
}),
...
...
@@ -47,309 +45,292 @@ return array(
}),
'laravel.database'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.database'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Database\Manager
(
$c
ontainer
->
resolve
(
'laravel.config'
));
return
new
Database\Manager
(
$c
->
resolve
(
'laravel.config'
));
}),
'laravel.download'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.download'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Download
(
$c
ontainer
->
resolve
(
'laravel.file'
));
return
new
Download
(
$c
->
resolve
(
'laravel.file'
));
}),
'laravel.file'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.file'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
File
(
$c
ontainer
->
resolve
(
'laravel.config'
)
->
get
(
'mimes'
));
return
new
File
(
$c
->
resolve
(
'laravel.config'
)
->
get
(
'mimes'
));
}),
'laravel.form'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.form'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
list
(
$request
,
$html
,
$url
)
=
array
(
$container
->
resolve
(
'laravel.request'
),
$container
->
resolve
(
'laravel.html'
),
$container
->
resolve
(
'laravel.url'
),
);
return
new
Form
(
$request
,
$html
,
$url
);
return
new
Form
(
$c
->
resolve
(
'laravel.request'
),
$c
->
resolve
(
'laravel.html'
),
$c
->
resolve
(
'laravel.url'
));
}),
'laravel.hasher'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.hasher'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Security\Hashing\Bcrypt
(
8
,
false
);
}),
'laravel.html'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.html'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
HTML
(
$c
ontainer
->
resolve
(
'laravel.url'
),
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.encoding'
));
return
new
HTML
(
$c
->
resolve
(
'laravel.url'
),
$c
->
resolve
(
'laravel.config'
)
->
get
(
'application.encoding'
));
}),
'laravel.input'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.input'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$request
=
$container
->
resolve
(
'laravel.request'
);
list
(
$file
,
$cookie
,
$input
,
$files
)
=
array
(
$c
->
resolve
(
'laravel.file'
),
$c
->
resolve
(
'laravel.cookie'
),
$c
->
resolve
(
'laravel.input.array'
),
$_FILES
,
);
return
new
Input
(
$file
,
$cookie
,
$input
,
$files
);
}),
'laravel.input.array'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$input
=
array
();
if
(
$request
->
method
()
==
'GET'
)
switch
(
$c
->
resolve
(
'laravel.request'
)
->
method
()
)
{
case
'GET'
:
$input
=
$_GET
;
}
elseif
(
$request
->
method
()
==
'POST'
)
break
;
case
'POST'
:
$input
=
$_POST
;
break
;
case
'PUT'
:
case
'DELETE'
:
if
(
$c
->
resolve
(
'laravel.request'
)
->
spoofed
())
{
$input
=
$_POST
;
}
elseif
(
$request
->
method
()
==
'PUT'
or
$request
->
method
==
'DELETE'
)
else
{
(
$request
->
spoofed
())
?
$input
=
$_POST
:
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
parse_str
(
file_get_contents
(
'php://input'
),
$input
);
}
}
unset
(
$input
[
'_REQUEST_METHOD'
]);
unset
(
$input
[
Request
::
spoofer
]);
return
new
Input
(
$container
->
resolve
(
'laravel.file'
),
$container
->
resolve
(
'laravel.cookie'
),
$input
,
$_FILES
)
;
return
$input
;
}),
'laravel.lang'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.lang'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
require_once
SYS_PATH
.
'lang'
.
EXT
;
return
new
Lang_Factory
(
$c
ontainer
->
resolve
(
'laravel.config'
),
array
(
SYS_LANG_PATH
,
LANG_PATH
));
return
new
Lang_Factory
(
$c
->
resolve
(
'laravel.config'
),
array
(
SYS_LANG_PATH
,
LANG_PATH
));
}),
'laravel.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
ontainer
)
'laravel.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
require_once
SYS_PATH
.
'loader'
.
EXT
;
$aliases
=
$c
ontainer
->
resolve
(
'laravel.config'
)
->
get
(
'aliases'
);
$aliases
=
$c
->
resolve
(
'laravel.config'
)
->
get
(
'aliases'
);
return
new
Loader
(
array
(
BASE_PATH
,
APP_PATH
.
'models/'
,
APP_PATH
.
'libraries/'
),
$aliases
);
return
new
Loader
(
array
(
BASE_PATH
,
APP_PATH
.
'models/'
,
APP_PATH
),
$aliases
);
}),
'laravel.
package'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
)
'laravel.
redirect'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Package
(
PACKAGE_PATH
);
return
new
Redirect
(
$c
->
resolve
(
'laravel.url'
)
);
}),
'laravel.re
direct'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.re
quest'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Re
direct
(
$container
->
resolve
(
'laravel.url'
)
);
return
new
Re
quest
(
$c
->
resolve
(
'laravel.uri'
)
->
get
(),
$_SERVER
,
$_POST
);
}),
'laravel.request'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
{
return
new
Request
(
$_SERVER
,
$_POST
,
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.url'
));
}),
'laravel.response'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.response'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
require_once
SYS_PATH
.
'response'
.
EXT
;
return
new
Response_Factory
(
$c
ontainer
->
resolve
(
'laravel.view'
),
$container
->
resolve
(
'laravel.file'
));
return
new
Response_Factory
(
$c
->
resolve
(
'laravel.view'
),
$c
->
resolve
(
'laravel.file'
));
}),
'laravel.
routing.router
'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
'laravel.
uri
'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Routing\Router
(
$c
->
resolve
(
'laravel.routing.loader'
),
CONTROLLER_PATH
);
return
new
URI
(
$_SERVER
,
$c
->
resolve
(
'laravel.config'
)
->
get
(
'application.url'
));
}),
'laravel.
routing.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.
url'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Routing\Loader
(
APP_PATH
,
ROUTE_PATH
);
}),
list
(
$router
,
$request
,
$base
,
$index
)
=
array
(
$c
->
resolve
(
'laravel.routing.router'
),
$c
->
resolve
(
'laravel.request'
),
$c
->
resolve
(
'laravel.config'
)
->
get
(
'application.url'
),
$c
->
resolve
(
'laravel.config'
)
->
get
(
'application.index'
),
);
'laravel.routing.caller'
=>
array
(
'resolver'
=>
function
(
$container
)
{
return
new
Routing\Caller
(
$container
,
require
APP_PATH
.
'filters'
.
EXT
,
CONTROLLER_PATH
);
return
new
URL
(
$router
,
$base
,
$index
,
$request
->
secure
());
}),
'laravel.
session.manage
r'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
'laravel.
validato
r'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$config
=
$c
->
resolve
(
'laravel.config'
);
$driver
=
$c
->
resolve
(
'laravel.session.'
.
$config
->
get
(
'session.driver'
));
require_once
SYS_PATH
.
'validation/validator'
.
EXT
;
return
new
Session\Manager
(
$driver
,
$c
->
resolve
(
'laravel.session.transporter'
),
$config
);
return
new
Validation\Validator_Factory
(
$c
->
resolve
(
'laravel.lang'
)
);
}),
'laravel.
session.transporter'
=>
array
(
'resolver'
=>
function
(
$c
)
'laravel.
view'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Session\Transporters\Cookie
(
$c
->
resolve
(
'laravel.cookie'
));
}),
'laravel.url'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
{
list
(
$request
,
$base
,
$index
)
=
array
(
$container
->
resolve
(
'laravel.request'
),
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.url'
),
$container
->
resolve
(
'laravel.config'
)
->
get
(
'application.index'
),
);
require_once
SYS_PATH
.
'view'
.
EXT
;
return
new
URL
(
$container
->
resolve
(
'laravel.routing.router'
),
$base
,
$index
,
$request
->
secure
()
);
return
new
View_Factory
(
new
View_Composer
(
require
APP_PATH
.
'composers'
.
EXT
),
VIEW_PATH
);
}),
/*
|--------------------------------------------------------------------------
| Laravel Routing Components
|--------------------------------------------------------------------------
*/
'laravel.
validator'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.
routing.router'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
require_once
SYS_PATH
.
'validation/validator'
.
EXT
;
return
new
Validation\Validator_Factory
(
$container
->
resolve
(
'laravel.lang'
));
return
new
Routing\Router
(
$c
->
resolve
(
'laravel.routing.loader'
),
CONTROLLER_PATH
);
}),
'laravel.
view'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.
routing.loader'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
require_once
SYS_PATH
.
'view'
.
EXT
;
return
new
View_Factory
(
$container
->
resolve
(
'laravel.view.composer'
),
VIEW_PATH
);
return
new
Routing\Loader
(
APP_PATH
,
ROUTE_PATH
);
}),
'laravel.
view.composer'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.
routing.caller'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
View_Composer
(
require
APP_PATH
.
'composers'
.
EXT
);
return
new
Routing\Caller
(
$c
,
require
APP_PATH
.
'filters'
.
EXT
,
CONTROLLER_PATH
);
}),
/*
|--------------------------------------------------------------------------
| Laravel C
ookie Session
Components
| Laravel C
aching
Components
|--------------------------------------------------------------------------
*/
'laravel.
session.cookie'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.
cache'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
$cookies
=
$container
->
resolve
(
'laravel.cookie'
);
$config
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'session'
);
return
new
Session\Drivers\Cookie
(
$container
->
resolve
(
'laravel.crypter'
),
$cookies
);
return
new
Cache\Manager
(
$c
,
$c
->
resolve
(
'laravel.config'
)
->
get
(
'cache.driver'
));
}),
/*
|--------------------------------------------------------------------------
| Laravel Database Session Components
|--------------------------------------------------------------------------
*/
'laravel.
session.database'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.
cache.apc'
=>
array
(
'resolver'
=>
function
(
$c
)
{
$table
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'session.table'
);
require_once
SYS_PATH
.
'cache/drivers/apc'
.
EXT
;
$key
=
$c
->
resolve
(
'laravel.config'
)
->
get
(
'cache.key'
);
return
new
Session\Drivers\Database
(
$container
->
resolve
(
'laravel.database'
)
->
connection
()
);
return
new
Cache\Drivers\APC
(
new
Cache\Drivers\APC_Engine
,
$key
);
}),
/*
|--------------------------------------------------------------------------
| Laravel Cache Manager
|--------------------------------------------------------------------------
*/
'laravel.cache
'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.cache
.file'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Cache\
Manager
(
$container
,
$container
->
resolve
(
'laravel.config'
)
->
get
(
'cache.driver'
)
);
return
new
Cache\
Drivers\File
(
$c
->
resolve
(
'laravel.file'
),
CACHE_PATH
);
}),
/*
|--------------------------------------------------------------------------
| Laravel File Cache & Session Components
|--------------------------------------------------------------------------
*/
'laravel.cache.
file'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.cache.
memcached'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Cache\Drivers\File
(
$container
->
resolve
(
'laravel.file'
),
CACHE_PATH
);
$key
=
$c
->
resolve
(
'laravel.config'
)
->
get
(
'cache.key'
);
return
new
Cache\Drivers\Memcached
(
$c
->
resolve
(
'laravel.cache.memcache.connection'
),
$key
);
}),
'laravel.
session.file'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.
cache.memcache.connection'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Session\Drivers\File
(
$container
->
resolve
(
'laravel.file'
),
SESSION_PATH
);
$memcache
=
new
\Memcache
;
foreach
(
$c
->
resolve
(
'laravel.config'
)
->
get
(
'cache.servers'
)
as
$server
)
{
$memcache
->
addServer
(
$server
[
'host'
],
$server
[
'port'
],
true
,
$server
[
'weight'
]);
}
if
(
$memcache
->
getVersion
()
===
false
)
{
throw
new
\Exception
(
'Could not establish memcached connection. Please verify your memcached configuration.'
);
}
return
$memcache
;
}),
/*
|--------------------------------------------------------------------------
| Laravel
APC Cache &
Session Components
| Laravel Session Components
|--------------------------------------------------------------------------
*/
'laravel.
cache.apc'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.
session.id'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
new
Cache\Drivers\APC
(
new
Proxy
,
$container
->
resolve
(
'laravel.config'
)
->
get
(
'cache.key'
)
);
return
$c
->
resolve
(
'laravel.cookie'
)
->
get
(
'laravel_session'
);
}),
'laravel.session.
id'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.session.
manager'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$c
)
{
return
$container
->
resolve
(
'laravel.cookie'
)
->
get
(
'laravel_session'
);
}),
$config
=
$c
->
resolve
(
'laravel.config'
);
'laravel.session.apc'
=>
array
(
'resolver'
=>
function
(
$container
)
{
$lifetime
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'session.lifetime'
);
$driver
=
$c
->
resolve
(
'laravel.session.'
.
$config
->
get
(
'session.driver'
));
return
new
Session\
Drivers\APC
(
$container
->
resolve
(
'laravel.cache.apc'
)
);
return
new
Session\
Manager
(
$driver
,
$c
->
resolve
(
'laravel.session.transporter'
),
$config
);
}),
/*
|--------------------------------------------------------------------------
| Laravel Memcached Cache & Session Components
|--------------------------------------------------------------------------
*/
'laravel.
cache.memcached'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.
session.transporter'
=>
array
(
'resolver'
=>
function
(
$c
)
{
$connection
=
$container
->
resolve
(
'laravel.cache.memcache.connection'
);
return
new
Session\Transporters\Cookie
(
$c
->
resolve
(
'laravel.cookie'
));
}),
$key
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'cache.key'
);
return
new
Cache\Drivers\Memcached
(
$connection
,
$key
);
'laravel.session.apc'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Session\Drivers\APC
(
$c
->
resolve
(
'laravel.cache.apc'
));
}),
'laravel.session.
memcached'
=>
array
(
'resolver'
=>
function
(
$container
)
'laravel.session.
cookie'
=>
array
(
'resolver'
=>
function
(
$c
)
{
$
lifetime
=
$container
->
resolve
(
'laravel.config'
)
->
get
(
'session.lifetim
e'
);
$
cookies
=
$c
->
resolve
(
'laravel.cooki
e'
);
return
new
Session\Drivers\
Memcached
(
$container
->
resolve
(
'laravel.cache.memcached'
)
);
return
new
Session\Drivers\
Cookie
(
$c
->
resolve
(
'laravel.crypter'
),
$cookies
);
}),
'laravel.
cache.memcache.connection'
=>
array
(
'singleton'
=>
true
,
'resolver'
=>
function
(
$container
)
'laravel.
session.database'
=>
array
(
'resolver'
=>
function
(
$c
)
{
if
(
!
class_exists
(
'Memcache'
))
{
throw
new
\Exception
(
'Attempting to use Memcached, but the Memcache PHP extension is not installed on this server.'
);
}
return
new
Session\Drivers\Database
(
$c
->
resolve
(
'laravel.database'
)
->
connection
());
}),
$memcache
=
new
\Memcache
;
foreach
(
$container
->
resolve
(
'laravel.config'
)
->
get
(
'cache.servers'
)
as
$server
)
'laravel.session.file'
=>
array
(
'resolver'
=>
function
(
$c
)
{
$memcache
->
addServer
(
$server
[
'host'
],
$server
[
'port'
],
true
,
$server
[
'weight'
]
);
}
return
new
Session\Drivers\File
(
$c
->
resolve
(
'laravel.file'
),
SESSION_PATH
);
}),
if
(
$memcache
->
getVersion
()
===
false
)
{
throw
new
\Exception
(
'Memcached is configured. However, no connections could be made. Please verify your memcached configuration.'
);
}
return
$memcache
;
'laravel.session.memcached'
=>
array
(
'resolver'
=>
function
(
$c
)
{
return
new
Session\Drivers\Memcached
(
$c
->
resolve
(
'laravel.cache.memcached'
));
}),
);
\ No newline at end of file
laravel/core.php
View file @
47db2ff1
...
...
@@ -70,3 +70,16 @@ spl_autoload_register(array($container->resolve('laravel.loader'), 'load'));
// Set the application environment configuration option.
// --------------------------------------------------------------
$container
->
resolve
(
'laravel.config'
)
->
set
(
'application.env'
,
$env
);
// --------------------------------------------------------------
// Define some convenient global functions.
// --------------------------------------------------------------
function
e
(
$value
)
{
return
IoC
::
container
()
->
resolve
(
'laravel.html'
)
->
entities
(
$value
);
}
function
__
(
$key
,
$replacements
=
array
(),
$language
=
null
)
{
return
IoC
::
container
()
->
resolve
(
'laravel.lang'
)
->
line
(
$key
,
$replacements
,
$language
);
}
\ No newline at end of file
laravel/facades.php
View file @
47db2ff1
...
...
@@ -52,6 +52,7 @@ class Redirect extends Facade { public static $resolve = 'laravel.redirect'; }
class
Request
extends
Facade
{
public
static
$resolve
=
'laravel.request'
;
}
class
Response
extends
Facade
{
public
static
$resolve
=
'laravel.response'
;
}
class
Session
extends
Facade
{
public
static
$resolve
=
'laravel.session'
;
}
class
URI
extends
Facade
{
public
static
$resolve
=
'laravel.uri'
;
}
class
URL
extends
Facade
{
public
static
$resolve
=
'laravel.url'
;
}
class
Validator
extends
Facade
{
public
static
$resolve
=
'laravel.validator'
;
}
class
View
extends
Facade
{
public
static
$resolve
=
'laravel.view'
;
}
\ No newline at end of file
laravel/file.php
View file @
47db2ff1
...
...
@@ -79,7 +79,7 @@ class File {
*/
public
function
delete
(
$path
)
{
@
unlink
(
$path
);
if
(
$this
->
exists
(
$path
))
@
unlink
(
$path
);
}
/**
...
...
laravel/form.php
View file @
47db2ff1
...
...
@@ -81,7 +81,7 @@ class Form {
$attributes
[
'accept-charset'
]
=
$this
->
html
->
encoding
;
}
$append
=
(
$method
==
'PUT'
or
$method
==
'DELETE'
)
?
$this
->
hidden
(
'_REQUEST_METHOD'
,
$method
)
:
''
;
$append
=
(
$method
==
'PUT'
or
$method
==
'DELETE'
)
?
$this
->
hidden
(
Request
::
spoofer
,
$method
)
:
''
;
return
'<form'
.
$this
->
html
->
attributes
(
$attributes
)
.
'>'
.
$append
.
PHP_EOL
;
}
...
...
laravel/loader.php
View file @
47db2ff1
...
...
@@ -7,14 +7,14 @@ class Loader {
*
* @var array
*/
p
ublic
$paths
;
p
rotected
$paths
;
/**
* The class aliases defined for the application.
*
* @var array
*/
p
ublic
$aliases
;
p
rotected
$aliases
;
/**
* Create a new class loader instance.
...
...
@@ -37,8 +37,12 @@ class Loader {
*/
public
function
load
(
$class
)
{
// All Laravel core classes follow a namespace to directory convention. So, we will
// replace all of the namespace slashes with directory slashes.
$file
=
strtolower
(
str_replace
(
'\\'
,
'/'
,
$class
));
// First, we'll check to determine if an alias exists. If it does, we will define the
// alias and bail out. Aliases are defined for most developer used core classes.
if
(
array_key_exists
(
$class
,
$this
->
aliases
))
return
class_alias
(
$this
->
aliases
[
$class
],
$class
);
foreach
(
$this
->
paths
as
$path
)
...
...
@@ -52,4 +56,57 @@ class Loader {
}
}
/**
* Register a class alias with the auto-loader.
*
* Note: Aliases are lazy-loaded, so the aliased class will not be included until it is needed.
*
* <code>
* // Register an alias for the "SwiftMailer\Transport" class
* Loader::alias('Transport', 'SwiftMailer\\Transport');
* </code>
*
* @param string $alias
* @param string $class
* @return void
*/
public
function
alias
(
$alias
,
$class
)
{
$this
->
aliases
[
$alias
]
=
$class
;
}
/**
* Register a path with the auto-loader.
*
* The registered path will be searched when auto-loading classes.
*
* <code>
* // Register a path to be searched by the auto-loader
* Loader::path('path/to/files');
* </code>
*
* @param string $path
* @return void
*/
public
function
path
(
$path
)
{
$this
->
paths
[]
=
rtrim
(
$path
,
'/'
)
.
'/'
;
}
/**
* Remove an alias from the auto-loader's alias registrations.
*
* <code>
* // Remove the "Transport" alias from the registered aliases
* Loader::forget_alias('Transport');
* </code>
*
* @param string $alias
* @return void
*/
public
function
forget_alias
(
$alias
)
{
unset
(
$this
->
aliases
[
$alias
]);
}
}
\ No newline at end of file
laravel/request.php
View file @
47db2ff1
...
...
@@ -2,12 +2,19 @@
class
Request
{
/**
* The URI for the current request.
*
* @var string
*/
protected
$uri
;
/**
* The $_SERVER array for the request.
*
* @var array
*/
p
ublic
$server
;
p
rotected
$server
;
/**
* The $_POST array for the request.
...
...
@@ -17,40 +24,30 @@ class Request {
protected
$post
;
/**
* The
base URL of the application
.
* The
route handling the current request
.
*
* @var
string
* @var
Routing\Route
*/
p
rotected
$url
;
p
ublic
$route
;
/**
* The request URI.
*
* After determining the URI once, this property will be set and returned
* on subsequent requests for the URI.
* The request data key that is used to indicate the spoofed request method.
*
* @var string
*/
protected
$uri
;
/**
* The route handling the current request.
*
* @var Routing\Route
*/
public
$route
;
const
spoofer
=
'__spoofer'
;
/**
* Create a new request instance.
*
* @param string $uri
* @param array $server
* @param array $post
* @param string $url
* @return void
*/
public
function
__construct
(
$
server
,
$post
,
$url
)
public
function
__construct
(
$
uri
,
$server
,
$post
)
{
$this
->
ur
l
=
$url
;
$this
->
ur
i
=
$uri
;
$this
->
post
=
$post
;
$this
->
server
=
$server
;
}
...
...
@@ -69,32 +66,7 @@ class Request {
*/
public
function
uri
()
{
if
(
!
is_null
(
$this
->
uri
))
return
$this
->
uri
;
if
(
isset
(
$this
->
server
[
'PATH_INFO'
]))
{
$uri
=
$this
->
server
[
'PATH_INFO'
];
}
elseif
(
isset
(
$this
->
server
[
'REQUEST_URI'
]))
{
$uri
=
parse_url
(
$this
->
server
[
'REQUEST_URI'
],
PHP_URL_PATH
);
}
else
{
throw
new
\Exception
(
'Unable to determine the request URI.'
);
}
if
(
$uri
===
false
)
{
throw
new
\Exception
(
'Malformed request URI. Request terminated.'
);
}
foreach
(
array
(
parse_url
(
$this
->
url
,
PHP_URL_PATH
),
'/index.php'
)
as
$value
)
{
$uri
=
(
strpos
(
$uri
,
$value
)
===
0
)
?
substr
(
$uri
,
strlen
(
$value
))
:
$uri
;
}
return
$this
->
uri
=
((
$uri
=
trim
(
$uri
,
'/'
))
==
''
)
?
'/'
:
$uri
;
return
$this
->
uri
;
}
/**
...
...
@@ -102,6 +74,14 @@ class Request {
*
* The format is determined by essentially taking the "extension" of the URI.
*
* <code>
* // Returns "html" for a request to "/user/profile"
* $format = Request::format();
*
* // Returns "json" for a request to "/user/profile.json"
* $format = Request::format();
* </code>
*
* @return string
*/
public
function
format
()
...
...
@@ -120,27 +100,62 @@ class Request {
*/
public
function
method
()
{
return
(
$this
->
spoofed
())
?
$this
->
post
[
'_REQUEST_METHOD'
]
:
$this
->
server
[
'REQUEST_METHOD'
];
return
(
$this
->
spoofed
())
?
$this
->
post
[
Request
::
spoofer
]
:
$this
->
server
[
'REQUEST_METHOD'
];
}
/**
* Get an item from the $_SERVER array.
*
* Like most array retrieval methods, a default value may be specified.
*
* <code>
* // Get an item from the $_SERVER array
* $value = Request::server('http_x_requested_for');
*
* // Get an item from the $_SERVER array or return a default value
* $value = Request::server('http_x_requested_for', '127.0.0.1');
* </code>
*
* @param string $key
* @param mixed $default
* @return string
*/
public
function
server
(
$key
=
null
,
$default
=
null
)
{
return
Arr
::
get
(
$this
->
server
,
strtoupper
(
$key
),
$default
);
}
/**
* Determine if the request method is being spoofed by a hidden Form element.
*
* Hidden elements are used to spoof PUT and DELETE requests since they are not supported by HTML forms.
* Hidden elements are used to spoof PUT and DELETE requests since they are not supported
* by HTML forms. If the request is being spoofed, Laravel considers the spoofed request
* method the actual request method throughout the framework.
*
* @return bool
*/
public
function
spoofed
()
{
return
is_array
(
$this
->
post
)
and
array_key_exists
(
'REQUEST_METHOD'
,
$this
->
post
);
return
is_array
(
$this
->
post
)
and
array_key_exists
(
Request
::
spoofer
,
$this
->
post
);
}
/**
* Get the requestor's IP address.
*
* A default may be passed and will be returned in the event the IP can't be determined
*
* <code>
* // Get the requestor's IP address
* $ip = Request::ip();
*
* // Get the requestor's IP address or return a default value
* $ip = Request::ip('127.0.0.1');
* </code>
*
* @param mixed $default
* @return string
*/
public
function
ip
()
public
function
ip
(
$default
=
'0.0.0.0'
)
{
if
(
isset
(
$this
->
server
[
'HTTP_X_FORWARDED_FOR'
]))
{
...
...
@@ -154,11 +169,16 @@ class Request {
{
return
$this
->
server
[
'REMOTE_ADDR'
];
}
return
(
$default
instanceof
\Closure
)
?
call_user_func
(
$default
)
:
$default
;
}
/**
* Get the HTTP protocol for the request.
*
* This method will return either "https" or "http", depending on whether HTTPS
* is being used for the current request.
*
* @return string
*/
public
function
protocol
()
...
...
@@ -167,17 +187,17 @@ class Request {
}
/**
* Determine if the request is using HTTPS.
* Determine if the
current
request is using HTTPS.
*
* @return bool
*/
public
function
secure
()
{
return
(
$this
->
protocol
()
==
'https'
)
;
return
$this
->
protocol
()
==
'https'
;
}
/**
* Determine if the request is an AJAX request.
* Determine if the
current
request is an AJAX request.
*
* @return bool
*/
...
...
laravel/routing/loader.php
View file @
47db2ff1
...
...
@@ -72,14 +72,6 @@ class Loader {
{
return
require
$path
;
}
// Even if we didn't find a matching file for the segment, we still want to
// check for a "routes.php" file which could handle the root route and any
// routes that are impossible to handle in an explicitly named file.
if
(
file_exists
(
$path
=
str_replace
(
'.php'
,
'/routes.php'
,
$path
)))
{
return
require
$path
;
}
}
return
array
();
...
...
@@ -99,7 +91,6 @@ class Loader {
$routes
=
array
();
// First we will check for the base routes file in the application directory.
if
(
file_exists
(
$path
=
$this
->
base
.
'routes'
.
EXT
))
{
$routes
=
array_merge
(
$routes
,
require
$path
);
...
...
laravel/routing/route.php
View file @
47db2ff1
...
...
@@ -99,7 +99,10 @@ class Route {
// route is delegating the responsibility for handling the request to a controller.
elseif
(
is_array
(
$this
->
callback
))
{
$callback
=
Arr
::
first
(
$this
->
callback
,
function
(
$key
,
$value
)
{
return
$key
==
'delegate'
or
$value
instanceof
Closure
;});
$callback
=
Arr
::
first
(
$this
->
callback
,
function
(
$key
,
$value
)
{
return
$key
==
'delegate'
or
$value
instanceof
Closure
;
});
return
(
$callback
instanceof
Closure
)
?
call_user_func_array
(
$callback
,
$this
->
parameters
)
:
new
Delegate
(
$callback
);
}
...
...
@@ -121,7 +124,12 @@ class Route {
*/
public
function
filters
(
$name
)
{
return
(
is_array
(
$this
->
callback
)
and
isset
(
$this
->
callback
[
$name
]))
?
explode
(
', '
,
$this
->
callback
[
$name
])
:
array
();
if
(
is_array
(
$this
->
callback
)
and
isset
(
$this
->
callback
[
$name
]))
{
return
explode
(
', '
,
$this
->
callback
[
$name
]);
}
return
array
();
}
/**
...
...
laravel/session/manager.php
View file @
47db2ff1
...
...
@@ -65,7 +65,10 @@ class Manager {
// are generated per session to protect against Cross-Site Request Forgery attacks on
// the application. It is up to the developer to take advantage of them using the token
// methods on the Form class and the "csrf" route filter.
if
(
!
$payload
->
has
(
'csrf_token'
))
$payload
->
put
(
'csrf_token'
,
Str
::
random
(
16
));
if
(
!
$payload
->
has
(
'csrf_token'
))
{
$payload
->
put
(
'csrf_token'
,
Str
::
random
(
16
));
}
return
$payload
;
}
...
...
laravel/uri.php
0 → 100644
View file @
47db2ff1
<?php
namespace
Laravel
;
class
URI
{
/**
* The $_SERVER array for the current request.
*
* @var array
*/
protected
$server
;
/**
* The application URL as specified in the application configuration file.
*
* @var string
*/
protected
$url
;
/**
* The URI for the current request.
*
* This property will be set after the URI is detected for the first time.
*
* @var string
*/
protected
$uri
;
/**
* Create a new URI instance.
*
* @param array $server
* @param string $url
* @return void
*/
public
function
__construct
(
$server
,
$url
)
{
$this
->
url
=
$url
;
$this
->
server
=
$server
;
}
/**
* Get the URI for the current request.
*
* @return string
*/
public
function
get
()
{
if
(
!
is_null
(
$this
->
uri
))
return
$this
->
uri
;
if
((
$uri
=
$this
->
from_server
())
===
false
)
{
throw
new
\Exception
(
'Malformed request URI. Request terminated.'
);
}
return
$this
->
uri
=
$this
->
format
(
$this
->
clean
(
$uri
));
}
/**
* Get a given URI segment from the URI for the current request.
*
* <code>
* // Get the first segment from the request URI
* $first = Request::uri()->segment(1);
*
* // Get the second segment or return a default value if it doesn't exist
* $second = Request::uri()->segment(2, 'Taylor');
*
* // Get all of the segments for the request URI
* $segments = Request::uri()->segment();
* </code>
*
* @param int $segment
* @param mixed $default
* @return string
*/
public
function
segment
(
$segment
=
null
,
$default
=
null
)
{
$segments
=
Arr
::
without
(
explode
(
'/'
,
$this
->
detect
()),
array
(
''
));
if
(
!
is_null
(
$segment
))
$segment
=
$segment
-
1
;
return
Arr
::
get
(
$segments
,
$segment
,
$default
);
}
/**
* Get the request URI from the $_SERVER array.
*
* @return string
*/
protected
function
from_server
()
{
// If the PATH_INFO $_SERVER element is set, we will use since it contains
// the request URI formatted perfectly for Laravel's routing engine.
if
(
isset
(
$this
->
server
[
'PATH_INFO'
]))
{
return
$this
->
server
[
'PATH_INFO'
];
}
// If the REQUEST_URI is set, we need to extract the URL path since this
// should return the URI formatted in a manner similar to PATH_INFO.
elseif
(
isset
(
$this
->
server
[
'REQUEST_URI'
]))
{
return
parse_url
(
$this
->
server
[
'REQUEST_URI'
],
PHP_URL_PATH
);
}
throw
new
\Exception
(
'Unable to determine the request URI.'
);
}
/**
* Remove extraneous segments from the URI such as the URL and index page.
*
* These segments need to be removed since they will cause problems in the
* routing engine if they are present in the URI.
*
* @param string $uri
* @return string
*/
protected
function
clean
(
$uri
)
{
foreach
(
array
(
parse_url
(
$this
->
url
,
PHP_URL_PATH
),
'/index.php'
)
as
$value
)
{
$uri
=
(
strpos
(
$uri
,
$value
)
===
0
)
?
substr
(
$uri
,
strlen
(
$value
))
:
$uri
;
}
return
$uri
;
}
/**
* Format the URI.
*
* If the request URI is empty, a single forward slash will be returned.
*
* @param string $uri
* @return string
*/
protected
function
format
(
$uri
)
{
return
((
$uri
=
trim
(
$uri
,
'/'
))
==
''
)
?
'/'
:
$uri
;
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment