LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 http://www.boddingtonparish.co.uk/php/output.php that's all I get... Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 and you've got the exact code I gave you? and nothing else on the page? Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 the exact code. Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 <?php $_POST['username'] = 'zezima'; $username = $_POST['username']; $username = strtolower(str_replace(' ', '_', $username)); $website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username); $stats = explode("\n", $website); $overall = array_shift(explode(",", $stats[0])); $stat['att'] = array_shift(explode(",", $stats[1])); $stat['def'] = array_shift(explode(",", $stats[2])); $stat['str'] = array_shift(explode(",", $stats[3])); $stat['hp'] = array_shift(explode(",", $stats[4])); $stat['rng'] = array_shift(explode(",", $stats[5])); $stat['pry'] = array_shift(explode(",", $stats[6])); $stat['mag'] = array_shift(explode(",", $stats[7])); $stat['ck'] = array_shift(explode(",", $stats[8])); $stat['wc'] = array_shift(explode(",", $stats[9])); $stat['flt'] = array_shift(explode(",", $stats[10])); $stat['fsh'] = array_shift(explode(",", $stats[11])); $stat['fm'] = array_shift(explode(",", $stats[12])); $stat['cra'] = array_shift(explode(",", $stats[13])); $stat['smi'] = array_shift(explode(",", $stats[14])); $stat['min'] = array_shift(explode(",", $stats[15])); $stat['her'] = array_shift(explode(",", $stats[16])); $stat['ag'] = array_shift(explode(",", $stats[17])); $stat['th'] = array_shift(explode(",", $stats[18])); $stat['sl'] = array_shift(explode(",", $stats[19])); $stat['frm'] = array_shift(explode(",", $stats[20])); $stat['rc'] = array_shift(explode(",", $stats[21])); $stat['hun'] = array_shift(explode(",", $stats[22])); $stat['cs'] = array_shift(explode(",", $stats[23])); $image_link = 'demo.png'; $image = imagecreatefrompng($image_link); $font_colour = imagecolorallocate($image, 0, 0, 0); $font_size = 5; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); $i = '0'; $a = '0'; foreach($stat as $s_key => $value){ imagestring($image, $font_size, $x[$a], $y[$i], $value, $font_colour); $i++; if($i == '5'){ $i = '0'; $a++; } } imagestring($image, $font_size, '240', '82', 'overall: ' . $overall, $font_colour); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> give that a try Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 nope. Also, isn't that set to just zezima? Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 Yeah, the first line sets $username to zezima. Just so you can test that it's working though. I don't get why the picture isn't showing... It's just display the alt text for it. Â Do you have gd library installed on your server? Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Not that I know of. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Will check this in a few hours Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 just put this code on a blank page: <?php phpinfo(); ?> Â then do a search for gd. you should hopefully find a table with something like: GD Support enabled in it... Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 gd GD Support enabled GD Version bundled (2.0.28 compatible) FreeType Support enabled FreeType Linkage with freetype GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 okay, I think the problem is that the image is in the wrong directory. I just typed in this into the address bar: http://www.boddingtonparish.co.uk/php/demo.png and got a 'page cannot be found' error. also the image you've got on the first post is listed at: http://reflexprojects.net/rs/rs/images/demo.png on a completely different server. Â You need to get the url correct for it. Also, not sure if gd can access external images, but don't see why not. Â change the image link to this: $image_link = 'http://reflexprojects.net/rs/rs/images/demo.png'; Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Hm. Should have worked. But yeah, I'll see. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Ok, the good news is that now the signature shows up. The bad news is that now the levels are wrong. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Discovered the problem. For some reason, it's showing the rank now, not the level. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Ok, so to finish this thing off, all I need to know is how to set each array to [1], not [0] which it appears as now. Then, I have also noticed that on the username display, there's a '1' at the end of every name Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 ah, sorry.. I was thinking you wanted the ranks.. <?php $username = $_POST['username']; $username = strtolower(str_replace(' ', '_', $username)); $website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username); $stats = explode("\n", $website); $overall = array_shift(explode(",", $stats[0])); $stat['att'] = explode(",", $stats[1]); $stat['def'] = explode(",", $stats[2]); $stat['str'] = explode(",", $stats[3]); $stat['hp'] = explode(",", $stats[4]); $stat['rng'] = explode(",", $stats[5]); $stat['pry'] = explode(",", $stats[6]); $stat['mag'] = explode(",", $stats[7]); $stat['ck'] = explode(",", $stats[8]); $stat['wc'] = explode(",", $stats[9]); $stat['flt'] = explode(",", $stats[10]); $stat['fsh'] = explode(",", $stats[11]); $stat['fm'] = explode(",", $stats[12]); $stat['cra'] = explode(",", $stats[13]); $stat['smi'] = explode(",", $stats[14]); $stat['min'] = explode(",", $stats[15]); $stat['her'] = explode(",", $stats[16]); $stat['ag'] = explode(",", $stats[17]); $stat['th'] = explode(",", $stats[18]); $stat['sl'] = explode(",", $stats[19]); $stat['frm'] = explode(",", $stats[20]); $stat['rc'] = explode(",", $stats[21]); $stat['hun'] = explode(",", $stats[22]); $stat['cs'] = explode(",", $stats[23]); $image_link = 'http://reflexprojects.net/rs/rs/images/demo.png'; $image = imagecreatefrompng($image_link); $font_colour = imagecolorallocate($image, 0, 0, 0); $font_size = 5; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); $i = '0'; $a = '0'; foreach($stat as $s_key => $value){ imagestring($image, $font_size, $x[$a], $y[$i], $value[1], $font_colour); $i++; if($i == '5'){ $i = '0'; $a++; } } imagestring($image, $font_size, '230', '82', 'overall:' . $overall, $font_colour); imagestring($image, $font_size, '240', '105', '' . $username, $font_colour); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 PERFECT. Except, A) How do I change the font, B) Zezima's total level should be 2277, not 1. Thanks in advance Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 Wait, total is still set to ranks. So, how do I set overall to level, not rank? Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 *bump* Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 27, 2007 Share Posted August 27, 2007 sorry, missed out the total... herre you go: <?php $_POST['username'] = 'zezima'; $username = $_POST['username']; $username = strtolower(str_replace(' ', '_', $username)); $website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username); $stats = explode("\n", $website); $overall = explode(",", $stats[0]); $stat['att'] = explode(",", $stats[1]); $stat['def'] = explode(",", $stats[2]); $stat['str'] = explode(",", $stats[3]); $stat['hp'] = explode(",", $stats[4]); $stat['rng'] = explode(",", $stats[5]); $stat['pry'] = explode(",", $stats[6]); $stat['mag'] = explode(",", $stats[7]); $stat['ck'] = explode(",", $stats[8]); $stat['wc'] = explode(",", $stats[9]); $stat['flt'] = explode(",", $stats[10]); $stat['fsh'] = explode(",", $stats[11]); $stat['fm'] = explode(",", $stats[12]); $stat['cra'] = explode(",", $stats[13]); $stat['smi'] = explode(",", $stats[14]); $stat['min'] = explode(",", $stats[15]); $stat['her'] = explode(",", $stats[16]); $stat['ag'] = explode(",", $stats[17]); $stat['th'] = explode(",", $stats[18]); $stat['sl'] = explode(",", $stats[19]); $stat['frm'] = explode(",", $stats[20]); $stat['rc'] = explode(",", $stats[21]); $stat['hun'] = explode(",", $stats[22]); $stat['cs'] = explode(",", $stats[23]); $image_link = 'http://reflexprojects.net/rs/rs/images/demo.png'; $image = imagecreatefrompng($image_link); $font_colour = imagecolorallocate($image, 0, 0, 0); $font_size = 5; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); $i = '0'; $a = '0'; foreach($stat as $s_key => $value){ imagestring($image, $font_size, $x[$a], $y[$i], $value[1], $font_colour); $i++; if($i == '5'){ $i = '0'; $a++; } } imagestring($image, $font_size, '210', '85', 'overall:' . $overall[1], $font_colour); imagestring($image, $font_size, '240', '105', '' . $username, $font_colour); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?>  to change the font, you can change it's size by changing the following line: $font_size = 5; sizes range from 1 to 5.  To change the font itself you should use imagettftext() instead of imagestring(), which is a bit more complicated but allows a lot more variation  change to this: <?php $_POST['username'] = 'zezima'; $username = $_POST['username']; $username = strtolower(str_replace(' ', '_', $username)); $website = file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username); $stats = explode("\n", $website); $overall = explode(",", $stats[0]); $stat['att'] = explode(",", $stats[1]); $stat['def'] = explode(",", $stats[2]); $stat['str'] = explode(",", $stats[3]); $stat['hp'] = explode(",", $stats[4]); $stat['rng'] = explode(",", $stats[5]); $stat['pry'] = explode(",", $stats[6]); $stat['mag'] = explode(",", $stats[7]); $stat['ck'] = explode(",", $stats[8]); $stat['wc'] = explode(",", $stats[9]); $stat['flt'] = explode(",", $stats[10]); $stat['fsh'] = explode(",", $stats[11]); $stat['fm'] = explode(",", $stats[12]); $stat['cra'] = explode(",", $stats[13]); $stat['smi'] = explode(",", $stats[14]); $stat['min'] = explode(",", $stats[15]); $stat['her'] = explode(",", $stats[16]); $stat['ag'] = explode(",", $stats[17]); $stat['th'] = explode(",", $stats[18]); $stat['sl'] = explode(",", $stats[19]); $stat['frm'] = explode(",", $stats[20]); $stat['rc'] = explode(",", $stats[21]); $stat['hun'] = explode(",", $stats[22]); $stat['cs'] = explode(",", $stats[23]); $image_link = 'http://reflexprojects.net/rs/rs/images/demo.png'; $image = imagecreatefrompng($image_link); //this is the font. You must include the filetype $font = 'arial.ttf'; $font_colour = imagecolorallocate($image, 0, 0, 0); $font_size = 10; // x axis //first number is x position for column 1 //second number is x position for cloumn 2 //third number is x position for column 3 //fourth number is x position for column 4 //fifth number is x position for column 5 $x = array('28', '80', '135', '188', '240'); // y axis //first number is y position for row 1 //second number is y position for row 2 //third number is y position for row 3 //fourth number is y position for row 4 //fifth number is y position for row 5 $y = array('20', '45', '66', '90', '115'); $i = '0'; $a = '0'; foreach($stat as $s_key => $value){ imagettftext($image, $font_size, 0, $x[$a], $y[$i], $font_colour, $font , $value[1]); $i++; if($i == '5'){ $i = '0'; $a++; } } imagettftext($image, $font_size, 0, '230', '100', $font_colour, $font , 'overall:' . $overall[1]); imagettftext($image, $font_size, 0, '250', '120', $font_colour, $font , $username); header('Content-type: image/png'); imagepng($image); imagedestroy($image); ?> note: using this method the font size is now in pixels, so the prevoius maximum of 5 would be very small... Also you need to upload the font file to the same directory as the others. In this example I'm using arial.ttf, but use whatever you like.  You'll have to change the x and y axis for everything depending on the fonts and font sizes too! I've tried to explain what veach number in the x and y arrays are for. Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 27, 2007 Author Share Posted August 27, 2007 brilliant! exactly what I wanted! Quote Link to comment Share on other sites More sharing options...
Dragen Posted August 28, 2007 Share Posted August 28, 2007 you should make it run off the get method, instead of post. It'd give more flexibility. You should then be able to link it with something like this: <img src="http://www.boddingtonparish.co.uk/php/processout.php?user=zezima" border="0" alt="runescape stats" /> Â Then people can use it in a web page, instead of just by itself Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 28, 2007 Author Share Posted August 28, 2007 I see. How would I do that? Also, the next question was going to be, how would I host it on my server so it updates constantly, instead of people having to get another each time. Kinda like, when you enter your name, the image appears on a page with the url in a box at the bottom. I could work that all out, but how would you do the GET instead of POST? Quote Link to comment Share on other sites More sharing options...
ReDucTor Posted August 28, 2007 Share Posted August 28, 2007 Your going to feel stupid after I say this  change  $username = $_POST['username'];  to  $username = $_GET['username']; Quote Link to comment Share on other sites More sharing options...
LemonInflux Posted August 28, 2007 Author Share Posted August 28, 2007 ... Â I did wonder about that tbh, but I thought 'naw, that's way too easy'. Shows I should have tried it. Thanks, though *hides in corner...* Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.