0

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);
?>
Nathan H
  • 48,033
  • 60
  • 165
  • 247
user3133630
  • 3
  • 1
  • 2
  • 5
  • 3
    `eregi()` is deprecated and probably removed from the version of PHP you are using. You need to use `preg_match()` instead (although I suspect regular expressions aren't needed at all and a standard comparison operator will do). – John Conde Jan 05 '14 at 06:39
  • Yeah, looks like you could use '=='... – JAL Jan 05 '14 at 06:41
  • Warning : This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged. – RaviRokkam Jan 05 '14 at 06:42
  • Who i use that guys?? thanks for help me, i'm a noob. Sorry :( – user3133630 Jan 05 '14 at 06:48
  • functions like ereg, eregi, split etc. are deprecated (not only deprecated, but completely removed) as of PHP 5.3. Read more http://www.php.net/manual/en/reference.pcre.pattern.posix.php – Fawzan Jan 05 '14 at 06:50
  • Folks, the assessment of `eregi` is correct, but look at the actual code logic. I make a case in my answer, but it seems like even if `eregi` worked, the logic of the conditional it is being used in makes little sense. Seems like overkill or uninformed programming to me. – Giacomo1968 Jan 05 '14 at 06:52
  • Exactly **WHY** are you tryign to grab a remote gif, decompress it in memory, then re-compress to gif? That's a TOTAL waste of system resources. you could just have `readfile($img);` and skip ALL of that `image*()` stuff. – Marc B Jan 05 '14 at 06:57

3 Answers3

1

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);
Giacomo1968
  • 25,759
  • 11
  • 71
  • 103
  • I tested it now, but doesn't work yet, i don't understand 'cause if u use just ($check = $home) i get the image online but if i use ($check == $home) i get the image offline but i'm online! – user3133630 Jan 05 '14 at 07:02
  • 1
    $check = $home would set the value of $check to the value of $home and then return true for doing so. So, it'll always be true. $check == $home would see if $check is the same thing as $home. Check out [comparison operators](http://us2.php.net/manual/en/language.operators.comparison.php) in php. – LoganEtherton Jan 05 '14 at 07:05
  • @user3133630 Part of the problem is your code makes little sense and the use of `eregi` is baffling. So now you need to get rid of `eregi` but it is unclear what your comparison or why it is set that way. Meaning, what is in `$home` and why is being compared to that huge URL? – Giacomo1968 Jan 05 '14 at 07:13
  • I tried but just appears the image offline, never the online!! – user3133630 Jan 05 '14 at 07:30
  • @user3133630 I will repeat what I said, “So now you need to get rid of eregi but it is unclear what your comparison or why it is set that way. Meaning, what is in $home and why is being compared to that huge URL?” – Giacomo1968 Jan 05 '14 at 07:38
0

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) {
LoganEtherton
  • 495
  • 4
  • 12
0

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'

kold-kreator
  • 179
  • 2
  • 2
  • 12
  • I tried this too, but doesn't work, i'm online but appears the image offline, may be this problem is 'cause the code doesn't get the file contents ??? – user3133630 Jan 05 '14 at 07:23
  • Test it, first check if the code is getting "anything", then you can eliminating one thing at a time... – kold-kreator Jan 05 '14 at 07:27
  • Just tested here, and it's working, just replace '=== TRUE' for '!== FALSE'... Check it: https://www.enginesistemas.com.br/habbo.php – kold-kreator Jan 05 '14 at 07:35
  • I just need a code if i'm online appears a online image and if i have offline appears a offline image. – user3133630 Jan 05 '14 at 07:35
  • Check the link I've posted. I just changed the TRUE/FALSE and created a $var to check with STRISTR. – kold-kreator Jan 05 '14 at 07:39
  • yes, appears online but in my not, check it: http://testesfods.comze.com/status.php?habbo=Deposito-Nando and i use that: if (stristr($home, 'http://habboo-a.akamaihd.net/habboweb/63_1dc60c6d6ea6e089c6893ab4e0541ee0/2245/web-gallery/images/myhabbo/profile/habbo_online_anim.gif') !== FALSE) – user3133630 Jan 05 '14 at 07:43