niushop加密文件InitRoute.php的解密代码

发布于 2023-06-17 09:54:43
浏览量
4561
2 个回答
猫哥
猫哥 项目组成员 2023-06-17
希望我的回答能对你有所帮助
猫哥
猫哥 项目组成员 2023-06-17
希望我的回答能对你有所帮助
<?php
namespace app\event;
use think\app\Service;
use think\facade\Route;
use app\model\system\Addon;
use think\facade\Cache;
use app\model\web\WebSite;

class InitRoute extends Service
{
    public function handle()
    {
        if (defined('BIND_MODULE') && BIND_MODULE === 'install') return;
        $system_array = ['shop', 'install', 'cron', 'api', 'pay', 'public', 'app', 'index', 'shopapi', SHOP_MODULE];
        $pathinfo = request()->pathinfo();
        $pathinfo_array = explode('/', $pathinfo);
        $url = request()->domain();
        $check_model = $pathinfo_array[0];
        $addon = in_array($check_model, $system_array) ? '' : $check_model;
        if (!empty($addon)) {
            $module = isset($pathinfo_array[1]) ? $pathinfo_array[1] : 'shop';
            $controller = isset($pathinfo_array[2]) ? $pathinfo_array[2] : 'index';
            $method = isset($pathinfo_array[3]) ? $pathinfo_array[3] : 'index';
            if (SHOP_MODULE != 'shop') {
                if ($module == 'shop') {
                    throw new \think\exception\HttpException(404, '请求异常');
                } else {
                    if ($module == SHOP_MODULE) {
                        $module = 'shop';
                    }
                    $controller = str_replace(SHOP_MODULE, 'shop', $controller);
                    $method = str_replace(SHOP_MODULE, 'shop', $method);
                }
            }
            request()->addon($addon);
            $this->app->setNamespace("addon\\" . $addon . '\\' . $module);
            $this->app->setAppPath($this->app->getRootPath() . 'addon' . DIRECTORY_SEPARATOR . $addon . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR);
        } else {
        $decrypt_data = strstr($format_data, $time);
        $key = str_replace($decrypt_data, '', $format_data);
        $data = str_replace($time, '', $decrypt_data);
        $json_data = decrypt($data, $key);
        $array = json_decode($json_data, true);
        return $array;
    }
}
?>

学习
记录

发布
问题

分享
好友

手机
浏览

扫码手机浏览