Файл: weplogs.ru/files/function.php
Строк: 218
<?php
    {
        $month = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
        $month_rus = array('Янв','Фев','Мар','Апр','Мая','Июн','Июл','Авг','Сент','Окт','Ноя','Дек');
        $timep = date("j M Y в H:i", $time);
        $timep = str_replace($month,$month_rus,$timep);
        return $timep;
    }
function navigation($total,$page,$url)
    {
        if($page-1 > 0)
            {
                $left='<span class="str_l"><a href="'.$url.''.($page-1).'">«</a></span>';
            }
        if($page+1 > 0 AND $page < $total)
            {
                $right = '<span class="str_l"><a href="'.$url.''.($page+1).'">»</a></span>';
            }
        if($page-3 > 0)
            {
                $first='<span class="str_l"><a href="'.$url.'1">1</a></span>[...]';
            }
        if($page-2 > 0)
            {
                $page2left='<span class="str_l"><a href="'.$url.''.($page-2).'">'.($page-2).'</a></span>';
            }
        if($page-1 > 0)
            {
                $page1left='<span class="str_l"><a href="'.$url.''.($page-1).'">'.($page-1).'</a></span>';
            }
        if($page+1 <= $total)
            {
                $page1right='<span class="str_l"><a href="'.$url.''.($page+1).'">'.($page + 1).'</a></span>';
            }
        if($page+2 <= $total)
            {
                $page2right='<span class="str_l"><a href="'.$url.''.($page+2).'">'.($page + 2).'</a></span>';
            }
        if($page+3 <= $total)
            {
                $page3right='[...]<span class="str_l"><a href="'.$url.''.($total).'">'.($total).'</a></span>';
            }
        echo '<div class="l1">'.$left.''.$first.$page2left.$page1left.'<span class="o">'.$page.'</span>'.$page1right.$page2right.$page3right.''.$right.'</div>';
    }
    
    
function wCache($content, $filename)
    {
        $fp = fopen('Cache/'.$filename, 'w');
        fwrite($fp, $content);
        fclose($fp);
    }
function unreg()
    {
        global $user_data;
        if($user_data)
            {
             header("Location: ../?");
            }
    }
function reg()
    {
        global $user_data;
        if(!$user_data)
            {
            header("Location: ../m/authentication");
            }
    }
function level($level)
    {
        global $user_data;
        if($user_data AND $user_data['level'] < $level OR !$user_data)
            {
                header("Location: ../?");
            }
    }
        
function filter($text)
    {
        global $mysqli;
        $text = htmlspecialchars($text);
        $text = str_replace("'", "'", $text);
        $text = str_replace('\', "\", $text);
        $text = str_replace("|", "I", $text);
        $text = str_replace("||", "I", $text);
        $text = str_replace("/\$/", "$", $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()
{
return true;
}  
function proxy()
    {
        if(isset($_SERVER['HTTP_VIA']))
            {
                return true;
            }
    }
function cy($url)
    {
        $url = str_replace("www.", "", $url);
        $ci_url = "http://bar-navig.yandex.ru/u?ver=2&show=32&url=http://www.".$url."/";
        $ci_data = implode("", file("$ci_url"));
        preg_match("/value="(.d*)"/", $ci_data, $ci);
        if ($ci[1] == "")
            {
                return 0;
            }
            else
            {
                return $ci[1];
            }
     }
     
///////////////////////////
function antispam_help($text)
 {
 $dom = array('www.','wap.'); //поддомены
 if(preg_match('#^(https?|ftp)://('.implode('|',$dom).')?'.str_replace('.', '.', $_SERVER['SERVER_NAME']).'#', $text[0]))
 return '<a href="'.$text[0].'">'.$text[0].'</a>';
 else
 return '[реклама]';
 }
//---------------------
 function antispam($text)
 {
 return preg_replace_callback("#(https?|ftp)://S+[^s.,>)];'"!?]#", 'antispam_help', $text);
 }
////////////////////////     
     
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',                                              // Курсив
            '#[red](.+?)[/red]#is',                                          // Красный
            '#[green](.+?)[/green]#is',                                      // Зеленый
            '#[blue](.+?)[/blue]#is',                                           // Синий
            '#[img](.+?)[/img]#is',    
            '#[center](.+?)[/center]#is',
            '#[u](.+?)[/u]#is',
            '#[del](.+?)[/del]#is',
            '#[big](.+?)[/big]#is',
            '#[small](.+?)[/small]#is'
        );
        $replace = array(
            '<b>$1</b>',                       // Жирный
            '<i>$1</i>',                       // Курсив
            '<span style="color:red">$1</span>',                               // Красный
            '<span style="color:green">$1</span>',                             // Зеленый
            '<span style="color:blue">$1</span>',                               // Синий
            '<img src="$1" alt="*" style="max-width:100%; border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; border-top-right-radius: 20px; border-top-left-radius: 20px;"/>',
            '<center>$1</center>',
            '<u>$1</u>',
            '<del>$1</del>',
            '<big>$1</big>',
            '<small>$1</small>'
       );
        return preg_replace($search, $replace, $text);
    }
    
    
function smail($text){
$i = '/Design/smail/'; // путь к смайлам
$text = strtr($text, array(
':)'=>'<img src="'.$i.'1.gif" alt=":)"/>',
':('=>'<img src="'.$i.'2.gif" alt=":("/>',
':P'=>'<img src="'.$i.'3.gif" alt=":P"/>',
':D'=>'<img src="'.$i.'4.gif" alt=":D"/>',
'O^'=>'<img src="'.$i.'5.gif" alt="O^"/>',
':ok:'=>'<img src="'.$i.'6.gif" alt=":ok:"/>',
));
return $text;
} 
    
    
    
$googlehost='toolbarqueries.google.com';
$googleua='Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.6) Gecko/20060728 Firefox/1.5';
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($String, 0x1505, 0x21);
    $Check2 = StrToNum($String, 0, 0x1003F);
    $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)) <<2 ) | ($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 (1 === ($Flag % 2)) {
            $Re += $Re;
            $Re = (int)($Re / 10) + ($Re % 10);
        }
        $CheckByte += $Re;
        $Flag ++;
    }
    $CheckByte %= 10;
    if (0 !== $CheckByte) {
        $CheckByte = 10 - $CheckByte;
        if (1 === ($Flag % 2) ) {
            if (1 === ($CheckByte % 2)) {
                $CheckByte += 9;
            }
            $CheckByte >>= 1;
        }
    }
    return '7'.$CheckByte.$HashStr;
}
function getch($url) { return CheckHash(HashURL($url)); }
function getPageRank($url) {
    global $googlehost,$googleua;
    $ch = getch($url);
    if ($fp) {
        $out = "GET /tbr?features=Rank&sourceid=navclient-ff&client=navclient-auto-ff&ch=$ch&q=info:$url HTTP/1.1rn";
        $out .= "User-Agent: $googleuarn";
        $out .= "Host: $googlehostrn";
        $out .= "Connection: Closernrn";
        fwrite($fp, $out);
        while (!feof($fp)) {
            $data = fgets($fp, 128);
            $pos = strpos($data, "Rank_");
            if($pos === false){
            } else{
                $pr=substr($data, $pos + 9);
                $pr=trim($pr);
                $pr=str_replace("n",'',$pr);
                if ($pr == "") {return 0;}
                else {
                return $pr;
                }
            }
         }
         fclose($fp);
     }
}    
    
    
    
    
function Seo_up(){
function count_day($d,$m,$y){ 
$thisday=intval((time()-mktime(0, 0, 0, $m, $d, $y))/86400);
if($thisday==0){$count_day=' [сегодня]';
} elseif($thisday==1){$count_day=' [вчера]';
} elseif($thisday==2){$count_day=' [позавчера]';
} elseif($thisday==3){$count_day=' [' .$thisday .' дня назад]';
} elseif($thisday==4){$count_day=' [' .$thisday .' дня назад]';
} else {$count_day=' [' .$thisday .' дней назад]';}
return $count_day;
}
function get_updates_pr() { 
@$xmldata = simplexml_load_file('http://pr-cy.ru/updates.xml');
return $xmldata;
}
$get_up=get_updates_pr();
$pr_exp=explode('.',$get_up->pr);
$yav_exp=explode('.',$get_up->yav);
$cy_exp=explode('.',$get_up->cy);
$pr_day=count_day($pr_exp[0],$pr_exp[1],$pr_exp[2]);
$yav_day=count_day($yav_exp[0],$yav_exp[1],$yav_exp[2]);
$cy_day=count_day($cy_exp[0],$cy_exp[1],$cy_exp[2]);
return '
<div class="li">
- <font color="red"><b>Я</b></font>ндекс ТИЦ: '.$cy_day.' '.$get_up->cy .'<br/>
- <font color="blue">G</font><font color="red">o</font><font color="yellow">o</font><font color="blue">g</font><font color="green">l</font><font color="red">e</font> PR: '.$pr_day .' '.$get_up->pr .'<br/>
- <font color="red"><b>Я</b></font>ндекс выдача: '.$yav_day.' '.$get_up->yav.'
</div>';
}    
    
?>