Просмотр файла includes/functions.php

Размер файла: 7.38Kb
<?php 
// by mides, icq: 529-899-6, mail: [email protected]

// вверх страниц
echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
echo '<html>';
echo '<head>';
echo '<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />';
echo '<title>'.$title.' - '.$config['title'].'</title>';
echo '<link href="../styles/'.$config['style'].'" rel="stylesheet" type="text/css" />';
echo '</head>';
echo '<body>';

// фильтрация
function sec($sec){
	$sec = htmlspecialchars(mysql_real_escape_string($sec));
	return $sec;
}

// фильтрация [цифры]
function num($num){
	$num = intval($num);
	return $num;
}

// показ заголовка
function tp($tp){
	echo '<div class="tp">'.$tp.'</div>';
	echo '<div class="s2" align="center">';
	$result = mysql_query("SELECT * FROM `adv` ORDER BY `id`");
	while($adv = mysql_fetch_assoc($result)){
 		if($adv['time'] <= time()){
			mysql_query("DELETE FROM `adv` WHERE `id` = '".$adv['id']."'");
		}
	echo '<a href="'.$adv['site_link'].'">'.$adv['site_name'].'</a><br/>';
 	}
	echo '</div>';
}

// показ ошибок
function error($error){
	echo '<div class="s1">Ошибка!</div><div class="s2">'.$error.'</div>';
}

// показ информации
function info($info){
	echo '<div class="s1">Информация</div><div class="s2">'.$info.'</div>';
}

// навигация "на главную"
function nav(){
	echo '<div class="s1">Навигация</div><div class="s2"><a href="../">на главную</a></div>';
}

// навигация "одна ссылка + на главную"
function nav2($link, $link_name){
	echo '<div class="s1">Навигация</div><div class="s2"><a href="'.$link.'">'.$link_name.'</a><br/><a href="../">на главную</a></div>';
}

// постраничная навигация "пред, след"
function navig2($page, $link, $pages){
if($page > 1) echo '&larr;<a href="'.$link.'page='.($page-1).'">пред.</a>|';
if($page < $pages) echo '<a href="'.$link.'page='.($page+1).'">след.</a>&rarr;<br/>';
}

// постраничная навигация "1, 2, 3..."
function navig($page, $link, $pages){
	if($pages > 1){
		echo 'cтраницы:<br/>';
		for($i = 1; $i <= $pages; $i++){
			if($i != $page){
				echo '<a href="'.$link.'page='.$i.'">'.$i.'</a> ';
			}else{
				echo '<u>'.$i.'</u> '; // выводим активую страницу текстом
			}
		}
		echo '<br/>';
	}else{
		echo 'cтраницы:<br/><u>1</u><br/>';
	}	
}

function bb($msg){	
	// smiles
	$msg = str_replace(':)', '<img src="../images/smiles/1.gif" alt="" />', $msg);
	$msg = str_replace(':-)', '<img src="../images/smiles/2.gif" alt="" />', $msg);
	$msg = str_replace(';))', '<img src="../images/smiles/3.gif" alt="" />', $msg);
	$msg = str_replace(':sad', '<img src="../images/smiles/4.gif" alt="" />', $msg);
	$msg = str_replace(';)', '<img src="../images/smiles/5.gif" alt="" />', $msg);
	$msg = str_replace('%0', '<img src="../images/smiles/6.gif" alt="" />', $msg);
	$msg = str_replace(':(', '<img src="../images/smiles/7.gif" alt="" />', $msg);
	$msg = str_replace(':-(', '<img src="../images/smiles/8.gif" alt="" />', $msg);
	$msg = str_replace(':yy', '<img src="../images/smiles/9.gif" alt="" />', $msg);
	$msg = str_replace(':sho', '<img src="../images/smiles/10.gif" alt="" />', $msg);
	$msg = str_replace(':o_o', '<img src="../images/smiles/11.gif" alt="" />', $msg);
	$msg = str_replace(':crazy', '<img src="../images/smiles/12.gif" alt="" />', $msg);
	$msg = str_replace(':d', '<img src="../images/smiles/13.gif" alt="" />', $msg);
	$msg = str_replace(':-d', '<img src="../images/smiles/14.gif" alt="" />', $msg);
	$msg = str_replace(':peace', '<img src="../images/smiles/15.gif" alt="" />', $msg);
	$msg = str_replace(':flud', '<img src="../images/smiles/16.gif" alt="" />', $msg);
	$msg = str_replace(':closed', '<img src="../images/smiles/17.gif" alt="" />', $msg);
	$msg = str_replace(':angry', '<img src="../images/smiles/18.gif" alt="" />', $msg);
	$msg = str_replace(':bravo', '<img src="../images/smiles/19.gif" alt="" />', $msg);
	$msg = str_replace(':ban', '<img src="../images/smiles/20.gif" alt="" />', $msg);
	$msg = str_replace(':f', '<img src="../images/smiles/21.gif" alt="" />', $msg);
	$msg = str_replace(':welcome', '<img src="../images/smiles/22.gif" alt="" />', $msg);
	$msg = str_replace(':good', '<img src="../images/smiles/23.gif" alt="" />', $msg);
	$msg = str_replace(':ubanned', '<img src="../images/smiles/24.gif" alt="" />', $msg);
	$msg = str_replace(':spam', '<img src="../images/smiles/25.gif" alt="" />', $msg);
	$msg = str_replace(':shut', '<img src="../images/smiles/26.gif" alt="" />', $msg);
	$msg = str_replace(':shock', '<img src="../images/smiles/27.gif" alt="" />', $msg);
	$msg = str_replace(':read', '<img src="../images/smiles/28.gif" alt="" />', $msg);
	$msg = str_replace(':overlook', '<img src="../images/smiles/29.gif" alt="" />', $msg);
	$msg = str_replace(':oops', '<img src="../images/smiles/30.gif" alt="" />', $msg);
	$msg = str_replace(':?', '<img src="../images/smiles/31.gif" alt="" />', $msg);
	$msg = str_replace(':@', '<img src="../images/smiles/32.gif" alt="" />', $msg);
	$msg = str_replace(';/', '<img src="../images/smiles/33.gif" alt="" />', $msg);
	$msg = str_replace(':off', '<img src="../images/smiles/34.gif" alt="" />', $msg);
	$msg = str_replace(':lol', '<img src="../images/smiles/35.gif" alt="" />', $msg);
	$msg = str_replace(':hack', '<img src="../images/smiles/36.gif" alt="" />', $msg);
	$msg = str_replace(':sorry', '<img src="../images/smiles/37.gif" alt="" />', $msg);
	
	// bb-codes
	
	$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("#\[white\](.*?)\[/white\]#si", "<span style=\"color: white\">\\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("#\[code\](.*?)\[/code\]#si", "<span style=\"color: #000\">\\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);
	//$msg = eregi_replace("((https?|ftp)://[[:alnum:]_=/-]+(\\.[[:alnum:]_=/-]+)*(/[[:alnum:]+&amp;._=/~%#]*(\\?[[:alnum:]?+&amp;_=/%#]*)?)?)", "<a href=\"\\1\">\\1</a>", $msg);
	
	return nl2br($msg);
} 

















?>