Файл: system/classes/Core.php
Строк: 51
<?php
class Core
{
static function go($var)
{
exit(header('location: ' . $var));
}
static function config($var, $cfg = 'default', $comment = null)
{
if (isset($comment))
{
$array = ['[' . $comment . ']'];
}
if ($fopen = fopen(ROOT . 'system/ini/' . $cfg . '.ini', 'w'))
{
foreach ($var as $key => $value)
{
$array[] = $key . ' = '' . htmlentities($value, ENT_QUOTES, 'UTF-8') . ''';
}
fputs($fopen, implode("rn", $array));
fclose($fopen);
}
}
static function time($time = NULL)
{
if (empty($time))
$time = time();
$date = date('d.m.Y', $time);
if ($date == date('d.m.Y'))
{
$time = Lang::word('Сегодня в') . ' ' . date('H:i', $time);
}
elseif ($date == date('d.m.Y', time() - 60 * 60 * 24))
{
$time = Lang::word('Вчера в') . ' ' . date('H:i', $time);
}
else
{
$time = date('d.m.Y H:i', $time);
}
return $time;
}
static function size($filesize = 0)
{
$type = [
' Bytes',
' KB',
' MB',
' GB',
' TB',
' PB',
' EB',
' ZB',
' YB'
];
return $size ? round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . $type[$i] : '0 Bytes';
}
static function show($type = NULL, $var = NULL)
{
global $smarty;
switch ($type)
{
case 'success':
$listing[] = [
'title' => Lang::word($var),
'div' => 'success',
];
break;
case 'warning':
$listing[] = [
'title' => Lang::word($var),
'div' => 'warning',
];
break;
case 'error':
if (empty($var))
{
global $error;
$var = $error;
$listing = null;
}
if (isset($var))
{
if (is_array($var))
{
foreach($var as $value)
{
$listing[] = [
'title' => Lang::word($value),
'div' => 'error'
];
}
}
else
{
$listing[] = [
'title' => Lang::word($var),
'div' => 'error'
];
}
}
break;
}
$smarty->assign('listing', $listing);
$smarty->display('listing.tpl');
}
static function only($type = NULL, $value = 1)
{
global $user;
switch ($type)
{
case 'guest':
if (isset($user))
{
self::go('/');
}
break;
case 'user':
if (!isset($user))
{
self::go('/');
}
break;
case 'level':
if (!isset($user) || $user['level'] < $value)
{
self::go('/');
}
break;
}
}
}