HEX
Server: nginx/1.28.1
System: Linux 10-41-63-61 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User: www (1001)
PHP: 7.4.33
Disabled: 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
Upload Files
File: /www/wwwroot/my.esfyn.top/app/Providers/AppServiceProvider.php
<?php

namespace App\Providers;

use App\Macros\RequestMacro;
use Expand\We7\Providers\We7ServiceProvider;
use Illuminate\Contracts\Container\BindingResolutionException;
use Illuminate\Support\Facades\URL;
use Illuminate\Support\ServiceProvider;
use Illuminate\Http\Request;

class AppServiceProvider extends ServiceProvider
{

    /**
     * Register any application services.
     *
     * @return void
     * @throws BindingResolutionException
     * @throws \ReflectionException
     */
    public function register()
    {
        $this->we7Service();

        Request::mixin($this->app->make(RequestMacro::class));

        request()->setLocale("");
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {

        $this->registerConfig();
        $this->templateViews();
        $this->loadThemeFunctions();
        $this->openHttps();
        $this->loadThemeConfig();
        $this->loadThemeSystemConfig();
    }

    /**
     * 加载模板
     *
     * @return void
     */
    protected function templateViews()
    {
        $this->loadViewsFrom(base_path("Template"), 'template');
    }

    /**
     * 加载管道操作配置
     *
     * @return void
     */
    protected function registerConfig()
    {

        if (file_exists(base_path('bootstrap/cache/pipeline.php'))) {
            $this->mergeConfigFrom(
                base_path('bootstrap/cache/pipeline.php'), 'pipeline'
            );
        }

    }

    /**
     * 加载模板自定义函数
     *
     * @return void
     */
    protected function loadThemeFunctions()
    {
        $theme = system_config('cms_theme') ?? 'default';
        $functions = base_path('Template/' . $theme . '/helpers/functions.php');

        if (file_exists($functions)) {
            include_once $functions;
        }
    }


    /**
     * 开启 HTTPS
     * @return void
     */
    protected function openHttps()
    {
        if (env('IS_HTTPS')) {

            URL::forceScheme('https');
        }
    }

    /**
     * 开启微擎模式
     * @return void
     */
    protected function we7Service()
    {
        if (env('IS_WE7')) {

            $this->app->register(We7ServiceProvider::class);

            if ($uniacid = \request()->input('i')) {

                session(['uniacid' => $uniacid]);
            }
        }
    }

    /**
     * 加载模板自定义配置
     *
     * @return void
     */
    protected function loadThemeConfig()
    {
        $theme = system_config('cms_theme') ?? 'default';
        $path = base_path('Template/' . $theme . '/config/template_config.php');

        if (file_exists($path)) {

            $this->mergeConfigFrom($path, 'template.config');
        }
    }

    /**
     * 加载模板后台配置
     *
     * @return void
     */
    protected function loadThemeSystemConfig()
    {
        $theme = system_config('cms_theme') ?? 'default';
        $path = base_path('Template/' . $theme . '/config/system_config.php');

        if (file_exists($path)) {

            $this->mergeConfigFrom($path, 'template.system');
        }
    }

}