Файл: system/funcs.php
Строк: 77
<?
class funcs {
function getCount($w,$tab){
return DB::$dbs->querySingle("SELECT count(".$w.") from ".$tab."");
}
function ves($b){
if($b<1024) $result=$b.'b';
if($b>=1024 && $b<1024*1024) $result=round($b/1024).'Kb';
if($b>=(1024*1024)) $result=round($b/(1024*1024)).'Mb';
return $result;
}
function text($text){
$text = bb(br(links(smiles($text))));
return $text;
}
function uNick($id){
$nick = DB::$dbs->queryFetch("SELECT `id`,`nick`,`sex`,`last`,`level` from `us` where `id` = ? limit 1",array($id));
if($nick['level'] > 3) $level = 'соз'; elseif($nick['level'] == 3) $level = 'ст. адм'; elseif($nick['level'] == 2) $level = 'адм'; elseif($nick['level'] == 1) $level = 'мд';
$gradient = DB::$dbs->queryFetch("SELECT * from `gradient` where `us` = ? limit 1",array($id));
return ($nick['id'] ? '<img src="/files/ico/'. ( $nick['last'] > (time()-3600) ? ( is_file ( $_SERVER['DOCUMENT_ROOT'].'/files/ico/'.$id.'.png' ) ? $nick['id']: ( $nick['sex']=='Муж' ? 'mon' : 'jon' ) ) : ( $nick['sex'] == 'Муж' ? 'mof' : 'jof' ) ) .'.png" alt="*"/> <a href="/us'.$id.'" style="text-decoration:none;'.(!$gradient['id'] ? 'color: black;':NULL).'"><b>'.($gradient['id'] ? gradient($nick['nick'],$gradient['start'],$gradient['end']):$nick['nick']).'</b></a>'.($nick['level'] > 0 ? ' <font color="green">['.$level.']</font>':NULL):'[Удалён]');
}
function page($param){
global $page,$total;
if ($page != 1) $pervpage = '<a href="'.$param.'/page1"><<</a>
<a href="'.$param.'/page'.($page-1).'"><</a> ';
if ($page != $total) $nextpage = ' <a href="'.$param.'/page'.($page+1).'">></a>
<a href="'.$param.'/page'.$total.'">>></a>';
if($page - 2 > 0) $page2left = ' <a href="'.$param.'/page'. ($page - 2) .'">'. ($page - 2) .'</a> | ';
if($page - 1 > 0) $page1left = '<a href="'.$param.'/page'. ($page - 1) .'">'. ($page - 1) .'</a> | ';
if($page + 2 <= $total) $page2right = ' | <a href="'.$param.'/page'. ($page + 2) .'">'. ($page + 2) .'</a>';
if($page + 1 <= $total) $page1right = ' | <a href="'.$param.'/page'. ($page + 1) .'">'. ($page + 1) .'</a>';
echo '<div class="news">Стр. '.$pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage.'</div>';
}
function num($num){
return trim(abs(intval($num)));
}
function flood($how,$sec,$what){
switch($how) {
case 'sec':
return $sec-(time()-intval($what)).' секунд';
break;
case 'min':
return substr((floatval((1-1)-(time()-intval($what))/60)+($sec/60)),0,3).' минут';
break;
default: return $sec; break;
}
}
}
$func = new funcs;
?>