proper check for .php plugin files
This commit is contained in:
parent
227cccfaa2
commit
a52f6894c0
@ -196,4 +196,15 @@ abstract class FileUtil {
|
|||||||
}
|
}
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check whether the given file name is a PHP file
|
||||||
|
*
|
||||||
|
* @param string $fileName
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
public static function isPhpFileName($fileName) {
|
||||||
|
$extension = substr($fileName, -4);
|
||||||
|
return (strtolower($extension) === '.php');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ namespace ManiaControl\Plugins;
|
|||||||
use ManiaControl\Callbacks\CallbackListener;
|
use ManiaControl\Callbacks\CallbackListener;
|
||||||
use ManiaControl\Callbacks\TimerListener;
|
use ManiaControl\Callbacks\TimerListener;
|
||||||
use ManiaControl\Commands\CommandListener;
|
use ManiaControl\Commands\CommandListener;
|
||||||
|
use ManiaControl\Files\FileUtil;
|
||||||
use ManiaControl\Logger;
|
use ManiaControl\Logger;
|
||||||
use ManiaControl\ManiaControl;
|
use ManiaControl\ManiaControl;
|
||||||
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
use ManiaControl\Manialinks\ManialinkPageAnswerListener;
|
||||||
@ -294,7 +295,7 @@ class PluginManager {
|
|||||||
|
|
||||||
$filePath = $directory . $pluginFile;
|
$filePath = $directory . $pluginFile;
|
||||||
if (is_file($filePath)) {
|
if (is_file($filePath)) {
|
||||||
if (!stripos($pluginFile, '.php')) {
|
if (!FileUtil::isPhpFileName($pluginFile)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$success = include_once $filePath;
|
$success = include_once $filePath;
|
||||||
@ -478,8 +479,8 @@ class PluginManager {
|
|||||||
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
$url = ManiaControl::URL_WEBSERVICE . 'plugins';
|
||||||
$this->maniaControl->getFileReader()
|
$this->maniaControl->getFileReader()
|
||||||
->loadFile($url, function ($dataJson, $error) use (&$function) {
|
->loadFile($url, function ($dataJson, $error) use (&$function) {
|
||||||
$data = json_decode($dataJson);
|
$data = json_decode($dataJson);
|
||||||
call_user_func($function, $data, $error);
|
call_user_func($function, $data, $error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user