Results 1 to 5 of 5
  1. #1
    Join Date
    May 2011
    Location
    England
    Posts
    427
    Tokens
    3,403
    Habbo
    Pension

    Latest Awards:

    Default [Pension] PHP 'Get Habbo Join Date' Script

    Right, so i've been attempting to get more knowledge of php, so I decided to code a basic little script which gets the join date of any given Habbo.com member. In order for this to work, the Habbo who's join date you want to get must have their profile public.

    Live demo:
    http://loduz.in/HabboJoinDate.php?habbo=INSERTNAMEHERE

    PHP Code:
    PHP Code:
    <?php

        
    ######################################
        ## PHP 'Get Habbo Join Date' Script ##
        ##    Created by Pension (Robbie)   ##
        ######################################
        
        
    $habbo $_GET['habbo'];
        
        function 
    getJoinDate($habbo)
         {
            
    $link file_get_contents('http://www.habbo.com/home/'.$habbo); 
        
            
    $date explode('<div class="birthday date">'$link); 
            
    $date explode('</div>'$date[1]); 
            
    $date trim($date[0]); 
        
            return 
    $date;
        }  
        
        echo 
    '<b>Member since:</b><br />'.getJoinDate($habbo);
    ?>
    It's kinda pointless, but I guess it *could* potentially be useful. Please rate/slate as much as you like

    robbie // pension.

  2. #2
    Join Date
    Oct 2005
    Location
    Spain, Valencia
    Posts
    20,492
    Tokens
    3,575
    Habbo
    GoldenMerc

    Latest Awards:

    Default

    Could be useful for someone, not too shabby ether +rep

  3. #3
    Join Date
    May 2011
    Location
    England
    Posts
    427
    Tokens
    3,403
    Habbo
    Pension

    Latest Awards:

    Default

    Quote Originally Posted by GoldenMerc View Post
    Could be useful for someone, not too shabby ether +rep
    Cheers dude, I'm starting out with basic things but I have big ambitions, aha!

    robbie // pension.

  4. #4
    Join Date
    Jun 2005
    Location
    /dev/null
    Posts
    4,918
    Tokens
    126

    Latest Awards:

    Default

    Pretty nice for somebody starting out. I would have used a preg_match to find the data in the HTML. Something like this (untested):

    PHP Code:
    <?php

        
    ######################################
        ## PHP 'Get Habbo Join Date' Script ##
        ##    Created by Pension (Robbie)   ##
        ######################################
        
        
    $habbo $_GET['habbo'];
        
        function 
    getJoinDate($habbo)
         {
            
    $link file_get_contents('http://www.habbo.com/home/'.$habbo); 
          
            
    preg_match('#<div class="birthday date">(.*?)</div>#s'$link$date);
            
    $date trim($date[1]); 
        
            return 
    $date;
        }  
        
        echo 
    '<b>Member since:</b><br />'.getJoinDate($habbo);
    ?>
    This sort of thing is a nice introduction to regex, which I don't know much about myself, but enough to get by. http://www.phpro.org/tutorials/Intro...PHP-Regex.html

    You may also consider using cURL to get web resources rather than file_get_contents. In this simple case it's more effort than it's worth, but cURL has a slight performance boost for getting web pages and has MANY features and lots of functionality http://www.php.net/manual/en/ref.curl.php for doing more advanced stuff.

  5. #5
    Join Date
    May 2011
    Location
    England
    Posts
    427
    Tokens
    3,403
    Habbo
    Pension

    Latest Awards:

    Default

    Quote Originally Posted by N!ck View Post
    Pretty nice for somebody starting out. I would have used a preg_match to find the data in the HTML. Something like this (untested):

    PHP Code:
    <?php

        
    ######################################
        ## PHP 'Get Habbo Join Date' Script ##
        ##    Created by Pension (Robbie)   ##
        ######################################
        
        
    $habbo $_GET['habbo'];
        
        function 
    getJoinDate($habbo)
         {
            
    $link file_get_contents('http://www.habbo.com/home/'.$habbo); 
          
            
    preg_match('#<div class="birthday date">(.*?)</div>#s'$link$date);
            
    $date trim($date[1]); 
        
            return 
    $date;
        }  
        
        echo 
    '<b>Member since:</b><br />'.getJoinDate($habbo);
    ?>
    This sort of thing is a nice introduction to regex, which I don't know much about myself, but enough to get by. http://www.phpro.org/tutorials/Intro...PHP-Regex.html

    You may also consider using cURL to get web resources rather than file_get_contents. In this simple case it's more effort than it's worth, but cURL has a slight performance boost for getting web pages and has MANY features and lots of functionality http://www.php.net/manual/en/ref.curl.php for doing more advanced stuff.
    Thanks for that, I'm going to take a look. +rep

    robbie // pension.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •