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
|
<?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");
|
||||||
|
@ -11,9 +11,27 @@ 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 !== "..") {
|
||||||
|
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";
|
$target = pathinfo($file)['filename'] . ".json";
|
||||||
$data = $this->pluginReader("{$realpath}/{$target}");
|
$data = file_get_contents("{$realpath}/{$target}");
|
||||||
$info = json_decode($data, true);
|
$info = json_decode($data, true);
|
||||||
if(!$info) {
|
if(!$info) {
|
||||||
PHPMC::Error()->Println("Error when load plugin: " . $file . ": No such plugin info file: " . $target . "<br>" . $data);
|
PHPMC::Error()->Println("Error when load plugin: " . $file . ": No such plugin info file: " . $target . "<br>" . $data);
|
||||||
@ -23,6 +41,8 @@ class Plugin {
|
|||||||
eval('$' . $info['main'] . '->onload();');
|
eval('$' . $info['main'] . '->onload();');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user