Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/think/App.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class App extends Container
*/
public function __construct(string $rootPath = '')
{
$this->thinkPath = realpath(dirname(__DIR__)) . DIRECTORY_SEPARATOR;
$this->thinkPath = dirname(__DIR__) . DIRECTORY_SEPARATOR;
$this->rootPath = $rootPath ? rtrim($rootPath, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR : $this->getDefaultRootPath();
$this->appPath = $this->rootPath . 'app' . DIRECTORY_SEPARATOR;
$this->runtimePath = $this->rootPath . 'runtime' . DIRECTORY_SEPARATOR;
Expand Down Expand Up @@ -538,14 +538,14 @@ protected function load(): void

$configPath = $this->getConfigPath();

$files = [];

if (is_dir($configPath)) {
$files = glob($configPath . '*' . $this->configExt);
}
foreach (scandir($configPath) as $name) {
if (!str_ends_with($name, $this->configExt) || !is_file($configPath . $name)) {
continue;
}

foreach ($files as $file) {
$this->config->load($file, pathinfo($file, PATHINFO_FILENAME));
$this->config->load($configPath . $name, pathinfo($name, PATHINFO_FILENAME));
}
}

if (is_file($appPath . 'event.php')) {
Expand Down
10 changes: 7 additions & 3 deletions src/think/Http.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
Expand Down Expand Up @@ -229,9 +230,12 @@ protected function loadRoutes(): void
$routePath = $this->getRoutePath();

if (is_dir($routePath)) {
$files = glob($routePath . '*.php');
foreach ($files as $file) {
include $file;
foreach (scandir($routePath) as $name) {
if (!str_ends_with($name, '.php') || !is_file($routePath . $name)) {
continue;
}

include $routePath . $name;
}
}

Expand Down
18 changes: 16 additions & 2 deletions src/think/Lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,22 @@ public function switchLangSet(string $langset)
]);

// 加载系统语言包
$files = glob($this->app->getAppPath() . 'lang' . DIRECTORY_SEPARATOR . $langset . '.*');
$this->load($files);
$appLangDir = $this->app->getAppPath() . 'lang' . DIRECTORY_SEPARATOR;
if (is_dir($appLangDir)) {
$files = [];

foreach (scandir($appLangDir) as $name) {
$path = $appLangDir . $name;

if (!str_starts_with($name, $langset) || !is_file($path) || !in_array(pathinfo($name, PATHINFO_EXTENSION), ['php', 'yaml', 'json'])) {
continue;
}

$files[] = $path;
}

$this->load($files);
}

// 加载扩展(自定义)语言包
$list = $this->app->config->get('lang.extend_list', []);
Expand Down
9 changes: 8 additions & 1 deletion src/think/log/driver/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,14 @@ protected function getMasterLogFile(): string
{

if ($this->config['max_files']) {
$files = glob($this->config['path'] . '*.log');
$files = [];
foreach (scandir($this->config['path']) as $name) {
if (!str_ends_with($name, '.log') || !is_file($this->config['path'] . $name)) {
continue;
}

$files[] = $this->config['path'] . $name;
}

try {
if (count($files) > $this->config['max_files']) {
Expand Down