Вход Регистрация
Файл: _core/_class/system.php
Строк: 145
<?php

    
# mark core  v1.0
    # author Drk in
    # date 24.10.19     
    
    # class system

    
class system {

        public static function 
check($msg# check data
        
{
        
        if (
is_array($msg)):
        foreach(
$msg as $key => $val):
        
$msg[$key] = self::check($val);
        endforeach;
        else:
        
$msg htmlspecialchars($msg);
        
$search = array(' ','|'''', '$', '\', '^', '%', '`', "", "x00", "x1A", chr(226) . chr(128) . chr(174));
        
$replace = array(' ','&#124;', '&#39;', '&#36;', '&#92;', '&#94;', '&#37;', '&#96;', '', '', '', '');
        
$msg = str_replace($search$replace$msg);
        
$msg = stripslashes(trim($msg));
        endif;
        return 
$msg;

        }  

        public static function abs(
$msg)  # abs intval data
        {

        return abs( intval(
$msg) );
        
        }    

        public static function gold()  # GOLD
        {

        
$msg = '<small><b><font color="#CE0025">G</font><font color="#8A006F">O</font><font color="#4600B9">L</font><font color="#2400DE">D</font></b></small>';
            
        return 
$msg;
        
        }    

        public static function utf_strlen(
$msg)  # strlen data
         {

        return strlen( utf8_decode(
$msg) );
         
        }    

        public static function utf_substr(
$msg)  # mb_substr data
         {

        return mb_substr(utf8_decode(
$msg),0,-1);
         
        }    

        public static function header(
$redirect,$msg = null,$err = null,$meta = null) # header redirect
        {

        if (
$err == null && $msg != null)$_SESSION['err'] = $msg;
        if (
$err == 1 && $msg != null)$_SESSION['show'] = $msg;
        if (
$meta == null):    
        header("Location: 
$redirect");
        else: 
        ?><META HTTP-EQUIV="REFRESH" CONTENT="0;<?=
$redirect?>"><?php endif;   
        exit();
        return;

        } 

        public static function ending(
$num$a$b$c) # ending data
        {

        
$q = ($num % 10 == 1 && $num % 100 != 11? 0: ($num % 10 >= 2 && $num % 10 <= 4 && ($num % 100 < 10 or $num % 100 >= 20)? 1: 2));
        return (
$q == 0? $a: ($q == 1? $b: ($q == 2? $c: null)));
    
        }
        
        public static function access(
$access) # check user and guest
        {

        global 
$user;
        if (isset(
$user) && $access == false):self::header('/','Страница доступна для гостей'); endif;     
        if (!isset(
$user) && $access == true):self::header('/','Страница доступна для пользователей'); endif;     
  
        }

        public static function adm() # check admin
        {

        global 
$user;
        if (isset(
$user) && $user['admin'] == 0 || !isset($user)):self::header('/','Ошибка отказано в доступе'); endif;    
        }

        public static function num(
$msg$len) # num data
        {

        
$wordsafe = FALSE; $dots = true; $slen = strlen($msg);
        if (
$slen <= $len) return $msg;
        if (
$wordsafe): $end = $len;   
        while ((
$msg[--$len] != ' ') && ($len > 0)): endwhile;
        if (
$len == 0)$len = $end;endif;
        if ((ord(
$msg[$len]) < 0x80) || (ord($msg[$len]) >= 0xC0))return substr($msg, 0, $len) . ($dots ? '...' : '');
        while (--
$len >= 0 && ord($msg[$len]) >= 0x80 && ord($msg[$len]) < 0xC0): endwhile;
        return substr(
$msg, 0, $len) . ($dots ? '...' : '');      

        }

        public static function on(
$time) # on data
        {

        
$timep = $time$time = time() - $time$his = date("H:i:s", $timep);  
        if (
$time == 0): return '<font color="red"><small>только что в '.$his.'</small></font>';
        elseif (
$time < 60): return '<font color="red"><small>'.$time.' '.self::ending($time, 'сек.', 'сек.', 'сек.').' назад в '.$his.'</small></font>';
        elseif (
$time >= 60 && $time < 3600): return '<font color="green"><small>'.round( $time / 60).' '.self::ending(round( $time / 60), 'мин.', 'мин.', 'мин.').' назад в '.$his.'</small></font>';
        elseif (
$time >= 3600 &&  $time < 86400): return '<font color="green"><small>'.round( $time / 3600).' '.self::ending(round( $time / 3600), 'ч.', 'ч.', 'ч.').' назад в '.$his.'</small></font>';    
        elseif (
$time >= 86400 && $time < 604800): return '<font color="green"><small>'.round( $time / 86400).' '.self::ending(round( $time / 86400), 'д.', 'д.', 'д.').' назад в '.$his.'</small></font>';    
        else: return self::time(
$timep); endif;

        }

        public static function time(
$time = null) # time data
        {

        if (
$time == NULL) $time = time(); $jmy = date("j M Y", $time);
        
$arr = [ 'jmy' => date("j M Y", $time), 'his' => date("H:i:s", $time) ];    
        if (
$arr['jmy'] == date("j M Y")): return 'Cегодня в '. $arr['his']; 
        elseif (
$arr['jmy'] == date("j M Y", time()-60*60*24)): return 'Вчера в '.$arr['his']; else: 
        
$array = [
        'Jan' => 'Янв', 'Feb' => 'Фев', 'Mar' => 'Марта', 'May' => 'Мая',
        'Apr' => 'Апр', 'Jun' => 'Июня', 'Jul' => 'Июля', 'Aug' => 'Авг',
        'Sep' => 'Сент', 'Oct' => 'Окт', 'Nov' => 'Ноября', 'Dec' => 'Дек',
        ];      

        return str_replace(array_keys(
$array), array_values($array), $jmy).' в '.$arr['his']; endif;
        
        }   



        
    } 
 
?>
Онлайн: 0
Реклама