mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-02-09 21:48:41 +00:00
Replacing realpath with file_exists
This commit is contained in:
parent
74e1053271
commit
4b09c7c1ba
|
|
@ -178,7 +178,7 @@ class Dispatcher
|
||||||
private function getController(string $controller)
|
private function getController(string $controller)
|
||||||
{
|
{
|
||||||
if (!isset($this->controllers[$controller])) {
|
if (!isset($this->controllers[$controller])) {
|
||||||
if (realpath($path = ROOT_PATH . '/' . str_replace('\\', '/', $controller) . '.php') === false) {
|
if (!file_exists($path = ROOT_PATH . '/' . str_replace('\\', '/', $controller) . '.php')) {
|
||||||
throw new PathException($path);
|
throw new PathException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,13 +103,9 @@ class FileLogger implements LoggerInterface
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_dir($lpath) || strpos($lpath, '.') === false) {
|
if (is_dir($lpath) || strpos($lpath, '.') === false) {
|
||||||
File::create($path = $lpath . '/' . date('Y-m-d') . '.log');
|
File::create($path = $path . '/' . date('Y-m-d') . '.log');
|
||||||
|
|
||||||
$path = realpath($path);
|
|
||||||
} else {
|
} else {
|
||||||
File::create($lpath);
|
File::create($lpath);
|
||||||
|
|
||||||
$path = realpath($lpath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ class FinanceFormulas
|
||||||
/**
|
/**
|
||||||
* Annual Percentage Yield
|
* Annual Percentage Yield
|
||||||
*
|
*
|
||||||
|
* @latex r = \left(APY + 1\right)^{\frac{1}{n}} \cdot n - 1
|
||||||
|
*
|
||||||
* @param float $apy Annual percentage yield
|
* @param float $apy Annual percentage yield
|
||||||
* @param int $n Number of times compounded
|
* @param int $n Number of times compounded
|
||||||
*
|
*
|
||||||
|
|
@ -62,7 +64,7 @@ class FinanceFormulas
|
||||||
*/
|
*/
|
||||||
public static function getStateAnnualInterestRateOfAPY(float $apy, int $n) : float
|
public static function getStateAnnualInterestRateOfAPY(float $apy, int $n) : float
|
||||||
{
|
{
|
||||||
return (pow($apy + 1, 1 / $n) - 1) * $n;
|
return pow($apy + 1, 1 / $n) * $n - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -73,11 +73,11 @@ class InfoManager
|
||||||
*/
|
*/
|
||||||
public function load()
|
public function load()
|
||||||
{
|
{
|
||||||
if (($path = realpath($this->path)) === false) {
|
if (!file_exists($this->path)) {
|
||||||
throw new PathException($this->path);
|
throw new PathException($this->path);
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->info = json_decode(file_get_contents($path), true);
|
$this->info = json_decode(file_get_contents($this->path), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -124,9 +124,9 @@ abstract class ModuleAbstract
|
||||||
public static function getLocalization(string $language, string $destination) : array
|
public static function getLocalization(string $language, string $destination) : array
|
||||||
{
|
{
|
||||||
$lang = [];
|
$lang = [];
|
||||||
if (($path = realpath($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) !== false) {
|
if (file_exists($oldPath = __DIR__ . '/../../Modules/' . static::MODULE_NAME . '/Theme/' . $destination . '/Lang/' . $language . '.lang.php')) {
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
$lang = include $path;
|
$lang = include $oldPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $lang;
|
return $lang;
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ class Router
|
||||||
*/
|
*/
|
||||||
public function importFromFile(string $path) : bool
|
public function importFromFile(string $path) : bool
|
||||||
{
|
{
|
||||||
if (file_exists($path)) {
|
if (stream_resolve_include_path($path) !== false) {
|
||||||
/** @noinspection PhpIncludeInspection */
|
/** @noinspection PhpIncludeInspection */
|
||||||
$this->routes += include $path;
|
$this->routes += include $path;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -194,9 +194,8 @@ class Directory extends FileAbstract implements DirectoryInterface
|
||||||
*/
|
*/
|
||||||
public static function delete(string $path) : bool
|
public static function delete(string $path) : bool
|
||||||
{
|
{
|
||||||
$path = realpath($oldPath = $path);
|
if (!file_exists($path) || !is_dir($path)) {
|
||||||
if ($path === false || !is_dir($path) || StringUtils::startsWith($path, ROOT_PATH)) {
|
throw new PathException($path);
|
||||||
throw new PathException($oldPath);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$files = scandir($path);
|
$files = scandir($path);
|
||||||
|
|
|
||||||
|
|
@ -205,9 +205,7 @@ abstract class ViewAbstract implements \Serializable
|
||||||
*/
|
*/
|
||||||
public function serialize()
|
public function serialize()
|
||||||
{
|
{
|
||||||
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
if (!file_exists(__DIR__ . '/../..' . $this->template . '.tpl.php')) {
|
||||||
|
|
||||||
if ($path === false) {
|
|
||||||
return $this->toArray();
|
return $this->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,10 +245,10 @@ abstract class ViewAbstract implements \Serializable
|
||||||
*/
|
*/
|
||||||
public function render() : string
|
public function render() : string
|
||||||
{
|
{
|
||||||
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
$path = __DIR__ . '/../..' . $this->template . '.tpl.php';
|
||||||
|
|
||||||
if ($path === false) {
|
if (!file_exists($path)) {
|
||||||
throw new PathException($oldPath);
|
throw new PathException($path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ob_start();
|
ob_start();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user