1
0
mirror of https://github.com/ZeroDream-CN/PHPMC7 synced 2024-11-24 13:15:10 +08:00

v7.3.3199 更新

修改插件加载时搜索目录的方式,同时搜索子目录插件
This commit is contained in:
Akkariin Meiko 2018-09-16 21:51:17 +08:00
parent e1fad288a2
commit 577f59708b
2 changed files with 30 additions and 10 deletions

View File

@ -1,7 +1,7 @@
<?php <?php
// PHPMC 7 Version define // PHPMC 7 Version define
// Don't change this, because it will interfere your update. // 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/Event.php");
include(ROOT . "/include/core/PHPMC/User.php"); include(ROOT . "/include/core/PHPMC/User.php");

View File

@ -11,16 +11,36 @@ class Plugin {
$realpath = realpath($path); $realpath = realpath($path);
$handle = opendir($path); $handle = opendir($path);
while($file = readdir($handle)) { while($file = readdir($handle)) {
if($file !== "." && $file !== ".." && pathinfo($file)['extension'] == "php") { if($file !== "." && $file !== "..") {
$target = pathinfo($file)['filename'] . ".json"; if(is_dir("{$realpath}/{$file}/")) {
$data = $this->pluginReader("{$realpath}/{$target}"); if(file_exists("{$realpath}/{$file}/{$file}.php") && file_exists("{$realpath}/{$file}/{$file}.json")) {
$info = json_decode($data, true); $files = "{$file}.php";
if(!$info) { $target = pathinfo($files)['filename'] . ".json";
PHPMC::Error()->Println("Error when load plugin: " . $file . ": No such plugin info file: " . $target . "<br>" . $data); $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); closedir($handle);