Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
fef0efb9
authored
Nov 05, 2019
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
temp3
parent
f7d0c024
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
36 additions
and
8 deletions
app/Http/Kernel.php
app/Http/Middleware/Check.php
app/Http/Middleware/CheckRequest.php
app/Http/Kernel.php
View file @
fef0efb9
...
@@ -28,6 +28,7 @@ class Kernel extends HttpKernel
...
@@ -28,6 +28,7 @@ class Kernel extends HttpKernel
\App\Http\Middleware\CheckLogin
::
class
,
\App\Http\Middleware\CheckLogin
::
class
,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse
::
class
,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse
::
class
,
\Illuminate\Session\Middleware\StartSession
::
class
,
\Illuminate\Session\Middleware\StartSession
::
class
,
\App\Http\Middleware\Check
::
class
,
\App\Http\Middleware\CheckRequest
::
class
,
\App\Http\Middleware\CheckRequest
::
class
,
],
],
...
...
app/Http/Middleware/Check.php
0 → 100644
View file @
fef0efb9
<?php
namespace
App\Http\Middleware
;
use
Closure
;
use
Session
;
class
Check
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public
function
handle
(
$request
,
Closure
$next
)
{
Session
::
put
(
'pid'
,
uniqid
(
'order_'
,
true
));
// if ($request->ajax() && $request->isMethod('post')) {
// }
return
$next
(
$request
);
}
}
app/Http/Middleware/CheckRequest.php
View file @
fef0efb9
...
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
...
@@ -5,6 +5,7 @@ namespace App\Http\Middleware;
use
Closure
;
use
Closure
;
use
Illuminate\Support\Facades\Redis
;
use
Illuminate\Support\Facades\Redis
;
use
Cookie
;
use
Cookie
;
use
Session
;
class
CheckRequest
class
CheckRequest
{
{
...
@@ -24,9 +25,10 @@ class CheckRequest
...
@@ -24,9 +25,10 @@ class CheckRequest
$key
=
$this
->
getFormKey
(
$request
);
$key
=
$this
->
getFormKey
(
$request
);
// if (!self::$redis) self::$redis = new Redis;
// if (!self::$redis) self::$redis = new Redis;
Redis
::
incr
(
$key
);
// 计数器
Redis
::
incr
(
$key
);
// 计数器
$count
=
Redis
::
get
(
$key
);
$count
=
Redis
::
get
(
$key
);
$pid
=
Session
::
get
(
'pid'
);
dump
(
$count
);
dump
(
$count
);
if
(
$count
>
1
)
return
abort
(
501
,
'请勿重新提交!'
);
// 501服务器不支持当前请求
if
(
$count
>
1
)
return
abort
(
501
,
'请勿重新提交!'
);
// 501服务器不支持当前请求
...
@@ -52,13 +54,6 @@ dump($count);
...
@@ -52,13 +54,6 @@ dump($count);
return
$next
(
$request
);
return
$next
(
$request
);
}
}
public
function
terminate
(
$request
,
$response
)
{
$key
=
$this
->
getFormKey
(
$request
);
dump
(
'响应信息'
);
// Redis::del($key);
}
public
function
getFormKey
(
$request
)
public
function
getFormKey
(
$request
)
{
{
$action
=
$request
->
route
()
->
getAction
();
// 获取路由信息
$action
=
$request
->
route
()
->
getAction
();
// 获取路由信息
...
...
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