Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYWAP
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
梁志锋
9 years ago
Commit
247d6b5af9b09f605f920a441ba9285c40922eeb
1 parent
fdfe5c21
添加文件
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
0 deletions
yohobuy/m.yohobuy.com/application/controllers/Tools.php
yohobuy/m.yohobuy.com/application/controllers/Tools.php
0 → 100644
View file @
247d6b5
<?php
use
Action\AbstractAction
;
class
ToolsController
extends
AbstractAction
{
//清缓存选项
public
function
indexAction
(){
header
(
"Content-type: text/html; charset=utf-8"
);
$html
=
'<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">'
.
'<link href="//cdn.bootcss.com/bootstrap/2.3.2/css/bootstrap.min.css" rel="stylesheet">'
.
'<div style="margin-left:20%"><br/><h2>清除Wap缓存</h2>'
;
$channels
=
array
(
'频道页(男生)'
=>
'http://yohobuy/'
,
'频道页(女生)'
=>
'http://yohobuy/girls'
,
'频道页(潮童)'
=>
'http://yohobuy/kids'
,
'频道页(创意生活)'
=>
'http://yohobuy/lifestyle'
,
);
$html
.=
'<ul style="margin-top:20px">'
;
foreach
(
$channels
as
$name
=>
$url
)
{
$url
=
'/tools/cacheclear?key='
.
$url
;
$html
.=
sprintf
(
'<li style="font-size:15px;height:35px;"><a href="%s" target="_blank">%s</a></li>'
,
$url
,
$name
);
}
$html
.=
'</ul></div>'
;
echo
$html
;
}
//清缓存
public
function
cacheclearAction
(){
header
(
"Content-type: text/html; charset=utf-8"
);
$key
=
$this
->
get
(
'key'
);
$cache_dir
=
'/Data/local/nginx-1.8.0/ngx_cache'
;
$request_url
=
$key
;
$url_hash
=
md5
(
$request_url
);
$dir1
=
substr
(
$url_hash
,
-
1
,
1
)
.
'/'
;
$dir2
=
substr
(
$url_hash
,
-
3
,
2
)
.
'/'
;
$cached_file
=
$cache_dir
.
$dir1
.
$dir2
.
$url_hash
;
if
(
is_file
(
$cached_file
))
{
if
(
unlink
(
$cached_file
))
{
echo
$request_url
.
" 缓存清除成功!
\n
"
;
}
else
{
echo
$request_url
.
" 缓存清除失败!
\n
"
;
}
echo
'ok'
;
}
else
{
echo
$request_url
.
" 未被缓存!
\n
"
;
}
}
}
?>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment