Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- Header('Content-type: image/png');
- /**
- * First the parse process~
- * $buffer contains a part of the stats website of the counter thread
- **/
- $parser = fopen('http://www.bronies.de/misc.php?action=whoposted&tid=1880', 'r');
- while(!feof($parser)) {
- /**
- * First gets the "all" count~
- **/
- $buffer = fgets($parser, 4096);
- if(preg_match('/<strong>Gesamtanzahl der Beitr.*ge: ([^<]*)<\/strong>/', $buffer)) $all = $buffer;
- if(isset($next)) {
- $user = $buffer;
- unset($next);
- }
- /**
- * Get username by UID
- **/
- if(isset($_REQUEST['uid'])) {
- // don't overwrite the username again if it's set already
- if(isset($username) && strlen($username) > 0) continue;
- if(preg_match('/uid='.$_REQUEST['uid'].'"/', $buffer)) {
- // get username
- preg_match('/false;">(.*?)<\//', $buffer, $username);
- // check if strong is still founded if so - it's a mod+
- if(!empty($username[1])) {
- if(preg_match('/<strong>/', $username[1])) {
- $username = explode('<strong>', $username[1]);
- }
- $username = $username[1];
- }
- }
- }
- /**
- * else get it by .. well .. username
- **/
- elseif(isset($_REQUEST['usr'])) {
- $username = $_REQUEST['usr'];
- }
- /**
- * get user count by username
- **/
- if(isset($username) && is_string($username)) {
- if(preg_match('/>('.$username.')</', $buffer)) {
- $next = TRUE;
- }
- } else {
- $username = NULL;
- }
- }
- fclose($parser);
- /**
- * get count numbers by the rough parsed informations
- **/
- if(isset($user))
- preg_match('/">((?!<a))(.*?)<\//', $user, $cur_count);
- preg_match('/e: (.*?)<\//', $all, $all_count);
- // set $v to the used version - if nothing given use v1
- $v = (isset($_REQUEST['v'])) ? (int)$_REQUEST['v'] : 1;
- switch($v) {
- case '1':
- $png = imagecreatefrompng('./userbar.png');
- $font = 'Impact.ttf';
- $size = 8;
- $pos = array('x' => 10, 'y' => 14);
- if(isset($cur_count) && !isset($_REQUEST['col'])) {
- if($cur_count[1] <= 1000) $text_color = imagecolorallocate($png, 229, 163, 98);
- if($cur_count[1] <= 600) $text_color = imagecolorallocate($png, 221, 229, 98);
- if($cur_count[1] <= 300) $text_color = imagecolorallocate($png, 196, 196, 196);
- if($cur_count[1] > 1000)$text_color = imagecolorallocate($png, 163, 229, 98);
- }
- break;
- case '2':
- switch($username) {
- case 'Demonheart':
- $png = imagecreatefrompng('./userbar2_violet.png');
- break;
- case 'Land':
- $png = imagecreatefrompng('./userbar2_red.png');
- break;
- default:
- $png = imagecreatefrompng('./userbar2.png');
- break;
- }
- $font = 'Lato-Regular.ttf';
- $size = 9;
- $pos = array('x' => 8, 'y' => 17);
- break;
- }
- // set text it will be exactly the same on both versions
- if(isset($cur_count) && is_array($cur_count)) {
- $text = '#'.$all_count[1].' ( '.$cur_count[2].' ) '.$username;
- } else {
- $text = '#'.$all_count[1];
- }
- // set text color default to white if no specific is given
- if(!isset($text_color))
- $text_color = imagecolorallocate($png, 255,255,255);
- // set text on the image
- imagettftext($png, $size, 0, $pos['x'], $pos['y'], $text_color, $font, $text);
- /**
- * print image and destroy it for less resource usage
- **/
- imagepng($png);
- imagedestroy($png);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement