Siento molestar de nuevo, pero me gustaría ayuda para poder conseguir terminar mi idea.
Mi idea es crear una imagen de estado de un servidor mediante url.
Ejemplo:
- IP: sorienrot.es
- Puerto: 25565 <- Puerto de servidor de Minecraft de ejemplo.
- Solucion: [URL="http://sorienrot.es/stats.php?ip=sorienrot.es&port=25565"]http://sorienrot.es/stats.php?ip=sorienrot.es&port=25565[/URL]
Se pueden añadir variables para elegir un estilo predeterminado con &estilo=1, &estilo=2, &estilo=3 asta el 5. Solo el 1 esta establecido.
Luego en caso de querer utilizar imágenes propias se puede usar las variables urlon para la imagen de encendio, y urloff para la de apagado.
Ejemplo: [URL="http://sorienrot.es/stats.php?ip=sorienrot.es&port=25565&urlon=http://www.laloterianavidad.com/mediaweb/reclamo_ninyo.jpg&urloff=https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/41977/1f82900201ad755ce26afeebdd59a0b6.jpeg"]http://sorienrot.es/stats.php?ip=sorienrot.es&port=25565&urlon=http://www.laloterianavidad.com/mediaweb/reclamo_ninyo.jpg&urloff=https://coderwall-assets-0.s3.amazonaws.com/uploads/user/avatar/41977/1f82900201ad755ce26afeebdd59a0b6.jpeg[/URL]
En caso de faltar uno, se quejara para que pongas el que le queda.
El problema surge al intentar utilizar, para que se pueda utilizar en foros y demás, <img></img> de html no sale la imagen. Según leí en post la idea seria utilizar esto:
Código PHP:
<?php
$im = imagecreatefrompng("test.png");
header('Content-Type: image/png');
?>
http://www.rinconastur.com/php/php77.php
Se puede ver en el apartado de Dibujando sobre una imagen de fondo el ejemplo entre comillas.
Ejemplo de la pagina, que se puede utilizar con img de foros.
http://www.rinconastur.com/php/ejemplo204a.php ====>>>>>
Codigo PHP en cuestion :
Código PHP:
<?php /*
*/
$ip = $_GET["ip"];
$port = $_GET["port"];
$estilo = $_GET["estilo"];
$urlon = $_GET["urlon"];
$urloff = $_GET["urloff"];
if (isset($_GET["ip"]))
{
if (isset($_GET["port"]))
{
if (isset($_GET["urloff"]))
{
if (isset($_GET["urlon"]))
{}
else
{
echo '<script language="javascript">';
echo 'alert("No as indicado la url de encendido. Ejemplo = stats.php?ip=14...14&port=...&urlon=URL_Propia")';
echo '</script>';
echo '<script>';
echo 'window.history.back()';
echo '</script>';
}
}
if (isset($_GET["urlon"]))
{
if (isset($_GET["urloff"]))
{}
else
{
echo '<script language="javascript">';
echo 'alert("No as indicado la url de apagado. Ejemplo = stats.php?ip=14...14&port=...&urloff=URL_Propia")';
echo '</script>';
echo '<script>';
echo 'window.history.back()';
echo '</script>';
}
}
if (isset($_GET["urlon"], $_GET["urloff"]))
{
/*Con urls*/
$imgfon = "$urlon";
$imgfoff = "$urloff";
function pingDomain($domain, $puerto)
{
$starttime = microtime(true);
$file = @fsockopen ($domain, $puerto, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;
if (!$file) $status = -1; // Site is down
else
{
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
if ($status <> -1)
{
return true;
}
return false;
}
if (pingDomain($ip, $port))
{
echo '<img src="'.$imgfon.'">';
}
else
{
echo '<img src="'.$imgfoff.'">';
}
/*Fin Con urls*/
}
else
{
/*Inicio estilos estilos*/
if (isset($_GET["estilo"]))
{
if($_GET["estilo"] == 1)
{
$imgfon = "/imagenes/estilo1on.png";
$imgfoff = "/imagenes/estilo1off.png";
}
else
{
if($_GET["estilo"] == 2)
{
$imgfon = "Imagen_2_on";
$imgfoff = "Imagen_2_off";
}
else
{
if($_GET["estilo"] == 3)
{
$imgfon = "Imagen_3_on";
$imgfoff = "Imagen_3_off";
}
else
{
if($_GET["estilo"] == 4)
{
$imgfon = "Imagen_4_on";
$imgfoff = "Imagen_4_off";
}
else
{
if($_GET["estilo"] == 5)
{
$imgfon = "Imagen_5_on";
$imgfoff = "Imagen_5_off";
}
}
}
}
}
}
else
{
/* Imagen estandar vacia */
$imgfon = "/imagenes/on.png";
$imgfoff = "/imagenes/off.png";
}
function pingDomain($domain, $puerto)
{
$starttime = microtime(true);
$file = @fsockopen ($domain, $puerto, $errno, $errstr, 10);
$stoptime = microtime(true);
$status = 0;
if (!$file) $status = -1; // Site is down
else
{
fclose($file);
$status = ($stoptime - $starttime) * 1000;
$status = floor($status);
}
if ($status <> -1)
{
return true;
}
return false;
}
if (pingDomain($ip, $port))
{
echo '<img src="'.$imgfon.'">';
}
else
{
echo '<img src="'.$imgfoff.'">';
}
/*Final estilos*/
}
}
else
{
echo '<script language="javascript">';
echo 'alert("No as indicado el puerto. Ejemplo = stats.php?ip=14...14&port=12345")';
echo '</script>';
echo '<script>';
echo 'window.history.back()';
echo '</script>';
}
}
else
{
echo '<script language="javascript">';
echo 'alert("No as indicado la ip. Ejemplo stats.php?ip=123.123.123.123")';
echo '</script>';
echo '<script>';
echo 'window.history.back()';
echo '</script>';
}
?>
Código PHP:
if (pingDomain($ip, $port))
{
echo '<img src="'.$imgfon.'">'; /* Aquí iría el código */
}
else
{
echo '<img src="'.$imgfoff.'">'; /* Aquí iría el código */
}
/*Final estilos*/