Avatar Caching system [REL]

Results 1 to 14 of 14
  1. #1
    Apprentice MeneerPHP is offline
    MemberRank
    Jan 2013 Join Date
    11Posts

    Avatar Caching system [REL]

    Hello,

    i have code a advanced avatar caching system, because i'm boring..

    PHP Code:
    <?phpheader('Content-Type: image/png');// Avatar caching system// CODER: Karim, AKA iFuckR
    // CONFIGdefine("HOST", "127.0.0.1"); // Gebruiker 127.0.0.1 voor snelheid!define("GEBRUIKER", "root"); // Gebruiker, meestal 'root'define("WACHTWOORD", "123"); // Wachtwoord, moet voor zichzelf sprekendefine("DATABASE", "bcstorm"); // Database naam.$map = './avatars'; // De map waar alles word opgeslagen.define("HOTEL", "habbo.co.uk"); // Het hotel waar de data vandaan moet komen, gebruik geen .com!// Verander niks onder deze lijn! Anders kan het systeem langzaam worden, of verknalt worden enzo.. xd

        
    mysql_connect(HOSTGEBRUIKERWACHTWOORD) or die ('FATALE FOUT: Onmogelijk om met MySQL server te verbinden!');    mysql_select_db(DATABASE) or die ('FATALE FOUT: Onmogelijk om te verbinden met database!'); 


    if (!
    is_dir($map))     {        if (!mkdir($map0true))             {                die('FATALE FOUT: Onmogelijk om folder aan te maken!');            }    }
        
    $figure $_GET['figure'];
    if(isset(
    $_GET['size'])){$size $_GET['size'];} else { $size'b';}
    if(isset(
    $_GET['direction'])){$direction $_GET['direction'];} else { $direction '2';}
    if(isset(
    $_GET['head_direction'])){$head $_GET['head_direction'];} else { $head '2'; }
    if(isset(
    $_GET['gesture'])){$gesture $_GET['gesture'];} else { $gesture '';}
    $lookhash md5("$figure$size$direction$head$gesture");

    if (
    file_exists("$map/$lookhash.png")) {    $finalavatar = require("$map/$lookhash.png");    } else {    $habbo file_get_contents("http://".HOTEL."/habbo-imaging/avatarimage?figure=".$figure."&size=".$size."&direction=".$direction."&head_direction=".$head."&gesture=".$gesture."");    $fp fopen("$map/$lookhash.png"'w');    fwrite($fp$habbo);    fclose($fp);    $finalavatar $habbo;}
    /// JAJAJAJAJ! EINDELIJK! DAAR IS DIE DAN, EN VELE MALEN SNELLER :o!echo $finalavatar;
    How it works.
    You make a php file, avatars.php or something, and it makes the source.




    The first time the script is used, there will a folder created ..
    and there are all avatars stored.


    The first time this avatar being watched, get stored on habbo hotel, to your web server.


    The next time you watched avatar, hosts.allow the avatar from the server read it does not use the internet, so equal * rads * from the server ..


  2. #2
    I don't even know azaidi is offline
    MemberRank
    Apr 2010 Join Date
    the NetherlandsLocation
    2,065Posts

    Re: Avatar Caching system [REL]

    When you have a lot of users your avatars folder/mysql database will become bigger than 1gb, so a very bad idea..

  3. #3
    Ask me about Daoism FullmetalPride is offline
    MemberRank
    Nov 2010 Join Date
    2,172Posts

    Re: Avatar Caching system [REL]

    When will people learn that caching speeds up load time but ruins disk space!? :<

  4. #4
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,610Posts

    Re: Avatar Caching system [REL]

    Quote Originally Posted by FullmetalPride View Post
    When will people learn that caching speeds up load time but ruins disk space!? :<
    Yeah use this on a hotel with daily 1000+ online and you need to get some more disk space. Think this is usefull for hotels with a max of 75 online.

  5. #5
    Valued Member Thekguy is offline
    MemberRank
    Dec 2011 Join Date
    DksvLocation
    122Posts

    Re: Avatar Caching system [REL]

    Quote Originally Posted by tdid View Post
    Yeah use this on a hotel with daily 1000+ online and you need to get some more disk space. Think this is usefull for hotels with a max of 75 online.
    22,000 images = 36.7 MB

    not bad?

  6. #6
    I don't even know azaidi is offline
    MemberRank
    Apr 2010 Join Date
    the NetherlandsLocation
    2,065Posts

    Re: Avatar Caching system [REL]

    Quote Originally Posted by Thekguy View Post
    22,000 images = 36.7 MB

    not bad?
    The problem is there are more than a billion possibilities. Ask people who have tried this what happens after a month of use.

  7. #7
    idk what to put here Joseph is offline
    MemberRank
    Oct 2007 Join Date
    CanehdaLocation
    1,317Posts

    Re: Avatar Caching system [REL]

    Quote Originally Posted by FullmetalPride View Post
    When will people learn that caching speeds up load time but ruins disk space!? :<
    He was bored so he coded something for the community? I didn't know that was so bad.

    To the OP, good release, it'll help with small hotels who are looking to use this :).

  8. #8
    Valued Member Thekguy is offline
    MemberRank
    Dec 2011 Join Date
    DksvLocation
    122Posts

    Re: Avatar Caching system [REL]

    can anny1 give me some of his avatar images? (.png)

    just alot :p

  9. #9
    I don't even know azaidi is offline
    MemberRank
    Apr 2010 Join Date
    the NetherlandsLocation
    2,065Posts

    Re: Avatar Caching system [REL]

    <?php
    header('Content-Type: image/png');

    $path = trim($_SERVER['PATH_INFO'], '/');
    $db = new MySQLi('p:localhost', 'root', 'admin', 'phoenix');

    if ($row = $db->query('SELECT image FROM avatars WHERE uri = \''.$path.'\' LIMIT 1')->fetch_assoc())
    {
    exit($row['image']);
    }

    $data = file_get_contents('http://www.habbo.nl/habbo-imaging/avatarimage?'.$path);
    $db->query('INSERT INTO avatars (uri, image) VALUES(\''.$db->real_escape_string($path).'\', \''.$db->real_escape_string($data).'\')');

    echo $data;
    ?>

    Better?

  10. #10
    Check http://arcturus.pw The General is offline
    DeveloperRank
    Aug 2011 Join Date
    7,610Posts

    Re: Avatar Caching system [REL]

    Quote Originally Posted by Thekguy View Post
    22,000 images = 36.7 MB

    not bad?
    Indeed not bad at all.

  11. #11
    I don't even know azaidi is offline
    MemberRank
    Apr 2010 Join Date
    the NetherlandsLocation
    2,065Posts

    Re: Avatar Caching system [REL]

    Quote Originally Posted by azaidi View Post
    <?php
    header('Content-Type: image/png');

    $path = trim($_SERVER['PATH_INFO'], '/');
    $db = new MySQLi('p:localhost', 'root', 'admin', 'phoenix');

    if ($row = $db->query('SELECT image FROM avatars WHERE uri = \''.$path.'\' LIMIT 1')->fetch_assoc())
    {
    exit($row['image']);
    }

    $data = file_get_contents('http://www.habbo.nl/habbo-imaging/avatarimage?'.$path);
    $db->query('INSERT INTO avatars (uri, image) VALUES(\''.$db->real_escape_string($path).'\', \''.$db->real_escape_string($data).'\')');

    echo $data;
    ?>
    If you use this with my QuickTPL or UberCMS with a cron job which cleans the table every week, it will really help you speed up your site.

  12. #12
    Valued Member iOmvuZ is offline
    MemberRank
    May 2012 Join Date
    104Posts

    Re: Avatar Caching system [REL]

    Thanks. But i aint gonna use it.

  13. #13
    Apprentice MeneerPHP is offline
    MemberRank
    Jan 2013 Join Date
    11Posts

    Re: Avatar Caching system [REL]

    No it is not bad.
    If you have 1000 online, and 250,000 users ..
    Will you approximately 8 million images have been cached but 8 gb.

  14. #14
    [̲̅$̲̅(̲̅1̲̅)̲̅$ ̲̅] leenster is offline
    MemberRank
    May 2008 Join Date
    KanaadaLocation
    992Posts

    Avatar Caching system [REL]

    If I am not mistaking with phoenix you can use last_updated to detect if the look of the user has changed and delete the old image.

    Sent from my BlackBerry 9800 using Tapatalk



Advertisement