PDA

View Full Version : [Help] PHP Script Problem



AaidenX
04-07-2013, 08:13 AM
Ok, so I need a PHP script to show a habbo user's motto, and did find a script but it doesn't actually seem to work.


<?php

class generator
{

var $data;
var $habboname;
var $hotel;
var $url;

function generator( $habboname, $hotel )
{

$this->habboname = $habboname;
$this->hotel = $hotel;
$this->url = "http://habbo." . $hotel . "/home/" . $habboname;
$this->data = @file_get_contents( $this->url );

}

function offline() {

if( eregi( "User personal habbo page is hidden", $this->data ) or !$this->name() ) {

return true;

}
else {

return false;

}

}



function online()
{

if ( eregi( "habbo_online_anim.gif", $this->data ) )
{

return true;

}
else
{

return false;

}

}

function motto()
{

$motto = explode( "<div class=\"profile-motto\">", $this->data );
$motto = explode( "<div", $motto[1] );
$motto = trim($motto[0]);

return $motto;

}

function badge()
{

if( eregi( "c_images/album1584/", $this->data ) )
{

$badge = explode( "/c_images/album1584/", $this->data );
$badge = explode( ".gif", $badge[1] );
$badge = trim( $badge[0] );
$badge = "http://images.habbo.com/c_images/album1584/" . $badge . ".gif";

return $badge;

}
else
{

return false;

}

}

function figure()
{

$figure = "http://www.habbo." . $this->hotel . "/habbo-imaging/avatarimage?user=" . $this->habboname . "&action=&direction=2&head_direction=3&gesture=sml&size=l&img_format=gif";
return $figure;

}

function birthDate()
{

$birthdate = explode( "<div class=\"birthday date\">", $this->data );
$birthdate = explode( "</div>", $birthdate[1] );
$birthdate = trim( $birthdate[0] );

return $birthdate;

}

function name()
{

$name = explode( "<span class=\"name-text\">", $this->data );
$name = explode( "</span>", $name[1] );
$name = trim( $name[0] );

return $name;

}

function groupBadge()
{

if( eregi( "/habbo-imaging/badge/", $this->data ) )
{

$badge = explode( "/habbo-imaging/badge/", $this->data );
$badge = explode( ".gif", $badge[1] );
$badge = trim( $badge[0] );
$badge = "http://www.habbo." . $this->hotel . "/habbo-imaging/badge/" . $badge . ".gif";

return $badge;

}
else
{

return false;

}

}

}

$habbo = $_GET['name'];

switch( $_GET['hotel'] ) {

case 'au':
$hotel = "com.au";
break;

case 'sg':
$hotel = "com.sg";
break;

case 'us':
$hotel = "com";
break;

case 'ca':
$hotel = "ca";
break;

default:
$hotel = "co.uk";
break;

}
?>
<?php
if( $motto = $data->name() ){
echo $motto;
}
?>

But if you have a better script than this/working one, please pass it to me. I would be also appreciated if you made that one working.

-Nick
04-07-2013, 08:36 AM
Ok, so I need a PHP script to show a habbo user's motto, and did find a script but it doesn't actually seem to work.


<?php

class generator
{

var $data;
var $habboname;
var $hotel;
var $url;

function generator( $habboname, $hotel )
{

$this->habboname = $habboname;
$this->hotel = $hotel;
$this->url = "http://habbo." . $hotel . "/home/" . $habboname;
$this->data = @file_get_contents( $this->url );

}

function offline() {

if( eregi( "User personal habbo page is hidden", $this->data ) or !$this->name() ) {

return true;

}
else {

return false;

}

}



function online()
{

if ( eregi( "habbo_online_anim.gif", $this->data ) )
{

return true;

}
else
{

return false;

}

}

function motto()
{

$motto = explode( "<div class=\"profile-motto\">", $this->data );
$motto = explode( "<div", $motto[1] );
$motto = trim($motto[0]);

return $motto;

}

function badge()
{

if( eregi( "c_images/album1584/", $this->data ) )
{

$badge = explode( "/c_images/album1584/", $this->data );
$badge = explode( ".gif", $badge[1] );
$badge = trim( $badge[0] );
$badge = "http://images.habbo.com/c_images/album1584/" . $badge . ".gif";

return $badge;

}
else
{

return false;

}

}

function figure()
{

$figure = "http://www.habbo." . $this->hotel . "/habbo-imaging/avatarimage?user=" . $this->habboname . "&action=&direction=2&head_direction=3&gesture=sml&size=l&img_format=gif";
return $figure;

}

function birthDate()
{

$birthdate = explode( "<div class=\"birthday date\">", $this->data );
$birthdate = explode( "</div>", $birthdate[1] );
$birthdate = trim( $birthdate[0] );

return $birthdate;

}

function name()
{

$name = explode( "<span class=\"name-text\">", $this->data );
$name = explode( "</span>", $name[1] );
$name = trim( $name[0] );

return $name;

}

function groupBadge()
{

if( eregi( "/habbo-imaging/badge/", $this->data ) )
{

$badge = explode( "/habbo-imaging/badge/", $this->data );
$badge = explode( ".gif", $badge[1] );
$badge = trim( $badge[0] );
$badge = "http://www.habbo." . $this->hotel . "/habbo-imaging/badge/" . $badge . ".gif";

return $badge;

}
else
{

return false;

}

}

}

$habbo = $_GET['name'];

switch( $_GET['hotel'] ) {

case 'au':
$hotel = "com.au";
break;

case 'sg':
$hotel = "com.sg";
break;

case 'us':
$hotel = "com";
break;

case 'ca':
$hotel = "ca";
break;

default:
$hotel = "co.uk";
break;

}
?>
<?php
if( $motto = $data->name() ){
echo $motto;
}
?>

But if you have a better script than this/working one, please pass it to me. I would be also appreciated if you made that one working.

not a pro but surely


$this->url = "http://habbo.com" . $hotel . "/home/" . $habboname;

AaidenX
04-07-2013, 08:59 AM
Not working!

My errors:


Notice: Undefined index: name in C:\Xampp\htdocs\Files\index.php on line 146

Notice: Undefined index: hotel in C:\Xampp\htdocs\Files\index.php on line 148

Notice: Undefined variable: data in C:\Xampp\htdocs\Files\index.php on line 173

Fatal error: Call to a member function name() on a non-object in C:\Xampp\htdocs\Files\index.php on line 173

N!ck
07-07-2013, 09:22 PM
Have you instantiated $data as an object of the generator class?


$data = new generator;

Before you try and use it.

Mr-Trainor
08-07-2013, 09:50 PM
not a pro but surely


$this->url = "http://habbo.com" . $hotel . "/home/" . $habboname;
The $hotel part will add that in, so if the user chose the .com hotel then the . $hotel . Would be .com and fill it in :P. So op if you put .com in manually then you should take away the . $hotel . :).

FlyingPigs
09-07-2013, 10:32 AM
Try this :)



<?php

class generator
{

var $data;
var $habboname;
var $hotel;
var $url;

function generator( $habboname, $hotel )
{

$this->habboname = $habboname;
$this->hotel = $hotel;
$this->url = "http://habbo." . $hotel . "/home/" . $habboname;
$this->data = @file_get_contents( $this->url );

}

function offline() {

if( eregi( "User personal habbo page is hidden", $this->data ) or !$this->name() ) {

return true;

}
else {

return false;

}

}



function online()
{

if ( eregi( "habbo_online_anim.gif", $this->data ) )
{

return true;

}
else
{

return false;

}

}

function motto()
{

$motto = explode( "<div class=\"profile-motto\">", $this->data );
$motto = explode( "<div", $motto[1] );
$motto = trim($motto[0]);

return $motto;

}

function badge()
{

if( eregi( "c_images/album1584/", $this->data ) )
{

$badge = explode( "/c_images/album1584/", $this->data );
$badge = explode( ".gif", $badge[1] );
$badge = trim( $badge[0] );
$badge = "http://images.habbo.com/c_images/album1584/" . $badge . ".gif";

return $badge;

}
else
{

return false;

}

}

function figure()
{

$figure = "http://www.habbo." . $this->hotel . "/habbo-imaging/avatarimage?user=" . $this->habboname . "&action=&direction=2&head_direction=3&gesture=sml&size=l&img_format=gif";
return $figure;

}

function birthDate()
{

$birthdate = explode( "<div class=\"birthday date\">", $this->data );
$birthdate = explode( "</div>", $birthdate[1] );
$birthdate = trim( $birthdate[0] );

return $birthdate;

}

function name()
{

$name = explode( "<span class=\"name-text\">", $this->data );
$name = explode( "</span>", $name[1] );
$name = trim( $name[0] );

return $name;

}

function groupBadge()
{

if( eregi( "/habbo-imaging/badge/", $this->data ) )
{

$badge = explode( "/habbo-imaging/badge/", $this->data );
$badge = explode( ".gif", $badge[1] );
$badge = trim( $badge[0] );
$badge = "http://www.habbo." . $this->hotel . "/habbo-imaging/badge/" . $badge . ".gif";

return $badge;

}
else
{

return false;

}

}

}

$habbo = $_GET['name'];

switch( $_GET['hotel'] ) {

case 'au':
$hotel = "com.au";
break;

case 'sg':
$hotel = "com.sg";
break;

case 'us':
$hotel = "com";
break;

case 'ca':
$hotel = "ca";
break;

default:
$hotel = "co.uk";
break;

}
?>
<?php
$mottof = new generator();
$mottof->generator($habbo, $_GET['hotel']);

echo $mottof->motto();
?>


Testing it right now and will update.

FlyingPigs
09-07-2013, 11:31 AM
Sorry for double posting but it looks like Habbo has updated its homepage system and requires a certain cookie. This code should work.



<?php
class Habbo
{

public function get_data($uri)
{
if (!function_exists('curl_init')) {
die('Curl is not installed!');
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, "YPF8827340282Jdskjhfiw_928937459182JAX666=" .
$_SERVER["SERVER_ADDR"] . ";DOAReferrer=;");
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, "habbo.com");
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

public function getMotto($username, $hotel)
{
$page = $this->get_data("http://www.habbo." . $hotel . "/home/" . $username);

if (strpos($page, '<div class="profile-motto">') !== false) {
$split = explode('<div class="profile-motto">', $page);
$split = explode("<div", $split[1]);

return $split[0];
} else {
return "No motto found";
}
}
}

$habbo = new Habbo;

echo $habbo->getMotto("happy", "com");
?>


cURL is required and won't work on my localhost

AaidenX
02-02-2014, 01:57 PM
@FlyingPigs it returns with no motto found! so yh... cURL is installed in my XAMPP

GoldenMerc
02-02-2014, 05:32 PM
Afaik its impossible now as Sulake had a big problem with someone searching all the badges etc

Sent from my HTC One using Tapatalk

eLv
03-02-2014, 08:28 AM
Just wanna say that grabbing only the basic details like avatar, online status, created date and motto is still available remotely even with the user profile being set to private, as seen on HabboEmotion: http://habboemotion.com/#habinfo

Badges and friends need a unique widget id which verify if the user have the widget or their profile shown, else it won't work. This only applies to the international hotels I think as I can still use old codes on other hotels to retrieve their badges and friends regardless their profile is set to hidden.

Just sharing.

Sent using mobile

Blinger
05-02-2014, 02:12 AM
<?php
class Habbo
{

public function get_data($uri)
{
if (!function_exists('curl_init')) {
die('Curl is not installed!');
}

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_COOKIE, "YPF8827340282Jdskjhfiw_928937459182JAX666=" .
$_SERVER["SERVER_ADDR"] . ";DOAReferrer=;");
$useragent = "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.1) Gecko/20061204 Firefox/2.0.0.1";
curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
curl_setopt($ch, CURLOPT_REFERER, "habbo.com");
$output = curl_exec($ch);
curl_close($ch);
return $output;
}

public function getMotto($username, $hotel)
{
$page = $this->get_data("http://www.habbo." . $hotel . "/home/" . $username);

if (strpos($page, '<div class="profile-motto">') !== false) {
$split = explode('<div class="profile-motto">', $page);
$split = explode("<div", $split[1]);

return $split[0];
} else {
return "No motto found";
}
}
}

$habbo = new Habbo;

echo $habbo->getMotto("happy", "com");
?>

That should work as long as you aren't on a localhost. I changed the line with the cookie info to just "curl_setopt($ch, CURLOPT_COOKIE, "YPF8827340282Jdskjhfiw_928937459182JAX666=IPGOESHE RE;");" as that's all that's needed. Chuck in your IP address in the bold spot and it's good to go.

Want to hide these adverts? Register an account for free!