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
1c694915
Commit
1c694915
authored
Jun 16, 2011
by
Taylor Otwell
Browse files
Options
Browse Files
Download
Plain Diff
merging develop.
parents
f6ea2676
04fb8136
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
81 additions
and
36 deletions
+81
-36
cookie.php
system/cookie.php
+9
-1
form.php
system/form.php
+1
-1
request.php
system/request.php
+6
-1
finder.php
system/route/finder.php
+1
-1
router.php
system/router.php
+1
-1
session.php
system/session.php
+35
-26
str.php
system/str.php
+28
-5
No files found.
system/cookie.php
View file @
1c694915
...
...
@@ -90,7 +90,15 @@ class Cookie {
*/
public
static
function
has
(
$name
)
{
return
(
!
is_null
(
static
::
get
(
$name
)));
foreach
(
func_get_args
()
as
$key
)
{
if
(
is_null
(
static
::
get
(
$key
)))
{
return
false
;
}
}
return
true
;
}
/**
...
...
system/form.php
View file @
1c694915
...
...
@@ -56,7 +56,7 @@ class Form {
/**
* Close a HTML form.
*
* @return
void
* @return
string
*/
public
static
function
close
()
{
...
...
system/request.php
View file @
1c694915
...
...
@@ -36,7 +36,12 @@ class Request {
// -------------------------------------------------------
elseif
(
isset
(
$_SERVER
[
'REQUEST_URI'
]))
{
$uri
=
str_replace
(
'/index.php'
,
''
,
$_SERVER
[
'REQUEST_URI'
]);
$uri
=
parse_url
(
$_SERVER
[
'REQUEST_URI'
],
PHP_URL_PATH
);
if
(
$uri
===
false
)
{
throw
new
\Exception
(
"Malformed request URI. Request terminated."
);
}
}
// -------------------------------------------------------
// Neither PATH_INFO or REQUEST_URI are available.
...
...
system/route/finder.php
View file @
1c694915
...
...
@@ -53,7 +53,7 @@ class Finder {
{
$route
=
$recursiveIterator
->
getSubIterator
();
if
(
$route
[
'name'
]
==
$name
)
if
(
isset
(
$route
[
'name'
])
and
$route
[
'name'
]
==
$name
)
{
return
static
::
$names
[
$name
]
=
array
(
$arrayIterator
->
key
()
=>
iterator_to_array
(
$route
));
}
...
...
system/router.php
View file @
1c694915
...
...
@@ -55,7 +55,7 @@ class Router {
// --------------------------------------------------------------
// Convert the route wild-cards to regular expressions.
// --------------------------------------------------------------
$route
=
str_replace
(
':num'
,
'[0-9]+'
,
str_replace
(
':any'
,
'
.
+'
,
$route
));
$route
=
str_replace
(
':num'
,
'[0-9]+'
,
str_replace
(
':any'
,
'
[a-zA-Z0-9\-_]
+'
,
$route
));
if
(
preg_match
(
'#^'
.
$route
.
'$#'
,
$method
.
' '
.
$uri
))
{
...
...
system/session.php
View file @
1c694915
...
...
@@ -17,15 +17,13 @@ class Session {
private
static
$session
=
array
();
/**
* Get the session driver instance.
* Get the session driver. If the driver has already been instantiated, that
* instance will be returned.
*
* @return Session\Driver
*/
public
static
function
driver
()
{
// -----------------------------------------------------
// Create the session driver if we haven't already.
// -----------------------------------------------------
if
(
is_null
(
static
::
$driver
))
{
static
::
$driver
=
Session\Factory
::
make
(
Config
::
get
(
'session.driver'
));
...
...
@@ -59,7 +57,7 @@ class Session {
}
// -----------------------------------------------------
//
Generate a CSRF token if one does not exist
.
//
Create a CSRF token for the session if necessary
.
// -----------------------------------------------------
if
(
!
static
::
has
(
'csrf_token'
))
{
...
...
@@ -70,20 +68,27 @@ class Session {
}
/**
* Determine if the session
contains an item
.
* Determine if the session
or flash data contains an item or set of items
.
*
* @param string $key
* @return bool
*/
public
static
function
has
(
$key
)
public
static
function
has
()
{
return
array_key_exists
(
$key
,
static
::
$session
[
'data'
])
or
array_key_exists
(
':old:'
.
$key
,
static
::
$session
[
'data'
])
or
array_key_exists
(
':new:'
.
$key
,
static
::
$session
[
'data'
]);
foreach
(
func_get_args
()
as
$key
)
{
if
(
!
array_key_exists
(
$key
,
static
::
$session
[
'data'
])
and
!
array_key_exists
(
':old:'
.
$key
,
static
::
$session
[
'data'
])
and
!
array_key_exists
(
':new:'
.
$key
,
static
::
$session
[
'data'
]))
{
return
false
;
}
}
return
true
;
}
/**
* Get an item from the session.
* Get an item from the session
or flash data
.
*
* @param string $key
* @return mixed
...
...
@@ -96,9 +101,6 @@ class Session {
{
return
static
::
$session
[
'data'
][
$key
];
}
// -----------------------------------------------------
// Check the flash data for the item.
// -----------------------------------------------------
elseif
(
array_key_exists
(
':old:'
.
$key
,
static
::
$session
[
'data'
]))
{
return
static
::
$session
[
'data'
][
':old:'
.
$key
];
...
...
@@ -125,7 +127,7 @@ class Session {
}
/**
* Write a
flash item to the session
.
* Write a
n item to the session flash data
.
*
* @param string $key
* @param mixed $value
...
...
@@ -176,17 +178,14 @@ class Session {
public
static
function
close
()
{
// -----------------------------------------------------
// Flash the old input
data to the session
.
// Flash the old input
to the session and age the flash
.
// -----------------------------------------------------
static
::
flash
(
'laravel_old_input'
,
Input
::
get
());
static
::
flash
(
'laravel_old_input'
,
Input
::
get
());
// -----------------------------------------------------
// Age the flash data.
// -----------------------------------------------------
static
::
age_flash
();
// -----------------------------------------------------
//
Sav
e the session data to storage.
//
Writ
e the session data to storage.
// -----------------------------------------------------
static
::
driver
()
->
save
(
static
::
$session
);
...
...
@@ -195,8 +194,18 @@ class Session {
// -----------------------------------------------------
if
(
!
headers_sent
())
{
$lifetime
=
(
Config
::
get
(
'session.expire_on_close'
))
?
0
:
Config
::
get
(
'session.lifetime'
);
Cookie
::
put
(
'laravel_session'
,
static
::
$session
[
'id'
],
$lifetime
,
Config
::
get
(
'session.path'
),
Config
::
get
(
'session.domain'
),
Config
::
get
(
'session.https'
));
$cookie
=
new
Cookie
(
'laravel_session'
,
static
::
$session
[
'id'
]);
if
(
!
Config
::
get
(
'session.expire_on_close'
))
{
$cookie
->
lifetime
=
Config
::
get
(
'session.lifetime'
);
}
$cookie
->
path
=
Config
::
get
(
'session.path'
);
$cookie
->
domain
=
Config
::
get
(
'session.domain'
);
$cookie
->
secure
=
Config
::
get
(
'session.https'
);
$cookie
->
send
();
}
// -----------------------------------------------------
...
...
@@ -234,12 +243,12 @@ class Session {
if
(
strpos
(
$key
,
':new:'
)
===
0
)
{
// -----------------------------------------------------
// Create an :old:
flash
item.
// Create an :old:
item for the :new:
item.
// -----------------------------------------------------
static
::
put
(
':old:'
.
substr
(
$key
,
5
),
$value
);
// -----------------------------------------------------
// Forget the :new:
flash
item.
// Forget the :new: item.
// -----------------------------------------------------
static
::
forget
(
$key
);
}
...
...
system/str.php
View file @
1c694915
...
...
@@ -47,20 +47,43 @@ class Str {
}
/**
* Generate a random alpha-numeric string.
* Generate a random alpha or alpha-numeric string.
*
* Supported types: 'alnum' and 'alpha'.
*
* @param int $length
* @param string $type
* @return string
*/
public
static
function
random
(
$length
=
16
)
public
static
function
random
(
$length
=
16
,
$type
=
'alnum'
)
{
$pool
=
str_split
(
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
,
1
);
$value
=
''
;
// -----------------------------------------------------
// Get the proper character pool for the type.
// -----------------------------------------------------
switch
(
$type
)
{
case
'alpha'
:
$pool
=
'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
break
;
default
:
$pool
=
'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
;
}
// -----------------------------------------------------
// Get the pool length and split the pool into an array.
// -----------------------------------------------------
$pool_length
=
strlen
(
$pool
)
-
1
;
$pool
=
str_split
(
$pool
,
1
);
// -----------------------------------------------------
// Build the random string to the specified length.
// -----------------------------------------------------
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
{
$value
.=
$pool
[
mt_rand
(
0
,
61
)];
$value
.=
$pool
[
mt_rand
(
0
,
$pool_length
)];
}
return
$value
;
...
...
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