Reducing path repetition

This commit is contained in:
Dennis Eichhorn 2015-12-28 21:27:41 +01:00
parent 75622e46f7
commit a042552878
3 changed files with 9 additions and 9 deletions

View File

@ -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;
}

View File

@ -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);

View File

@ -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();