mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-11 09:48:40 +00:00
Reducing path repetition
This commit is contained in:
parent
75622e46f7
commit
a042552878
|
|
@ -133,12 +133,12 @@ abstract class ModuleAbstract
|
|||
$lang = [];
|
||||
if (isset(static::$localization[$destination])) {
|
||||
foreach (static::$localization[$destination] as $file) {
|
||||
if(($path = $path = realpath(__DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php')) === false) {
|
||||
throw new FilePathException(__DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php');
|
||||
if(($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php')) === false) {
|
||||
throw new FilePathException($oldPath);
|
||||
}
|
||||
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
include realpath(__DIR__ . '/../../Modules/' . static::$module . '/Theme/lang/' . $file . '.' . $language . '.lang.php');
|
||||
include realpath($path);
|
||||
/** @var array $MODLANG */
|
||||
$lang += $MODLANG;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -246,11 +246,11 @@ class ModuleManager
|
|||
$c = count($files);
|
||||
|
||||
for ($i = 0; $i < $c; $i++) {
|
||||
$path = realpath(self::MODULE_PATH . '/' . $files[$i] . '/info.json');
|
||||
$path = realpath($oldPath = self::MODULE_PATH . '/' . $files[$i] . '/info.json');
|
||||
|
||||
if (file_exists($path)) {
|
||||
if(strpos($path, self::MODULE_PATH) === false) {
|
||||
throw new FilePathException(self::MODULE_PATH . '/' . $files[$i] . '/info.json');
|
||||
throw new FilePathException($oldPath);
|
||||
}
|
||||
|
||||
$json = json_decode(file_get_contents($path), true);
|
||||
|
|
@ -296,11 +296,11 @@ class ModuleManager
|
|||
// todo download;
|
||||
}
|
||||
|
||||
$path = realpath(self::MODULE_PATH . '/' . $module . '/' . 'info.json');
|
||||
$path = realpath($oldPath = self::MODULE_PATH . '/' . $module . '/' . 'info.json');
|
||||
|
||||
if ($path !== false) {
|
||||
if(strpos($path, self::MODULE_PATH) === false) {
|
||||
throw new FilePathException(self::MODULE_PATH . '/' . $module . '/' . 'info.json');
|
||||
throw new FilePathException($oldPath);
|
||||
}
|
||||
|
||||
$info = json_decode(file_get_contents($path), true);
|
||||
|
|
|
|||
|
|
@ -279,10 +279,10 @@ class View implements RenderableInterface
|
|||
public function render() : \string
|
||||
{
|
||||
$this->l11n->setLang($this->app->l11nManager->getLanguage($this->response->getL11n()->getLanguage()));
|
||||
$path = realpath(__DIR__ . '/../..' . $this->template . '.tpl.php');
|
||||
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
||||
|
||||
if (strpos($path, ROOT_PATH) === false) {
|
||||
throw new FilePathException(__DIR__ . '/../..' . $this->template . '.tpl.php');
|
||||
throw new FilePathException($oldPath);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user