DRC - Digital reality crew logo
DRC Forum | Register | Log in | Forum help | Search

My lame attempt at dynamically updated signature


DRC Forum
» Personal Interests
    » Programming
        » My lame attempt at dynamically updated signature
            » Page 1 of 1

  Post new topicReply to topic

Author Message
|DRC| Wartex






Tuesday, August 2 2011, 01:22:32 #43662     My lame attempt at dynamically updated signature


I wrote a test PHP script to rip data from my Quakelive profile and insert it into a signature dynamically. I will make this "public" so you can have your own stats in there. Look below.
_________________

Profile | Send PM | WWW | AIM | YIM | MSN | SKYPE | ICQ
 
Sponsored Ad






Today #     Sponsored Ads


WWW
 
|DRC| Wartex






Sunday, August 7 2011, 17:15:09 #43681     


Code:
<?php
$imgname = "wartex.jpg";
$im = @imagecreatefromjpeg($imgname);
header('Content-Type: image/jpeg');


function download_file($file, $ref)
{
        $curl_obj = curl_init();
        curl_setopt($curl_obj, CURLOPT_URL, $file);
        curl_setopt($curl_obj, CURLOPT_REFERER, $ref);
        curl_setopt($curl_obj, CURLOPT_BINARYTRANSFER, 1);
        curl_setopt($curl_obj, CURLOPT_RETURNTRANSFER, TRUE);
        curl_setopt($curl_obj, CURLOPT_MAXREDIRS, SPDR_MAX_REDIR);
        curl_setopt($curl_obj, CURLOPT_SSL_VERIFYPEER, FALSE);
        $downloaded_binary = curl_exec($curl_obj);

        curl_close($curl_obj);
        return $downloaded_binary;
}


$file = 'http://www.quakelive.com/profile/statistics/Wartex?_=444';
$cut_start = '<div class="prf_weapons cl">';
$cut_end = '<div id="qlv_profileMiddle" class="statistics">';

$html = download_file($file, 'http://www.quakelive.com');
$rest = substr($html, strpos ( $html,  $cut_start) + strlen($cut_start));


$rest = substr($rest, 0, strpos ( $rest,  $cut_end));
$rest = preg_replace('/\ \ +/', ' ', $rest);

preg_match_all("#<p ([^>]*)>(.+?)</p>#is", $rest, $matches);
$divs = $matches[2];
unset($matches);

$acc_values = Array();

foreach ($divs as $key => $value)
{
   preg_match_all("#<div ([^>]*)>(.+?)</div>#is", $value, $matches);
   $matches[2][2] = strip_tags($matches[2][2]);
   $acc_values[$matches[2][0]] = $matches[2];
}

//print_r($acc_values);

$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 128, 128, 128);
$black = imagecolorallocate($im, 0, 0, 0);

$text = 'QUAKELIVE ACCURACIES';
$font = 'SF_Quartzite.ttf';
$fsize = 20;

imagettftext($im, $fsize, 0, 13, 28, $black, $font, $text);
imagettftext($im, $fsize, 0, 12, 27, $white, $font, $text);

$fsize = 12;
$text = 'Railgun: '.$acc_values['Railgun'][2];

imagettftext($im, $fsize, 0, 13, 48, $black, $font, $text);
imagettftext($im, $fsize, 0, 12, 47, $white, $font, $text);

$text = 'Rocket Launcher: '.$acc_values['Rocket Launcher'][2];

imagettftext($im, $fsize, 0, 13, 58, $black, $font, $text);
imagettftext($im, $fsize, 0, 12, 57, $white, $font, $text);

$text = 'Lightning Gun: '.$acc_values['Lightning Gun'][2];

imagettftext($im, $fsize, 0, 13, 68, $black, $font, $text);
imagettftext($im, $fsize, 0, 12, 67, $white, $font, $text);


imagejpeg($im);
imagedestroy($im);


?>
Profile | Send PM | WWW | AIM | YIM | MSN | SKYPE | ICQ
 
Display posts from previous:   


Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum



Optimized with phpBB SEO
Questions? Contact us at fubar_54-81-197-24@wartex.net