Вход Регистрация
Файл: blog_ecsx/private.files/core.file.php
Строк: 186
<?php

$db 
= new mysqli('localhost''tje4_test''qwqwqw11''tje4_test');

$db->query("SET NAMES 'UTF8'"); 

if(
$db->connect_errno){ die('Ошибка подключения '.$db ->connect_error);

}

$act = isset($_GET['act']) ? htmlspecialchars($_GET['act']) : '';

session_start(); 

ob_start(); 


if(isset(
$_COOKIE['login'])  && isset($_COOKIE['password'])) {

$user $db->query("SELECT * FROM `users` WHERE `login` = '".text($_COOKIE['login'])."' && `password` = '".text($_COOKIE['password'])."' LIMIT 1") ->fetch_assoc();

$db->query("UPDATE `users` SET `ip` = '$_SERVER[REMOTE_ADDR]' WHERE `id` = '$user[id]'");

$db->query("UPDATE `users` SET `online` = '".time()."' WHERE `id` = '$user[id]'");


/*if(($user['login'] !== $_COOKIE['login']) or ($user['password'] !== $_COOKIE['password'])){

setcookie("login", "", time() - 3600*24*30*12, "/");

setcookie("password", "", time() - 3600*24*30*12, "/");

msg('Ошибка прочтения COCKIE данных');

header('Location: /index.php');*/



}

function 
text($m){ 
    
$m htmlspecialchars($m); 
  
  
$m mysql_escape_string($m); 
  
  return 
$m
}

function 
num($m){ 

 
$m intval($m); 
   
 
$m abs($m); 
 
   return 
$m



function 
msg($sms){ 
    echo 
'<div class="error"> <center>'.$sms.'</center> </div>'



function 
auth() {

global 
$user;

if(isset(
$user['id'])) header('Location: /index.php');

}

function 
no_auth() {

global 
$user;

if(!isset(
$user['id'])) header('Location: /index.php');

}

function  
timer($time=NULL){ 
    if (
$time == NULL)$time time(); 
 
   
$timep="".date("j M Y в H:i"$time).""
    
    
$time_p[0]=date("j n Y"$time); 
   
    
$time_p[1]=date("H:i"$time); 

     

    if (
$time_p[0] == date("j n Y"))$timep date("H:i:s"$time); 

    if (
$time_p[0] == date("j n Y"time()-60*60*24))$timep "Вчера в $time_p[1]"

     
    
$timep=str_replace("Jan","Января",$timep); 

    
$timep=str_replace("Feb","Февраля",$timep); 

    
$timep=str_replace("Mar","Марта",$timep); 

    
$timep=str_replace("May","Мая",$timep); 

    
$timep=str_replace("Apr","Апреля",$timep); 

    
$timep=str_replace("Jun","Июня",$timep); 

    
$timep=str_replace("Jul","Июля",$timep); 

    
$timep=str_replace("Aug","Августа",$timep); 

    
$timep=str_replace("Sep","Сентября",$timep); 

    
$timep=str_replace("Oct","Октября",$timep); 

    
$timep=str_replace("Nov","Ноября",$timep); 

    
$timep=str_replace("Dec","Декабря",$timep); 

    return 
$timep
}

function 
page($k_page=1){ // Выдает текущую страницу

$page=1;

if (isset(
$_GET['page'])){

if (
$_GET['page']=='end')$page=intval($k_page);elseif(is_numeric($_GET['page'])) $page=intval($_GET['page']);}

if (
$page<1)$page=1;

if (
$page>$k_page)$page=$k_page;

return 
$page;}



function 
k_page($k_post=0,$k_p_str=10){ // Высчитывает количество страниц

if ($k_post!=0){$v_pages=ceil($k_post/$k_p_str);return $v_pages;}

else return 
1;}


function 
str($link='?',$k_page=1,$page=1){ // Вывод номеров страниц (только на первый взгляд кажется сложно ;))

echo '<div class="razd4">';



if (
$page<1)$page=1;

if (
$page!=1)echo "<a class='nav_btn' href="".$link."page=1" title='Первая страница'>&lt;&lt;</a> ";

if (
$page!=1)echo "<a class='nav_btn' href="".$link."page=1" title='Страница №1'>1</a> ";else echo "<span class='nav_btn'>1</span> ";

for (
$ot=-3$ot<=3$ot++){

if (
$page+$ot>&& $page+$ot<$k_page){

if (
$ot==-&& $page+$ot>2)echo " ";

if (
$ot!=0)echo "<a class='nav_btn' href="".$link."page=".($page+$ot)."" title='Страница №".($page+$ot)."'>".($page+$ot)."</a> ";else echo "<span class='nav_btn'>".($page+$ot)."</span> ";

if (
$ot==&& $page+$ot<$k_page-1)echo " ";}}

if (
$page!=$k_page)echo "<a class='nav_btn' href="".$link."page=end" title='Страница №$k_page'>$k_page</a> ";elseif ($k_page>1)echo "<span class='nav_btn'>$k_page</span>";

if (
$page!=$k_page)echo "<a class='nav_btn' href="".$link."page=end" title='Последняя страница'> &gt;&gt;</a> ";

echo 
'</div><div class="razdel"></div>';

}

function 
who($id 0) {    
    
global 
$db;

$us $db->query("SELECT * FROM `users` WHERE `id` = '$id' LIMIT 1")->fetch_assoc();

if(
$us['sex'] == '1' && $us['online'] <= time()-600$ico '<img src="/design.files/moff.png" width="14px" alt="off" />';
    
elseif(
$us['sex'] == '2' && $us['online'] <= time()-600$ico '<img src="/design.files/woff.png" width="14px" alt="off" />';
    
elseif(
$us['sex'] == '1' && $us['online'] > time()-600$ico '<img src="/design.files/mon.png" width="14px" alt="on" />';
    
elseif(
$us['sex'] == '2' && $us['online'] > time()-600$ico '<img src="/design.files/won.png" width="14px" alt="on" />';


if(
$us['prava'] == '1'){ $np='';}
    
elseif(
$us['prava'] == '2'){ $np  '<font color="red"> Администратор</font>'; }
    
elseif(
$us['prava'] == '3'){ $np  '<font color="orange"> Создатель</font>';}
    
    
    return (empty(
$us)?'БОТ':' '.$ico.' <a href="/user/'.$us['id'].'"> '.$us['login'].' '.$np.'</a>');
}


function 
cat($id 0) {    
    
global 
$db;

$cat $db->query("SELECT * FROM `category` WHERE `id` = '$id' LIMIT 1")->fetch_assoc();

return (empty(
$cat)?'NOT FOUND':' '.$cat['name'].'');

}

function 
art($id 0) {    
    
global 
$db;

$cat $db->query("SELECT * FROM `articles` WHERE `id` = '$id' LIMIT 1")->fetch_assoc();

return (empty(
$cat)?'NOT FOUND':' '.$cat['name'].'');

}

function 
cutStr($str$lenght 100$end '...'$charset 'UTF-8'$token '~') {
   
 
$str strip_tags($str);
 
   if (
mb_strlen($str$charset) >= $lenght) {
    
   
$wrap wordwrap($str$lenght$token);
       
 
$str_cut mb_substr($wrap0mb_strpos($wrap$token0$charset), $charset);    
      
  return 
$str_cut .= $end;
  
  } else {
       
 return 
$str;
    }




function 
br($msg,$br='<br />'){return preg_replace("#((<br( ?/?)>)|n|r)+#i",$br$msg);} // переносы строк

function bb($str)

{
    
$msg strip_tags(stripslashes(htmlspecialchars($str)));
    
$str=htmlentities($strENT_QUOTES'UTF-8'); // преобразуем все к нормальному перевариванию браузером
    
$str=eregi_replace("((https?|ftp|http)://[[:alnum:]_=/-]+(\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&._=/%]*(\?[[:alnum:]?+&_=/%]*)?)?).(ru|org|net|info|org.ua|h2m.ru|wen.ru|com|mobi|me|us|in|su|ru.com|kiev.ua|com.ua|pp.ua|co.ua|biz.ua|kz|com.kz|org.kz|am|co.am|com.am|net.am|org.am|md|pw|cc|tv|name|tel|info|pro|xxx|fm|lt|ch|cz|be|at|li|pl|im|lu|co|mx|asia|ws|io)""Реклама запрещена"$msg);
    
$str preg_replace('/[b](.+)[/b]/isU''<b>$1</b>'$str); 
    
$str preg_replace('/[u](.+)[/u]/isU''<span style="text-decoration:underline;">$1</span>'$str); 
    
$str preg_replace('/[s](.+)[/s]/isU''<s>$1</s>'$str); 
    
$str preg_replace('/[c](.+)[/c]/isU''<center>$1</center>'$str); 
    
$str preg_replace('/[i](.+)[/i]/isU''<i>$1</i>'$str); 

$str preg_replace('/[big](.+)[/big]/isU''<span style="font-size:large;">$1</span>'$str); 
    
$str preg_replace('/[small](.+)[/small]/isU''<span style="font-size:small;">$1</span>'$str); 
    
$str preg_replace('/[color=(.+)](.+)[/color]/isU''<span style="color:$1;">$2</span>'$str); 
    
$str preg_replace('/[link=(.+)](.+)[/link]/isU''<img src="/design.files/world.png"> <a href="$1">$2</a>'$str); 
    
$str preg_replace('/[img](.+)[/img]/isU''<img src=$1>'$str); 
    
$str preg_replace('/[input-text](.+)[/input-text]/isU''<input type=text value=$1>'$str); 

$str preg_replace('/[marq](.+)[/marq]/isU''<marquee>$1</marquee>'$str); 
    
$str preg_replace('/[marq](.+)[/marq]/isU''<marquee>$1</marquee>'$str); 

$str str_replace('[br]','<br>',$str);
    
$str=br($str); // переносы строк
    
return $str// возвращаем обработанную строку
}




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