mirror of
https://gitee.com/fastadminnet/framework.git
synced 2026-07-07 23:22:48 +08:00
Merge branch 'master' of https://github.com/liu21st/think
This commit is contained in:
@@ -72,6 +72,10 @@ return [
|
|||||||
// URL模块映射
|
// URL模块映射
|
||||||
'url_module_map' => [],
|
'url_module_map' => [],
|
||||||
|
|
||||||
|
// 默认输出类型
|
||||||
|
'default_return_type' => 'html',
|
||||||
|
// 默认语言
|
||||||
|
'default_lang' => 'zh-cn',
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 视图及模板设置
|
// | 视图及模板设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
@@ -113,12 +117,15 @@ return [
|
|||||||
'prefix' => '',
|
'prefix' => '',
|
||||||
'expire' => 0,
|
'expire' => 0,
|
||||||
],
|
],
|
||||||
|
// 是否使用session
|
||||||
|
'use_session' => true,
|
||||||
|
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
// | 会话设置
|
// | 会话设置
|
||||||
// +----------------------------------------------------------------------
|
// +----------------------------------------------------------------------
|
||||||
|
|
||||||
'session' => [
|
'session' => [
|
||||||
|
'id' => '',
|
||||||
'prefix' => 'think',
|
'prefix' => 'think',
|
||||||
'type' => '',
|
'type' => '',
|
||||||
'auto_start' => true,
|
'auto_start' => true,
|
||||||
|
|||||||
@@ -82,7 +82,8 @@ class Cookie
|
|||||||
$name = $config['prefix'] . $name;
|
$name = $config['prefix'] . $name;
|
||||||
// 设置cookie
|
// 设置cookie
|
||||||
if (is_array($value)) {
|
if (is_array($value)) {
|
||||||
$value = 'think:' . json_encode(array_map('urlencode', $value));
|
array_walk_recursive($value, $this->jsonFormatProtect, 'encode');
|
||||||
|
$value = 'think:' . json_encode($value);
|
||||||
}
|
}
|
||||||
$expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
|
$expire = !empty($config['expire']) ? time() + intval($config['expire']) : 0;
|
||||||
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
setcookie($name, $value, $expire, $config['path'], $config['domain'], $config['secure'], $config['httponly']);
|
||||||
@@ -103,10 +104,10 @@ class Cookie
|
|||||||
$value = $_COOKIE[$name];
|
$value = $_COOKIE[$name];
|
||||||
if (0 === strpos($value, 'think:')) {
|
if (0 === strpos($value, 'think:')) {
|
||||||
$value = substr($value, 6);
|
$value = substr($value, 6);
|
||||||
return array_map('urldecode', json_decode($value, true));
|
$value = json_decode(MAGIC_QUOTES_GPC ? stripslashes($value) : $value, true);
|
||||||
} else {
|
array_walk_recursive($value, $this->jsonFormatProtect, 'decode');
|
||||||
return $value;
|
|
||||||
}
|
}
|
||||||
|
return $value;
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -156,4 +157,12 @@ class Cookie
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function jsonFormatProtect(&$val, $key, $type = 'encode')
|
||||||
|
{
|
||||||
|
if (!empty($val) && true !== $val) {
|
||||||
|
$val = 'decode' == $type ? urldecode($val) : urlencode($val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ class Session
|
|||||||
if (isset($config['prefix'])) {
|
if (isset($config['prefix'])) {
|
||||||
self::$prefix = $config['prefix'];
|
self::$prefix = $config['prefix'];
|
||||||
}
|
}
|
||||||
if (isset($config['id'])) {
|
if (isset($config['id']) && !empty($config['id'])) {
|
||||||
session_id($config['id']);
|
session_id($config['id']);
|
||||||
}
|
}
|
||||||
if (isset($config['name'])) {
|
if (isset($config['name'])) {
|
||||||
|
|||||||
Reference in New Issue
Block a user