Viewing posts tagged with: IconBuffet

July 3rd, 2007 How I did the IconBuffet Stamps page

Everyone keeps asking how I did the IconBuffet Stamps page. Here is the code. It has a couple little extras in there because I was planning on adding a “total possible points” calculation, but it seemed useless because “possible points” requires as many diamond deliveries as you can, and let’s face it…those are hard to make.

 
function data_encode($data, $keyprefix = "", $keypostfix = "") {
    assert( is_array($data) );
    $vars=null;
    foreach($data as $key=>$value) {
        if (is_array($value)) {
            $vars .= data_encode($value, $keyprefix.$key.$keypostfix.urlencode("["), urlencode("]"));
        }    else {
            $vars .= $keyprefix.$key.$keypostfix."=".urlencode($value)."&";
        }
    }
    return substr($vars, 0, -1);
}
if (isset($_REQUEST['username'], $_REQUEST['password'])) {
 
    $post_data = array('email'=>$_REQUEST['username'], 'password'=>$_REQUEST['password']);
 
    $ch = curl_init("https://www.iconbuffet.com/people;login");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($ch, CURLOPT_HEADER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies/ib_{$_REQUEST['username']}.cookie");
    curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies/ib_{$_REQUEST['username']}.cookie");
    curl_setopt($ch, CURLOPT_POSTFIELDS, data_encode($post_data));
 
    $home_page = curl_exec($ch);
 
    $regex = '|';
    $regex .= '<p>You have collected\s*(\d+)\s*Free Deliveries?</p>.*'; //get number of received deliveries
    $regex .= '<h4 class="stamps">\s*(\d+)\s*Stamps?</h4>.*'; //get number of stamps in bank
    $regex .= '<h4 class="tokens">\s*(\d+)\s*Tokens?</h4>.*'; //get number of tokens in bank
    $regex .= '|Ums';
    preg_match($regex, $home_page, $matches);
    $deliveries['received'] = $matches[1];
    $stamps['in_bank'] = $matches[2];
    $tokens['in_bank'] = $matches[3];
 
    curl_setopt($ch, CURLOPT_URL, "https://www.iconbuffet.com/people/{$_REQUEST['username']};stats");
    curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accept: text/javascript, text/html, application/xml, text/xml, */*"));
 
    $stats = curl_exec($ch);
 
    $regex = '!';
    $regex .= '(\d+)\s*</strong>\s*Bronze.*'; //get Bronze deliveries
    $regex .= '(\d+)\s*</strong>\s*Silver.*'; //get Silver deliveries
    $regex .= '(\d+)\s*</strong>\s*Gold.*'; //get Gold deliveries
    $regex .= '(\d+)\s*</strong>\s*Diamond.*'; //get Diamond deliveries
    $regex .= '(\d+)\s*</strong>\s*(?:Person|People) referred.*'; //get People referred
    $regex .= "(\d+)\s*</strong>\s*VIP's referred.*"; //get VIP's referred
    $regex .= '!Ums';
    preg_match($regex, $stats, $matches);
 
    $deliveries['bronze'] = $matches[1];
    $deliveries['silver'] = $matches[2];
    $deliveries['gold'] = $matches[3];
    $deliveries['diamond'] = $matches[4];
 
    $referrals['regular'] = $matches[5];
    $referrals['vip'] = $matches[6];
 
    $stamps['used'] = 0;
    $stamps['used'] += $deliveries['bronze'];
    $stamps['used'] += $deliveries['silver']*3;
    $stamps['used'] += $deliveries['gold']*5;
    $stamps['used'] += $deliveries['diamond']*10;
 
    $stamps['total'] = array_sum($referrals)*15 + $deliveries['received']*5;
 
    echo '<pre>';
    echo sprintf("%-9s{$stamps['total']}\r\n", 'Total:');
    echo sprintf("%-9s{$stamps['used']}\r\n", 'Used:');
    echo sprintf("%-9s{$stamps['in_bank']}\r\n", 'In Bank:');
    $stamps['in_wild'] = $stamps['total']-$stamps['used']-$stamps['in_bank'];
    echo sprintf("%-9s{$stamps['in_wild']}\r\n", 'In Wild:');
    echo '</pre>';
    curl_close($ch);
} else {
?>
<form action="" method="post">
    <fieldset>
        <legend>Login</legend>
        <div>
            <label for="username">Username:</label>
            <input type="text" id="username" name="username" />
        </div>
        <div>
            <label for="password">Password:</label>
            <input type="password" id="password" name="password" />
        </div>
        <div class="submit">
            <input type="submit" id="submit" name="submit" value="Login &raquo;" />
        </div>
    </fieldset>
</form>
<?php } ?>
 

May 25th, 2007 IconBuffet

As a web programmer that is not graphically inclined, I find myself drawn to good, free graphics. Iconbuffet.com has just such graphics. They currently have 87 free icon sets, each having between 7 and 55 icons. There is a community that trades them, and they’ve added a bit of a twist by creating a points system that gives users bragging rights (as well as some other added benefits). Every month you are given 10 tokens (30 if you pay to be VIP), and can use those to accept icons from your friends. Each set is worth 1-10 tokens (bronze sets are worth 1, Silver are worth 3, Gold are worth 5, and Diamond are worth 10). You also earn stamps, which are used to send sets (again, according to how the set is rated).
The icons are all quality icons, I find that the community is a nice place to take my focus when I need a breather from my programming. So, how can you check it out and become involved?

First, check out all their cool icons.
Then, Sign Up (If you use this link, I get some extra points and stamps.)
Lastly, come over to my profile and let me know what icon sets you want. I’ll send them over right away.

Search