Browse Source

add ip check for clean cache function

master
filesite 2 months ago
parent
commit
cf274bb96f
  1. 15
      themes/beauty/controller/SiteController.php
  2. 4
      themes/beauty/views/site/index.php

15
themes/beauty/controller/SiteController.php

@ -231,12 +231,17 @@ Class SiteController extends Controller { @@ -231,12 +231,17 @@ Class SiteController extends Controller {
$msg = 'OK';
try {
$cacheDir = __DIR__ . '/../../../runtime/cache/';
$files = scandir($cacheDir);
foreach($files as $file) {
if (!preg_match('/\.json$/i', $file)) {continue;}
if (Common::isAdminIp($this->getUserIp()) == false) {
$code = 0;
$msg = '403 Forbidden,禁止访问';
}else {
$cacheDir = __DIR__ . '/../../../runtime/cache/';
$files = scandir($cacheDir);
foreach($files as $file) {
if (!preg_match('/\.json$/i', $file)) {continue;}
unlink("{$cacheDir}{$file}");
unlink("{$cacheDir}{$file}");
}
}
}catch(Exception $e) {
$code = 0;

4
themes/beauty/views/site/index.php

@ -21,7 +21,9 @@ $main_view_cls = $menu_ext_status == 'opened' ? '' : 'full'; @@ -21,7 +21,9 @@ $main_view_cls = $menu_ext_status == 'opened' ? '' : 'full';
<!-- Brand and toggle get grouped for better mobile display navbar-inverse-->
<div class="navbar-header">
<div class="navbar-toggle">
<?php if (!empty($viewData['isAdminIp'])) { ?>
<img class="svg icon1 svgimg verMiddle cleanCacheJS" src="/img/beauty/refresh.svg" alt="清空缓存数据" title="刷新缓存数据" style="padding-top:2px;margin-top:2px">
<?php } ?>
<img class="svg icon1 svgimg lampJS verMiddle" src="/img/beauty/buld.svg" alt="点击关灯/开灯" title="点击关灯/开灯">
<img class="icon1 svg connectmeJS svgimg verMiddle" src="/img/beauty/contactUs.svg" alt="联系我们" title="联系我们" />
<button type="button" class="collapsed mr_button" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
@ -38,7 +40,9 @@ $main_view_cls = $menu_ext_status == 'opened' ? '' : 'full'; @@ -38,7 +40,9 @@ $main_view_cls = $menu_ext_status == 'opened' ? '' : 'full';
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<div class="nb_right nav navbar-nav navbar-right hidden-xs">
<?php if (!empty($viewData['isAdminIp'])) { ?>
<img class="svg icon1 svgimg verMiddle cleanCacheJS" src="/img/beauty/refresh.svg" alt="清空缓存数据" title="刷新缓存数据" style="padding-top:2px;margin-top:2px">
<?php } ?>
<img class="svg icon1 svgimg iconr2 lampJS verMiddle" src="/img/beauty/buld.svg" alt="点击关灯/开灯" title="点击关灯/开灯">
<img class="icon1 svg connectmeJS svgimg iconr2 verMiddle" src="/img/beauty/contactUs.svg" alt="联系我们" title="联系我们" />
</div>

Loading…
Cancel
Save