深圳全飞鸿

标题: fastadmin中对CDN的逻辑梳理 [打印本页]

作者: syant    时间: 2025-1-22 11:58
标题: fastadmin中对CDN的逻辑梳理
CDN的全称是Content Delivery Network,CDN 指的是内容分发网络

app/config.php中
// 视图输出字符串内容替换,留空则会自动进行计算
    'view_replace_str'       => [
        '__PUBLIC__' => '',
        '__ROOT__'   => '',
        '__CDN__'    => '/dba',
    ],


作者: syant    时间: 2025-1-22 14:29
以首页帐号图标的显示入手分析:1、原代码
<div class="pull-left image">
    <a href="general/profile" class="addtabsit"><img src="{$admin.avatar|cdnurl|htmlentities}" class="img-circle" /></a>
</div>


2、解析后的代码
<img class="profile-user-img img-responsive img-circle" src="<?php echo htmlentities(cdnurl($admin['avatar'] ?? '') ?? ''); ?>" alt="">

3、找到代码
>>>>c:\apache24\htdocs\application50\common.php<<<<<
    function cdnurl($url, $domain = false)


作者: syant    时间: 2025-1-22 14:41
本帖最后由 syant 于 2025-1-22 14:52 编辑

$cdnurl = \think\Config::get('upload.cdnurl');


{
    "_sys_": {
        "app_host": "",
        "app_debug": true,
        "app_trace": false,
        "app_status": "",
        "app_multi_module": true,
        "auto_bind_module": false,
        "root_namespace": [],
        "extra_file_list": [
            "C:\\Apache24\\htdocs\\libs\\thinkphp5027\\helper.php"
        ],
        "default_return_type": "html",
        "default_ajax_return": "json",
        "default_jsonp_handler": "jsonpReturn",
        "var_jsonp_handler": "callback",
        "default_timezone": "PRC",
        "lang_switch_on": false,
        "default_filter": "",
        "default_lang": "zh-cn",
        "class_suffix": false,
        "controller_suffix": false,
        "default_module": "index",
        "deny_module_list": [
            "common",
            "admin"
        ],
        "default_controller": "Index",
        "default_action": "index",
        "default_validate": "",
        "empty_controller": "Error",
        "use_action_prefix": false,
        "action_suffix": "",
        "controller_auto_search": true,
        "var_pathinfo": "s",
        "pathinfo_fetch": [
            "ORIG_PATH_INFO",
            "REDIRECT_PATH_INFO",
            "REDIRECT_URL"
        ],
        "pathinfo_depr": "/",
        "https_agent_name": "",
        "url_html_suffix": "",
        "url_common_param": true,
        "url_param_type": 0,
        "url_route_on": true,
        "route_config_file": [
            "route"
        ],
        "route_complete_match": false,
        "url_route_must": false,
        "url_domain_deploy": false,
        "url_domain_root": "",
        "url_convert": true,
        "url_controller_layer": "controller",
        "var_method": "_method",
        "var_ajax": "_ajax",
        "var_pjax": "_pjax",
        "request_cache": false,
        "request_cache_expire": null,
        "request_cache_except": [],
        "template": {
            "type": "Think",
            "view_path": "",
            "view_suffix": "html",
            "view_depr": "\\",
            "tpl_begin": "{",
            "tpl_end": "}",
            "taglib_begin": "{",
            "taglib_end": "}",
            "tpl_cache": true
        },
        "view_replace_str": {
            "__PUBLIC__": "/sfc/",
            "__ROOT__": "/sfc/",
            "__CDN__": "/dba"
        },
        "dispatch_success_tmpl": "C:\\Apache24\\htdocs/application/common\\view\\tpl\\dispatch_jump.tpl",
        "dispatch_error_tmpl": "C:\\Apache24\\htdocs/application/common\\view\\tpl\\dispatch_jump.tpl",
        "exception_tmpl": "C:\\Apache24\\htdocs\\libs\\thinkphp5027\\tpl\\think_exception.tpl",
        "error_message": "你所浏览的页面暂时无法访问",
        "show_error_msg": false,
        "exception_handle": "",
        "record_trace": false,
        "log": {
            "type": "File",
            "path": "C:\\Apache24\\htdocs/application/runtime\\log\\",
            "level": []
        },
        "trace": {
            "type": "Html"
        },
        "cache": {
            "type": "File",
            "path": "C:\\Apache24\\htdocs/application/runtime\\cache\\",
            "prefix": "",
            "expire": 0
        },
        "session": {
            "id": "",
            "var_session_id": "",
            "prefix": "think",
            "type": "",
            "auto_start": true
        },
        "cookie": {
            "prefix": "",
            "expire": 0,
            "path": "/",
            "domain": "",
            "secure": false,
            "httponly": "",
            "setcookie": true
        },
        "database": {
            "type": "mysql",
            "dsn": "",
            "hostname": "127.0.0.1",
            "database": "dba",
            "username": "root",
            "password": "vnxzyupu",
            "hostport": "",
            "params": [],
            "charset": "utf8mb4",
            "prefix": "d_",
            "debug": false,
            "deploy": 0,
            "rw_separate": false,
            "master_num": 1,
            "slave_no": "",
            "fields_strict": true,
            "resultset_type": "array",
            "auto_timestamp": false,
            "datetime_format": false,
            "sql_explain": false
        },
        "paginate": {
            "type": "bootstrap",
            "var_page": "page",
            "list_rows": 15
        },
        "console": {
            "name": "Think Console",
            "version": "0.1",
            "user": null
        },
        "app_namespace": "app",
        "allow_lang_list": [
            "zh-cn",
            "en"
        ],
        "http_agent_ip": "REMOTE_ADDR",
        "http_exception_template": [],
        "captcha": {
            "codeSet": "2345678abcdefhijkmnpqrstuvwxyzABCDEFGHJKLMNPQRTUVWXY",
            "fontSize": 18,
            "useCurve": false,
            "useZh": false,
            "imageH": 40,
            "imageW": 130,
            "length": 4,
            "reset": true
        },
        "token": {
            "type": "Mysql",
            "key": "3Qg6mM742bG1sFZdLHPINVkfvBEpRuxn",
            "hashalgo": "ripemd160",
            "expire": 0
        },
        "fastadmin": {
            "usercenter": true,
            "user_register_captcha": "text",
            "login_captcha": false,
            "login_failure_retry": true,
            "login_unique": false,
            "loginip_check": true,
            "login_background": "",
            "multiplenav": true,
            "multipletab": true,
            "show_submenu": false,
            "adminskin": "",
            "breadcrumb": false,
            "unknownsources": false,
            "backup_global_files": true,
            "auto_record_log": true,
            "addon_pure_mode": true,
            "cors_request_domain": "localhost,127.0.0.1",
            "version": "1.5.2.20240906",
            "api_url": "https://api.fastadmin.net"
        },
        "addons": {
            "autoload": false,
            "hooks": [],
            "route": [],
            "priority": [],
            "domain": ""
        },
        "queue": {
            "connector": "Redis",
            "expire": 0,
            "default": "default",
            "host": "127.0.0.1",
            "port": 6379,
            "password": "",
            "select": 0,
            "timeout": 0,
            "persistent": false
        },
        "site": {
            "name": "全飞鸿DBA运维",
            "beian": "",
            "cdnurl": "/sfc",
            "version": 1737527958,
            "timezone": "Asia/Shanghai",
            "forbiddenip": "",
            "languages": {
                "backend": "zh-cn",
                "frontend": "zh-cn"
            },
            "fixedpage": "dashboard",
            "categorytype": {
                "default": "Default",
                "page": "Page",
                "article": "Article",
                "test": "Test"
            },
            "configgroup": {
                "basic": "Basic",
                "email": "Email",
                "dictionary": "Dictionary",
                "user": "User",
                "example": "Example"
            },
            "mail_type": "1",
            "mail_smtp_host": "smtp.qq.com",
            "mail_smtp_port": "465",
            "mail_smtp_user": "",
            "mail_smtp_pass": "",
            "mail_verify_type": "2",
            "mail_from": "",
            "attachmentcategory": {
                "category1": "Category1",
                "category2": "Category2",
                "custom": "Custom"
            }
        },
        "upload": {
            "uploadurl": "/sfc/C.php/ajax/upload",
            "cdnurl": "/sfc",
            "savekey": "/uploads/{year}{mon}{day}/{filemd5}{.suffix}",
            "maxsize": "10mb",
            "mimetype": "jpg,png,bmp,jpeg,gif,webp,zip,rar,wav,mp4,mp3,webm",
            "multiple": false,
            "chunking": false,
            "chunksize": 2097152,
            "fullmode": false,
            "thumbstyle": "",
            "bucket": "local",
            "multipart": [],
            "storage": "local"
        }
    }
}



作者: syant    时间: 2025-1-22 15:13
config加载这些:
C:\Apache24\htdocs/application/config.php
C:\Apache24\htdocs/application/database.php
C:\Apache24\htdocs/application/extra\addons.php
C:\Apache24\htdocs/application/extra\queue.php
C:\Apache24\htdocs/application/extra\site.php
C:\Apache24\htdocs/application/extra\upload.php
C:\Apache24\htdocs/application/admin\config.php
作者: syant    时间: 2025-1-22 15:46
结论:
thinkphp/library/think/App.php

//1. 加载模块配置
            $config = Config::load(CONF_PATH . $module . 'config' . CONF_EXT);

//2. 读取数据库配置文件
            $filename = CONF_PATH . $module . 'database' . CONF_EXT;
            Config::load($filename, 'database');

//3. 读取扩展配置文件
            if (is_dir(CONF_PATH . $module . 'extra')) {
                $dir   = CONF_PATH . $module . 'extra';
                $files = scandir($dir);
                foreach ($files as $file) {
                    if ('.' . pathinfo($file, PATHINFO_EXTENSION) === CONF_EXT) {
                        $filename = $dir . DS . $file;
                        Config::load($filename, pathinfo($file, PATHINFO_FILENAME));
                    }
                }
            }

//3. 加载应用状态配置
            if ($config['app_status']) {
                Config::load(CONF_PATH . $module . $config['app_status'] . CONF_EXT);
            }




欢迎光临 深圳全飞鸿 (http://www.nagomes.com/disc/) Powered by Discuz! X3.2