123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?php
-
-
- namespace app\common\logic;
-
- use think\Db;
-
-
- class HtmlCacheLogic
- {
- public function __construct()
- {
-
- }
-
-
-
- public function clear_index()
- {
- $web_cmsmode = tpCache('web.web_cmsmode');
- $html_cache_arr = config('HTML_CACHE_ARR');
- if (1 == intval($web_cmsmode)) {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_Index_index']['filename'].'/*_html/index*.html');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $file) {
- if (file_exists($file) && preg_match('/index(_\d+)?\.html$/i', $file)) {
- @unlink($file);
- }
- }
- }
- } else {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_Index_index']['filename'].'/*_cache/index/*');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $dir) {
- if (file_exists($dir) && is_dir($dir)) {
- delFile($dir, true);
- }
- }
- }
- }
- }
-
-
-
- public function clear_arctype($typeids = [])
- {
- $web_cmsmode = tpCache('web.web_cmsmode');
- $html_cache_arr = config('HTML_CACHE_ARR');
- if (!empty($typeids)) {
- foreach ($typeids as $key => $tid) {
- if (1 == intval($web_cmsmode)) {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_Lists_index']['filename'].'/*_html/'.$tid.'*.html');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $file) {
- if (file_exists($file) && preg_match('/'.$tid.'(_\d+)?\.html$/i', $file)) {
- @unlink($file);
- }
- }
- }
- } else {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_Lists_index']['filename'].'/*_cache/'.$tid.'/*');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $dir) {
- if (file_exists($dir) && is_dir($dir)) {
- delFile($dir, true);
- }
- }
- }
- }
- }
- } else {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_Lists_index']['filename'].'/*');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $dir) {
- if (file_exists($dir) && is_dir($dir)) {
- delFile($dir, true);
- }
- }
- }
- }
-
- $this->clear_index();
- }
-
-
-
- public function clear_archives($aids = [])
- {
- $web_cmsmode = tpCache('web.web_cmsmode');
- $html_cache_arr = config('HTML_CACHE_ARR');
- if (!empty($aids)) {
- $row = Db::name('archives')->field('aid,typeid')
- ->where([
- 'aid' => ['IN', $aids],
- ])->select();
- foreach ($row as $key => $val) {
- $aid = $val['aid'];
- $typeid = $val['typeid'];
- if (1 == intval($web_cmsmode)) {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_View_index']['filename'].'/*_html/'.$aid.'*.html');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $file) {
- if (preg_match('/'.$aid.'(_\d+)?\.html$/i', $file)) {
- @unlink($file);
- }
- }
- }
- } else {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_View_index']['filename'].'/*_cache/'.$aid.'/*');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $dir) {
- if (file_exists($dir) && is_dir($dir)) {
- delFile($dir, true);
- }
- }
- }
- }
- }
- } else {
- $fileList = glob(HTML_ROOT.'http*/'.$html_cache_arr['home_View_index']['filename'].'*');
- if (!empty($fileList)) {
- foreach ($fileList as $k2 => $dir) {
- if (file_exists($dir) && is_dir($dir)) {
- delFile($dir, true);
- }
- }
- }
- }
-
- $this->clear_arctype();
- }
- }
|