Skip to content
This repository has been archived by the owner on Apr 2, 2020. It is now read-only.

Commit

Permalink
控制session启动,默认关闭,小修改
Browse files Browse the repository at this point in the history
  • Loading branch information
flxxyz committed Mar 1, 2018
1 parent aab2e1a commit 370247b
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 8 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"keywords": ["framework", "php", "simple", "notorm", "简单框架"],
"description": "This is a simple PHP framework",
"homepage": "http://github.com/flxxyz/Col",
"version": "0.0.9",
"version": "0.1.0",
"type": "library",
"license": "MIT",
"authors": [
Expand Down
5 changes: 3 additions & 2 deletions config/session.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
return [
'expire' => 360, // 单位: 分钟
'open' => true, // 打开session(默认关闭)
'expire' => 360, // 单位: 分钟
'limiter' => 'private',
'perfix' => 'Col'
'perfix' => 'Col',
];
6 changes: 3 additions & 3 deletions src/Common/Util.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* @package Col
* @author Allisea.Feng <https://blog.flxxxyz.com/>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @version 0.0.9
* @version 0.1.0
*/
class Util
{
Expand Down Expand Up @@ -200,7 +200,7 @@ static function getDayAll($time = null): array
* @param null $referer
* @return object
*/
static function getHttp($uri = null, $data = [], $referer = null): object
static function getHttp($uri = null, $data = [], $referer = null)
{
if (is_null($uri)) {
return new Closure;
Expand All @@ -221,7 +221,7 @@ static function getHttp($uri = null, $data = [], $referer = null): object
* @param null $referer
* @return object
*/
static function postHttp($uri = null, $data = [], $referer = null): object
static function postHttp($uri = null, $data = [], $referer = null)
{
if (is_null($uri)) {
return new Closure;
Expand Down
31 changes: 30 additions & 1 deletion src/Common/function.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* @package Col
* @author Allisea.Feng <https://blog.flxxxyz.com/>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @version 0.0.7
* @version 0.1.0
*/

use Col\{
Expand Down Expand Up @@ -325,6 +325,35 @@ function format_date($time)
}
}

if (!function_exists('hex_conver')) {
/**
* 格式化文件大小输出符合的单位
* @param int $bit
* @return string
*/
function hex_conver($bit = 0)
{
if($bit == 0) {
return '0B';
}

$bytes = [
'TB' => pow(1024, 4),
'GB' => pow(1024, 3),
'MB' => pow(1024, 2),
'KB' => 1024,
'B' => 1,
];

foreach ($bytes as $name => $value) {
$n = intval($bit) / $value;
if (0 != $c = floor($n)) {
return round($n, 2) . $name;
}
}
}
}

if (!function_exists('floor_tree')) {
/**
* 层级评论树
Expand Down
6 changes: 5 additions & 1 deletion src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @package Col
* @author Allisea.Feng <https://blog.flxxxyz.com/>
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @version 0.0.6
* @version 0.1.0
*/
class Session
{
Expand All @@ -26,6 +26,10 @@ public function __construct()
public static function make()
{
$config = config('session');
$open = isset($config['open']) ? $config['open']:false;
if(!$open) {
return new \stdClass();
}
session_cache_expire($config['expire']);
session_cache_limiter($config['limiter']);
session_name($config['perfix']);
Expand Down

0 comments on commit 370247b

Please sign in to comment.