1
0
mirror of https://github.com/ZeroDream-CN/PHPMC7 synced 2026-05-18 19:49:53 +08:00

修复重复加载插件的bug

人生就是在不断地修复bug...
This commit is contained in:
2018-09-16 22:01:26 +08:00
Unverified
parent 577f59708b
commit f4eb01463d
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -1,6 +1,8 @@
<?php
class Plugin {
public $plugins;
public function __construct() {
if(!file_exists("plugins/")) {
mkdir("plugins/", 0775);
@@ -21,7 +23,11 @@ class Plugin {
if(!$info) {
PHPMC::Error()->Println("Error when load plugin: " . $files . ": No such plugin info file: " . $target . "<br>" . $data);
}
if(stristr($this->plugins, $info['package'] . ";")) {
continue;
}
include("{$realpath}/{$file}/{$files}");
$this->plugin .= $info['package'] . ";";
eval('$' . $info['main'] . ' = new ' . $info['main'] . '();');
eval('$' . $info['main'] . '->onload();');
} else {
@@ -36,7 +42,11 @@ class Plugin {
if(!$info) {
PHPMC::Error()->Println("Error when load plugin: " . $file . ": No such plugin info file: " . $target . "<br>" . $data);
}
if(stristr($this->plugins, $info['package'] . ";")) {
continue;
}
include("{$realpath}/{$file}");
$this->plugin .= $info['package'] . ";";
eval('$' . $info['main'] . ' = new ' . $info['main'] . '();');
eval('$' . $info['main'] . '->onload();');
}