Файл: www/function.php
Строк: 100
<?php
////////////ББ-Коды//////////////////////
function bb_code($message) {
$message = preg_replace('#[code](.*?)[/code]#si', '<div style="background-image:url(/images/79_32.jpg); border: 2px solid #ccc;"><div style="background:#bfbfbf;)"><strong>Код:</strong></div><textarea style="background:#d3dddd; margin:5px 0 5px 0; padding: 0 3px 5px 11px; resize: none; border: none;" rows="10" cols="75%" name="content">1</textarea></div>', $message);
$message = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $message);
$message = preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $message);
$message = preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $message);
$message = preg_replace('#[s](.*?)[/s]#si', '<strike>1</strike>', $message);
$message = preg_replace('#[left](.*?)[/left]#si', '<div align="left">1</div>', $message);
$message = preg_replace('#[center](.*?)[/center]#si', '<div align="center">1</div>', $message);
$message = preg_replace('#[right](.*?)[/right]#si', '<div align="right">1</div>', $message);
$message = preg_replace('#[justify](.*?)[/justify]#si', '<div align="justify">1</div>', $message);
$message = preg_replace('#[size=50](.*?)[/size]#si', '<font size="1">1 </font>', $message);
$message = preg_replace('#[size=85](.*?)[/size]#si', '<font size="2">1 </font>', $message);
$message = preg_replace('#[size=100](.*?)[/size]#si', '<font size="3">1 </font>', $message);
$message = preg_replace('#[size=150](.*?)[/size]#si', '<font size="4">1 </font>', $message);
$message = preg_replace('#[size=200](.*?)[/size]#si', '<font size="6">1 </font>', $message);
$message = preg_replace('#[quote](.*?)[/quote]#si', '<TABLE bgcolor="#7384ab"><TR><TH ALIGN=left><small>Цитата:</small></TH></TR><TR><TD>1 </TR></TABLE>', $message);
$message = preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $message);
$message = preg_replace('#[color=(.*?)](.*?)[/color]#si', '<font color="1">2</font>', $message);
$message = preg_replace('#[red](.*?)[/red]#si', '<font color="#FF0000">1</font>', $message);
$message = preg_replace('#[green](.*?)[/green]#si', '<font color="#00FF00">1</font>', $message);
$message = preg_replace('#[blue](.*?)[/blue]#si', '<font color="#0000FF">1</font>', $message);
$message = preg_replace('#[yellow](.*?)[/yellow]#si', '<font color="#FFFF00">1</font>', $message);
$message = preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $message);
$message = preg_replace('#[url=(.*?)](.*?)[/url]#si', '<a href="1" target="_blank">2</a>', $message);
$message = preg_replace('#[video](.*?)[/video]#si', '<iframe src="http://www.youtube.com/embed/1" width="640" height="480" frameborder="0"></iframe>', $message);
$message = preg_replace('#[table](.*?)[/table]#si', '<table class="wbb-table" border>1</table>', $message);
$message = preg_replace('#[tr](.*?)[/tr]#si', '<tr>1</tr>', $message);
$message = preg_replace('#[td](.*?)[/td]#si', '<td>1</td>', $message);
$message = preg_replace('#[img](.*?)[/img]#si', '<img src="1">', $message);
$message = preg_replace('#[img width=(.*?),height=(.*?)](.*?)[/img]#si', '<img src="3" width="1" height="2"', $message);
/// Смайлики
$message=str_replace(":sm1:", '<img src="TextEditor/theme/default/img/smiles/sm1.png">', $message);
$message=str_replace(":sm2:", '<img src="TextEditor/theme/default/img/smiles/sm2.png">', $message);
$message=str_replace(":sm3:", '<img src="TextEditor/theme/default/img/smiles/sm3.png">', $message);
$message=str_replace(":sm4:", '<img src="TextEditor/theme/default/img/smiles/sm4.png">', $message);
$message=str_replace(":sm5:", '<img src="TextEditor/theme/default/img/smiles/sm5.png">', $message);
$message=str_replace(":sm6:", '<img src="TextEditor/theme/default/img/smiles/sm6.png">', $message);
$message=str_replace(":sm7:", '<img src="TextEditor/theme/default/img/smiles/sm7.png">', $message);
$message=str_replace(":sm8:", '<img src="TextEditor/theme/default/img/smiles/sm8.png">', $message);
$message=str_replace(":sm9:", '<img src="TextEditor/theme/default/img/smiles/sm9.png">', $message);
$message=str_replace(":sm10:", '<img src="TextEditor/theme/default/img/smiles/sm10.png">', $message);
$message=str_replace(":sm11:", '<img src="TextEditor/theme/default/img/smiles/sm11.png">', $message);
$message=str_replace(":sm12:", '<img src="TextEditor/theme/default/img/smiles/sm12.png">', $message);
return $message;
}
/*Функция для генерации случайной строки*/
function generateCode($length=6)
{
$chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPRQSTUVWXYZ0123456789";
$code = "";
$clen = strlen($chars) - 1;
while (strlen($code) < $length) {
$code .= $chars[mt_rand(0,$clen)];
}
return $code;
}
/*Массив данных зверя*/
$inf = mysql_fetch_array(mysql_query("Select * FROM `users` WHERE `id`='".(int)$_COOKIE['id']."'"));
/*Обрабатываем логин пользователя*/
function login($id)
{
$us = mysql_fetch_array(mysql_query("SELECT `login`, `effect` FROM `users` WHERE `id` = '".(int)$id."'"), 0);
if($us['login']) $login = $us['login'];
else
$login = '[Удален]';
return animat($login, $us['effect']);
}
/*Функция анимации для ника*/
function animat($text, $effect)
{
global $inf;
return '<span class="ef'.$effect.'"> '.$text.' </span>';
}
/*Текст обрабатываем*/
function text($text)
{
global $inf;
return '<span class="ef'.$inf['text_eff'].'"> '.$text.' </span>';
}
?>