mirror of
https://github.com/Karaka-Management/phpOMS.git
synced 2026-01-19 04:58: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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,13 +103,9 @@ class FileLogger implements LoggerInterface
|
|||
}
|
||||
|
||||
if (is_dir($lpath) || strpos($lpath, '.') === false) {
|
||||
File::create($path = $lpath . '/' . date('Y-m-d') . '.log');
|
||||
|
||||
$path = realpath($path);
|
||||
File::create($path = $path . '/' . date('Y-m-d') . '.log');
|
||||
} else {
|
||||
File::create($lpath);
|
||||
|
||||
$path = realpath($lpath);
|
||||
}
|
||||
|
||||
$this->path = $path;
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ class FinanceFormulas
|
|||
/**
|
||||
* Annual Percentage Yield
|
||||
*
|
||||
* @latex r = \left(APY + 1\right)^{\frac{1}{n}} \cdot n - 1
|
||||
*
|
||||
* @param float $apy Annual percentage yield
|
||||
* @param int $n Number of times compounded
|
||||
*
|
||||
|
|
@ -62,7 +64,7 @@ class FinanceFormulas
|
|||
*/
|
||||
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()
|
||||
{
|
||||
if (($path = realpath($this->path)) === false) {
|
||||
if (!file_exists($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
|
||||
{
|
||||
$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 */
|
||||
$lang = include $path;
|
||||
$lang = include $oldPath;
|
||||
}
|
||||
|
||||
return $lang;
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ class Router
|
|||
*/
|
||||
public function importFromFile(string $path) : bool
|
||||
{
|
||||
if (file_exists($path)) {
|
||||
if (stream_resolve_include_path($path) !== false) {
|
||||
/** @noinspection PhpIncludeInspection */
|
||||
$this->routes += include $path;
|
||||
|
||||
|
|
|
|||
|
|
@ -194,9 +194,8 @@ class Directory extends FileAbstract implements DirectoryInterface
|
|||
*/
|
||||
public static function delete(string $path) : bool
|
||||
{
|
||||
$path = realpath($oldPath = $path);
|
||||
if ($path === false || !is_dir($path) || StringUtils::startsWith($path, ROOT_PATH)) {
|
||||
throw new PathException($oldPath);
|
||||
if (!file_exists($path) || !is_dir($path)) {
|
||||
throw new PathException($path);
|
||||
}
|
||||
|
||||
$files = scandir($path);
|
||||
|
|
|
|||
|
|
@ -205,9 +205,7 @@ abstract class ViewAbstract implements \Serializable
|
|||
*/
|
||||
public function serialize()
|
||||
{
|
||||
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
||||
|
||||
if ($path === false) {
|
||||
if (!file_exists(__DIR__ . '/../..' . $this->template . '.tpl.php')) {
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
|
|
@ -247,10 +245,10 @@ abstract class ViewAbstract implements \Serializable
|
|||
*/
|
||||
public function render() : string
|
||||
{
|
||||
$path = realpath($oldPath = __DIR__ . '/../..' . $this->template . '.tpl.php');
|
||||
$path = __DIR__ . '/../..' . $this->template . '.tpl.php';
|
||||
|
||||
if ($path === false) {
|
||||
throw new PathException($oldPath);
|
||||
if (!file_exists($path)) {
|
||||
throw new PathException($path);
|
||||
}
|
||||
|
||||
ob_start();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user