Файл: function.php
Строк: 160
<?
function user($id){
$ank = mysql_fetch_array(mysql_query("SELECT * FROM `user` WHERE `id` = '$id'"));
if($ank['date'] < (time()-600)) $tut = '';
elseif($ank['date'] < (time()-60))
{$tut='<span class="cGrey">*</span>';
}else{
$tut = '';}
return "<img src='/img/user".($ank['date'] <= time()-600?"off":null).".png'> <a href='/$id'>$ank[name]</a><span class='c".($ank['status']==0?"'>":null)."".($ank['status']==2?"Moder'>[мод]":null)."".($ank['status']==3?"аdmin'>[соз]":null)."</span>".$tut."";}
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=15){
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){
if ($page<1)$page=1;
echo'<div class="umenu"><div class="page">';
if ($page!=1)echo " <a href="".$link."page=1" title='Страница №1' class='button_one'>1</a> ";
else echo " <b>1</b> ";
for ($ot=-3; $ot<=3; $ot++){
if ($page+$ot>1 && $page+$ot<$k_page){
if ($ot==-3 && $page+$ot>2)echo " .. ";
if ($ot!=0)echo " <a href="".$link."page=".($page+$ot)."" title='Страница №".($page+$ot)."' class='button_one'>".($page+$ot)."</a> ";
else echo " <b>".($page+$ot)."</b> ";
if ($ot==3 && $page+$ot<$k_page-1)echo " .. ";}}
if ($page!=$k_page)echo " <a href="".$link."page=end" title='Страница №$k_page' class='button_one'>$k_page</a> ";
elseif ($k_page>1)echo " <b>$k_page</b> ";
echo'</div></div>';
}
function my_esc($str){
return mysql_real_escape_string($str);}
function maketime($string) {
if($string < 3600){
$string = sprintf("%02d:%02d", (int)($string / 60) % 60, $string % 60);
}else{
$string = sprintf("%02d:%02d:%02d", (int)($string / 3600) % 24, (int)($string / 60) % 60, $string % 60);};
return $string;};
function err_game($msg){
echo "<b><div class='umenu'><img src='img/err.png' /> <span class='cRed'>$msg</span></div></b>";}
function msg_game($msg){echo "<b><div class='umenu'><img src='img/ok.png' /> <span class='cDGreen'>$msg</span></div></b>";}
function vremja($time=NULL){
$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 br($str,$br='<br />'){return preg_replace("#((<br( ?/?)>)|n|r)+#i",$br, $str);}
function smiles($str) {
$str = preg_replace('/:)|:-)|:smile:/', '<img src="/img/smiles/smiley-smile.png" alt="Smile" />', $str);
$str = preg_replace('/:D|:-D/', '<img src="/img/smiles/smiley-grin.png" alt="Smile" />', $str);
$str = preg_replace('/:(|:-(/', '<img src="/img/smiles/smiley-sad.png" alt="Smile" />', $str);
$str = preg_replace('/;-(|;(/', '<img src="/img/smiles/smiley-cry.png" alt="Smile" />', $str);
$str = preg_replace('/;)|;-)/', '<img src="/img/smiles/smiley-wink.png" alt="Smile" />', $str);
$str = preg_replace('/8)|8-)/', '<img src="/img/smiles/smiley-cool.png" alt="Smile" />', $str);
$str = preg_replace('/=O|O_O/', '<img src="/img/smiles/smiley-eek.png" alt="Smile" />', $str);
$str = str_replace('$)', '<img src="/img/smiles/smiley-money.png" alt="Smile" />', $str);
$str = str_replace(':*', '<img src="/img/smiles/smiley-kiss.png" alt="Smile" />', $str);
$str = preg_replace('/:P/', '<img src="/img/smiles/smiley-razz.png" alt="Smile" />', $str);
$str = str_replace(':|', '<img src="/img/smiles/smiley-netural.png" alt="Smile" />', $str);
$str = preg_replace('/:Z/', '<img src="/img/smiles/smiley-sleep.png" alt="Smile" />', $str);
$str = preg_replace('/:lol:/', '<img src="/img/smiles/smiley-lol.png" alt="Smile" />', $str);
$str = preg_replace('/:rofl:/', '<img src="/img/smiles/smiley-yell.png" alt="Smile" />', $str);
$str = str_replace(':&', '<img src="/img/smiles/smiley-confuse.png" alt="Smile" />', $str);
$str = str_replace(':>', '<img src="/img/smiles/smiley-evil.png" alt="Smile" />', $str);
$str = str_replace(':@', '<img src="/img/smiles/smiley-mad.png" alt="Smile" />', $str);
$str = preg_replace('/:angel:/', '<img src="/img/smiles/smiley-angel.png" alt="Smile" />', $str);
$str = preg_replace('/:bla:/', '<img src="/img/smiles/smiley-draw.png" alt="Smile" />', $str);
$str = preg_replace('/:fat:/', '<img src="/img/smiles/smiley-fat.png" alt="Smile" />', $str);
$str = preg_replace('/:kitty:/', '<img src="/img/smiles/smiley-kitty.png" alt="Smile" />', $str);
$str = preg_replace('/:green:/', '<img src="/img/smiles/smiley-mr-green.png" alt="Smile" />', $str);
$str = str_replace('%)', '<img src="/img/smiles/smiley-nerd.png" alt="Smile" />', $str);
$str = preg_replace('/:red:/', '<img src="/img/smiles/smiley-red.png" alt="Smile" />', $str);
$str = preg_replace('/:roll:/', '<img src="/img/smiles/smiley-roll.png" alt="Smile" />', $str);
$str = preg_replace('/:sweat:/', '<img src="/img/smiles/smiley-sweat.png" alt="Smile" />', $str);
$str = preg_replace('/:slim:/', '<img src="/img/smiles/smiley-slim.png" alt="Smile" />', $str);
$str = preg_replace('/:surprise:/', '<img src="/img/smiles/smiley-surprise.png" alt="Smile" />', $str);
$str = preg_replace('/:wink:/', '<img src="/img/smiles/smiley-wink.png" alt="Smile" />', $str);
$str = str_replace('<)', '<img src="/img/smiles/smiley-twist.png" alt="Smile" />', $str);
$str = str_replace(':]', '<img src="/img/smiles/smiley-zipper.png" alt="Smile" />', $str);
return $str;}
function output_text($str){
$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('/[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("/(http://)?([[:alnum:]]|_){3,30}(s+)?(.|,)(s+)?([[:alnum:]]|){3,30}(s)?(.|,)?(s)?([[:alnum:]]){2,4}/i", "", $str);
$str = smiles($str);
$str = br($str);
return $str;}
?>