Foros del Web » Programando para Internet » PHP »

Algien que me ayude con este codigo

Estas en el tema de Algien que me ayude con este codigo en el foro de PHP en Foros del Web. Alguien podria ayudarme con este codigo ya que no me genera el archivo XML mi problema es que generando un HTMl me funciona correctamente, pero ...
  #1 (permalink)  
Antiguo 24/10/2007, 15:54
 
Fecha de Ingreso: junio-2007
Mensajes: 10
Antigüedad: 16 años, 9 meses
Puntos: 0
Algien que me ayude con este codigo

Alguien podria ayudarme con este codigo ya que no me genera el archivo XML
mi problema es que generando un HTMl me funciona correctamente, pero nunca he generado un XML, y lo necesito para un flash.

Gracias de antemano

<?php
//ob_start();
header('Content-type: text/xml');
//truco por si short_open_tag = On
echo '<';
?>
?xml version="1.0" encoding="iso-8859-1"?>
<?php
$lgsl_cache_time = 1;
$lgsl_hostname_shorten = 1;
$lgsl_hostname_length = 40;
$lgsl_hide_offline = 0;
$lgsl_hostname_to_ip = 0;

$lgsl_path = "";

require_once($lgsl_path."lgsl_protocol.php");

if (!is_writable($lgsl_path."lgsl_cache.dat")) { echo "El archivo LGSL_CACHE.DAT no se puede escribir"; exit; }

$lines = file($lgsl_path."lgsl_cache.dat");
$last_line = count($lines) - 1;
$last_update = intval($lines[$last_line]);
$time_check = time() - ($lgsl_cache_time * 60);

if ($time_check < $last_update)
{

unset($lines[$last_line]);
unset($data_cache);

foreach ($lines as $line_number=>$line)
{
$data_cache[$line_number] = unserialize($line);
}
}
else
{

ignore_user_abort(true);

$lines = file($lgsl_path."lgsl_servers.txt");

$data_counter = 0;
unset($data_cache);

foreach ($lines as $line)
{
if (!trim($line)) { continue; }

$part = explode(":", $line);
$server_ip = trim($part[0]);
$server_port = trim($part[1]);
$server_type = trim($part[2]);

if (!$server_ip || !$server_port) { continue; }

$data = lgsl_query($server_ip, $server_port, $server_type, "info");

$data[gamemod] = preg_replace("/[^A-Za-z0-9 \_\-]/", "_", strtolower($data[gamemod]));
$data[mapname] = preg_replace("/[^A-Za-z0-9 \_\-]/", "_", strtolower($data[mapname]));

$data_counter += 1;
$data_cache[$data_counter] = $data;
}

$fh = fopen($lgsl_path."lgsl_cache.dat","w");

foreach($data_cache as $line)
{
$line = serialize($line)."\r\n";
fwrite($fh,$line);
}

fwrite($fh, time());

fclose($fh);

ignore_user_abort(false);

}


echo '<servers>';


$lgsl_stats_servers = 0;
$lgsl_stats_players = 0;
$lgsl_stats_maxplayers = 0;

foreach($data_cache as $data)
{
if (!$data[status] && $lgsl_hide_offline) { continue; }

if (!$data[status])
{
$lgsl_image_status = $lgsl_path."images/status/server_offline.gif";
$data[status] = "OFFLINE";
$data[hostname] = "Unknown";
$data[mapname] = "unknown";
}
else if (!$data[password])
{
$lgsl_image_status = $lgsl_path."images/status/server_online.gif";
$data[status] = "ONLINE";
}
else
{
$lgsl_image_status = $lgsl_path."images/status/server_online_password.gif";
$data[status] = "ONLINE CON PASSWORD";
}

$lgsl_image_icon = $lgsl_path."images/icons/$data[gametype]/$data[gamemod].gif";

if (!file_exists($lgsl_image_icon))
{
$lgsl_image_icon = $lgsl_path."images/icons/$data[gametype]/$data[gametype].gif";

if (!file_exists($lgsl_image_icon))
{
$lgsl_image_icon = $lgsl_path."images/status/unknown.gif";
}
}

if (strlen($data[hostname]) > $lgsl_hostname_length)
{
if ($lgsl_hostname_shorten == 1)
{
$data[hostname] = substr($data[hostname], 0, $lgsl_hostname_length - 3) . "...";
}
else if ($lgsl_hostname_shorten == 2)
{
$data[hostname] = "..." . substr($data[hostname], - $lgsl_hostname_length);
}
}

$data[hostname] = htmlentities($data[hostname], ENT_QUOTES);

if ($lgsl_hostname_to_ip) { $data[ip] = gethostbyname($data[ip]); }

$lgsl_launch = lgsl_get("launch", $data[ip], $data[port], $data[gametype]);



$lgsl_stats_servers++;
$lgsl_stats_players += $data[players];
$lgsl_stats_maxplayers += $data[maxplayers];
//-----------------------------------------------------------------------------------------------------------+

echo '<serve statuts="'$data[status]'" image_status="'$lgsl_image_status'" tipo_juego="'$data[gametype] - $data[gamemod]'" image_tipo_juego="'$lgsl_image_icon'" ip_server="'$data[ip]:$data[port]'" nombre_server="'$data[hostname]'" mapa_actual="'$data[mapname]'" jugadores_actual="'$data[players]'" jugadores_maximos="'$data[maxplayers]'" />';
} // DL ULTIMO foreach
echo '</servers>';
//-----------------------------------------------------------------------------------------------------------+


?>
  #2 (permalink)  
Antiguo 24/10/2007, 16:07
Avatar de TolerantX  
Fecha de Ingreso: marzo-2006
Ubicación: Guadalajara, México.
Mensajes: 408
Antigüedad: 18 años
Puntos: 10
Re: Algien que me ayude con este codigo

Emm, y cuál es el problema?, debes ser más explícito. ¿en dónde tuviste broncas?, si te salen errores , ¿cuáles son?
__________________
TolerantX
http://tolerantx.com
Linux User #385226
  #3 (permalink)  
Antiguo 24/10/2007, 16:14
 
Fecha de Ingreso: junio-2007
Mensajes: 10
Antigüedad: 16 años, 9 meses
Puntos: 0
Re: Algien que me ayude con este codigo

cuando ejecuto la pagina como si fuese normal, no me genera el xml
ejemplo: www.ermanikomio.com/verServer/server_xm_l8.php

en cambio en html si lo ejecuta bien:

www.ermanikomio.com/verServer/index.php

este archivo lo necesito generar en XML para poder integrarlo en el Flash.
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 04:02.