Файл: wapxl.ru/shaxty/text_old.php
Строк: 174
<?
function bb_code($var = '') {
////////////////////////////////////////////////////////////
// Обработка ссылок и тэгов BBCODE в тексте //
//////////////////////////////////////////////////////////// // <div class='quote'>
$var = preg_replace(array ('#[code](.*?)[/code]#se'), array ("''.nosmiles(highlight('$1')).''"), str_replace("]n", "]", $var));
$var = preg_replace('#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>', $var);
$var = preg_replace('#[i](.*?)[/i]#si', '<span style="font-style:italic;">1</span>', $var);
$var = preg_replace('#[u](.*?)[/u]#si', '<span style="text-decoration:underline;">1</span>', $var);
$var = preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $var);
$var = preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $var);
$var = preg_replace('#[sup](.*?)[/sup]#si', '<sup>1</sup>', $var);
$var = preg_replace('#[sub](.*?)[/sub]#si', '<sub>1</sub>', $var);
$var = preg_replace('#[big](.*?)[/big]#si', '<big>1</big>', $var);
$var = preg_replace('#[s](.*?)[/s]#si', '<span style="text-decoration: line-through;">1</span>', $var);
$var = preg_replace('#[red](.*?)[/red]#si', '<span style="color:red">1</span>', $var);
$var = preg_replace('#[t](.*?)[/t]#si', '<input name="text" type="text" value="1">', $var);
$var = preg_replace('#[green](.*?)[/green]#si', '<span style="color:green">1</span>', $var);
$var = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:blue">1</span>', $var);
$var = preg_replace('#[q](.*?)[/q]#si', '<div>"1"</div>', $var);
$var = preg_replace_callback('~\[url=(http://.+?)\](.+?)\[/url\]|(http://(www.)?[0-9a-zа-яА-Я.-]+.[0-9a-zа-яА-Я]{2,6}[0-9a-zA-Zа-яА-Я/?.-~&;_=%:#]*)~', 'url_replace', $var);
$var = @eregi_replace("((http://))((([а-я0-9-]+(.[а-я0-9-]+)*(.[а-я;]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[а-я0-9~#%&'_+=:;?.-]*)*)", "<a href="\0">\3</a>", $var);
return $var;
}
function spoiler_bb($var){
$spoil = rand(0000,9999);
if(is_mobile()==0){
$var = preg_replace('#[spoiler](.*?)[/spoiler]#si', '<b>Спойлер</b> <span id="sp'.$spoil.'" style="line-height: 18px">(<a href="#" onClick="spoiler('.$spoil.'); return false">Отобразить</a>)</span><div class="quote" id="spoiler'.$spoil.'" style="display: none">
$1
</div><br />', $var);
$var = preg_replace('#[spoiler=(.*?)](.*?)[/spoiler]#si', '<b>$1</b> <span id="sp'.$spoil.'" style="line-height: 18px">(<a href="#" onClick="spoiler('.$spoil.'); return false">Отобразить</a>)</span><div class="quote" id="spoiler'.$spoil.'" style="display: none">
$2
</div><br />', $var);
}else{
$var = preg_replace('#[spoiler](.*?)[/spoiler]#si', '$1', $var);
$var = preg_replace('#[spoiler=(.*?)](.*?)[/spoiler]#si', '$2', $var);
}
return $var; // удалить это
}
/*функция тега img*/
function img_bb($var){
/*if (function_exists('curl_init')) {
return preg_replace_callback('#[img](.*?)[/img]#si', function($img) {
$img[1] = "http://".$img[1];
$curl = curl_init($img[1]);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_exec($curl);
$mime = curl_getinfo($curl, CURLINFO_CONTENT_TYPE);
$size = curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD);
curl_close($curl);
if (!in_array($mime, array('image/png', 'image/jpeg', 'image/gif', 'image/x-png'))) {
return '[нет изображения]';
} else {
$sizs = GetImageSize($img[1]);
$razm = 800;
$width = $sizs[0];
$height = $sizs[1]; //.$width.'x'.$height.'|'.($size/1024)
if ($size <= 1024*500 and $sizs[0] <= 1000 and $sizs[1] <= 1000) {
return '<a href="'.$img[1].'"><img src="'.F.'pic2.php?file='.$img[1].'" alt="Нажмите для просмотра изображения" /></a>';
} else return '<a href="'.$img[1].'">[Изображение слишком большое]</a>';
}
}, $var);
}
*/
return $var; // удалить это
}
function nosmiles($string) {
$string = preg_replace("#<img src="(.*?)" alt="" />#i", '', $string);
return $string;
}
function php_code($var = '') {
$var = preg_replace(array ('#[code](.*?)[/code]#se'), array ("''.php('$1').''"), str_replace("]n", "]", $var));
$var = preg_replace('#[b](.*?)[/b]#si', '<span style="font-weight: bold;">1</span>', $var);
$var = preg_replace('#[i](.*?)[/i]#si', '<span style="font-style:italic;">1</span>', $var);
$var = preg_replace('#[u](.*?)[/u]#si', '<span style="text-decoration:underline;">1</span>', $var);
$var = preg_replace('#[small](.*?)[/small]#si', '<small>1</small>', $var);
$var = preg_replace('#[del](.*?)[/del]#si', '<del>1</del>', $var);
$var = preg_replace('#[s](.*?)[/s]#si', '<span style="text-decoration: line-through;">1</span>', $var);
$var = preg_replace('#[red](.*?)[/red]#si', '<span style="color:red">1</span>', $var);
$var = preg_replace('#[green](.*?)[/green]#si', '<span style="color:green">1</span>', $var);
$var = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:blue">1</span>', $var);
$var = preg_replace('#[q](.*?)[/q]#si', '<div class="citata">"1"</div>', $var);
$var = preg_replace_callback('~\[url=(http://.+?)\](.+?)\[/url\]|(http://(www.)?[0-9a-z.-]+.[0-9a-z]{2,6}[0-9a-zA-Z/?.-~&;_=%:#]*)~', 'url_replace', $var);
return $var;
}
function php($code) {
$code = strtr($code, array('<' => '<', '>' => '>', '&' => '&', '"' => '"', '$' => '$', '%' => '%', ''' => "'", '\' => '\', '^' => '^', '`' => '`', '|' => '|', '<br />' => ""));
$code = highlight_string(stripslashes($code), true);
$code = strtr($code, array("rn" => '<br />', '$' => '$', "'" => ''', '%' => '%', '\' => '\', '`' => '`', '^' => '^', '|' => '|'));
$code = '<div class="d">' . $code . '</div>';
return $code;
}
function highlight($code) {
//$code = nosmiles($code);
$code = html_entity_decode(trim($code), ENT_QUOTES, 'UTF-8');
$code = strtr($code, array('<' => '<', '>' => '>', '&' => '&', '"' => '"', '$' => '$', '%' => '%', ''' => "'", '\' => '\', '^' => '^', '`' => '`', '|' => '|', '<br />' => "brbr"));
$code = highlight_string(stripslashes($code), true);
$code = strtr($code, array("brbr" => '<br />', '$' => '$', "'" => ''', '%' => '%', '\' => '\', '`' => '`', '^' => '^', '|' => '|'));
// <div class='quote'>
$code = '<br /><div class="phpcode">' . $code . '</div>';
return $code;
}
function smiles($msg)
{
global $db, $set,$user;
$f_smiles=file(H."smiles/smiles.txt");
for ($i=0;$i<count($f_smiles);$i++)
{
$str_sm=explode(' ',trim($f_smiles[$i]));
$str_sm2='';
for ($z=1;$z<count($str_sm);$z++)
{
if ($z>1){$str_sm2.=' ';}
$str_sm2.=$str_sm[$z];
}
$str_sm2=explode(',',$str_sm2);
for ($i2=0;$i2<count($str_sm2);$i2++)
{
$str_sm2[$i2]=stripcslashes(htmlspecialchars($str_sm2[$i2]));
$msg=str_replace("$str_sm2[$i2]", "<img src="/smiles/$str_sm[0].gif" alt="" />", $msg);
}
}
$f_smiles=file(H."smiles/smiles_mod.txt");
for ($i=0;$i<count($f_smiles);$i++)
{
$str_sm=explode(' ',trim($f_smiles[$i]));
$str_sm2='';
for ($z=1;$z<count($str_sm);$z++)
{
if ($z>1){$str_sm2.=' ';}
$str_sm2.=$str_sm[$z];
}
$str_sm2=explode(',',$str_sm2);
for ($i2=0;$i2<count($str_sm2);$i2++)
{
$str_sm2[$i2]=stripcslashes(htmlspecialchars($str_sm2[$i2]));
$msg=str_replace("$str_sm2[$i2]", "<img src="/smiles/$str_sm[0].gif" alt="" />", $msg);
}
}
return $msg;
}
function url_replace($m) {
global $db, $_SERVER;
if (!isset($m[3])) {
$target = (strpos($m[1], $_SERVER['HTTP_HOST']) === false) ? ' target="_blank"' : '';
return '<a href="' . $m[1] . '"' . $target . '>' . $m[2] . '</a>';
} else {
$target = (strpos($m[3], $_SERVER['HTTP_HOST']) === false) ? ' target="_blank"' : '';
return '<a href="' . $m[3] . '"' . $target . '>' . $m[3] . '</a>';
}
}
function notags($var = '') {
////////////////////////////////////////////////////////////
// Вырезание BBcode тэгов из текста //
////////////////////////////////////////////////////////////
$var = strtr($var, array (
'[green]' => '',
'[/green]' => '',
'[red]' => '',
'[/red]' => '',
'[blue]' => '',
'[/blue]' => '',
'[b]' => '',
'[/b]' => '',
'[i]' => '',
'[/i]' => '',
'[u]' => '',
'[/u]' => '',
'[s]' => '',
'[/s]' => '',
'[q]' => '',
'[/q]' => '',
'[small]' => '',
'[/small]' => '',
'[del]' => '',
'[/del]' => '',
'[code]' => '',
'[/code]' => ''
));
return $var;
}
// Антимат, бля
function antimat($string){
//$mat = file_get_contents(H."shaxty/antimat.shaxty");
$arr_mat= explode("|",$mat);
foreach($arr_mat as $value){
if($value!=""){
$string = preg_replace("|$value|iu","***",$string);
}}
return $string;}
/*function antimat($str) {
global $db, $_SERVER;
$arrmat = mysql_fetch_array(mysql_query("Select * from antimat ORDER BY LENGTH(`mat_string`) DESC"));
if (count($arrmat) > 0) {
foreach($arrmat as $val) {
$str = preg_replace('|' . preg_quote($val['mat_string']) . '|iu', '***', $str);
}
}
return $str;
}*/
function br($msg,$br='<br />')
{
$msg=eregi_replace("((<br( ?/?)>)|n|r)+","rn", $msg);
return $msg;
}
function text($str, $br = 1, $tags = 1) {
if ($br == 1)
$str = nl2br($str);
elseif ($br == 2)
$str = str_replace("rn", ' ', $str);
if ($tags == 1){
$str = spoiler_bb($str);
$str = bb_code($str);
$str = smiles($str);
$str = img_bb($str);
}elseif ($tags == 2){
$str = notags($str);
}
$str = strtr($str, array (
chr(0)=> '',
chr(1)=> '',
chr(2)=> '',
chr(3)=> '',
chr(4)=> '',
chr(5)=> '',
chr(6)=> '',
chr(7)=> '',
chr(8)=> '',
chr(9)=> '',
chr(10)=> '',
chr(11)=> '',
chr(12)=> '',
chr(13)=> '',
chr(14)=> '',
chr(15)=> '',
chr(16)=> '',
chr(17)=> '',
chr(18)=> '',
chr(19)=> '',
chr(20)=> '',
chr(21)=> '',
chr(22)=> '',
chr(23)=> '',
chr(24)=> '',
chr(25)=> '',
chr(26)=> '',
chr(27)=> '',
chr(28)=> '',
chr(29)=> '',
chr(30)=> '',
chr(31)=> ''
));
$str = antimat($str);
return $str;
}
function translit($str) {
$str = strtr($str, array (
'a' => 'а',
'b' => 'б',
'v' => 'в',
'g' => 'г',
'd' => 'д',
'e' => 'е',
'yo' => 'ё',
'zh' => 'ж',
'z' => 'з',
'i' => 'и',
'j' => 'й',
'k' => 'к',
'l' => 'л',
'm' => 'м',
'n' => 'н',
'o' => 'о',
'p' => 'п',
'r' => 'р',
's' => 'с',
't' => 'т',
'u' => 'у',
'f' => 'ф',
'h' => 'х',
'c' => 'ц',
'ch' => 'ч',
'w' => 'ш',
'sh' => 'щ',
'q' => 'ъ',
'y' => 'ы',
'x' => 'э',
'yu' => 'ю',
'ya' => 'я',
'A' => 'А',
'B' => 'Б',
'V' => 'В',
'G' => 'Г',
'D' => 'Д',
'E' => 'Е',
'YO' => 'Ё',
'ZH' => 'Ж',
'Z' => 'З',
'I' => 'И',
'J' => 'Й',
'K' => 'К',
'L' => 'Л',
'M' => 'М',
'N' => 'Н',
'O' => 'О',
'P' => 'П',
'R' => 'Р',
'S' => 'С',
'T' => 'Т',
'U' => 'У',
'F' => 'Ф',
'H' => 'Х',
'C' => 'Ц',
'CH' => 'Ч',
'W' => 'Ш',
'SH' => 'Щ',
'Q' => 'Ъ',
'Y' => 'Ы',
'X' => 'Э',
'YU' => 'Ю',
'YA' => 'Я'
));
return $str;
}
?>