From af0e433845db9a08979199c81369422e994939bf Mon Sep 17 00:00:00 2001 From: Visman Date: Sat, 10 Mar 2018 21:24:39 +0700 Subject: [PATCH] 2018-03-10 --- app/bootstrap.php | 32 ++++++++++++++++---------------- app/functions.php | 36 ++++++++++++++++++------------------ public/index.php | 2 +- 3 files changed, 35 insertions(+), 35 deletions(-) diff --git a/app/bootstrap.php b/app/bootstrap.php index cc962844..548c4e2a 100644 --- a/app/bootstrap.php +++ b/app/bootstrap.php @@ -7,23 +7,23 @@ use ForkBB\Models\Page; use RuntimeException; // боевой -#error_reporting(E_ALL); -#ini_set('display_errors', 0); -#ini_set('log_errors', 1); +#\error_reporting(E_ALL); +#\ini_set('display_errors', 0); +#\ini_set('log_errors', 1); // разраб -error_reporting(E_ALL); -ini_set('display_errors', 1); -ini_set('log_errors', 1); +\error_reporting(E_ALL); +\ini_set('display_errors', 1); +\ini_set('log_errors', 1); -mb_language('uni'); -mb_internal_encoding('UTF-8'); -mb_substitute_character(0xFFFD); +\mb_language('uni'); +\mb_internal_encoding('UTF-8'); +\mb_substitute_character(0xFFFD); require __DIR__ . '/../vendor/autoload.php'; -if (file_exists(__DIR__ . '/config/main.php')) { +if (\file_exists(__DIR__ . '/config/main.php')) { $c = new Container(include __DIR__ . '/config/main.php'); -} elseif (file_exists(__DIR__ . '/config/install.php')) { +} elseif (\file_exists(__DIR__ . '/config/install.php')) { $c = new Container(include __DIR__ . '/config/install.php'); } else { throw new RuntimeException('Application is not configured'); @@ -33,10 +33,10 @@ require __DIR__ . '/functions.php'; \ForkBB\_init($c); // https or http? -if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { - $c->BASE_URL = str_replace('http://', 'https://', $c->BASE_URL); +if (isset($_SERVER['HTTPS']) && \strtolower($_SERVER['HTTPS']) !== 'off') { + $c->BASE_URL = \str_replace('http://', 'https://', $c->BASE_URL); } else { - $c->BASE_URL = str_replace('https://', 'http://', $c->BASE_URL); + $c->BASE_URL = \str_replace('https://', 'http://', $c->BASE_URL); } $c->PUBLIC_URL = $c->BASE_URL . $forkPublicPrefix; @@ -53,7 +53,7 @@ $c->TIME_FORMATS = [$c->config->o_time_format, 'H:i:s', 'H:i', 'g:i:s a', 'g:i a $controllers = ['Routing', 'Primary']; $page = null; -while (! $page instanceof Page && $cur = array_pop($controllers)) { +while (! $page instanceof Page && $cur = \array_pop($controllers)) { $page = $c->$cur; } @@ -63,6 +63,6 @@ if (null !== $page->onlinePos) { $tpl = $c->View->rendering($page); if (null !== $tpl && $c->DEBUG > 0) { $debug = $c->View->rendering($c->Debug->debug()); - $tpl = str_replace('', $debug, $tpl); + $tpl = \str_replace('', $debug, $tpl); } exit($tpl); diff --git a/app/functions.php b/app/functions.php index 435b1873..bf7e8c02 100644 --- a/app/functions.php +++ b/app/functions.php @@ -35,9 +35,9 @@ function __($arg, ...$args) $tr = $c->Lang->get($arg); - if (is_array($tr)) { - if (isset($args[0]) && is_int($args[0])) { - $n = array_shift($args); + if (\is_array($tr)) { + if (isset($args[0]) && \is_int($args[0])) { + $n = \array_shift($args); eval('$n = (int) ' . $tr['plural']); $tr = $tr[$n]; } else { @@ -47,11 +47,11 @@ function __($arg, ...$args) if (empty($args)) { return $tr; - } elseif (is_array($args[0])) { - return strtr($tr, array_map('\ForkBB\e', $args[0])); + } elseif (\is_array($args[0])) { + return \strtr($tr, \array_map('\ForkBB\e', $args[0])); } else { - $args = array_map('\ForkBB\e', $args); - return sprintf($tr, ...$args); + $args = \array_map('\ForkBB\e', $args); + return \sprintf($tr, ...$args); } } @@ -64,7 +64,7 @@ function __($arg, ...$args) */ function e($arg) { - return htmlspecialchars($arg, ENT_HTML5 | ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8'); + return \htmlspecialchars($arg, \ENT_HTML5 | \ENT_QUOTES | \ENT_SUBSTITUTE, 'UTF-8'); } /** @@ -96,8 +96,8 @@ function cens($arg) */ function num($number, $decimals = 0) { - return is_numeric($number) - ? number_format($number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep')) + return \is_numeric($number) + ? \number_format($number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep')) : 'not a number'; } @@ -136,14 +136,14 @@ function dt($arg, $dateOnly = false, $dateFormat = null, $timeFormat = null, $ti $timeFormat = $c->TIME_FORMATS[$c->user->time_format]; } - $date = gmdate($dateFormat, $arg); + $date = \gmdate($dateFormat, $arg); if(! $noText) { - $now = time() + $diff; + $now = \time() + $diff; - if ($date == gmdate($dateFormat, $now)) { + if ($date == \gmdate($dateFormat, $now)) { $date = __('Today'); - } elseif ($date == gmdate($dateFormat, $now - 86400)) { + } elseif ($date == \gmdate($dateFormat, $now - 86400)) { $date = __('Yesterday'); } } @@ -151,9 +151,9 @@ function dt($arg, $dateOnly = false, $dateFormat = null, $timeFormat = null, $ti if ($dateOnly) { return $date; } elseif ($timeOnly) { - return gmdate($timeFormat, $arg); + return \gmdate($timeFormat, $arg); } else { - return $date . ' ' . gmdate($timeFormat, $arg); + return $date . ' ' . \gmdate($timeFormat, $arg); } } @@ -166,7 +166,7 @@ function dt($arg, $dateOnly = false, $dateFormat = null, $timeFormat = null, $ti */ function utc($timestamp) { - return gmdate('c', $timestamp); // Y-m-d\TH:i:s\Z + return \gmdate('c', $timestamp); // Y-m-d\TH:i:s\Z } /** @@ -184,5 +184,5 @@ function size($size) $size /= 1024; } - return __('%s ' . $units[$i], sprintf('%.2f', $size)); + return __('%s ' . $units[$i], num($size, 2)); // \sprintf('%.2f', $size) } diff --git a/public/index.php b/public/index.php index b9d8149c..e5c09c45 100644 --- a/public/index.php +++ b/public/index.php @@ -1,6 +1,6 @@