mirror of
https://github.com/ZeroDream-CN/PHPMC7
synced 2024-11-24 04:52:54 +08:00
v7.3.3199 更新
修改插件加载时搜索目录的方式,同时搜索子目录插件
This commit is contained in:
parent
e1fad288a2
commit
577f59708b
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
// PHPMC 7 Version define
|
||||
// Don't change this, because it will interfere your update.
|
||||
define("PHPMC_VERSION", "7.3.3185");
|
||||
define("PHPMC_VERSION", "7.3.3199");
|
||||
|
||||
include(ROOT . "/include/core/PHPMC/Event.php");
|
||||
include(ROOT . "/include/core/PHPMC/User.php");
|
||||
|
@ -11,16 +11,36 @@ class Plugin {
|
||||
$realpath = realpath($path);
|
||||
$handle = opendir($path);
|
||||
while($file = readdir($handle)) {
|
||||
if($file !== "." && $file !== ".." && pathinfo($file)['extension'] == "php") {
|
||||
$target = pathinfo($file)['filename'] . ".json";
|
||||
$data = $this->pluginReader("{$realpath}/{$target}");
|
||||
$info = json_decode($data, true);
|
||||
if(!$info) {
|
||||
PHPMC::Error()->Println("Error when load plugin: " . $file . ": No such plugin info file: " . $target . "<br>" . $data);
|
||||
if($file !== "." && $file !== "..") {
|
||||
if(is_dir("{$realpath}/{$file}/")) {
|
||||
if(file_exists("{$realpath}/{$file}/{$file}.php") && file_exists("{$realpath}/{$file}/{$file}.json")) {
|
||||
$files = "{$file}.php";
|
||||
$target = pathinfo($files)['filename'] . ".json";
|
||||
$data = file_get_contents("{$realpath}/{$file}/{$target}");
|
||||
$info = json_decode($data, true);
|
||||
if(!$info) {
|
||||
PHPMC::Error()->Println("Error when load plugin: " . $files . ": No such plugin info file: " . $target . "<br>" . $data);
|
||||
}
|
||||
include("{$realpath}/{$file}/{$files}");
|
||||
eval('$' . $info['main'] . ' = new ' . $info['main'] . '();');
|
||||
eval('$' . $info['main'] . '->onload();');
|
||||
} else {
|
||||
echo "Error: {$realpath}/{$file}/{$file}.php";
|
||||
exit;
|
||||
}
|
||||
} else {
|
||||
if(pathinfo($file)['extension'] == "php") {
|
||||
$target = pathinfo($file)['filename'] . ".json";
|
||||
$data = file_get_contents("{$realpath}/{$target}");
|
||||
$info = json_decode($data, true);
|
||||
if(!$info) {
|
||||
PHPMC::Error()->Println("Error when load plugin: " . $file . ": No such plugin info file: " . $target . "<br>" . $data);
|
||||
}
|
||||
include("{$realpath}/{$file}");
|
||||
eval('$' . $info['main'] . ' = new ' . $info['main'] . '();');
|
||||
eval('$' . $info['main'] . '->onload();');
|
||||
}
|
||||
}
|
||||
include("{$realpath}/{$file}");
|
||||
eval('$' . $info['main'] . ' = new ' . $info['main'] . '();');
|
||||
eval('$' . $info['main'] . '->onload();');
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
|
Loading…
Reference in New Issue
Block a user