Вход Регистрация
Файл: Sys/function.php
Строк: 155
<?php
function data($time)
    {
        
$month = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
        
$month_rus = array('Янв','Фев','Мар','Апр','Мая','Июн','Июл','Авг','Сент','Окт','Ноя','Дек');
        
$timep date("j M Y - H:i:s"$time);
        
$timep str_replace($month,$month_rus,$timep);
        return 
$timep;
    }
function 
navigation($total,$page,$url)
    {   echo
'<div class="st2"><div class="middle_back">';
        if(
$page-0)
            {
                
$left='<a href="'.$url.''.($page-1).'"><-Пред.</a>';
            }
        else
            {
                
$left '<-Пред.';
            }
        if(
$page+AND $page $total)
            {
                
$right '<a href="'.$url.''.($page+1).'">След.-></a>';
            }
        else
            {
                
$right 'След.->';
            }
        echo 
''.$left.' | '.$right.'<br />';
        if(
$page-0)
            {
                
$first='<a href="'.$url.'1">1</a>..';
            }
        if(
$page-0)
            {
                
$page2left='<a href="'.$url.''.($page-2).'">'.($page-2).'</a>,';
            }
        if(
$page-0)
            {
                
$page1left='<a href="'.$url.''.($page-1).'">'.($page-1).'</a>,';
            }
        if(
$page+<= $total)
            {
                
$page1right=',<a href="'.$url.''.($page+1).'">'.($page 1).'</a>';
            }
        if(
$page+<= $total)
            {
                
$page2right=',<a href="'.$url.''.($page+2).'">'.($page 2).'</a>';
            }
        if(
$page+<= $total)
            {
                
$page3right='..<a href="'.$url.''.($total).'">'.($total).'</a>';
            }
        echo 
'Страницы: '.$first.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$page3right.'';
         echo
'</div></div>';
    }
function 
wCache($content$filename)
    {
        
$fp fopen('Cache/'.$filename'w');
        
fwrite($fp$content);
        
fclose($fp);
    }
function 
unreg()
    {
        global 
$user_data;
        if(
$user_data)
            {
                echo 
'<div id="st21">
 <div class="st2">
                             <h2 class="title"></h2>

                                <div class="middle_back">Доступ только не авторизованным пользователям.</div></div></div>'
;
                include(
'Sys/foot.php');
                exit;
            }
    }
function 
reg()
    {
        global 
$user_data;
        if(!
$user_data)
            {
                echo 
'<div id="st21">
 <div class="st2">
                             <h2 class="title"></h2>

                                <div class="middle_back">Доступ только авторизованным пользователям.</div></div></div>'
;
                require_once(
'Sys/foot.php');
                exit;
            }
    }
function 
level($level)
    {
        global 
$user_data;
        if(
$user_data AND $user_data['level'] < $level OR !$user_data)
            {
                echo 
'<div id="st21">
 <div class="st2">
                             <h2 class="title"></h2>

                                <div class="middle_back">Доступ только администратору.</div></div><br /></div>'
;
                require_once(
'Sys/foot.php');
                exit;
            }
    }
function 
filter($text)
    {
        global 
$mysqli;
        
$text htmlspecialchars($text);
        
$text str_replace("'""&#39;"$text);
        
$text str_replace('\', "&#92;", $text);
        $text = str_replace("|", "I", $text);
        $text = str_replace("||", "I", $text);

        $text = str_replace("/\$/", "&#36;", $text);
        $text = mysqli_real_escape_string($mysqli,$text);
        return $text;
    }
function password()
    {
        $s = str_split('
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789');
        $pass = '';
        for ($i = 0; $i <= 15; $i++)
            {
                $rand = mt_rand(5,25);
                $pass .= $s[$rand];
            }
        return $pass;
    }
function keyRand()
    {
        $s = str_split('
aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789');
        $key = '';
        for ($i = 0; $i <= 45; $i++)
            {
                $rand = mt_rand(2,30);
                $key .= $s[$rand];
            }
        return $key;
    }

function mobile()
    {
         $useragent = strtolower($_SERVER['
HTTP_USER_AGENT']);
         $useragent = str_replace('
windows ce', '',$useragent);
         if(
         strpos($useragent, "win") !== false OR
         strpos($useragent, "linux") !== false OR
         strpos($useragent, "lynx") !== false OR
         strpos($useragent, "unix") !== false OR
         strpos($useragent, "macintosh") !== false OR
         strpos($useragent, "powerpc") !== false)
         {
            return false;
         }
         else
         {
            return true;
         }
    }


    /*function mobile()
    {

            return true;

    }  */



function proxy()
    {
        if(isset($_SERVER['
HTTP_VIA']))
            {
                return true;
            }
    }

function compression()
    {
        if(preg_match('
#gzip#iU',$_SERVER['HTTP_ACCEPT_ENCODING']))
            
{
                return 
1;
            }
        else
            {
                return 
0;
            }
    }
function 
bbCodes($text/*некоторая часть с JohnCms 4.3.0*/
    
{
        
$search = array(
            
'#[b](.+?)[/b]#is',                                              // Жирный
            
'#[i](.+?)[/i]#is',
            
'#[u](.+?)[/u]#is',                                              // Курсив
            
'#[red](.+?)[/red]#is',                                          // Красный
            
'#[green](.+?)[/green]#is',                                      // Зеленый
            
'#[blue](.+?)[/blue]#is',                                         // Синий
            
'#[link=(.+?)](.+?)[/link]#is',
             
'#[link](.+?)[/link]#is',
            
'#[img](.+?)[/img]#is',                                         // Синий
            
'#[img right](.+?)[/img]#is',
            
'#[img left](.+?)[/img]#is',
            
'#[center](.+?)[/center]#is',                                         // Синий
            
'#[left](.+?)[/left]#is',                             // Синий
            
'#[right](.+?)[/right]#is',                             // Синий
            
'#[justify](.+?)[/justify]#is',
            
'#[quote](.+?)[/quote]#is',
            
'#[color=(.+?)](.+?)[/color]#is',
            
'#[size=(.+?)](.+?)[/size]#is'


        
);
        
$replace = array(
           
'<span style="font-weight: bold">$1</span>',                       // Жирный
           
'<span style="font-style:italic">$1</span>',                       // Курсив
            
'<span style="text-decoration:underline">$1</span>',
            
'<span style="color:red">$1</span>',                               // Красный
            
'<span style="color:green">$1</span>',                             // Зеленый
            
'<span style="color:blue">$1</span>',                              // Синий
            
'<a href="$1">$2</a>',
            
'<a href="$1">$1</a>',
            
'<img src="$1">',                             // Синий
            
'<img src="$1" class="imgright">',
            
'<img src="$1" class="imgleft">',
            
'<div align="center">$1</div>',
            
'<div align="left">$1</div>',
            
'<div align="right">$1</div>',
            
'<div align="justify">$1</div>',
            
'<div class="quote">$1</div>',
            
'<span style="color:$1">$2</span>',
            
'<span style="font-size:$1px">$2</span>'                              // Синий

        
);
        return 
preg_replace($search$replace$text);
    }
function 
StrToNum($Str$Check$Magic)
{
    
$Int32Unit 4294967296;

    
$length strlen($Str);
    for (
$i 0$i $length$i++) {
        
$Check *= $Magic;

        if (
$Check >= $Int32Unit) {
            
$Check = ($Check $Int32Unit * (int) ($Check $Int32Unit));

            
$Check = ($Check < -2147483648) ? ($Check $Int32Unit) : $Check;
        }
        
$Check += ord($Str{$i});
    }
    return 
$Check;
}
function 
HashURL($String)
{
    
$Check1 StrToNum($String0x15050x21);
    
$Check2 StrToNum($String00x1003F);

    
$Check1 >>= 2;
    
$Check1 = (($Check1 >> 4) & 0x3FFFFC0 ) | ($Check1 0x3F);
    
$Check1 = (($Check1 >> 4) & 0x3FFC00 ) | ($Check1 0x3FF);
    
$Check1 = (($Check1 >> 4) & 0x3C000 ) | ($Check1 0x3FFF);

    
$T1 = (((($Check1 0x3C0) << 4) | ($Check1 0x3C)) <<) | ($Check2 &
0xF0F );
    
$T2 = (((($Check1 0xFFFFC000) << 4) | ($Check1 0x3C00)) << 0xA) |
(
$Check2 0xF0F0000 );

    return (
$T1 $T2);
}
function 
CheckHash($Hashnum)
{
    
$CheckByte 0;
    
$Flag 0;

    
$HashStr sprintf('%u'$Hashnum) ;
    
$length strlen($HashStr);

    for (
$i $length 1;  $i >= 0;  $i --) {
        
$Re $HashStr{$i};
        if (
=== ($Flag 2)) {
            
$Re += $Re;
            
$Re = (int)($Re 10) + ($Re 10);
        }
        
$CheckByte += $Re;
        
$Flag ++;
    }

    
$CheckByte %= 10;
    if (
!== $CheckByte) {
        
$CheckByte 10 $CheckByte;
        if (
=== ($Flag 2) ) {
            if (
=== ($CheckByte 2)) {
                
$CheckByte += 9;
            }
            
$CheckByte >>= 1;
        }
    }

    return 
'7'.$CheckByte.$HashStr;
}

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