Просмотр файла system/functions.php

Размер файла: 8.39Kb
<?php
#----------------------------------#
#**********[WHT] ICQBot************#
#         Made by : Sklep          #
#    E-mail : [email protected]    #
#    Site : http://Wap-Hack.Ru     #
#          ICQ : 712788            #
#----------------------------------#
error_reporting(false);
/*======================================================================*\
	Функция:	CheckICQStatus
	Назначение:	Для определения ICQ статуса юзера
	Ввод:		$uin	указываем номер в сервисе ICQ
	Вывод:		echo CheckICQStatus($uin); выводит состояние юзера в icq
\*======================================================================*/
function CheckICQStatus($uin)
{
    if(fsockopen ("status.icq.com", 80, &$errno, &$errstr, 30) && ($uin=='' || strlen($uin)>=5))
    {   
      $fp = fsockopen ("status.icq.com", 80, &$errno, &$errstr, 30);
      fputs($fp, "GET /online.gif?icq=$uin&img=5&online= HTTP/1.0\n\n"); 

        while(!feof($fp) && !$icq_finished) 
        { 
          $line=fgets($fp,128);
            if (substr($line,0,9)=='Location:')
		    {
                if(substr($line,13,11)=='online1.gif')
			      $status = 1;
			    else
                  $status = 0; 
            }
        } 
      fclose($fp);	 
    }
	else
	  $status = 2;
	  
    switch ($status)
	{
      case 0: $icq_status = 0; 
	  break;
                
	  case 1: $icq_status = 1; 
	  break;
                
	  case 2: $icq_status = 0; 
	  break;
    }
  return $icq_status;		
}
/*======================================================================*\
	Функция:	utf_to_win
	Назначение:	перекодирует любой текст кодировку Win-1251
	Ввод:		$a    любой текст
	Вывод:		echo utf_to_win($a);	выводит перекодированный текст
\*======================================================================*/
$_utf8win1251 = array( 
"\xD0\x90"=>"\xC0","\xD0\x91"=>"\xC1","\xD0\x92"=>"\xC2","\xD0\x93"=>"\xC3","\xD0\x94"=>"\xC4", 
"\xD0\x95"=>"\xC5","\xD0\x81"=>"\xA8","\xD0\x96"=>"\xC6","\xD0\x97"=>"\xC7","\xD0\x98"=>"\xC8", 
"\xD0\x99"=>"\xC9","\xD0\x9A"=>"\xCA","\xD0\x9B"=>"\xCB","\xD0\x9C"=>"\xCC","\xD0\x9D"=>"\xCD", 
"\xD0\x9E"=>"\xCE","\xD0\x9F"=>"\xCF","\xD0\xA0"=>"\xD0","\xD0\xA1"=>"\xD1","\xD0\xA2"=>"\xD2", 
"\xD0\xA3"=>"\xD3","\xD0\xA4"=>"\xD4","\xD0\xA5"=>"\xD5","\xD0\xA6"=>"\xD6","\xD0\xA7"=>"\xD7", 
"\xD0\xA8"=>"\xD8","\xD0\xA9"=>"\xD9","\xD0\xAA"=>"\xDA","\xD0\xAB"=>"\xDB","\xD0\xAC"=>"\xDC", 
"\xD0\xAD"=>"\xDD","\xD0\xAE"=>"\xDE","\xD0\xAF"=>"\xDF","\xD0\x87"=>"\xAF","\xD0\x86"=>"\xB2", 
"\xD0\x84"=>"\xAA","\xD0\x8E"=>"\xA1","\xD0\xB0"=>"\xE0","\xD0\xB1"=>"\xE1","\xD0\xB2"=>"\xE2", 
"\xD0\xB3"=>"\xE3","\xD0\xB4"=>"\xE4","\xD0\xB5"=>"\xE5","\xD1\x91"=>"\xB8","\xD0\xB6"=>"\xE6", 
"\xD0\xB7"=>"\xE7","\xD0\xB8"=>"\xE8","\xD0\xB9"=>"\xE9","\xD0\xBA"=>"\xEA","\xD0\xBB"=>"\xEB", 
"\xD0\xBC"=>"\xEC","\xD0\xBD"=>"\xED","\xD0\xBE"=>"\xEE","\xD0\xBF"=>"\xEF","\xD1\x80"=>"\xF0", 
"\xD1\x81"=>"\xF1","\xD1\x82"=>"\xF2","\xD1\x83"=>"\xF3","\xD1\x84"=>"\xF4","\xD1\x85"=>"\xF5", 
"\xD1\x86"=>"\xF6","\xD1\x87"=>"\xF7","\xD1\x88"=>"\xF8","\xD1\x89"=>"\xF9","\xD1\x8A"=>"\xFA", 
"\xD1\x8B"=>"\xFB","\xD1\x8C"=>"\xFC","\xD1\x8D"=>"\xFD","\xD1\x8E"=>"\xFE","\xD1\x8F"=>"\xFF", 
"\xD1\x96"=>"\xB3","\xD1\x97"=>"\xBF","\xD1\x94"=>"\xBA","\xD1\x9E"=>"\xA2"); 

function utf_to_win($a)
{ 
  global $_utf8win1251; 
    if (is_array($a))
	{ 
        foreach ($a as $k => $v)
		{ 
            if (is_array($v))
              $a[$k] = utf_to_win($v); 
            else
              $a[$k] = strtr($v, $_utf8win1251); 
         
	    } 
      return $a; 
    }
	else 
      return strtr($a, $_utf8win1251);
}
/*======================================================================*\
	Функция:	win_to_utf
	Назначение:	перекодирует любой текст кодировку utf-8
	Ввод:		$a    любой текст
	Вывод:		echo win_to_utf($a);	выводит перекодированный текст
\*======================================================================*/
$_win1251utf8 = array( 
"\xC0"=>"\xD0\x90","\xC1"=>"\xD0\x91","\xC2"=>"\xD0\x92","\xC3"=>"\xD0\x93","\xC4"=>"\xD0\x94", 
"\xC5"=>"\xD0\x95","\xA8"=>"\xD0\x81","\xC6"=>"\xD0\x96","\xC7"=>"\xD0\x97","\xC8"=>"\xD0\x98", 
"\xC9"=>"\xD0\x99","\xCA"=>"\xD0\x9A","\xCB"=>"\xD0\x9B","\xCC"=>"\xD0\x9C","\xCD"=>"\xD0\x9D", 
"\xCE"=>"\xD0\x9E","\xCF"=>"\xD0\x9F","\xD0"=>"\xD0\xA0","\xD1"=>"\xD0\xA1","\xD2"=>"\xD0\xA2", 
"\xD3"=>"\xD0\xA3","\xD4"=>"\xD0\xA4","\xD5"=>"\xD0\xA5","\xD6"=>"\xD0\xA6","\xD7"=>"\xD0\xA7", 
"\xD8"=>"\xD0\xA8","\xD9"=>"\xD0\xA9","\xDA"=>"\xD0\xAA","\xDB"=>"\xD0\xAB","\xDC"=>"\xD0\xAC", 
"\xDD"=>"\xD0\xAD","\xDE"=>"\xD0\xAE","\xDF"=>"\xD0\xAF","\xAF"=>"\xD0\x87","\xB2"=>"\xD0\x86", 
"\xAA"=>"\xD0\x84","\xA1"=>"\xD0\x8E","\xE0"=>"\xD0\xB0","\xE1"=>"\xD0\xB1","\xE2"=>"\xD0\xB2", 
"\xE3"=>"\xD0\xB3","\xE4"=>"\xD0\xB4","\xE5"=>"\xD0\xB5","\xB8"=>"\xD1\x91","\xE6"=>"\xD0\xB6", 
"\xE7"=>"\xD0\xB7","\xE8"=>"\xD0\xB8","\xE9"=>"\xD0\xB9","\xEA"=>"\xD0\xBA","\xEB"=>"\xD0\xBB", 
"\xEC"=>"\xD0\xBC","\xED"=>"\xD0\xBD","\xEE"=>"\xD0\xBE","\xEF"=>"\xD0\xBF","\xF0"=>"\xD1\x80", 
"\xF1"=>"\xD1\x81","\xF2"=>"\xD1\x82","\xF3"=>"\xD1\x83","\xF4"=>"\xD1\x84","\xF5"=>"\xD1\x85", 
"\xF6"=>"\xD1\x86","\xF7"=>"\xD1\x87","\xF8"=>"\xD1\x88","\xF9"=>"\xD1\x89","\xFA"=>"\xD1\x8A", 
"\xFB"=>"\xD1\x8B","\xFC"=>"\xD1\x8C","\xFD"=>"\xD1\x8D","\xFE"=>"\xD1\x8E","\xFF"=>"\xD1\x8F", 
"\xB3"=>"\xD1\x96","\xBF"=>"\xD1\x97","\xBA"=>"\xD1\x94","\xA2"=>"\xD1\x9E"); 

function win_to_utf($a)
{ 
  global $_win1251utf8; 
    if (is_array($a))
	{ 
        foreach ($a as $k => $v)
		{ 
            if (is_array($v))
              $a[$k] = win_to_utf($v); 
            else
              $a[$k] = strtr($v, $_win1251utf8); 
         
	    } 
      return $a; 
    }
	else 
      return strtr($a, $_win1251utf8);
}
/*======================================================================*\
	Функция:	win_to_utf
	Назначение:	перекодирует любой текст кодировку utf-8
	Ввод:		$a    любой текст
	Вывод:		echo win_to_utf($a);	выводит перекодированный текст
\*======================================================================*/
function uptimes($uptime)
{
  $time = time();

  $end_dey = date('j',$time)-date('j',$uptime);
  $end_hour = date('h',$time)-date('h',$uptime);
  $end_min = date('i',$time)-date('i',$uptime);
  $end_sek = date('s',$time)-date('s',$uptime);

    if($end_dey<0)
      $end_dey = $end_dey + 31;
    if($end_hour<0)
      $end_hour = $end_hour + 12;
    if($end_min<0)
      $end_min = $end_min + 60;
    if($end_sek<0)
      $end_sek = $end_sek + 60;

  $datas = "Бот в онлайне: ";
  
    if($end_dey>0)
      $datas .= $end_dey.'дн. ';
    if($end_hour>0)
      $datas .= $end_hour.'час. ';
    if($end_min>0)
      $datas .= $end_min.'мин. ';
    if($end_sek>0)
      $datas .= $end_sek.'сек.';
	  
  $datas .= "\r\nДата запуска: ".date('d F Y',$uptime)."\r\nВремя запуска: ".date('H:i:s',$uptime);

  return $datas;
}

/*======================================================================*\
	Функция:	win_to_utf
	Назначение:	перекодирует любой текст кодировку utf-8
	Ввод:		$a    любой текст
	Вывод:		echo win_to_utf($a);	выводит перекодированный текст
\*======================================================================*/
 function pages($total,$config_pages,$next=0,$pages)
{  
      echo 'Страницы:';
	  
      $asd = $next-($config_pages*3);
      $asd2 = $next+($config_pages*4);
     
        if($asd<$total && $asd>0)
		  echo ' <a href="'.$pages.'">1</a> ... ';
     
        for($i=$asd; $i<$asd2;)
        {
            if($i<$total && $i>=0)
			{
                $ii = floor(1+$i/$config_pages);
             
                if ($next==$i)
                  echo ' <b>'.$ii.'</b>';
                else
                  echo ' <a href="'.$pages.'next='.$i.'">'.$ii.'</a>';
             
			}
         
		  $i = $i+$config_pages;
		}
		
        if($asd2<$total)
		  echo ' ... <a href="'.$pages.'next='.$ba2.'">'.$ba.'</a>';
}
?>