Avatar caching error

Proximity

IDK?
Feb 13, 2014
673
56
So I am trying to avatar cache for my radio it will grab the user name from the db and their look and show it

K0_1eya8kyUC4n8NpzdC-HtbCI3tbKa4JkHTH6Yb2R0

but I am getting that

here is the code

Code:
<?php

    if(isset($_GET['user'])) {

        $host = "127.0.0.1";
        $username = "root";
        $password = "";
        $dbname = "";
        $connect = mysql_connect($host, $username, $password) or die(mysql_error());
        mysql_select_db($dbname, $connect) or die("Could not connect to database, error: ".mysql_error());
        $user = mysql_real_escape_string($_GET['user']);
        $figure = "figure=".mysql_result(mysql_query("SELECT look FROM users WHERE username='".$user."' LIMIT 1"),0);
        header('Content-Type: image/png');
        exit(file_get_contents('http://habbo.com/habbo-imaging/avatarimage?'.$figure.http_build_query($_GET)));

    }

    else {

        $url = 'http://habbo.com/habbo-imaging/avatarimage?figure='.http_build_query($_GET);
        header('Content-Type: image/png');
        exit(file_get_contents($url));

    }

?>


@Westyy maybe you can help me and yes I just removed the details
 

Proximity

IDK?
Feb 13, 2014
673
56
I do not know but when I tried claweds version here:
Its blank and I get nothing AND YES I DID PUT MYSQL DETAILS IN!
Code:
<?php

    // Copyright Clawed.
    // Got bored to be honest.
   
    function filter( $string ) {
        return mysql_real_escape_string( $string );
    }
   
    define( "HOSTNAME", "localhost" );
    define( "USERNAME", "root" );
    define( "PASSWORD", "kyle" );
    define( "DATABASE", "test" );
   
    if( !mysql_connect( HOSTNAME, USERNAME, PASSWORD ) ) die( mysql_error() );
    if( !mysql_select_db( DATABASE ) ) die( mysql_error() );
   
    $url = "http://habbo.com/";
   
    if( !filter( $_GET['username'] ) ) {
        die( "<h1>Error</h1><hr>Username required.<hr>" );
    }
   
    $query = mysql_query( "SELECT * FROM users WHERE username = '" . filter( $_GET['username'] ) . "'" ) or die( mysql_error() );
    if( mysql_num_rows( $query ) < 1 ) { die( "Username does not exists." ); }
    $array = mysql_fetch_assoc( $query );
    $url = $url . "habbo-imaging/avatarimage?figure=" . $array['look'];
   
    if( filter( $_GET['direction'] ) ) {
        $url = $url . "&direction=" . filter( $_GET['direction'] );
    }
   
    if( filter( $_GET['gesture'] ) ) {
        $url = $url . "&gesture=" . filter( $_GET['gesture'] );
    }
   
    if( filter( $_GET['size'] ) ) {
        $url = $url . "&size=" . filter( $_GET['size'] );
    }
   
    if( filter( $_GET['img_format'] ) ) {
        $url = $url . "&img_format=" . filter( $_GET['img_format'] );
    }
   
    if( filter( $_GET['action'] ) ) {
        $url = $url . "&action=" . filter( $_GET['action'] );
    }
   
    $dir = "avatars/";
    $open = fopen( $url, "r" );
    $hash = filter( $array['username'] ) . "-" . md5( $array['look'] );
    $path = $dir . $hash . ".png";
   
    if( !file_exists( $path ) ) {
        if( $open ) {
            file_put_contents( $path, $open );
            $image = file_get_contents( $path );
            fclose( $open );
        }
    }else{
        $image = file_get_contents( $path );
    }
   
    header( "Content-Type: image/png" );
    exit( $image );

?>
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
Here try this, configure it to your liking (idk if it works i just wrote this)

PHP:
<?php
// griimnak lel
class db {
    public static function connect() {

        try {

            $db['host'] = '';
            $db['user'] = '';
            $db['pass'] = '';
            $db['name'] = '';

            $conn = new pdo("mysql:host=$db['host'];dbname=$db['name'];", $db['user'], $db['pass']);
            $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
            return $conn;
        } catch(PDOException $e) {
            die('db error', $e);

        }
    }
}

if (isset($_GET['user'])) {
    $q = db::connect()->prepare("SELECT look FROM users WHERE username=:username");
    $q->bindParam(':username', $_GET['user']);
    $q->execute();
    $try = $q->fetchAll();

    if ($try) {
        foreach ($try as $row) {
            $result = $row['look'];
        }
    } else {
        $result = null;
    }

    echo '<img src="https://www.habbo.com/habbo-imaging/avatarimage?figure='.$result.'">';


}
 

Proximity

IDK?
Feb 13, 2014
673
56
So I am using this script it puts the avatar into the directory but it doesn't show the avatar

Code:
<?phperror_reporting(-1);
?>
    <?php
// Report all PHP errors

    // Copyright Clawed.
    // Got bored to be honest.
   
    function filter( $string ) {
        return mysql_real_escape_string( $string );
    }
   
    define( "HOSTNAME", "localhost" );
    define( "USERNAME", "root" );
    define( "PASSWORD", "" );
    define( "DATABASE", "" );
   
    if( !mysql_connect( HOSTNAME, USERNAME, PASSWORD ) ) die( mysql_error() );
    if( !mysql_select_db( DATABASE ) ) die( mysql_error() );
   
    $url = "http://habbo.ca/";
   
    if( !filter( $_GET['username'] ) ) {
        die( "<h1>Error</h1><hr>Username required.<hr>" );
    }
   
    $query = mysql_query( "SELECT look,username FROM users WHERE username = '" . filter( $_GET['username'] ) . "'" ) or die( mysql_error() );
    if( mysql_num_rows( $query ) < 1 ) { die( "Username does not exists." ); }
    $array = mysql_fetch_assoc( $query );
    $url = $url . "habbo-imaging/avatarimage?figure=" . $array['look'];
   
    if( filter( $_GET['direction'] ) ) {
        $url = $url . "&direction=" . filter( $_GET['direction'] );
    }
   
    if( filter( $_GET['gesture'] ) ) {
        $url = $url . "&gesture=" . filter( $_GET['gesture'] );
    }
   
    if( filter( $_GET['size'] ) ) {
        $url = $url . "&size=" . filter( $_GET['size'] );
    }
   
    if( filter( $_GET['img_format'] ) ) {
        $url = $url . "&img_format=" . filter( $_GET['img_format'] );
    }
   
    if( filter( $_GET['action'] ) ) {
        $url = $url . "&action=" . filter( $_GET['action'] );
    }
   
    $dir = "./avatars/";
    $open = fopen( $url, "r" );
    $hash = filter( $array['username'] ) . "-" . md5( $array['look'] );
    $path = $dir . $hash . ".png";
   
    if( !file_exists( $path ) ) {
        if( $open ) {
            file_put_contents( $path, $open );
            $image = file_get_contents( $path );
            fclose( $open );
        }
    }else{
        $image = file_get_contents( $path );
    }
   
    header( "Content-Type: image/png" );
    exit( $image );

?>
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
So I am using this script it puts the avatar into the directory but it doesn't show the avatar

Code:
<?phperror_reporting(-1);
?>
    <?php
// Report all PHP errors

    // Copyright Clawed.
    // Got bored to be honest.
  
    function filter( $string ) {
        return mysql_real_escape_string( $string );
    }
  
    define( "HOSTNAME", "localhost" );
    define( "USERNAME", "root" );
    define( "PASSWORD", "" );
    define( "DATABASE", "" );
  
    if( !mysql_connect( HOSTNAME, USERNAME, PASSWORD ) ) die( mysql_error() );
    if( !mysql_select_db( DATABASE ) ) die( mysql_error() );
  
    $url = "http://habbo.ca/";
  
    if( !filter( $_GET['username'] ) ) {
        die( "<h1>Error</h1><hr>Username required.<hr>" );
    }
  
    $query = mysql_query( "SELECT look,username FROM users WHERE username = '" . filter( $_GET['username'] ) . "'" ) or die( mysql_error() );
    if( mysql_num_rows( $query ) < 1 ) { die( "Username does not exists." ); }
    $array = mysql_fetch_assoc( $query );
    $url = $url . "habbo-imaging/avatarimage?figure=" . $array['look'];
  
    if( filter( $_GET['direction'] ) ) {
        $url = $url . "&direction=" . filter( $_GET['direction'] );
    }
  
    if( filter( $_GET['gesture'] ) ) {
        $url = $url . "&gesture=" . filter( $_GET['gesture'] );
    }
  
    if( filter( $_GET['size'] ) ) {
        $url = $url . "&size=" . filter( $_GET['size'] );
    }
  
    if( filter( $_GET['img_format'] ) ) {
        $url = $url . "&img_format=" . filter( $_GET['img_format'] );
    }
  
    if( filter( $_GET['action'] ) ) {
        $url = $url . "&action=" . filter( $_GET['action'] );
    }
  
    $dir = "./avatars/";
    $open = fopen( $url, "r" );
    $hash = filter( $array['username'] ) . "-" . md5( $array['look'] );
    $path = $dir . $hash . ".png";
  
    if( !file_exists( $path ) ) {
        if( $open ) {
            file_put_contents( $path, $open );
            $image = file_get_contents( $path );
            fclose( $open );
        }
    }else{
        $image = file_get_contents( $path );
    }
  
    header( "Content-Type: image/png" );
    exit( $image );

?>
is your $dir correct?
 

griimnak

You're a slave to the money then you die
Jul 20, 2013
957
800
It's gotta being something with the directories not be writeable, it's the only problem i can suspect.
and if you can't get it working, fuck it, why do you need chached avatars anyways? seems a bit pointless imo besides the fact you're taking up disk space to save avatar images for all your users.
 

Users who are viewing this thread

Top