<?php
// by mides, 1da.su
include_once 'db.php';
$setting_r = mysql_query("SELECT * FROM `settings`");
$set = mysql_fetch_assoc($setting_r);
if (isset($_COOKIE['ulogin']) and isset($_COOKIE['upass'])) {
$ulogin = check($_COOKIE['ulogin']);
$upass = check($_COOKIE['upass']);
if ($ulogin != $set['login'] or $upass != $set['pass']) {
setcookie('ulogin', '', time() - 86400*31, '/');
setcookie('upass', '', time() - 86400*31, '/');
}
}
function tp($title){
echo '<div class="title">'.$title.'</div><div class="main">';
return;
}
function error($error){
echo '<div class="title">Ошибка!</div><div class="main">'.$error;
return;
}
function info($info){
echo '<div class="title">Информация</div><div class="main">'.$info;
return;
}
function nav_main(){
echo '</div><div class="navigation"><a href="index.php?act=main">На главную</a></div>';
return;
}
function nav($link){
echo '</div><div class="navigation"><a href="'.$link.'">Назад</a><br /><a href="index.php?act=main">На главную</a></div>';
return;
}
function nav2($link, $link_name){
echo '</div><div class="navigation"><a href="'.$link.'">'.$link_name.'</a><br /><a href="index.php?act=main">На главную</a></div>';
return;
}
function check($check){
$check = htmlspecialchars(mysql_real_escape_string($check));
$search = array('|', '\'', '$', '\\', '^', '%', '`', "\0", "\x00", "\x1A", "⁄∩");
$replace = array('|', ''', '$', '\', '^', '%', '`', '', '', '', '');
$msg = str_replace($search, $replace, $msg);
$msg = stripslashes(trim($msg));
return $check;
}
function generate($number){
$arr = array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','r','s','t','u','v','x','y','z','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','R','S','T','U','V','X','Y','Z','1','2','3','4','5','6','7','8','9','0');
// Генерируем пароль
$pass = '';
for($i = 0; $i < $number; $i++){
// Вычисляем случайный индекс массива
$index = rand(0, count($arr) - 1);
$pass .= $arr[$index];
}
return $pass;
}
function navig($page, $link, $pages) {
if ($pages > 1) {
echo '</div><div class="main">Cтр.: ';
for ($k = 1; $k <= $pages; $k++) {
if ( $k == 1 or $k == $pages or 2 >= ($page - $k) and -2 <= ($page - $k) ) {
if ($k == $page) {
$write = '<u>'.$k.'</u> ';
} else {
$write = '<a href="'.$link.'p='.$k.'">'.$k.'</a> ';
}
echo $write;
}
}
}
}
function bb($msg){
$result_sm = mysql_query("SELECT * FROM `smiles`");
while ($s = mysql_fetch_assoc($result_sm)) {
$msg = str_replace($s['code'], '<img src="'.$s['path'].'" alt="" />', $msg);
}
$msg = preg_replace("#\[url=(.*?)\](.*?)\[/url\]#si", "<a href=\"\\1\">\\2</a>", $msg);
$msg = preg_replace("#\[red\](.*?)\[/red\]#si", "<span style=\"color: red\">\\1</span>", $msg);
$msg = preg_replace("#\[blue\](.*?)\[/blue\]#si", "<span style=\"color: blue\">\\1</span>", $msg);
$msg = preg_replace("#\[black\](.*?)\[/black\]#si", "<span style=\"color: black\">\\1</span>", $msg);
$msg = preg_replace("#\[green\](.*?)\[/green\]#si", "<span style=\"color: green\">\\1</span>", $msg);
$msg = preg_replace("#\[orange\](.*?)\[/orange\]#si", "<span style=\"color: orange\">\\1</span>", $msg);
$msg = preg_replace("#\[pink\](.*?)\[/pink\]#si", "<span style=\"color: pink\">\\1</span>", $msg);
$msg = preg_replace("#\[gray\](.*?)\[/gray\]#si", "<span style=\"color: gray\">\\1</span>", $msg);
$msg = preg_replace("#\[big\](.*?)\[/big\]#si", "<span style=\"font-size: 20px\">\\1</span>", $msg);
$msg = preg_replace("#\[small\](.*?)\[/small\]#si", "<span style=\"font-size: 8px\">\\1</span>", $msg);
$msg = preg_replace("#\[b\](.*?)\[/b\]#si", "<b>\\1</b>", $msg);
$msg = preg_replace("#\[u\](.*?)\[/u\]#si", "<u>\\1</u>", $msg);
$msg = preg_replace("#\[i\](.*?)\[/i\]#si", "<i>\\1</i>", $msg);
$msg = preg_replace("#\[strike\](.*?)\[/strike\]#si", "<strike>\\1</strike>", $msg);
return nl2br($msg);
}
?>