Вход Регистрация
Файл: system/functions.php
Строк: 99
<?php

  
function TextGuard($text){
  
$text trim($text);
  
$text htmlspecialchars($text);
  
$text mysql_escape_string($text);
  return 
$text;
  }
  
  function 
gradient($text,$from=''$to=''$mode="hex"){
  
$text iconv("UTF-8""windows-1251"$text);

  if(
$mode=="hex"){
  
$to hexdec($to[0].$to[1]).",".hexdec($to[2].$to[3]).",".hexdec($to[4].$to[5]);
  
$from hexdec($from[0].$from[1]).",".hexdec($from[2].$from[3]).",".hexdec($from[4].$from[5]);
  }
  if( empty(
$text) )
  return 
'';
  else
  
$levels=strlen($text);
  if (empty(
$from))
  
$from = array(0,0,255);
  else
  
$from explode(","$from);
  if (empty(
$to))
  
$to = array(255,0,0);
  else
  
$to explode(","$to);
  
$output "";
  for (
$i=1;$i<=$levels;$i++){
  for (
$ii=0;$ii<4;$ii++){
  
$tmp[$ii] = $from[$ii] - $to[$ii];
  
$tmp[$ii] = floor($tmp[$ii] / $levels);
  
$rgb[$ii] = $from[$ii] -($tmp[$ii] * $i);
  if(
$rgb[$ii] > 255$rgb[$ii] = 255;
  
$rgb[$ii] = dechex($rgb[$ii]);
  
$rgb[$ii] = strtoupper($rgb[$ii]);
  if(
strlen($rgb[$ii]) < 2$rgb[$ii] = "0$rgb[$ii]";
  }
  
$output .= "<font color="#".$rgb[0].$rgb[1].$rgb[2]."">" . $text[$i -1 ] . "</font>";
  
}
  return 
iconv("windows-1251",  "UTF-8"$output);
  
  }
  
  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()-360) return '<img src="/modules/profile/images/mon.png"/>';
  else return 
'<img src="/modules/profile/images/mof.png"/>';
  }elseif(
$users['sex'] == 2){
  if(
$users['online'] > time()-360) return '<img src="/modules/profile/images/jon.png"/>';
  else return 
'<img src="/modules/profile/images/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) 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 `user` where `id` = "'.$id.'" limit 1'));
  
  if(
$users != 0){
  
  if(
$users['status'] >= 1){
  
  if(
$users['status'] == 1$access 'мд'; elseif($users['status'] == 2$access 'адм';
  elseif(
$users['status'] == 3$access 'ст. адм'; elseif($users['status'] == 4$access 'соз';

  return 
'<font color="green">['.$access.']</font>';

  }
  
  }
  
  }

 
  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 && $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 $hours2 $hours.' часов';
  if(
$min $min2 $min.' минут';
  if(
$sec $sec2 $sec.' секунд';

  return 
$day2.' '.$hours2.' '.$min2.' '.$sec2
  }

  function 
bbcode($mes){

  
//$mes=htmlspecialchars($mes);
  
$mes=stripslashes($mes);
  
$mes preg_replace('#[b](.*?)[/b]#si''<b>1</b>'$mes);
  
$mes preg_replace('#[i](.*?)[/i]#si''<i>1</i>'$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('#[img](.*?)[/img]#si''<a href="http://1"><img src="http://1" alt="[IMG]" style="max-width:50px;max-height:50px;"/></a>'$mes);
  
$mes preg_replace('#[url=(.*?)](.*?)[/url]#si''<a href="1">2</a>'$mes);
  
  
$mes=str_replace('">http://','">',$mes);
  
$mes=str_replace("rn","<br/>",$mes);
  
$mes=str_replace("[br]","<br/>",$mes);
  
$mes=str_replace("
  "
,"<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;

  }
  
?>
Онлайн: 1
Реклама