<?php
ob_start();
function data($time){
$month = array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
$month_rus = array('Янв','Фев','Мар','Апр','Мая','Июн','Июл','Авг','Сент','Окт','Ноя','Дек');
$timep = date("j M в H:i", $time);
$timep = str_replace($month,$month_rus, $timep);
return $timep;
}

function navigation($all,$napage,$page,$url,$total){
if(!($all<=$napage)){
echo '<div class="faz">Стр:&nbsp;';
if($page-1>0)echo'<span class="str_l"><b><a href="'.$url.'page='.($page-1).'"><</a></b></span>&nbsp;';
if($page-2>0)$first='<span class="str_l"><a href="'.$url.'page=1">1</a></span>&nbsp;[...]&nbsp;';
if($page-1>0)$page1left='<span class="str_l"><a href="'.$url.'page='.($page-1).'">'.($page-1).'</a></span>&nbsp;';
if($page+1<=$total)$page1right='<span class="str_l">&nbsp;<a href="'.$url.'page='.($page+1).'">'.($page + 1).'</a></span>&nbsp;';
if($page+2<=$total)$page2right='[...]&nbsp;<span class="str_t"><a href="'.$url.'page='.($total).'">'.($total).'</a></span>&nbsp;';
echo''.$first.''.$page1left.'<span class="o">'.$page.'</span>'.$page1right.''.$page2right.'&nbsp';
if($page+1>0 && $page<$total)echo '<span class="str_l"><a href="'.$url.'page='.($page+1).'">></a></span>';
echo'</div>';
}}

function unreg() {     
global $user_data; 
if($user_data){ 
header("Location: ../index.php"); 
}}

function reg(){ 
global $user_data; 
if(!$user_data){ 
header("Location: ../str/enter.php"); 
}}

function level($level){ 
global $user_data; 
if($user_data AND $user_data['level'] < $level OR !$user_data){ 
header("Location: ../index.php"); 
}}

function filter($t){ 
$t = trim(htmlspecialchars($t)); 
$t = str_replace("%","",$t); 
$t = str_replace("\r","",$t);
$t = str_replace("\n","<br>",$t);
$t = str_replace("|","&#166;",$t);
$t = preg_replace("/s(w+s)1/i","$1",$t);
return $t; 
}

function stats($t){ 
$t = intval($t); 
$t = number_format($t);
$t = str_replace(","," ",$t);
return $t; 
}

function password(){
$s = str_split('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789');
$pass = '';
for ($i = 0; $i <= 7; $i++) {
$rand = mt_rand(5,25);
$pass .= $s[$rand];
} 
return $pass;
}

function key_rand(){
$s = str_split('aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ0123456789');
$key = '';
for ($i = 0; $i <= 15; $i++){
$rand = mt_rand(2,30);
$key .= $s[$rand];
} 
return $key;
}

$systema = mysql_query("SELECT * FROM `".$prefix."settings`");
$set = array();
while ($query = mysql_fetch_array($systema)){
$set[$query[0]] = $query[1];
}


if(isset($_COOKIE['login']) AND isset($_COOKIE['password'])){
$user = mysql_query("SELECT * FROM `".$prefix."users` WHERE `login`='".htmlspecialchars(mysql_real_escape_string(trim($_COOKIE['login'])))."' AND `password`='".htmlspecialchars(mysql_real_escape_string(trim($_COOKIE['password'])))."'");
if(mysql_num_rows($user) > 0){
$user_data = mysql_fetch_array($user);
}}

$pages = ($user_data) ? $user_data['pages'] : $set['pages'];
$page_platforms = ($user_data) ? $user_data['page_platforms'] : $set['page_platforms'];
$page_sait = ($user_data) ? $user_data['page_sait'] : $set['page_sait'];
$page_top = ($user_data) ? $user_data['page_top'] : $set['page_top'];
$page_sait_comments = ($user_data) ? $user_data['page_sait_comments'] : $set['page_sait_comments'];
$page_news = ($user_data) ? $user_data['page_news'] : $set['page_news'];
$page_nc = ($user_data) ? $user_data['page_newsc'] : $set['page_newsc'];
$page_users = $set['page_users'];

?>