Просмотр файла inc/func.php

Размер файла: 2.01Kb
<?
defined('WBCAT') or die('Restricted access');
// Функция  обработка тегов в тексте
function tags($text = '') {
$text = preg_replace('#\[b\](.*?)\[/b\]#si', '<span style="font-weight: bold;">\1</span>', $text);
$text = preg_replace('#\[i\](.*?)\[/i\]#si', '<span style="font-style:italic;">\1</span>', $text);
$text = preg_replace('#\[u\](.*?)\[/u\]#si', '<span style="text-decoration:underline;">\1</span>', $text);
$text = preg_replace('#\[s\](.*?)\[/s\]#si', '<span style="text-decoration: line-through;">\1</span>', $text);
$text = preg_replace('#\[red\](.*?)\[/red\]#si', '<span style="color:red">\1</span>', $text);
$text = preg_replace('#\[green\](.*?)\[/green\]#si', '<span style="color:green">\1</span>', $text);
$text = preg_replace('#\[blue\](.*?)\[/blue\]#si', '<span style="color:blue">\1</span>', $text);
$text = preg_replace_callback('~\\[url=(https?://.+?)\\](.+?)\\[/url\\]|(https?://(www.)?[0-9a-z\.-]+\.[0-9a-z]{2,6}[0-9a-zA-Z/\?\.\~&amp;_=/%-:#]*)~', 'url_replace', $text);
return $text;
}
// Функция парсинга ссылки
function url_replace($s) {
if (!isset ($s[3])) {
return '<a href="' . $s[1] . '">' . $s[2] . '</a>';
}
else {
return '<a href="' . $s[3] . '">' . $s[3] . '</a>';
}
}     
// Функция смайлов
function smileys($text){
$text = strtr($text, array(
':)'=>'<img src="smileys/1.gif" alt=":)"/>',
':('=>'<img src="smileys/2.gif" alt=":("/>',
':P'=>'<img src="smileys/3.gif" alt=":P"/>',
':D'=>'<img src="smileys/4.gif" alt=":D"/>',
));
return $text;
} 
// Преобразование числа в ip
function int2ip($i) {
   $d[0]=(int)($i/256/256/256);
   $d[1]=(int)(($i-$d[0]*256*256*256)/256/256);
   $d[2]=(int)(($i-$d[0]*256*256*256-$d[1]*256*256)/256);
   $d[3]=$i-$d[0]*256*256*256-$d[1]*256*256-$d[2]*256;
   return "$d[0].$d[1].$d[2].$d[3]";
}
// Преобразование ip в число
function ip2int($ip) {
   $a=explode(".",$ip);
   return $a[0]*256*256*256+$a[1]*256*256+$a[2]*256+$a[3];
}


?>