Перейти к публикации
Гость videtorlv

Помощь line 552

Рекомендованные сообщения

Гость videtorlv

Помогите найти ошибку :

Warning: Invalid argument supplied for foreach() in /home/on/public_html/engine/function/protocol.php on line 552

 

<?php
/*
=====================================================
  Nulled by MD-company
-----------------------------------------------------
  Сайт автора http://videtor.ru/
-----------------------------------------------------
  Copyright (c) © 2011-2012
=====================================================
  Файл: protocol.php
=====================================================
*/
if( !defined( 'LM') ) die('Попытка взлома?');
function protocol_list()
{
return array(
'cs'=>"05",
'czero'=>"05",
'css'=>"05",
'l4d'=>"05",
'l4d2'=>"05",
'hl2dm'=>"05",
'q3'=>"02",
'tf2'=>"05",
'cod2'=>"02",
'cod4'=>"02",
'codww'=>"02",
'dods'=>"05"
);
return $protocol_list;
}
function query_live($type,$ip,$q_port,$request)
{
if (preg_match("/[^0-9a-z.-[]:]/i",$ip))
{
return;
}
$protocol_list=protocol_list();
if (!isset($protocol_list[$type]))
{
return;
}
$function = 'query_'.$protocol_list[$type];
if (!function_exists($function))
{
return;
}
if (!intval($q_port))
{
return;
}
$server = array(
'b'=>array('type'=>$type,'ip'=>$ip,'q_port'=>$q_port,'status'=>1),
's'=>array('game'=>'','name'=>'','map'=>'','players'=>0,'playersmax'=>0,'password'=>''),
'e'=>array(),
'p'=>array(),
't'=>array());
$response = query_direct($server,$request,$function,'udp');
if (!$response)
{
$server['b']['status'] = 0;
}
else
{
if (empty($server['s']['game']))
$server['s']['game'] = $type;
if (empty($server['s']['map']))
$server['s']['map']  = '-';
if (($pos = strrpos($server['s']['map'],'/'))  !== FALSE) {$server['s']['map'] = substr($server['s']['map'],$pos +1);}
if (($pos = strrpos($server['s']['map'],'')) !== FALSE) {$server['s']['map'] = substr($server['s']['map'],$pos +1);}
$server['s']['players']	= intval($server['s']['players']);
$server['s']['playersmax'] = intval($server['s']['playersmax']);
if (isset($server['s']['password'][0]))
$server['s']['password'] = (strtolower($server['s']['password'][0]) == 't') ?1 : 0;
else
$server['s']['password'] = intval($server['s']['password']);
if (strpos($request,'p') === FALSE &&empty($server['p']) &&$server['s']['players'] != 0)
unset($server['p']);
if (strpos($request,'p') === FALSE &&empty($server['t']))
unset($server['t']);
if (strpos($request,'e') === FALSE &&empty($server['e']))
unset($server['e']);
if (strpos($request,'s') === FALSE &&empty($server['s']['name']))
unset($server['s']);
}
return $server;
}
function query_direct(&$server,$request,$function,$scheme)
{
$fp = @fsockopen($scheme.'://'.$server['b']['ip'],$server['b']['q_port'],$errno,$errstr,1);
if (!$fp) return FALSE;
$config['timeout'] = 0;
stream_set_timeout($fp,$config['timeout'],$config['timeout'] ?0 : 500000);
stream_set_blocking($fp,TRUE);
$need	  = array();
$need['s'] = strpos($request,'s') !== FALSE ?TRUE : FALSE;
$need['e'] = strpos($request,'e') !== FALSE ?TRUE : FALSE;
$need['p'] = strpos($request,'p') !== FALSE ?TRUE : FALSE;
if ($need['e'] &&!$need['s']) $need['s'] = TRUE;
do
{
$need_check = $need;
$response = call_user_func_array($function,array(&$server,&$need,&$fp));
if (!$response) break;
if ($need_check == $need) break;
if ($need['p'] &&$server['s']['players'] == '0') {$need['p'] = FALSE;}
}
while ($need['s'] == TRUE ||$need['e'] == TRUE ||$need['p'] == TRUE);
@fclose($fp);
return $response;
}
function query_02(&$server,&$need,&$fp)
{
if	 ($server['b']['type'] == "quake2")			  {fwrite($fp,"xFFxFFxFFxFFstatus");}
elseif ($server['b']['type'] == "warsowold")		   {fwrite($fp,"xFFxFFxFFxFFgetinfo");}
elseif (strpos($server['b']['type'],"moh") !== FALSE) {fwrite($fp,"xFFxFFxFFxFFx02getstatus");}
else					{fwrite($fp,"xFFxFFxFFxFFgetstatus");}
$buffer = fread($fp,4096);
if (!$buffer) return FALSE;
$part = explode("n",$buffer);
array_pop($part);
$item = explode("",$part[1]);
foreach ($item as $item_key =>$data_key)
{
if (!($item_key %2)) continue;
$data_key			   = strtolower(parse_color($data_key,"1"));
$server['e'][$data_key] = parse_color($item[$item_key+1],"1");
}
if (!empty($server['e']['hostname']))	{$server['s']['name'] = $server['e']['hostname'];}
if (!empty($server['e']['sv_hostname'])) {$server['s']['name'] = $server['e']['sv_hostname'];}
if (isset($server['e']['gamename'])) {$server['s']['game'] = $server['e']['gamename'];}
if (isset($server['e']['mapname']))  {$server['s']['map']  = $server['e']['mapname'];}
$server['s']['players'] = empty($part['2']) ?0 : count($part) -2;
if (isset($server['e']['maxclients']))	{$server['s']['playersmax'] = $server['e']['maxclients'];}
if (isset($server['e']['sv_maxclients'])) {$server['s']['playersmax'] = $server['e']['sv_maxclients'];}
if (isset($server['e']['pswrd']))	  {$server['s']['password'] = $server['e']['pswrd'];}
if (isset($server['e']['needpass']))   {$server['s']['password'] = $server['e']['needpass'];}
if (isset($server['e']['g_needpass'])) {$server['s']['password'] = $server['e']['g_needpass'];}
array_shift($part);
array_shift($part);
if ($server['b']['type'] == "nexuiz")
{
$pattern = "/(.*) (.*) (.*)"(.*)"/U";$fields = array(1=>"score",2=>"ping",3=>"team",4=>"name");
}
elseif ($server['b']['type'] == "warsow")
{
$pattern = "/(.*) (.*) "(.*)" (.*)/";$fields = array(1=>"score",2=>"ping",3=>"name",4=>"team");
}
elseif ($server['b']['type'] == "sof2")
{
$pattern = "/(.*) (.*) (.*) "(.*)"/";$fields = array(1=>"score",2=>"ping",3=>"deaths",4=>"name");
}
elseif (strpos($server['b']['type'],"mohpa") !== FALSE)
{
$pattern = "/(.*) (.*) (.*) (.*) (.*) "(.*)" "(.*)"/";$fields = array(2=>"score",3=>"deaths",4=>"time",6=>"rank",7=>"name");
}
elseif (strpos($server['b']['type'],"moh") !== FALSE)
{
$pattern = "/(.*) "(.*)"/";$fields = array(1=>"ping",2=>"name");
}
else
{
$pattern = "/(.*) (.*) "(.*)"/";$fields = array(1=>"score",2=>"ping",3=>"name");
}
foreach ($part as $player_key =>$data)
{
if (!$data) {continue;}
preg_match($pattern,$data,$match);
foreach ($fields as $match_key =>$field_name)
{
if (isset($match[$match_key]))
$server['p'][$player_key][$field_name] = trim($match[$match_key]);
}
$server['p'][$player_key]['name'] = parse_color($server['p'][$player_key]['name'],"1");
if (isset($server['p'][$player_key]['time']))
{
$server['p'][$player_key]['time'] = lm_time($server['p'][$player_key]['time']);
}
}
return TRUE;
}
function query_05(&$server,&$need,&$fp)
{
if ($server['b']['type'] == "halflifewon")
{
if	 ($need['s']) {fwrite($fp,"xFFxFFxFFxFFdetailsx00");}
elseif ($need['p']) {fwrite($fp,"xFFxFFxFFxFFplayersx00");}
elseif ($need['e']) {fwrite($fp,"xFFxFFxFFxFFrulesx00");}
}
else
{
$challenge_code = isset($need['challenge']) ?$need['challenge'] : "x00x00x00x00";
if	 ($need['s']) {fwrite($fp,"xFFxFFxFFxFFx54Source Engine Queryx00");}
elseif ($need['p']) {fwrite($fp,"xFFxFFxFFxFFx55{$challenge_code}");}
elseif ($need['e']) {fwrite($fp,"xFFxFFxFFxFFx56{$challenge_code}");}
}
$packet_temp  = array();
$packet_type  = 0;
$packet_count = 0;
$packet_total = 4;
do
{
$packet = fread($fp,4096);if (!$packet) return FALSE;
if	 ($need['s']) {if ($packet[4] == "D")					{continue;}}
elseif ($need['p']) {if ($packet[4] == "m"||$packet[4] == "I")					  {continue;}}
elseif ($need['e']) {if ($packet[4] == "m"||$packet[4] == "I"||$packet[4] == "D") {continue;}}
if	 (substr($packet,0,5) == "xFFxFFxFFxFFx41") {$need['challenge'] = substr($packet,5,4);return TRUE;}
elseif (substr($packet,0,4) == "xFFxFFxFFxFF")	 {$packet_total = 1;$packet_type = 1;}
elseif (substr($packet,9,4) == "xFFxFFxFFxFF")	 {$packet_total = ord($packet[8]) &0xF;$packet_type = 2;}
elseif (substr($packet,12,4) == "xFFxFFxFFxFF")	 {$packet_total = ord($packet[8]);$packet_type = 3;}
elseif (substr($packet,18,2) == "BZ")				   {$packet_total = ord($packet[8]);$packet_type = 4;}
$packet_count ++;
$packet_temp[] = $packet;
}
while ($packet &&$packet_count <$packet_total);
if ($packet_type == 0) {return $server['s'] ?TRUE : FALSE;}
$buffer = array();
foreach ($packet_temp as $packet)
{
if	 ($packet_type == 1) {$packet_order = 0;}
elseif ($packet_type == 2) {$packet_order = ord($packet[8]) >>4;$packet = substr($packet,9);}
elseif ($packet_type == 3) {$packet_order = ord($packet[9]);$packet = substr($packet,12);}
elseif ($packet_type == 4) {$packet_order = ord($packet[9]);$packet = substr($packet,18);}
$buffer[$packet_order] = $packet;
}
ksort($buffer);
$buffer = implode("",$buffer);
if ($packet_type == 4)
{
if (!function_exists("bzdecompress"))
{
$server['e']['bzip2'] = "unavailable";$need['e'] = FALSE;
return TRUE;
}
$buffer = bzdecompress($buffer);
}
$header = cut_byte($buffer,4);
if ($header != "xFFxFFxFFxFF") {return FALSE;}
$response_type = cut_byte($buffer,1);
if ($response_type == "I")
{
$server['e']['netcode']	 = ord(cut_byte($buffer,1));
$server['s']['name']		= cut_string($buffer);
$server['s']['map']		 = cut_string($buffer);
$server['s']['game']		= cut_string($buffer);
$server['e']['description'] = cut_string($buffer);
$server['e']['appid']	   = lm_unpack(cut_byte($buffer,2),"S");
$server['s']['players']	 = ord(cut_byte($buffer,1));
$server['s']['playersmax']  = ord(cut_byte($buffer,1));
$server['e']['bots']		= ord(cut_byte($buffer,1));
$server['e']['dedicated']   = cut_byte($buffer,1);
$server['e']['os']		  = cut_byte($buffer,1);
$server['s']['password']	= ord(cut_byte($buffer,1));
$server['e']['anticheat']   = ord(cut_byte($buffer,1));
$server['e']['version']	 = cut_string($buffer);
}
elseif ($response_type == "m")
{
$server_ip				  = cut_string($buffer);
$server['s']['name']		= cut_string($buffer);
$server['s']['map']		 = cut_string($buffer);
$server['s']['game']		= cut_string($buffer);
$server['e']['description'] = cut_string($buffer);
$server['s']['players']	 = ord(cut_byte($buffer,1));
$server['s']['playersmax']  = ord(cut_byte($buffer,1));
$server['e']['netcode']	 = ord(cut_byte($buffer,1));
$server['e']['dedicated']   = cut_byte($buffer,1);
$server['e']['os']		  = cut_byte($buffer,1);
$server['s']['password']	= ord(cut_byte($buffer,1));
if (ord(cut_byte($buffer,1)))
{
$server['e']['mod_url_info']	 = cut_string($buffer);
$server['e']['mod_url_download'] = cut_string($buffer);
$buffer = substr($buffer,1);
$server['e']['mod_version']	  = lm_unpack(cut_byte($buffer,4),"l");
$server['e']['mod_size']		 = lm_unpack(cut_byte($buffer,4),"l");
$server['e']['mod_server_side']  = ord(cut_byte($buffer,1));
$server['e']['mod_custom_dll']   = ord(cut_byte($buffer,1));
}
$server['e']['anticheat'] = ord(cut_byte($buffer,1));
$server['e']['bots']	  = ord(cut_byte($buffer,1));
}
elseif ($response_type == "D")
{
$returned = ord(cut_byte($buffer,1));
$player_key = 0;
while ($buffer)
{
$server['p'][$player_key]['pid']   = ord(cut_byte($buffer,1));
$server['p'][$player_key]['name']  = cut_string($buffer);
$server['p'][$player_key]['score'] = lm_unpack(cut_byte($buffer,4),"l");
$server['p'][$player_key]['time']  = time(lm_unpack(cut_byte($buffer,4),"f"));
$player_key ++;
}
}
elseif ($response_type == "E")
{
$returned = lm_unpack(cut_byte($buffer,2),"S");
while ($buffer)
{
$item_key   = strtolower(cut_string($buffer));
$item_value = cut_string($buffer);
$server['e'][$item_key] = $item_value;
}
}
if ($need['s'] &&!$need['e']) {$server['e'] = array();}
if	 ($need['s']) {$need['s'] = FALSE;}
elseif ($need['p']) {$need['p'] = FALSE;}
elseif ($need['e']) {$need['e'] = FALSE;}
return TRUE;
}
function parse_color($string,$type)
{
switch($type)
{
case "1":
$string = preg_replace("/^x.../","",$string);
$string = preg_replace("/^./","",$string);
$string_length = strlen($string);
for ($i=0;$i<$string_length;$i++)
{
$char = ord($string[$i]);
if ($char >160) {$char = $char -128;}
if ($char >126) {$char = 46;}
if ($char == 16) {$char = 91;}
if ($char == 17) {$char = 93;}
if ($char  <32) {$char = 46;}
$string[$i] = chr($char);
}
break;
case "2":
$string = preg_replace("/^[x20-x7E]/","",$string);
break;
case "doomskulltag":
$string = preg_replace("/x1c./","",$string);
break;
case "farcry":
$string = preg_replace("/$d/","",$string);
break;
case "painkiller":
$string = preg_replace("/#./","",$string);
break;
case "quakeworld":
$string_length = strlen($string);
for ($i=0;$i<$string_length;$i++)
{
$char = ord($string[$i]);
if ($char >141) {$char = $char -128;}
if ($char <32)  {$char = $char +30;}
$string[$i] = chr($char);
}
break;
case "savage":
$string = preg_replace("/^[a-z]/","",$string);
$string = preg_replace("/^[0-9]+/","",$string);
$string = preg_replace("/lan .*^/U","",$string);
$string = preg_replace("/con .*^/U","",$string);
break;
case "swat4":
$string = preg_replace("/[c=......]/Usi","",$string);
break;
}
return $string;
}
function lm_time($seconds)
{
if ($seconds === "") {return "";}
$n = $seconds <0 ?"-": "";
$seconds = abs($seconds);
$h = intval($seconds / 3600);
$m = intval($seconds / 60  ) %60;
$s = intval($seconds	   ) %60;
$h = str_pad($h,"2","0",STR_PAD_LEFT);
$m = str_pad($m,"2","0",STR_PAD_LEFT);
$s = str_pad($s,"2","0",STR_PAD_LEFT);
return "{$n}{$h}:{$m}:{$s}";
}
function lm_unpack($string,$format)
{
list(,$string) = @unpack($format,$string);
return $string;
}
function cut_byte(&$buffer,$length)
{
$string = substr($buffer,0,$length);
$buffer = substr($buffer,$length);
return $string;
}
function cut_string(&$buffer,$start_byte = 0,$end_marker = "x00")
{
$buffer = substr($buffer,$start_byte);
$length = strpos($buffer,$end_marker);
if ($length === FALSE) {$length = strlen($buffer);}
$string = substr($buffer,0,$length);
$buffer = substr($buffer,$length +strlen($end_marker));
return $string;
}
function cut_pascal(&$buffer,$start_byte = 1,$length_adjust = 0,$end_byte = 0)
{
$length = ord(substr($buffer,0,$start_byte)) +$length_adjust;
$string = substr($buffer,$start_byte,$length);
$buffer = substr($buffer,$start_byte +$length +$end_byte);
return $string;
}
function query_cached($type,$ip,$q_port,$request,$id = NULL)
{
global $main,$conf,$lang;
if ($id != NULL)
{
$id		   = intval($id);
$mysql_query  = 'SELECT * FROM `lm_list` WHERE `id`=''.$id.'' LIMIT 1';
$mysql_result = $main->db->query($mysql_query);
$mysql_row	= $main->db->fetch($mysql_result);
if (!$mysql_row) {return FALSE;}
list($type,$ip,$q_port) = array($mysql_row['type'],$mysql_row['ip'],$mysql_row['q_port']);
}
else
{
list($type,$ip,$q_port) = array($main->db->R_Escape($type),$main->db->R_Escape($ip),intval($q_port));
if (!$type ||!$ip ||!$q_port) return;
$mysql_query  = 'SELECT * FROM `lm_list` WHERE `type`=''.$type.'' AND `ip`=''.$ip.'' AND `q_port`=''.$q_port.'' LIMIT 1';
$mysql_result = $main->db->query($mysql_query);
$mysql_row	= $main->db->fetch($mysql_result);
if (!$mysql_row)
{
if (strpos($request,"a") === FALSE) return;
$mysql_query  = "INSERT INTO `lm_list` (`type`,`ip`,`q_port`,`cache`,`cache_time`) VALUES ('{$type}','{$ip}','{$q_port}','','')";
$mysql_result = $main->db->query($mysql_query);
$mysql_row	= array("id"=>$main->db->insert(),"zone"=>"0","comment"=>"");
}
}
$cache	  = empty($mysql_row['cache'])	  ?array()	  : unserialize(base64_decode($mysql_row['cache']));
$cache_time = empty($mysql_row['cache_time']) ?array(0,0,0) : explode("_",$mysql_row['cache_time']);
if (empty($cache['b']) ||!is_array($cache))
{
$cache	  = array();
$cache['b'] = array();
$cache['b']['status']  = 0;
$cache['b']['pending'] = 1;
}
$cache['b']['type']	= $type;
$cache['b']['ip']	  = $ip;
$cache['b']['q_port']  = $q_port;
$cache['o']['request'] = $request;
$cache['o']['id']	  = $mysql_row['id'];
if (!isset($cache['s']) or !$cache['b']['status'])
{
$cache['s']			   = array();
$cache['s']['game']	   = $type;
$cache['s']['name']	   = charset_convert($lang['view_text5'],'Windows-1251');
$cache['s']['map']		= charset_convert($lang['view_text4'],'Windows-1251');
$cache['s']['players']	= 0;
$cache['s']['playersmax'] = 0;
$cache['s']['password']   = 0;
$cache['s']['ping']	   = 0;
}
if (!isset($cache['e'])) {$cache['e'] = array();}
if (!isset($cache['p'])) {$cache['p'] = array();}
$needed = '';
if (strpos($request,"c") === FALSE)
{
if (strpos($request,"s") !== FALSE &&time() <img src='https://nevex.pw/public/style_emoticons/<#EMO_DIR#>/smile.gif.png' class='bbc_emoticon' alt=':)' />$cache_time[0]+($conf['update']*60))) {$needed .= "s";}
if (strpos($request,"e") !== FALSE &&time() <img src='https://nevex.pw/public/style_emoticons/<#EMO_DIR#>/smile.gif.png' class='bbc_emoticon' alt=':)' />$cache_time[1]+($conf['update']*60))) {$needed .= "e";}
if (strpos($request,"p") !== FALSE &&time() <img src='https://nevex.pw/public/style_emoticons/<#EMO_DIR#>/angry.gif.png' class='bbc_emoticon' alt=':)' />$cache_time[2]+($conf['update']*60))) {$needed .= "p";}
}
if ($needed)
{
if(empty($mysql_row['country']))
{
require_once LM_DIR .'/function/geoip.php';
$gi=geoip_open(LM_DIR .'/GeoIP.dat',GEOIP_STANDARD);
$country=geoip_country_code_by_addr($gi,gethostbyname($mysql_row['ip']));
geoip_close($gi);
}
$country=($mysql_row['country']!='') ?$mysql_row['country'] : $country;
$packed_times = time() +($conf['update']*60) +10;
$packed_times = $packed_times.'_'.$packed_times.'_'.$packed_times;
$mysql_query  = 'UPDATE `lm_list` SET `cache_time`=''.$packed_times.'' WHERE `id`=''.$mysql_row['id'].'' LIMIT 1';
$mysql_result = $main->db->query($mysql_query);
$live = query_live($type,$ip,$q_port,$needed);
if (!$live['b']['status'])
$live = query_live($type,$ip,$q_port,$needed);
if (!$live['b']['status'])
{
$live['s']['game']	   = $cache['s']['game'];
$live['s']['name']	   = $lang['view_text5'];
$live['s']['map']		= $lang['view_text4'];
$live['s']['password']   = $cache['s']['password'];
$live['s']['players']	= 0;
$live['s']['playersmax'] = $cache['s']['playersmax'];
$live['s']['ping']	   = 0;
$live['e']			   = array();
$live['p']			   = array();
if(time() <img src='https://nevex.pw/public/style_emoticons/<#EMO_DIR#>/angry.gif.png' class='bbc_emoticon' alt=':)' />($conf['delete']*24*60*60) +$mysql_row['last_con']))
$main->db->query('DELETE FROM `lm_list` where `id`=''.$mysql_row['id'].''');
}
$live = charset_convert($live,charset_detect($live));
if (isset($live['b'])) {$cache['b'] = $live['b'];$cache['b']['pending'] = 0;}
if (isset($live['s'])) {$cache['s'] = $live['s'];$cache_time[0] = time();}
if (isset($live['e'])) {$cache['e'] = $live['e'];$cache_time[1] = time();}
if (isset($live['p'])) {$cache['p'] = $live['p'];$cache_time[2] = time();}
if($cache['b']['status'])
$main->db->query('INSERT INTO `lm_history` (`sid`,`map`,`rang`,`players`,`time`) VALUES (''.$mysql_row['id'].'',''.$cache['s']['map'].'',''.cache_rang($mysql_row['id']).'',''.$cache['s']['players'].'',''.time().'')');
$cache['s']['ping']=rand(5,80);
$packed_cache = $main->db->R_Escape(base64_encode(serialize($cache)));
$packed_times = $main->db->R_Escape(implode("_",$cache_time));
$mysql_query  = 'UPDATE `lm_list` SET `country`=''.$country.'',`last_con`=''.((!$cache['b']['status']) ?$mysql_row['last_con'] : time()).'',`map`=''.$cache['s']['map'].'',`status`=''.$cache['b']['status'].'',`cache`=''.$packed_cache.'',`cache_time`=''.$packed_times.'' WHERE `id`=''.$mysql_row['id'].'' LIMIT 1';
$mysql_result = $main->db->query($mysql_query);
}
if (strpos($request,"s") === FALSE) {unset($cache['s']);}
if (strpos($request,"e") === FALSE) {unset($cache['e']);}
if (strpos($request,"p") === FALSE) {unset($cache['p']);}
return $cache;
}
function lm_timer($action)
{
global $conf;
$microtime  = microtime();
$microtime  = explode(' ',$microtime);
$microtime  = $microtime[1] +$microtime[0];
$timer = $microtime -0.01;
$time_limit = 1;
$time_php   = ini_get("max_execution_time");
if ($time_limit >$time_php)
{
@set_time_limit($time_limit +5);
$time_php = ini_get("max_execution_time");
if ($time_limit >$time_php)
{
$time_limit = $time_php -5;
}
}
if ($action == "limit")
{
return $time_limit;
}
$microtime  = microtime();
$microtime  = explode(' ',$microtime);
$microtime  = $microtime[1] +$microtime[0];
$time_taken = $microtime -$timer;
if ($action == "check")
{
return ($time_taken >$time_limit) ?TRUE : FALSE;
}
else
{
return round($time_taken,2);
}
}
function server_html($server,$word_wrap = 20)
{
foreach ($server as $key =>$value)
$server[$key] = is_array($value) ?server_html($value,$word_wrap) : string_html($value,FALSE,$word_wrap);
return $server;
}
function string_html($string,$xml_feed = FALSE,$word_wrap = 0)
{
if ($word_wrap)
$string = word_wrap($string,$word_wrap);
if ($xml_feed != FALSE)
{
$string = htmlspecialchars($string,ENT_QUOTES);
}
elseif (function_exists("mb_convert_encoding"))
{
$string = htmlspecialchars($string,ENT_QUOTES);
$string = @mb_convert_encoding($string,"HTML-ENTITIES","UTF-8");
}
else
{
$string = htmlentities($string,ENT_QUOTES,"UTF-8");
}
if ($word_wrap)
$string = word_wrap($string);
return $string;
}
function word_wrap($string,$length_limit = 0)
{
if (!$length_limit)
return str_replace("x05x06","​",$string);
$word_list = explode(" ",$string);
foreach ($word_list as $key =>$word)
{
$word_length = function_exists("mb_strlen") ?mb_strlen($word,"UTF-8") : strlen($word);
if ($word_length <$length_limit) {continue;}
$word_new = "";
for ($i=0;$i<$word_length;$i+=$length_limit)
{
$word_new .= function_exists("mb_substr") ?mb_substr($word,$i,$length_limit,"UTF-8") : substr($word,$i,$length_limit);
$word_new .= "x05x06";
}
$word_list[$key] = $word_new;
}
return implode(" ",$word_list);
}
function charset_detect($server)
{
if (!function_exists("mb_detect_encoding")) {return "AUTO";}
$test = "";
if (isset($server['s']['name'])) {$test .= " {$server['s']['name']} ";}
if (isset($server['p']) &&$server['p'])
{
foreach ($server['p'] as $player)
{
if (isset($player['name'])) {$test .= " {$player['name']} ";}
}
}
$charset = @mb_detect_encoding($server['s']['name'],"UTF-8, Windows-1252, ISO-8859-1, ISO-8859-15");
return $charset ?$charset : "AUTO";
}
function charset_convert($server,$charset)
{
if (!function_exists("mb_convert_encoding")) {return $server;}
if (is_array($server))
{
foreach ($server as $key =>$value)
{
$server[$key] = charset_convert($value,$charset);
}
}
else
{
$server = @mb_convert_encoding($server,"UTF-8",$charset);
}
return $server;
}
function cache_rang($id)
{
global $main;
$i = 0;
$query  = $main->db->query('SELECT * FROM `lm_list` ORDER BY golos DESC');
while($result = $main->db->fetch($query))
{
$i=$i+1;
if($id==$result['id']) $rang = $i;
}
return $rang;
}
?>

 

 

Буду вам очень признателен

Изменено пользователем Андрей
Длинный код надо прятать в спойлер!

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
Гость ViRuS

ошибка на 552 строке...

 

 

function server_html($server,$word_wrap = 20)

{

foreach ($server as $key =>$value)

$server[$key] = is_array($value) ?server_html($value,$word_wrap) : string_html($value,FALSE,$word_wrap);

return $server;

}

 

сам пхп плохо знаю, не помогу

Изменено пользователем ViRuS

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
Гость videtorlv

Вирус в выделеном коде уже что та исправил ?

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
volfing

Походу переменная $server не подставляется в функцию а следовательно и не подставляется в foreach, ищите проблему куда у вас переменная $server деется.

PS:Про спойлеры не слышал ?

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
Гость videtorlv

Ну у меня крч проблема вот в чем:

В блоке вип нажимаю на страницу с сервером "Описание" там не все данные :) все же может в этой строчке кто найдет ошибку ?

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
TheAndrey

function server_html($server,$word_wrap = 20)
{
foreach ($server as $key =>$value)
$server[$key] = is_array($value) ?server_html($value,$word_wrap) : string_html($value,FALSE,$word_wrap);
return $server;
}

В переменной $server должен быть массив, а она у Вас пуста, либо содержит что-то отличное от массива.

 

С проверкой на массив (чтобы интерпретатор не ругался):

function server_html($server,$word_wrap = 20)
{
if(is_array($server)){
foreach ($server as $key =>$value)
$server[$key] = is_array($value) ?server_html($value,$word_wrap) : string_html($value,FALSE,$word_wrap);
}
return $server;
}

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
Гость videtorlv

Андрей, испробую спасибо

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
Гость videtorlv

Все спс . Андрей помог :)

Поделиться сообщением


Ссылка на сообщение
Поделиться на других сайтах
Гость
Эта тема закрыта для публикации сообщений.

×
×
  • Создать...