More path fixes

This commit is contained in:
Dennis Eichhorn 2015-12-29 19:57:10 +01:00
parent a042552878
commit f4ad56632f

View File

@ -14,6 +14,8 @@
* @link http://orange-management.com * @link http://orange-management.com
*/ */
namespace phpOMS\Module; namespace phpOMS\Module;
use phpOMS\System\FilePathException;
use phpOMS\Validation\Validator;
/** /**
* InfoManager class. * InfoManager class.
@ -45,7 +47,7 @@ class InfoManager
* @var \string * @var \string
* @since 1.0.0 * @since 1.0.0
*/ */
private static $module_path = __DIR__ . '/../../Modules/'; const MODULE_PATH = __DIR__ . '/../../Modules/';
/** /**
* Object constructor. * Object constructor.
@ -57,9 +59,11 @@ class InfoManager
*/ */
public function __construct(\string $module) public function __construct(\string $module)
{ {
if (file_exists(self::$module_path . $module . '/info.json')) { if (($path = realpath($oldPath = self::MODULE_PATH . $module . '/info.json')) === false || Validator::startsWith($path, self::MODULE_PATH)) {
$this->fp = fopen(self::$module_path . $module . '/info.json', 'r'); throw new FilePathException($oldPath);
} }
$this->fp = fopen($oldPath, 'r');
} }
public function update() public function update()