-
Dove sta l' errore?
Avevo creato questo 'script' in php per estrarre dalla pagina scelta una stringa, ovvero la data di registrazione. Se metto il codice senza l' elseif funziona correttamente (http://exabyte.altervista.org/data.php , per provare inserite ad esempio armadillo) ma se metto con le elseif per far in modo che si può scegliere un posto diverso (dovete sapere che questo gioco è in tutto il mondo, quindi ha diversi domini con diversa gente e ho necessità di far in modo che si possano scegliere tutti gli hotel).. Avevo scritto questo ma non funziona, non so perchè:
Codice PHP:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<link href="css.css" type="text/css" rel="stylesheet">
<title>#exabyte</title>
</head>
<body>
<div class="area_header">
<div class="area_menu">
<div class="menu"><a href="index.php">Home</a> | <font color="white">Tools</font> | <a href="screen.php">Screen</a> | <a href="video.php">Video</a></div></div>
<div class="header">#€xabyte</div></div>
<div class="area_text"><div class="text">
<form action="" method="POST">
Inserisci il nome habbo<br>
<input type="text" class="input_text" name="habbo"><br><br>
<select name="hotel" class="input_select">
<option value="it">Habbo.it</option>
<option value="com">Habbo.com</option>
<option value="es">Habbo.es</option>
<option value="de">Habbo.de</option>
<option value="nl">Habbo.nl</option>
<option value="com.br">Habbo.com.br</option>
<option value="dk">Habbo.dk</option>
<option value="fi">Habbo.fi</option>
<option value="fr">Habbo.fr</option>
<option value="ie">Habbo.ie</option>
<option value="no">Habbo.no</option>
<option value="se">Habbo.se</option>
</select>
<input type="submit" class="input_submit" value="Invia"></form>
<?
$habbo = $_POST['habbo'];
if (empty($habbo)) {
echo "<br><br>Campo vuoto o Home Nascosta.";
} elseif ($hotel == "it") {
$fp = fsockopen("www.habbo.it/home/{$habbo}", 80);
$file = "http://www.habbo.it/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "com") {
$fp = fsockopen("www.habbo.com/home/{$habbo}", 80);
$file = "http://www.habbo.com/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "es") {
$fp = fsockopen("www.habbo.es/home/{$habbo}", 80);
$file = "http://www.habbo.es/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "de") {
$fp = fsockopen("www.habbo.de/home/{$habbo}", 80);
$file = "http://www.habbo.de/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "nl") {
$fp = fsockopen("www.habbo.nl/home/{$habbo}", 80);
$file = "http://www.habbo.nl/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "com.br") {
$fp = fsockopen("www.habbo.com.br/home/{$habbo}", 80);
$file = "http://www.habbo.com.br/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "dk") {
$fp = fsockopen("www.habbo.dk/home/{$habbo}", 80);
$file = "http://www.habbo.dk/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "fi") {
$fp = fsockopen("www.habbo.fi/home/{$habbo}", 80);
$file = "http://www.habbo.fi/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "fr") {
$fp = fsockopen("www.habbo.fr/home/{$habbo}", 80);
$file = "http://www.habbo.fr/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "ie") {
$fp = fsockopen("www.habbo.ie/home/{$habbo}", 80);
$file = "http://www.habbo.ie/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "no") {
$fp = fsockopen("www.habbo.no/home/{$habbo}", 80);
$file = "http://www.habbo.no/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}} elseif ($hotel == "se") {
$fp = fsockopen("www.habbo.se/home/{$habbo}", 80);
$file = "http://www.habbo.se/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}}
?>
</div></div>
<div class="area_text_footer"><div class="footer_cp"><div class="footer_copyr">Copyright <? echo(date("Y")); ?> © . All rights reserved. Skin made from <a href="http://habbo.it/home/armadillo" target="_blank">#exabyte</a>.</div></div></div>
</body>
</html>
-
Ma se $hotel contiene "it o com o quellocheé" non sarebbe più semplice un:
Codice PHP:
<?php
$habbo = $_POST['habbo'];
$hotel = $_POST['hotel'];
if (!empty($habbo) && !empty($hotel)) {
$fp = fsockopen("www.habbo.{$hotel}/home/{$habbo}", 80);
$file = "http://www.habbo.{$hotel}/home/{$habbo}";
$sorgente_file_remoto = implode("", file($file));
if(eregi("<div class=\"birthday date\">(.+)<div>", $sorgente_file_remoto, $titolo)) {
echo "<br><br>La data di registrazione di <b>$habbo</b> è <b>$titolo[1]</b>";
}
else
{
echo "<br /><br />Utente non trovato :("; // Non è detto che trovi sempre il nick inserito
}
}
else
{
echo "<br /><br />Campo vuoto o Home Nascosta.";
}
?>
No perché, ad essere sincero, non noto altre differenze :|
-
ahah sì ci avevo pensato ma ero andato a mangiare e avevo scordato di farlo lol .. Però guarda tu stesso: http://exabyte.altervista.org/test.php
Come vedi non funziona ugualmente..
AAAH SAI DOVE STAVA L' ERRORE? AVEVO SCORDATO DI DICHIARARE LA VARIABILE $hotel, risolto grazie XD
-
Vedi gli edit precedenti, non avevo ancora notato la tua replica.
-
Perchè utilizzi fsockopen, file e implode, puoi utilizzare solo file_get_contents:
Codice PHP:
$sorgente_file_remoto = file_get_contents($file);
inoltre la funzione eregi è deprecata.