Файл: titwar.ru/system/functions.php
Строк: 173
<?
function _string($string) {
$string = trim($string);
$string = mysql_escape_string($string);
$string = htmlspecialchars($string);
return $string;
}
function _num($i) {
$i = (int) abs($i);
return $i;
}
function n_f($i) {
if($i >= 10000 && $i < 1000000) {
$i = number_format($i, 0, '', '.');
$i = round($i,3).'K';
}
elseif($i >= 1000000) {
$i = number_format($i, 0, '', '.');
$i = round($i,3).'M';
}
else
{
$i = number_format($i, 0, '', ''');
}
return $i;
}
function pages($path) {
global $page, $pages;
if(($page - 2) > 0) {
echo ' <a href="'.$path.'page=1"><<</a> ';
}
else
{
echo '<<';
}
if($page - 1 > 0) {
echo ' <a href="'.$path.'page='.($page - 1).'"><</a> ';
}
else
{
echo ' < ';
}
if($page == $pages && $page - 4 > 0) {
echo ' <a href="'.$path.'page='.($page - 4).'">'.($page - 4).'</a> ';
}
if($page == $pages && $page - 3 > 0) {
echo ' <a href="'.$path.'page='.($page - 3).'">'.($page - 3).'</a> ';
}
if($page - 2 > 0) {
echo ' <a href="'.$path.'page='.($page - 2).'">'.($page - 2).'</a> ';
}
if($page - 1 > 0) {
echo ' <a href="'.$path.'page='.($page - 1).'">'.($page - 1).'</a> ';
}
echo $page;
if($page + 1 <= $pages) {
echo ' <a href="'.$path.'page='.($page + 1).'">'.($page + 1).'</a> ';
}
if($page + 2 <= $pages) {
echo ' <a href="'.$path.'page='.($page + 2).'">'.($page + 2).'</a> ';
}
if($page == 1 && $page + 3 <= $pages) {
echo ' <a href="'.$path.'page='.($page + 3).'">'.($page + 3).'</a> ';
}
if($page == 1 && $page + 4 <= $pages) {
echo ' <a href="'.$path.'page='.($page + 4).'">'.($page + 4).'</a> ';
}
if($page + 1 <= $pages) {
echo ' <a href="'.$path.'page='.($page + 1).'">></a> ';
}
else
{
echo ' > ';
}
if(($page + 2) <= $pages) {
echo ' <a href="'.$path.'page='.$pages.'">>></a> ';
}
else
{
echo ' >> ';
}
}
function bbcode($str)
{
//$str = strip_tags($str);
//$str=preg_replace("/@(.+)@/Usi","<a href='/site.php?nick=\1'>\1</a>",$str);
//$str = preg_replace("/@(. )/si","<a href='/site.php?nick=\1'>\1</a>",$str);
$str=preg_replace("/[b](.+)[/b]/Usi","<strong>\1</strong>",$str);
$str=preg_replace("/[i](.+)[/i]/Usi","<em>\1</em>",$str);
$str=preg_replace("/[u](.+)[/u]/Usi","<u>\1</u>",$str);
$str=preg_replace("/[s](.+)[/s]/Usi","<s>\1</s>",$str);
//$str=preg_replace("/[b](.+)[/b]/Usi","<big>\1</big>",$str);
$str=preg_replace("/[small](.+)[/small]/Usi","<small>\1</small>",$str);
$str=preg_replace("/[sup](.+)[/sup]/Usi","<sup>\1</sup>",$str);
$str=preg_replace("/[sub](.+)[/sub]/Usi","<sub>\1</sub>",$str);
$str=preg_replace("/[code](.+)[/code]/Usi","<code>\1</code>",$str);
$str=preg_replace("/[color=(.*)](.*)[/color]/Usi", "<font color='\1'>\2</font>", $str);
$str=preg_replace("/[rang=(.*)](.*)[/rang]/Usi", "<div style='background-color:\1'>\2</div>", $str);
$str=preg_replace("/[size=(.*)](.*)[/size]/Usi", "<span style="font-size:\1">\2</span>", $str);
$str=preg_replace("/[img=(.*)]/Usi","<img src='\1' border="0"/>",$str);
$str=preg_replace("/[br]/Usi","<br>",$str);
$str=preg_replace("/[hr]/Usi","<hr>",$str);
//$str = preg_replace("/@(.*)/si","<a href='/site.php?nick=\1'>$1</a>",$str);
$str=preg_replace("/[url=(.*)](.*)[/url]/Usi","<a href='\1'>\2</a> ",$str);
$str=preg_replace("/[center](.*)[/center]/Usi","<div align=center>\1</div>",$str);
$str=preg_replace("/[right](.*)[/right]/Usi","<div align=right>\1</div>",$str);
$str=preg_replace("/[left](.*)[/left]/Usi","<div align=left>\1</div>",$str);
$str=str_replace("rn","<br/>",$str);
return $str;
}
function bbfunc($str)
{
$str=preg_replace("/<strong>(. )</strong>/Usi","[b]\1[/b]",$str);
$str=preg_replace("/<em>(. )</em>/Usi","[i]\1[/i]",$str);
$str=preg_replace("/<u>(. )</u>/Usi","[u]\1[/u]",$str);
$str=preg_replace("/<s>(. )</s>/Usi","[s]\1[/s]",$str);
$str=preg_replace("/<big>(. )</big>/Usi","[big]\1[/big]",$str);
$str=preg_replace("/<small>(. )</small>/Usi","[small]\1[/small]",$str);
$str=preg_replace("/<sup>(. )</sup>/Usi","[sup]\1[/sup]",$str);
$str=preg_replace("/<sub>(. )</sub>/Usi","[sub]\1[/sub]",$str);
$str=preg_replace("/<code>(. )</code>/Usi","[code]\1[/code]",$str);
$str=preg_replace("/<br/>/Usi", "n", $str);
$str=preg_replace("/<span style="color:(.*)">(.*)</span>/Usi","[color=\1]\2[/color]", $str);
$str=preg_replace("/<span style="font-size:(.*)">(.*)</span>/Usi", "[size=\1]\2[/size]", $str);
$str=preg_replace("/<img src='(.*)' alt='(.*)' border="0"/>/Usi","[img=\1]\2[/img]",$str);
//$str = strip_tags($str);
return $str;
}
function smiles($string) {
$string = str_replace(array(':@)',':ded'), '<img src="/images/smiles/mini_ded.gif" alt="*"/>', $string);
$string = str_replace(array('O:-)','o:-)'),'<img src="/images/smiles/mini_angel.gif" alt="*"/>', $string);
$string = str_replace(array(']:-)',']:-]'),'<img src="/images/smiles/mini_diablo.gif" alt="*"/>', $string);
$string = str_replace(array(':$',':-$',':-['),'<img src="/images/smiles/mini_blush.gif" alt="*"/>', $string);
$string = str_replace(array(':))',':-))','-))','=))'),'<img src="/images/smiles/mini_lol.gif" alt="*"/>', $string);
$string = str_replace(array(':)',':-)','=)'),'<img src="/images/smiles/mini_ulibka.gif" alt="*"/>', $string);
$string = str_replace(array(';)',';-)'),'<img src="/images/smiles/mini_podmigivanie.gif" alt="*"/>', $string);
$string = str_replace(array(':-D',':-d',':D',')))'),'<img src="/images/smiles/mini_spin.gif" alt="*"/>', $string);
$string = str_replace(array(':-P',':-p',':-Р',':-р',':P',':p'),'<img src="/images/smiles/mini_yazyk.gif" alt="*"/>', $string);
$string = str_replace(array(':(',':-('),'<img src="/images/smiles/mini_sad.gif" alt="*"/>', $string);
$string = str_replace(array(':'(',':'-('),'<img src="/images/smiles/mini_cry.gif" alt="*"/>', $string);
$string = str_replace(array(':]',':-]'),'<img src="/images/smiles/mini_dovolen.gif" alt="*"/>', $string);
$string = str_replace(array(':-/',':-\'),'<img src="/images/smiles/mini_hm.gif" alt="*"/>', $string);
$string = str_replace(array('8-)','%-)'),'<img src="/images/smiles/mini_krut.gif" alt="*"/>', $string);
$string = str_replace(array(':*',':-*'),'<img src="/images/smiles/mini_kiss.gif" alt="*"/>', $string);
$string = str_replace(array('%)','%-)'),'<img src="/images/smiles/mini_crazy.gif" alt="*"/>', $string);
$string = str_replace(array(':-o',':-O',':-о',':-О','O.o','О.о','O_o','o_O'),'<img src="/images/smiles/mini_chok.gif" alt="*"/>', $string);
$string = str_replace(array('O^','o^'),'<img src="/images/smiles/mini_bye.gif" alt="*"/>', $string);
$string = str_replace(array(':Ob',':ob'),'<img src="/images/smiles/mini_good.gif" alt="*"/>', $string);
$string = str_replace(array('6-(','%-E',':gigi'),'<img src="/images/smiles/mini_fingal.gif" alt="*"/>', $string);
$string = str_replace(array(':bravo',':браво'),'<img src="/images/smiles/mini_bravo.gif" alt="*"/>', $string);
$string = str_replace(array(':heart',':сердце'),'<img src="/images/smiles/mini_heart.gif" alt="*"/>', $string);
$string = str_replace(array(':fig',':фиг'),'<img src="/images/smiles/mini_fig.gif" alt="*"/>', $string);
$string = str_replace(array(':rose',':роза','@--'),'<img src="/images/smiles/mini_rose.gif" alt="*"/>', $string);
$string = str_replace(array(':krut',':крут'),'<img src="/images/smiles/mini_krut.gif" alt="*"/>', $string);
$string = str_replace(array('сайт','tk','gl','http','r u','mpesh','bt','war','лох','чмо','пидар','пробелов'),'*', $string);
$string = str_replace(array('dOOb','doob','d00b'),'<img src="/images/smiles/mini_friends.gif" alt="*"/>', $string);
$string=bbcode($string);
return $string;
}
function _time($i) {
$h = floor(($i / 3600) - $d * 24);
$m = floor(($i - $h * 3600 - $d * 86400) / 60);
$s = $i - ($m * 60 + $h * 3600 + $d * 86400);
return ($h > 0 ? ($h < 10 ? '0':'').$h.':':'').($m > 0 ? ($m < 10 ? '0':'').$m.':':'00:').($s > 0 ? ($s < 10 ? '0':'').$s:'00');
}
function bb($string) {
$string = str_replace("rn","<br/>",$string);
return $string;
}
function _times($i) {
$d = floor($i / 86400);
$h = floor(($i / 3600) - $d * 24);
$m = floor(($i - $h * 3600 - $d * 86400) / 60);
$s = $i - ($m * 60 + $h * 3600 + $d * 86400);
if($d > 0) {
$result = $d.' d';
}
elseif($h > 0)
{
$result = $h.' h';
}elseif($m > 0)
{
$result = $m.' min';
}elseif($s >= 0)
{
$result = $s.' sec';
}
return $result.' back';
}
?>