Visman před 7 roky
rodič
revize
af0e433845
3 změnil soubory, kde provedl 35 přidání a 35 odebrání
  1. 16 16
      app/bootstrap.php
  2. 18 18
      app/functions.php
  3. 1 1
      public/index.php

+ 16 - 16
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('<!-- debuginfo -->', $debug, $tpl);
+    $tpl = \str_replace('<!-- debuginfo -->', $debug, $tpl);
 }
 exit($tpl);

+ 18 - 18
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)
 }

+ 1 - 1
public/index.php

@@ -1,6 +1,6 @@
 <?php
 
-$forkStart = empty($_SERVER['REQUEST_TIME_FLOAT']) ? microtime(true) : $_SERVER['REQUEST_TIME_FLOAT'];
+$forkStart = empty($_SERVER['REQUEST_TIME_FLOAT']) ? \microtime(true) : $_SERVER['REQUEST_TIME_FLOAT'];
 $forkPublic = __DIR__;
 $forkPublicPrefix = '';