Файл: Vipmas/magaz/functions.php
Строк: 143
<?
function ustatus($id){
$users = mysql_fetch_array(mysql_query('select * from `user` where `id` = "'.$id.'" limit 1'));
if($users['sex'] == 1){
if($users['online'] > time()-3600) return '<img src="/modules/bl/files/'.$users['icon'].'.png" alt="*" width="16" height="16"/>';
else return '<img src="/modules/bl/files/mof.png"/>';
}elseif($users['sex'] == 2){
if($users['online'] > time()-3600) return '<img src="/modules/bl/files/'.$users['icon1'].'.png" alt="*" width="16" height="16"/>';
else return '<img src="/modules/bl/files/jof.png"/>';
}}
function uname($id){
$users = mysql_fetch_array(mysql_query('select * from `user` where `id` = "'.$id.'" limit 1'));
if($users != 0){
$nicks = mysql_query("SELECT * FROM `nicks` where `who` = '".$users['id']."' ORDER BY `id` DESC LIMIT 1");
while($nicks2 = mysql_fetch_assoc($nicks)){
$users['login'] = $nicks2['new'];
}
$gradient = mysql_fetch_array(mysql_query('select * from `gradient` where `who` = "'.$id.'" limit 1'));
if($gradient != 0 && $gradient['start'] != NULL && $gradient['end'] != NULL) return '<b>'.gradient($users['login'],$gradient['start'],$gradient['end']).'</b>'; else return '<b>'.$users['login'].'</b>';
}else{
return '[Удален]';
}
}
function uaccess($id){
$users = mysql_fetch_array(mysql_query('select * from `users` where `id` = "'.$id.'" limit 1'));
if($users != 0){
if($users['level'] >= 1){
if($users['level'] == 1) $access = 'мд'; elseif($users['level'] == 2) $access = 'адм';
elseif($users['level'] == 3) $access = 'созд'; elseif($users['ked'] == 1) $access = 'мошенник';
return '<font color="green">['.$access.']</font>';
}
}
}
function user($id)
{
$us = mysql_fetch_array(mysql_query('select * from `user` where `id` = "'.$id.'" limit 1'));
if($us == 0)
{
return '[Удалён]';
}
else
{
$nicks = mysql_query("SELECT * FROM `nicks` where `who` = '".$us['id']."' ORDER BY `id` DESC LIMIT 1");
while($nicks2 = mysql_fetch_assoc($nicks)){
$us['login'] = $nicks2['new'];
}
$gradient = mysql_fetch_array(mysql_query('select * from `gradient` where `who` = "'.$id.'" limit 1'));
if($gradient != 0 && $gradient['start'] != NULL && $gradient['end'] != NULL) $us_login = '<b>'.gradient($us['login'],$gradient['start'],$gradient['end']).'</b>'; else $us_login = $us['login'];
switch($us['status']) {
case '1': $us_access = 'мд';
break;
case '2': $us_access = 'адм';
break;
case '3': $us_access = 'ст.адм';
break;
case '4': $us_access = 'соз';
break;
}
if($us['status'] >= 1) $us_access2 = ' <font color="green">['.$us_access.']</font>';
return '<img src="/modules/profile/images/'.($us['sex'] == 1 ? 'm' : 'j').($us['online'] > (time()-300) ? 'on' : 'of').'.png" alt="*"/> <a href="/us'.$us['id'].'"><b>'.$us_login.'</b></a> '.$us_access2;
echo ''.$us_prepis2.'';
}
}
function slv($str,$msg1,$msg2,$msg3) {
$str = (int)$str;
$str1 = abs($str) % 100;
$str2 = $str % 10;
if ($str1 > 10 && $str1 < 20) return $str .' '. $msg3;
if ($str2 > 1 && $str2 < 5) return $str .' '. $msg2;
if ($str2 == 1) return $str .' '. $msg1;
return $str .' '. $msg3;
}
function times($times=NULL){
$time = time();
if(($time-$times)<=60){
$timesp = slv((($time-$times)),'секунду','секунды','секунд').' назад';
return $timesp;
} else if(($time-$times)<=3600){$timesp = slv((($time-$times)/60),'минуту','минуты','минут').' назад';
return $timesp;
} else {
$today = date("j M Y", $time);
$today = date("j M Y", $time);
$yesterday = date("j M Y", strtotime("-1 day"));
$timesp=date("j M Y в H:i", $times);
$timesp = str_replace($today, 'Сегодня', $timesp);
$timesp = str_replace($yesterday, 'Вчера', $timesp);
$timesp = strtr($timesp, array ("Jan" => "Янв","Feb" => "Фев","Mar" => "Марта","May" => "Мая","Apr" => "Апр","Jun" => "Июня","Jul" => "Июля","Aug" => "Авг","Sep" => "Сент","Oct" => "Окт","Nov" => "Ноября","Dec" => "Дек",));
return $timesp;}
}
function times2($string) {
$day=floor($string/86400);
$hours=floor(($string/3600)-$day*24);
$min=floor(($string-$hours*3600-$day*86400)/60);
$sec=$string-($min*60+$hours*3600+$day*86400);
if($day > 0) $day2 = $day.' дней';
if($hours > 0 ) $hours2 = $hours.' часов';
if($min > 0 ) $min2 = $min.' минут';
if($sec > 0 ) $sec2 = $sec.' секунд';
return $day2.' '.$hours2.' '.$min2.' '.$sec2;
}
function antispam($text){
$text = trim($text);
$anti = mysql_query("SELECT * FROM `antispam` ");
while($spam = mysql_fetch_array($anti)){
$text = str_replace($spam['site'],''.$spam['zamena'].'',$text);
}
return $text;
}
function bbcode($mes){
$mes=stripslashes($mes);
$mes = preg_replace("#(?:http://)?(.*?)(.gif|.png|.jpeg|.jpg)#",'<img src="http://12" alt="Изображение"/>', $mes);
$mes = preg_replace('~http://([^ rnt`'"]+)(s|$)~iu', '<a href="http://1"><img src="http://www.iconsearch.ru/uploads/icons/realistik-new/16x16/package_network.png" alt="Ссылка"/> Ссылка</a> ', $mes);
$mes = preg_replace('#[b](.*?)[/b]#si', '<b>1</b>', $mes);
$mes = preg_replace('#[i](.*?)[/i]#si', '<i>1</i>', $mes);
$mes = preg_replace('#[red](.*?)[/red]#si', '<span style="color:#FF0000;">1</span>', $mes);
$mes = preg_replace('#[blue](.*?)[/blue]#si', '<span style="color:#00008b;">1</span>', $mes);
$mes = preg_replace('#[white](.*?)[/white]#si', '<span style="color:#ffffff;">1</span>', $mes);
$mes = preg_replace('#[green](.*?)[/green]#si', '<span style="color:#006400;">1</span>', $mes);
$mes = preg_replace('#[u](.*?)[/u]#si', '<u>1</u>', $mes);
$mes = preg_replace('#[cit](.*?)[/cit]#si', '<div class="cit">1</div>', $mes);
$mes = preg_replace('#[url=(.*?)](.*?)[/url]#si', '<a href="1">2</a>', $mes);
$mes=str_replace("rn","<br/>",$mes);
$mes=str_replace("[br]","<br/>",$mes);
$mes = preg_replace('#[code](.*?)[/code]#si', '<div class="cit"><code>1</code></div>', $mes);
return $mes;
}
function smiles($text){
$text = trim($text);
$smiles = mysql_query("SELECT * FROM `smiles` ORDER BY `id` DESC");
while($smiles2 = mysql_fetch_array($smiles)){
$text = str_replace($smiles2['name'],' <img src="/smiles/'.$smiles2['img'].'" alt="'.$smiles2['name'].'"/> ',$text);
}
return $text;
}
?>