Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
U
UserAdminV2
Overview
Overview
Details
Activity
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
庄欣
UserAdminV2
Commits
af36cb3d
Commit
af36cb3d
authored
Oct 20, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
various refactoring and tweaks.
parent
df9130da
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
140 additions
and
108 deletions
+140
-108
application/config/cache.php
+4
-1
application/filters.php
+9
-2
application/language/en/.gitignore
+0
-0
application/language/en/pagination.php
+0
-0
application/language/en/validation.php
+0
-0
laravel/bootstrap/constants.php
+0
-1
laravel/bootstrap/errors.php
+19
-6
laravel/cache/drivers/driver.php
+1
-1
laravel/cache/manager.php
+2
-2
laravel/config/container.php
+1
-1
laravel/database/connection.php
+34
-34
laravel/database/grammars/grammar.php
+3
-8
laravel/html.php
+8
-1
laravel/lang.php
+1
-4
laravel/routing/controller.php
+2
-4
laravel/routing/route.php
+17
-10
laravel/routing/router.php
+7
-2
laravel/security/auth.php
+7
-4
laravel/security/crypter.php
+7
-5
laravel/session/manager.php
+3
-6
laravel/validation/validator.php
+5
-5
laravel/view.php
+10
-11
No files found.
application/config/cache.php
View file @
af36cb3d
...
...
@@ -45,8 +45,10 @@ return array(
|
*/
'servers'
=>
array
(
'memcached'
=>
array
(
array
(
'host'
=>
'127.0.0.1'
,
'port'
=>
11211
,
'weight'
=>
100
),
),
);
\ No newline at end of file
application/filters.php
View file @
af36cb3d
...
...
@@ -59,13 +59,19 @@ return array(
'auth'
=>
function
()
{
if
(
!
Auth
::
check
())
return
Redirect
::
to_login
();
if
(
!
Auth
::
check
())
{
return
Redirect
::
to_login
();
}
},
'csrf'
=>
function
()
{
if
(
Input
::
get
(
'csrf_token'
)
!==
Form
::
raw_token
())
return
Response
::
error
(
'500'
);
if
(
Input
::
get
(
'csrf_token'
)
!==
Form
::
raw_token
())
{
return
Response
::
error
(
'500'
);
}
},
);
\ No newline at end of file
application/language/en/.gitignore
deleted
100644 → 0
View file @
df9130da
laravel
/language/en/pagination.php
→
application
/language/en/pagination.php
View file @
af36cb3d
File moved
laravel
/language/en/validation.php
→
application
/language/en/validation.php
View file @
af36cb3d
File moved
laravel/bootstrap/constants.php
View file @
af36cb3d
...
...
@@ -49,7 +49,6 @@ $constants = array(
'ROUTE_PATH'
=>
APP_PATH
.
'routes/'
,
'SESSION_PATH'
=>
STORAGE_PATH
.
'sessions/'
,
'SYS_CONFIG_PATH'
=>
SYS_PATH
.
'config/'
,
'SYS_LANG_PATH'
=>
SYS_PATH
.
'language/'
,
'SYS_VIEW_PATH'
=>
SYS_PATH
.
'views/'
,
'VIEW_PATH'
=>
APP_PATH
.
'views/'
,
);
...
...
laravel/bootstrap/errors.php
View file @
af36cb3d
...
...
@@ -6,8 +6,12 @@
* error handler to create a more readable message.
*/
$message
=
function
(
$e
)
{
$file
=
str_replace
(
array
(
APP_PATH
,
SYS_PATH
),
array
(
'APP_PATH/'
,
'SYS_PATH/'
),
$e
->
getFile
());
{
$search
=
array
(
APP_PATH
,
SYS_PATH
);
$replace
=
array
(
'APP_PATH/'
,
'SYS_PATH/'
);
$file
=
str_replace
(
$search
,
$replace
,
$e
->
getFile
());
return
rtrim
(
$e
->
getMessage
(),
'.'
)
.
' in '
.
$file
.
' on line '
.
$e
->
getLine
()
.
'.'
;
};
...
...
@@ -35,14 +39,23 @@ $severity = function($e)
E_STRICT
=>
'Runtime Notice'
,
);
return
(
array_key_exists
(
$e
->
getCode
(),
$levels
))
?
$levels
[
$e
->
getCode
()]
:
$e
->
getCode
();
if
(
array_key_exists
(
$e
->
getCode
(),
$levels
))
{
$level
=
$levels
[
$e
->
getCode
()];
}
else
{
$level
=
$e
->
getCode
();
}
return
$level
;
};
/**
* Create the exception handler function. All of the error handlers
* registered
with PHP call this closure to keep the code D.R.Y.
*
Each of the formatting closures defined above will be passed
* into the handler for convenient use.
* registered
by the framework call this closure to avoid duplicate
*
code. Each of the formatting closures defined above will be
*
passed
into the handler for convenient use.
*/
$handler
=
function
(
$e
)
use
(
$message
,
$severity
)
{
...
...
laravel/cache/drivers/driver.php
View file @
af36cb3d
...
...
@@ -61,7 +61,7 @@ abstract class Driver {
* cache, store the default value in the cache and return it.
*
* <code>
* // Get an item from the cache, or cache a value for 15 minutes
if it doesn't exist
* // Get an item from the cache, or cache a value for 15 minutes
* $name = Cache::remember('name', 'Taylor', 15);
*
* // Use a closure for deferred execution
...
...
laravel/cache/manager.php
View file @
af36cb3d
...
...
@@ -12,8 +12,8 @@ class Manager {
/**
* Get a cache driver instance.
*
* If no driver name is specified, the default cache driver will
be
* returned as defined in the cache configuration file.
* If no driver name is specified, the default cache driver will
*
be
returned as defined in the cache configuration file.
*
* <code>
* // Get the default cache driver instance
...
...
laravel/config/container.php
View file @
af36cb3d
...
...
@@ -101,7 +101,7 @@ return array(
{
$memcache
=
new
\Memcache
;
foreach
(
Config
::
get
(
'cache.
servers
'
)
as
$server
)
foreach
(
Config
::
get
(
'cache.
memcached
'
)
as
$server
)
{
$memcache
->
addServer
(
$server
[
'host'
],
$server
[
'port'
],
true
,
$server
[
'weight'
]);
}
...
...
laravel/database/connection.php
View file @
af36cb3d
...
...
@@ -44,6 +44,36 @@ class Connection {
}
/**
* Begin a fluent query against a table.
*
* @param string $table
* @return Query
*/
public
function
table
(
$table
)
{
return
new
Query
(
$this
,
$this
->
grammar
(),
$table
);
}
/**
* Create a new query grammar for the connection.
*
* @return Grammars\Grammar
*/
protected
function
grammar
()
{
if
(
isset
(
$this
->
grammar
))
return
$this
->
grammar
;
switch
(
isset
(
$this
->
config
[
'grammar'
])
?
$this
->
config
[
'grammar'
]
:
$this
->
driver
())
{
case
'mysql'
:
return
$this
->
grammar
=
new
Grammars\MySQL
;
default
:
return
$this
->
grammar
=
new
Grammars\Grammar
;
}
}
/**
* Execute a SQL query against the connection and return a single column result.
*
* <code>
...
...
@@ -109,18 +139,18 @@ class Connection {
*/
public
function
query
(
$sql
,
$bindings
=
array
())
{
//
First we need to remove all expressions from the bindings
//
since they will be placed into the query as raw string
s.
//
Remove expressions from the bindings since they injected into
//
the query as raw strings and are not bound parameter
s.
foreach
(
$bindings
as
$key
=>
$value
)
{
if
(
$value
instanceof
Expression
)
unset
(
$bindings
[
$key
]);
}
$sql
=
$this
->
transform
(
$sql
,
$bindings
);
$sql
=
$this
->
transform
(
trim
(
$sql
)
,
$bindings
);
$this
->
queries
[]
=
compact
(
'sql'
,
'bindings'
);
return
$this
->
execute
(
$this
->
pdo
->
prepare
(
trim
(
$sql
)
),
$bindings
);
return
$this
->
execute
(
$this
->
pdo
->
prepare
(
$sql
),
$bindings
);
}
/**
...
...
@@ -179,36 +209,6 @@ class Connection {
}
/**
* Begin a fluent query against a table.
*
* @param string $table
* @return Query
*/
public
function
table
(
$table
)
{
return
new
Query
(
$this
,
$this
->
grammar
(),
$table
);
}
/**
* Create a new query grammar for the connection.
*
* @return Grammars\Grammar
*/
protected
function
grammar
()
{
if
(
isset
(
$this
->
grammar
))
return
$this
->
grammar
;
switch
(
isset
(
$this
->
config
[
'grammar'
])
?
$this
->
config
[
'grammar'
]
:
$this
->
driver
())
{
case
'mysql'
:
return
$this
->
grammar
=
new
Grammars\MySQL
;
default
:
return
$this
->
grammar
=
new
Grammars\Grammar
;
}
}
/**
* Get the driver name for the database connection.
*
* @return string
...
...
laravel/database/grammars/grammar.php
View file @
af36cb3d
...
...
@@ -47,8 +47,6 @@ class Grammar {
{
$sql
=
array
();
// Iterate through each query component, calling the compiler for that
// component and passing the query instance into the compiler.
foreach
(
$this
->
components
as
$component
)
{
if
(
!
is_null
(
$query
->
$component
))
...
...
@@ -111,9 +109,6 @@ class Grammar {
*/
protected
function
joins
(
Query
$query
)
{
// Since creating a JOIN clause using string concatenation is a little
// cumbersome, we will create a format we can pass to "sprintf" to
// make things cleaner.
$format
=
'%s JOIN %s ON %s %s %s'
;
foreach
(
$query
->
joins
as
$join
)
...
...
@@ -281,9 +276,9 @@ class Grammar {
// every insert to the table.
$columns
=
$this
->
columnize
(
array_keys
(
reset
(
$values
)));
// Build the list of parameter place-holders
for the array of values bound
//
to the query. Each insert statement should have the same number of bound
//
parameters, so we can
just use the first array of values.
// Build the list of parameter place-holders
of values bound to the query.
//
Each insert should have the same number of bound paramters, so we can
// just use the first array of values.
$parameters
=
$this
->
parameterize
(
reset
(
$values
));
$parameters
=
implode
(
', '
,
array_fill
(
0
,
count
(
$values
),
'('
.
$parameters
.
')'
));
...
...
laravel/html.php
View file @
af36cb3d
...
...
@@ -270,7 +270,14 @@ class HTML {
foreach
(
$list
as
$key
=>
$value
)
{
$html
.=
(
is_array
(
$value
))
?
static
::
elements
(
$type
,
$value
)
:
'<li>'
.
static
::
entities
(
$value
)
.
'</li>'
;
if
(
is_array
(
$value
))
{
$html
.=
static
::
elements
(
$type
,
$value
);
}
else
{
$html
.=
'<li>'
.
static
::
entities
(
$value
)
.
'</li>'
;
}
}
return
'<'
.
$type
.
static
::
attributes
(
$attributes
)
.
'>'
.
$html
.
'</'
.
$type
.
'>'
;
...
...
laravel/lang.php
View file @
af36cb3d
...
...
@@ -37,7 +37,7 @@ class Lang {
*
* @var array
*/
protected
$paths
=
array
(
SYS_LANG_PATH
,
LANG_PATH
);
protected
$paths
=
array
(
LANG_PATH
);
/**
* Create a new Lang instance.
...
...
@@ -164,9 +164,6 @@ class Lang {
$language
=
array
();
// Language files cascade. Typically, the system language array is
// loaded first, followed by the application array. This allows the
// convenient overriding of the system language files.
foreach
(
$this
->
paths
as
$directory
)
{
if
(
file_exists
(
$path
=
$directory
.
$this
->
language
.
'/'
.
$file
.
EXT
))
...
...
laravel/routing/controller.php
View file @
af36cb3d
...
...
@@ -60,13 +60,11 @@ abstract class Controller {
}
// The after filter and the framework expects all responses to
// be instances of the Response class. If the
route
did not
// be instances of the Response class. If the
method
did not
// return an instsance of Response, we will make on now.
if
(
!
$response
instanceof
Response
)
$response
=
new
Response
(
$response
);
$filters
=
array_merge
(
$controller
->
filters
(
'after'
),
array
(
'after'
));
Filter
::
run
(
$filters
,
array
(
$response
));
Filter
::
run
(
$controller
->
filters
(
'after'
),
array
(
$response
));
return
$response
;
}
...
...
laravel/routing/route.php
View file @
af36cb3d
...
...
@@ -93,6 +93,12 @@ class Route {
// Since "before" filters can halt the request cycle, we will return
// any response from the before filters. Allowing filters to halt the
// request cycle makes tasks like authorization convenient.
//
// The route is responsible for running the global filters, and any
// filters defined on the route itself. Since all incoming requests
// come through a route (either defined or ad-hoc), it makes sense
// to let the route handle the global filters. If the route uses
// a controller, the controller will only call its own filters.
$before
=
array_merge
(
array
(
'before'
),
$this
->
filters
(
'before'
));
if
(
!
is_null
(
$response
=
Filter
::
run
(
$before
,
array
(),
true
)))
...
...
@@ -104,21 +110,22 @@ class Route {
{
if
(
$response
instanceof
Delegate
)
{
return
Controller
::
call
(
$response
->
destination
,
$this
->
parameters
);
$response
=
Controller
::
call
(
$response
->
destination
,
$this
->
parameters
);
}
else
// The after filter and the framework expects all responses to
// be instances of the Response class. If the route did not
// return an instsance of Response, we will make on now.
if
(
!
$response
instanceof
Response
)
{
// The after filter and the framework expects all responses to
// be instances of the Response class. If the route did not
// return an instsance of Response, we will make on now.
if
(
!
$response
instanceof
Response
)
$response
=
new
Response
(
$response
);
$response
=
new
Response
(
$response
);
}
$filters
=
array_merge
(
$this
->
filters
(
'after'
),
array
(
'after'
));
$filters
=
array_merge
(
$this
->
filters
(
'after'
),
array
(
'after'
));
Filter
::
run
(
$filters
,
array
(
$response
));
Filter
::
run
(
$filters
,
array
(
$response
));
return
$response
;
}
return
$response
;
}
return
Response
::
error
(
'404'
);
...
...
laravel/routing/router.php
View file @
af36cb3d
...
...
@@ -153,7 +153,10 @@ class Router {
foreach
(
explode
(
', '
,
$keys
)
as
$key
)
{
// Append the provided formats to the route as an optional regular expression.
if
(
!
is_null
(
$formats
=
$this
->
provides
(
$callback
)))
$key
.=
'(\.('
.
implode
(
'|'
,
$formats
)
.
'))?'
;
if
(
!
is_null
(
$formats
=
$this
->
provides
(
$callback
)))
{
$key
.=
'(\.('
.
implode
(
'|'
,
$formats
)
.
'))?'
;
}
if
(
preg_match
(
'#^'
.
$this
->
wildcards
(
$key
)
.
'$#'
,
$destination
))
{
...
...
@@ -216,7 +219,9 @@ class Router {
{
foreach
(
array_reverse
(
$segments
,
true
)
as
$key
=>
$value
)
{
if
(
file_exists
(
$path
=
$this
->
controllers
.
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
))
$controller
=
implode
(
'/'
,
array_slice
(
$segments
,
0
,
$key
+
1
))
.
EXT
;
if
(
file_exists
(
$path
=
$this
->
controllers
.
$controller
))
{
return
$key
+
1
;
}
...
...
laravel/security/auth.php
View file @
af36cb3d
<?php
namespace
Laravel\Security
;
use
Laravel\IoC
;
use
Laravel\Str
;
use
Laravel\Config
;
use
Laravel\Cookie
;
...
...
@@ -42,7 +41,7 @@ class Auth {
/**
* Get the current user of the application.
*
* This method will call the "user" closure in the auth
entication
configuration file.
* This method will call the "user" closure in the auth configuration file.
* If the user is not authenticated, null will be returned by the methd.
*
* If no user exists in the session, the method will check for a "remember me"
...
...
@@ -64,7 +63,9 @@ class Auth {
static
::
$user
=
call_user_func
(
Config
::
get
(
'auth.user'
),
Session
::
get
(
Auth
::
user_key
));
if
(
is_null
(
static
::
$user
)
and
!
is_null
(
$cookie
=
Cookie
::
get
(
Auth
::
remember_key
)))
$cookie
=
Cookie
::
get
(
Auth
::
remember_key
);
if
(
is_null
(
static
::
$user
)
and
!
is_null
(
$cookie
))
{
static
::
$user
=
static
::
recall
(
$cookie
);
}
...
...
@@ -113,7 +114,9 @@ class Auth {
{
$config
=
Config
::
get
(
'auth'
);
if
(
!
is_null
(
$user
=
call_user_func
(
$config
[
'attempt'
],
$username
,
$password
,
$config
)))
$user
=
call_user_func
(
$config
[
'attempt'
],
$username
,
$password
,
$config
);
if
(
!
is_null
(
$user
))
{
static
::
login
(
$user
,
$config
,
$remember
);
...
...
laravel/security/crypter.php
View file @
af36cb3d
...
...
@@ -54,7 +54,9 @@ class Crypter {
$iv
=
mcrypt_create_iv
(
static
::
iv_size
(),
$randomizer
);
return
base64_encode
(
$iv
.
mcrypt_encrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
));
$value
=
mcrypt_encrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
);
return
base64_encode
(
$iv
.
$value
);
}
/**
...
...
@@ -67,20 +69,20 @@ class Crypter {
{
list
(
$iv
,
$value
)
=
static
::
parse
(
base64_decode
(
$value
,
true
));
return
rtrim
(
mcrypt_decrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
),
"
\0
"
);
$value
=
mcrypt_decrypt
(
static
::
$cipher
,
static
::
key
(),
$value
,
static
::
$mode
,
$iv
);
return
rtrim
(
$value
,
"
\0
"
);
}
/**
* Parse an encrypted value into the input vector and the actual value.
*
* If the given value is not valid base64 data, an exception will be thrown.
*
* @param string $value
* @return array
*/
protected
static
function
parse
(
$value
)
{
if
(
!
is_string
(
$value
)
)
if
(
$value
===
false
)
{
throw
new
\Exception
(
'Decryption error. Input value is not valid base64 data.'
);
}
...
...
laravel/session/manager.php
View file @
af36cb3d
...
...
@@ -137,9 +137,9 @@ class Manager {
/**
* Write an item to the session flash data.
*
* Flash data only exists for the next request. After that, it will
*
be removed from the session. Flash data is useful for temporary
*
status
or welcome messages.
* Flash data only exists for the next request. After that, it will
be
*
removed from the session. Flash data is useful for temporary status
* or welcome messages.
*
* <code>
* // Flash an item to the session
...
...
@@ -236,9 +236,6 @@ class Manager {
{
static
::
$session
[
'last_activity'
]
=
time
();
// To age the data, we will forget all of the old keys and then
// rewrite the newly flashed items to have old keys, which will
// be available for the next request.
foreach
(
static
::
$session
[
'data'
]
as
$key
=>
$value
)
{
if
(
strpos
(
$key
,
':old:'
)
===
0
)
static
::
forget
(
$key
);
...
...
laravel/validation/validator.php
View file @
af36cb3d
...
...
@@ -281,7 +281,7 @@ class Validator {
*/
protected
function
validate_size
(
$attribute
,
$value
,
$parameters
)
{
return
$this
->
get_
size
(
$attribute
,
$value
)
==
$parameters
[
0
];
return
$this
->
size
(
$attribute
,
$value
)
==
$parameters
[
0
];
}
/**
...
...
@@ -294,7 +294,7 @@ class Validator {
*/
protected
function
validate_between
(
$attribute
,
$value
,
$parameters
)
{
return
$this
->
get_size
(
$attribute
,
$value
)
>=
$parameters
[
0
]
and
$this
->
get_
size
(
$attribute
,
$value
)
<=
$parameters
[
1
];
return
$this
->
size
(
$attribute
,
$value
)
>=
$parameters
[
0
]
and
$this
->
size
(
$attribute
,
$value
)
<=
$parameters
[
1
];
}
/**
...
...
@@ -307,7 +307,7 @@ class Validator {
*/
protected
function
validate_min
(
$attribute
,
$value
,
$parameters
)
{
return
$this
->
get_
size
(
$attribute
,
$value
)
>=
$parameters
[
0
];
return
$this
->
size
(
$attribute
,
$value
)
>=
$parameters
[
0
];
}
/**
...
...
@@ -320,7 +320,7 @@ class Validator {
*/
protected
function
validate_max
(
$attribute
,
$value
,
$parameters
)
{
return
$this
->
get_
size
(
$attribute
,
$value
)
<=
$parameters
[
0
];
return
$this
->
size
(
$attribute
,
$value
)
<=
$parameters
[
0
];
}
/**
...
...
@@ -335,7 +335,7 @@ class Validator {
* @param mixed $value
* @return mixed
*/
protected
function
get_
size
(
$attribute
,
$value
)
protected
function
size
(
$attribute
,
$value
)
{
if
(
is_numeric
(
$value
)
and
$this
->
has_rule
(
$attribute
,
$this
->
numeric_rules
))
{
...
...
laravel/view.php
View file @
af36cb3d
...
...
@@ -133,10 +133,9 @@ class View {
{
if
(
is_null
(
static
::
$composers
))
static
::
$composers
=
require
APP_PATH
.
'composers'
.
EXT
;
// The view's name may specified in several different ways in the
// composers file. The composer may simple have a string value,
// which is the name. Or, it may an array value in which a
// "name" key exists.
// The view's name may specified in several different ways in the composers
// file. The composer may simple have a string value, which is the name.
// Or, it may an array value in which a "name" key exists.
foreach
(
static
::
$composers
as
$key
=>
$value
)
{
if
(
$name
===
$value
or
(
is_array
(
$value
)
and
$name
===
Arr
::
get
(
$value
,
'name'
)))
...
...
@@ -174,10 +173,10 @@ class View {
{
static
::
compose
(
$this
);
// All nested views and responses are evaluated before the
//
main view. This allows the assets used by these views to
//
be added to the asset container before the main view is
//
evaluated and dumps the
links to the assets.
// All nested views and responses are evaluated before the
main view.
//
This allows the assets used by the nested views to be added to the
//
asset container before the main view is evaluated and dumps the
// links to the assets.
foreach
(
$this
->
data
as
&
$data
)
{
if
(
$data
instanceof
View
or
$data
instanceof
Response
)
...
...
@@ -188,9 +187,9 @@ class View {
ob_start
()
and
extract
(
$this
->
data
,
EXTR_SKIP
);
// If the view is
a "Blade" view, we need to check the view for
//
modifications and get the path to the compiled view file.
//
Otherwise, we'll just
use the regular path to the view.
// If the view is
Bladed, we need to check the view for modifications
//
and get the path to the compiled view file. Otherwise, we'll just
// use the regular path to the view.
$view
=
(
strpos
(
$this
->
path
,
BLADE_EXT
)
!==
false
)
?
$this
->
compile
()
:
$this
->
path
;
try
{
include
$view
;
}
catch
(
Exception
$e
)
{
ob_get_clean
();
throw
$e
;
}
...
...
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