AAO25.com
Community => The Lounge => Topic started by: Spanky on Sunday, September 12, 2010, 15:41:47 PM
-
I like your sig, you took the time to code it, propz to you. I'm NOT blocking it, I can and do appreciate the hard work you put in it, I sure as hell couldn't do that. I just massively block things that I find annoying or pointless. Your sig is none of those, it's just 1 sig on 1 site that isn't annoying or pointless. So don't be all butthurt and have fun in school eh? :)
-
Spanky, I don't really care about my WCG stats. I know that the ultimate payoff will be when this project actually helps find cures for cancer. It's not about the points, I know that, believe me. I take the subject of finding cures for cancer very seriously. It's personal for me and if I had money to donate to cancer research I probably would. But, I'm in college and honestly, I barely have enough money to make that work. The only way I can help find a cure for cancer is through running this project on my computer, with what little good it does. I used to run Folding@Home but for some reason the school blocks the downloading of "cores," which are the programs that actually do the work. Otherwise, I would still be running Folding@Home.
I kinda did this for fun. When I noticed that they didn't offer an image you could use with your signature, I got all creative and made one on my own. There's probably some simple answer out there to this problem, or site that would make one for me. But, I just decided I would just put some time into learning php and create my own simple stats tracker. I really don't know why I chose php either.
<?php
function StatsToImage($username)
{
$font = 'fonts/times.ttf'; // Font to use to generate the image.
$fontSize = 8; // font size.
$transparent = true;
$fg_color = array(0, 0, 0);
$bg_color = array(255, 255, 255);
$msg = "";
$Points = "";
$Rank = "";
$lines = file('http://www.worldcommunitygrid.org/getDynamicImage.do?memberName='. $username. '&mnOn=true&stat=1&imageNum=1&rankOn=true&projectsOn=false&special=false');
foreach ($lines as $line_num => $line) {
$pos = strripos(htmlspecialchars($line), ";Points");
if ($pos) {
$Points = $line;
$pos = strripos($Points , "&");
$Points = substr($Points, 0, $pos);
$Points = trim($Points, " \t.");
}
$pos = strripos(htmlspecialchars($line), "(Rank");
if ($pos) {
$Rank = $line;
$pos = strripos($Rank , ";");
$Rank = substr($Rank, $pos+1, strlen($Rank));
$pos = strripos($Rank , ")");
$Rank = substr($Rank, 0, $pos);
$Rank = trim($Rank, " \t.");
}
}
$msg = "Username:". $username. " | Points: ". $Points. " | Rank: ". $Rank;
$width = 0;
$height = 0;
$bounds = array();
$image = null;
// Determine font height
$bounds = ImageTTFBBox($fontSize, 0, $font, "W");
$font_height = abs($bounds[7]-$bounds[1]);
// Determine image size.
$bounds = ImageTTFBBox($fontSize, 0, $font, $msg);
$width = abs($bounds[4]-$bounds[6]);
$height = abs($bounds[7]-$bounds[1]);
$image = imagecreate($width+1, $height+1); // Initialize type image
$background = ImageColorAllocate($image, $bg_color[0], $bg_color[1], $bg_color[2]);
$foreground = ImageColorAllocate($image, $fg_color[0], $fg_color[1], $fg_color[2]);
if ($transparent) {
ImageColorTransparent($image, $background);
}
// Build image from text.
ImageTTFText($image, $fontSize, 0, 0, $font_height, $foreground, $font, $msg);
// Save PNG to file.
imagepng($image, "stats.png");
}
StatsToImage("computerguy89"); // Call function
?>
-
I just wish there was a program to fold to prevent cancer instead of finding a cure after the fact. I'd be all over that like white on rice.
-
Delta, hopefully you see this sometime soon. Could I use this code (or a modified version) for PostQuote?