2018-03-10

This commit is contained in:
Visman 2018-03-10 21:24:39 +07:00
parent e05ec6cf3a
commit af0e433845
3 changed files with 35 additions and 35 deletions

View file

@ -7,23 +7,23 @@ use ForkBB\Models\Page;
use RuntimeException; use RuntimeException;
// боевой // боевой
#error_reporting(E_ALL); #\error_reporting(E_ALL);
#ini_set('display_errors', 0); #\ini_set('display_errors', 0);
#ini_set('log_errors', 1); #\ini_set('log_errors', 1);
// разраб // разраб
error_reporting(E_ALL); \error_reporting(E_ALL);
ini_set('display_errors', 1); \ini_set('display_errors', 1);
ini_set('log_errors', 1); \ini_set('log_errors', 1);
mb_language('uni'); \mb_language('uni');
mb_internal_encoding('UTF-8'); \mb_internal_encoding('UTF-8');
mb_substitute_character(0xFFFD); \mb_substitute_character(0xFFFD);
require __DIR__ . '/../vendor/autoload.php'; 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'); $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'); $c = new Container(include __DIR__ . '/config/install.php');
} else { } else {
throw new RuntimeException('Application is not configured'); throw new RuntimeException('Application is not configured');
@ -33,10 +33,10 @@ require __DIR__ . '/functions.php';
\ForkBB\_init($c); \ForkBB\_init($c);
// https or http? // https or http?
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) !== 'off') { if (isset($_SERVER['HTTPS']) && \strtolower($_SERVER['HTTPS']) !== 'off') {
$c->BASE_URL = str_replace('http://', 'https://', $c->BASE_URL); $c->BASE_URL = \str_replace('http://', 'https://', $c->BASE_URL);
} else { } 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; $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']; $controllers = ['Routing', 'Primary'];
$page = null; $page = null;
while (! $page instanceof Page && $cur = array_pop($controllers)) { while (! $page instanceof Page && $cur = \array_pop($controllers)) {
$page = $c->$cur; $page = $c->$cur;
} }
@ -63,6 +63,6 @@ if (null !== $page->onlinePos) {
$tpl = $c->View->rendering($page); $tpl = $c->View->rendering($page);
if (null !== $tpl && $c->DEBUG > 0) { if (null !== $tpl && $c->DEBUG > 0) {
$debug = $c->View->rendering($c->Debug->debug()); $debug = $c->View->rendering($c->Debug->debug());
$tpl = str_replace('<!-- debuginfo -->', $debug, $tpl); $tpl = \str_replace('<!-- debuginfo -->', $debug, $tpl);
} }
exit($tpl); exit($tpl);

View file

@ -35,9 +35,9 @@ function __($arg, ...$args)
$tr = $c->Lang->get($arg); $tr = $c->Lang->get($arg);
if (is_array($tr)) { if (\is_array($tr)) {
if (isset($args[0]) && is_int($args[0])) { if (isset($args[0]) && \is_int($args[0])) {
$n = array_shift($args); $n = \array_shift($args);
eval('$n = (int) ' . $tr['plural']); eval('$n = (int) ' . $tr['plural']);
$tr = $tr[$n]; $tr = $tr[$n];
} else { } else {
@ -47,11 +47,11 @@ function __($arg, ...$args)
if (empty($args)) { if (empty($args)) {
return $tr; return $tr;
} elseif (is_array($args[0])) { } elseif (\is_array($args[0])) {
return strtr($tr, array_map('\ForkBB\e', $args[0])); return \strtr($tr, \array_map('\ForkBB\e', $args[0]));
} else { } else {
$args = array_map('\ForkBB\e', $args); $args = \array_map('\ForkBB\e', $args);
return sprintf($tr, ...$args); return \sprintf($tr, ...$args);
} }
} }
@ -64,7 +64,7 @@ function __($arg, ...$args)
*/ */
function e($arg) 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) function num($number, $decimals = 0)
{ {
return is_numeric($number) return \is_numeric($number)
? number_format($number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep')) ? \number_format($number, $decimals, __('lang_decimal_point'), __('lang_thousands_sep'))
: 'not a number'; : '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]; $timeFormat = $c->TIME_FORMATS[$c->user->time_format];
} }
$date = gmdate($dateFormat, $arg); $date = \gmdate($dateFormat, $arg);
if(! $noText) { if(! $noText) {
$now = time() + $diff; $now = \time() + $diff;
if ($date == gmdate($dateFormat, $now)) { if ($date == \gmdate($dateFormat, $now)) {
$date = __('Today'); $date = __('Today');
} elseif ($date == gmdate($dateFormat, $now - 86400)) { } elseif ($date == \gmdate($dateFormat, $now - 86400)) {
$date = __('Yesterday'); $date = __('Yesterday');
} }
} }
@ -151,9 +151,9 @@ function dt($arg, $dateOnly = false, $dateFormat = null, $timeFormat = null, $ti
if ($dateOnly) { if ($dateOnly) {
return $date; return $date;
} elseif ($timeOnly) { } elseif ($timeOnly) {
return gmdate($timeFormat, $arg); return \gmdate($timeFormat, $arg);
} else { } 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) 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; $size /= 1024;
} }
return __('%s ' . $units[$i], sprintf('%.2f', $size)); return __('%s ' . $units[$i], num($size, 2)); // \sprintf('%.2f', $size)
} }

View file

@ -1,6 +1,6 @@
<?php <?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__; $forkPublic = __DIR__;
$forkPublicPrefix = ''; $forkPublicPrefix = '';