<?php
function bb_code($msg){
$msg=stripslashes($msg);
$msg=trim($msg);
$msg=str_replace("\r\n"," <br/>",$msg);
$msg=str_replace("
"," <br/>",$msg);
$msg = preg_replace('#\[big\](.*?)\[/big\]#si', '<big>\1</big>', $msg);
$msg = preg_replace('#\[b\](.*?)\[/b\]#si', '<b>\1</b>', $msg);
$msg = preg_replace('#\[i\](.*?)\[/i\]#si', '<i>\1</i>', $msg);
$msg = preg_replace('#\[u\](.*?)\[/u\]#si', '<u>\1</u>', $msg);
$msg = preg_replace('#\[small\](.*?)\[/small\]#si', '<small>\1</small>', $msg);
$msg = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color:#FF0000">\1</span>', $msg);
$msg = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color:#00FF00">\1</span>', $msg);
$msg = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color:#0000FF">\1</span>', $msg);
$msg = preg_replace('#\[yellow\](.*?)\[/yellow\]#si', '<span style="color:#FFFF00">\1</span>', $msg);
$msg = preg_replace('#\[quote\](.*?)\[/quote\]#si', '<q>\1</q>', $msg);
$msg = preg_replace('#\[del\](.*?)\[/del\]#si', '<del>\1</del>', $msg);
$msg=preg_replace("!(http://[\S]+)([\s]|$)!i","<a href=\"\\1\">\\1</a> ",$msg);
$msg = preg_replace('#\[bgblue\](.*?)\[/bgblue\]#si', '<span style="background:blue;color:white;">\1</span>', $msg);
$msg = preg_replace('#\[bgred\](.*?)\[/bgred\]#si', '<span style="background:red;color:white;">\1</span>', $msg);
$msg = preg_replace('#\[bggreen\](.*?)\[/bggreen\]#si', '<span style="background:green;color:white;">\1</span>', $msg);
return $msg;
}
///
function badwords($msg){
if(file_exists($_SERVER['DOCUMENT_ROOT'].'/data/badwords.dat')){
$mat = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/data/badwords.dat');
$arr_mat = explode("|",$mat);
foreach($arr_mat as $value){
if($value != "") {
$msg = preg_replace("|$value|iu","[мат]",$msg);
}}}
return $msg;
}
///
function russian($text){
$text=htmlspecialchars($text);
$text=stripslashes($text);
return $text;
}
///
function smiles($msg){
$msg=htmlspecialchars($msg);
$msg=stripslashes($msg);
$msg=trim($msg);
$msg=str_replace(":)",' <img src="../images/smiles/).gif" alt=":)"/> ',$msg);
$msg=str_replace(":(",' <img src="../images/smiles/(.gif" alt=":("/> ',$msg);
$msg=str_replace(".превед.",' <img src="../images/smiles/preved.gif" alt=".превед."/> ',$msg);
$msg=str_replace(".мат.",' <img src="../images/smiles/censored.gif" alt=".мат."/> ',$msg);
$msg=str_replace("[мат]",' <img src="../images/smiles/censored.gif" alt="[мат]"/> ',$msg);
$msg=str_replace(".качаюсь.",' <img src="../images/smiles/kachaius.gif" alt=".качаюсь."/> ',$msg);
$msg=str_replace(".смтел.",' <img src="../images/smiles/smtel.gif" alt=".смтел."/> ',$msg);
$msg=str_replace(".ловрыб.",' <img src="../images/smiles/lovrib.gif" alt=".ловрыб."/> ',$msg);
$msg=str_replace(".фингал.",' <img src="../images/smiles/fingal.gif" alt=".фингал."/> ',$msg);
$msg=str_replace(".дуэль.",' <img src="../images/smiles/duel.gif" alt=".дуэль."/> ',$msg);
$msg=str_replace(".dj.",' <img src="../images/smiles/dj.gif" alt=".dj."/> ',$msg);
$msg=str_replace(".урааа.",' <img src="../images/smiles/uraaa.gif" alt=".урааа."/> ',$msg);
$msg=str_replace(".беее.",' <img src="../images/smiles/beee.gif" alt=".беее."/> ',$msg);
$msg=str_replace(".ого.",' <img src="../images/smiles/ogo.gif" alt=".ого."/> ',$msg);
$msg=str_replace(".холодно.",' <img src="../images/smiles/holodno.gif" alt=".холодно."/> ',$msg);
$msg=str_replace(".зубы.",' <img src="../images/smiles/zubi.gif" alt=".зубы."/> ',$msg);
$msg=str_replace(".поцелуй.",' <img src="../images/smiles/pocelui.gif" alt=".поцелуй."/> ',$msg);
return $msg;
}
function extract16color($color16){
$mask16=array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
$color_mask=array("r","g","b");
$true_color=array("r"=>0,"g"=>0,"b"=>0);
$color16=substr($color16,1);
for($icm=0; $icm<count($color_mask); $icm++){
$color16_temp=array(substr($color16,($icm*2),1),substr($color16,($icm*2)+1,1));
for ($ic=0; $ic<2; $ic++){
for($i=0; $i<count($mask16); $i++){
if ($color16_temp[$ic]==$mask16[$i]){
$color16_temp[$ic]=$i;
break;
}
}
}
$true_color[$color_mask[$icm]]=((int)$color16_temp[0]*16)+(int)$color16_temp[1];
}
return $true_color;
}
function make16color($color10){
$mask16=array("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F");
$color_mask=array("r","g","b");
$true_color="#";
for($icm=0; $icm<count($color_mask); $icm++){
$color10_temp=(int)$color10[$color_mask[$icm]];
$true_color.=$mask16[(int)($color10_temp/16)];
$true_color.=$mask16[$color10_temp%16];
}
return $true_color;
}
function GradientText($text,$sColor,$eColor){
$color_mask=array("r","g","b");
$color_move=array("r"=>0,"g"=>0,"b"=>0);
$color_add=array("r"=>0,"g"=>0,"b"=>0);
$word=array();
$length=strlen($text);
$output="";
$Gzip="";
$current_color="#000000";
$max=0;
if($length>0){
$sColor=extract16color($sColor);
$eColor=extract16color($eColor);
$cColor=$sColor;
for($i=0; $i<count($color_mask); $i++){
$temp=$sColor[$color_mask[$i]]-$eColor[$color_mask[$i]];
$color_add[$color_mask[$i]]=abs($temp);
if(abs($temp)>$max){
$max=abs($temp);
}
if($temp<0){
$color_move[$color_mask[$i]]=1;
} else if ($temp>0){
$color_move[$color_mask[$i]]=-1;
} else {
$color_move[$color_mask[$i]]=0;
}
}
for($i=0; $i<$length; $i++){
$char=substr($text,$i,1);
$test=ord($char);
if($test>=128 and $test<=255 | $test=""){
$char=substr($text,$i,2);
$i++;
}
$word[]=$char;
}
}
$length=count($word);
$koeff_add=@(($max/$length)/$max)*100;
for($i=0; $i<$length; $i++){
for($i2=0; $i2<count($color_mask); $i2++){
$add=(($color_add[$color_mask[$i2]]/100)*$koeff_add)*$color_move[$color_mask[$i2]];
$cColor[$color_mask[$i2]]+=$add;
}
$current_color=make16color($cColor);
if(!$i){
$output.='<font color="'.$current_color.'">'.$word[$i];
$Gzip=$current_color;
} else {
if($current_color==$Gzip | $word[$i]==" "){
$output.=$word[$i];
} else {
$output.='</font><font color="'.$current_color.'">'.$word[$i];
$Gzip=$current_color;
}
}
}
if(strlen($output)){
$output.="</font>";
}
return $output;
}
function check($msg){
$msg=htmlspecialchars($msg);
$msg=stripslashes($msg);
return $msg;
}
//ф-ия навигации
function nav($all,$p=1, $go , $page)
{
$max = ceil($all/$page);
if($max>1)
{
echo'<div class="login">Страницы: ';
$in=-4;
$out=4;
if($p!=1)
{
echo (' <a href="'.$go.'p=1">1</a> ');
}
else
{
echo ('<b>1</b>');
}
for ($ot=$in; $ot<=$out; $ot++)
{
$str=$p+$ot;
if($str>1 AND $str<$max)
{
if($in==$ot AND $str>2)
{
echo (' [...] ');
}
if($ot!=0)
{
echo (' <a href="'.$go.'p='.$str.'"> '.$str.' </a>');
}
else
{
echo (' <b>'.$str.'</b>');
}
if($ot==$out AND $str<$max-1)
{
echo (' [...] ');
}
}
}
if($p!=$max)
{
echo (' <a href="'.$go.'p='.$max.'"> '.$max.' </a>');
}
elseif($max>1)
{
echo ('<b>'.$max.'</b>');
}
echo '</div>';
}
}
?>