Файл: bdls.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 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('dOOb','doob','d00b'),'<img src="/images/smiles/mini_friends.gif" alt="*"/>', $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);
$string = preg_replace('/[(/?)(b|i|u|s)s*]/', "<$1$2>", $string);
return $string;
}
function vremja($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.' д';
}
elseif($h > 0)
{
$result = $h.' ч';
}elseif($m > 0)
{
$result = $m.' м';
}elseif($s >= 0)
{
$result = $s.' с';
}
return $result.'';
}
function strong($msg){
$msg = trim($msg);
$msg = htmlspecialchars($msg);
$msg = mysql_escape_string($msg);
return $msg;
}
function page($k_page=1) {
$page = 1;
$page = strong($page);
$k_page = strong($k_page);
if(isset($_GET['selection'])) {
if ($_GET['selection']=='top')
$page = strong(intval($k_page));
elseif(is_numeric($_GET['selection']))
$page = strong(intval($_GET['selection']));
}
if ($page<1)$page=1;
if ($page>$k_page)$page=$k_page;
return $page;
}
function k_page($k_post = 0,$k_p_str = 10) {
if ($k_post != 0) {
$v_pages = ceil($k_post/$k_p_str);
return $v_pages;
}
else return 1;
}
function str($link='?',$k_page=1,$page=1){
if ($page<1)$page=1;
$page = strong($page);
$k_page = strong($k_page);
if ($page>1)echo ' ';
else echo " ";
echo " ";
if ($page<$k_page)echo ' ';
else echo " ";
echo ' ';;
if ($page != 1)
echo '<a href="'.$link.'selection=1" class="navigation">1</a>';
else echo ' ';
for ($ot=-3; $ot<=3; $ot++){
if ($page+$ot>1 && $page+$ot<$k_page){
if ($ot==-3 && $page+$ot>2)echo " ..";
if ($ot!=0)echo ' <a href="'.$link.'selection='.($page+$ot).'" class="navigation">'.($page+$ot).'</a>';
else echo ' ';
if ($ot==3 && $page+$ot<$k_page-1)echo " ..";}}
if ($page!=$k_page)echo ' <a href="'.$link.'selection=top" class="navigation">'.$k_page.'</a>';
elseif ($k_page>1)echo ' ';
}
function text($m){
$m = htmlspecialchars($m);
$m = mysql_escape_string($m);
return $m;
}
function num($m){
$m = intval($m);
$m = abs($m);
return $m;
}
?>