Файл: upload/core/functions/helpers.php
Строк: 79
<?php
function homeLink()
{
$home = 'https://' . $_SERVER['HTTP_HOST'];
return $home;
}
function ReloadPage()
{
echo '<script type="text/javascript">window.location.href="' . homeLink() . $_SERVER['REQUEST_URI'] . '";</script>';
}
function RedirectToPage($page)
{
echo '<script type="text/javascript">window.location.href="' . homeLink() . $page . '";</script>';
}
function chars($msg)
{
$msg = trim($msg);
$msg = htmlspecialchars($msg, ENT_QUOTES, 'UTF-8');
return $msg;
}
function Asset($path)
{
$full = $_SERVER['DOCUMENT_ROOT'] . $path;
// Если файл существует — добавляем версию
if (is_file($full)) {
$version = filemtime($full);
return homeLink() . $path . '?v=' . $version;
}
// Если файла нет — возвращаем без версии
return homeLink() . $path;
}
function getMySQLVersion()
{
$output = shell_exec('mysql -V');
preg_match('@[0-9]+.[0-9]+.[0-9]+@', $output, $version);
return $version[0];
}
function vremja($time = NULL)
{
$time = (int)$time;
if ($time <= 0) $time = time();
$data = date('j.n.y', $time);
if ($data == date('j.n.y')) $res = 'Сегодня в ' . date('G:i', $time);
elseif ($data == date('j.n.y', time() - 86400)) $res = 'Вчера в ' . date('G:i', $time);
elseif ($data == date('j.n.y', time() - 172800)) $res = 'Позавчера в ' . date('G:i', $time);
else {
$m = ['0','Янв','Фев','Мар','Апр','Май','Июн','Июл','Авг','Сен','Окт','Ноя','Дек'];
$res = date('j ' . $m[date('n', $time)] . ' Y в G:i', $time);
$res = str_replace(date('Y'), '', $res);
}
return $res;
}
function genRandomString($length = 10, $characters = null) {
if ($characters === null) {
$characters = 'abcdefghkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!#$%&?';
}
$charactersLength = strlen($characters);
$randomString = '';
for ($i = 0; $i < $length; $i++) {
$randomIndex = random_int(0, $charactersLength - 1);
$randomString .= $characters[$randomIndex];
}
return $randomString;
}
function OrderGenKey()
{
$allowed = [0,2,3,4,6,7,8,9]; // без 1 и 5
$orderDigits = '';
for ($i = 0; $i < 30; $i++) {
$orderDigits .= $allowed[array_rand($allowed)];
}
return $orderDigits;
}
function TemplateLink($theme)
{
$link = homeLink() . '/core/templates/' . $theme;
return $link;
}
?>