Domanda

I have this code but, when I logged in habbo the function doesn't work for the image online, it just shows the image offline:

<?php
$name = $_GET['habbo'];
$home = file_get_contents("http://www.habbo.com.br/home/".$name);
if (eregi("http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online_anim.gif", $home))
{
$img = "http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online.gif";
}
else
{
$img = "http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_offline.gif";
}
header("Content-type: image/gif");
$im = imagecreatefromgif($img);
imagegif($im);
imagedestroy($im);
?>
È stato utile?

Soluzione 2

Try this:

<?php
$name = $_GET['habbo'];
$home = file_get_contents('http://www.habbo.com.br/home/'.$habbo);
if (stristr($home, 'http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online_anim.gif') == TRUE)
{
    $img = 'http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online.gif';
}
    else
{
    $img = 'http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_offline.gif';
}
header('Content-type: image/gif');
$im = imagecreatefromgif($img);
imagegif($im);
imagedestroy($im);

stristr acts like eregi when you're not using regexp, this should find the string and compare if it's TRUE or FALSE.

Update: '=== TRUE' to '== TRUE'

Altri suggerimenti

The problem is that eregi is depreciated as of PHP 5.3 to 5.4 and completely removed in PHP 5.5. But that said, looking at your code it makes no sense why eregi is there to begin with. Look at this line:

if (eregi("http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online_anim.gif", $home))

What exactly is the pattern matching that is happening? I seems like it is a simple == check to me. So I would suggest trying this. I am also cleaning up your formatting as well for readability:

$name = $_GET['habbo'];

$home = file_get_contents("http://www.habbo.com.br/home/".$name);

$check = "http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online_anim.gif";

if ($check == $home) {
  $img = "http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online.gif";
}
else {
  $img = "http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_offline.gif";
}

header("Content-type: image/gif");

$im = imagecreatefromgif($img);

imagegif($im);
imagedestroy($im);

A couple of things:

First, eregi is deprecated in favor of preg_match using the case-insensitive regular expression marker (i). So, you should switch to using preg_match in this and future cases in which a regular expression match needs to be made.

Second, eregi and preg_match don't return boolean values. So, you're going to need to use the identity operator (=== or !==) to test for matches.

Lastly, it's highly unlikely that a match will ever be made, since you're not using a regular expression in your search. You need to be doing something like this:

if (eregi('/someregex/i', $home) !== FALSE){

It may be helpful for you to review the syntax for PCRE-style regular expressions, which can be found here, as well as check the return values for the functions you're using. There's a note on php.net about checking returns using the identity operator.

It seems that you're just searching for a username, in which case it may make more sense to search via stripos, as it's much faster than a regular expression, and searches only for string literals, as you seem to be doing:

$name = $_GET['habbo'];
$home = file_get_contents("http://www.habbo.com.br/home/" . $name);
if (stripos($home, "<whatever you're searching for>") !== FALSE) {

Either way, you need to check what you're actually searching for. Currently, you seem to be searching for the path leading to that image within the contents of the $home. Unless that complete string is present, you're not going to find it. If you're just searching for habbo_online_anim.gif within $home, try this:

if (stripos($home, 'habbo_online_anim.gif') !== FALSE) {
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top