`Karl Posted November 9, 2009 Share Posted November 9, 2009 Okay, so here's my code. It's quite messy but hell, who cares <?php $username = $_GET['username']; $type = $_GET['type']; //$username = strtolower(str_replace(' ', '_', $username)); if(!$username) { echo ("You didn't enter a username."); } $index = @file_get_contents('http://hiscore.runescape.com/index_lite.ws?player=' . $username); if ($index != "") { $lulwut = explode("\n", $index); $overall = explode(",", $lulwut[0]); $lol['att'] = explode(",", $lulwut[1]); $lol['def'] = explode(",", $lulwut[2]); $lol['str'] = explode(",", $lulwut[3]); $lol['hp'] = explode(",", $lulwut[4]); $lol['rng'] = explode(",", $lulwut[5]); $lol['pry'] = explode(",", $lulwut[6]); $lol['mag'] = explode(",", $lulwut[7]); $lol['ck'] = explode(",", $lulwut[8]); $lol['wc'] = explode(",", $lulwut[9]); $lol['flt'] = explode(",", $lulwut[10]); $lol['fsh'] = explode(",", $lulwut[11]); $lol['fm'] = explode(",", $lulwut[12]); $lol['cra'] = explode(",", $lulwut[13]); $lol['smi'] = explode(",", $lulwut[14]); $lol['min'] = explode(",", $lulwut[15]); $lol['her'] = explode(",", $lulwut[16]); $lol['ag'] = explode(",", $lulwut[17]); $lol['th'] = explode(",", $lulwut[18]); $lol['sl'] = explode(",", $lulwut[19]); $lol['frm'] = explode(",", $lulwut[20]); $lol['rc'] = explode(",", $lulwut[21]); $lol['hun'] = explode(",", $lulwut[22]); $lol['cs'] = explode(",", $lulwut[23]); $lol['sum'] = explode(",", $lulwut[24]); if($type == 1) { $image_URL = './red.png'; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); } if($type == 2) { $image_URL = './brushedred.png'; $x = array('37', '89', '145', '200', '256'); $y = array('10', '36', '61', '90', '118'); } if($type == 3) { $image_URL = './brushedpurple.png'; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); } if($type == 4) { $image_URL = './blue.png'; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); } if($type == 5) { $image_URL = './green.png'; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); } if($type == 6) { $image_URL = './gradient.png'; $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); } if($type == 7) { $image_URL = './pw.png'; $x = array('35', '95', '150', '205', '260'); $y = array('8', '36', '62', '90', '119'); } else { } $image = imagecreatefrompng($image_URL); $fcolour = imagecolorallocate($image, 255, 255, 255); $fsize = 5; $fsize2 = 2; $lol['hp'] = str_replace('-1', '10', $lol['hp']); $row = '0'; $column = '0'; foreach($lol as $s_key => $value){ $value[1] = str_replace('-1', '1', $value[1]); imagestring($image, $fsize, $x[$row], $y[$column], $value[1], $fcolour); $row++; if($row == '5'){ $row = '0'; $column++; } } $overall[1] = str_replace('-1', 'Not Ranked', $overall[1]); $overall[1] = str_replace('Verdana', 'Not Ranked', $overall[1]); imagestring($image, $fsize2, '240', '105', 'Total:' . $overall[1], $fcolour); $username = str_replace('_', ' ', $username); imagestring($image, $fsize2, '240', '115', 'RSN:' . $username, $fcolour); imagepng($image); imagedestroy($image); } else { echo("You have entered an invalid username or the username was not found on the hiscores."); } ?> As you can see: foreach($lol as $s_key => $value){ $value[1] = str_replace('-1', '1', $value[1]); imagestring($image, $fsize, $x[$row], $y[$column], $value[1], $fcolour); $row++; if($row == '5'){ $row = '0'; $column++; } } The data is put out in rows and columns. I want to change this so that I can put each piece of information on the sig seperately. For example: if($type == 1) { $image_URL = './red.png'; imagestring($image, 5, 50, 50, $lol['att'], $fcolour); imagestring($image, 5, 50, 50, $lol['str], $fcolour); imagestring($image, 5, 50, 50, $lol['def'], $fcolour); } But I have no idea how I'd go about doing it. Also, is there any way to change this code so that it can be .png at the end so it can work on forums? Here's an example of it: http://pure-warfare.com/statsigs/sig.php?username=mmmmetallica&type=1 Thanks for any tips put forward. ~Karl Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/ Share on other sites More sharing options...
MadTechie Posted November 9, 2009 Share Posted November 9, 2009 The data is put out in rows and columns. I want to change this so that I can put each piece of information on the sig seperately. just update the XY's for the type you want to change $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); is there any way to change this code so that it can be .png at the end so it can work on forums? header("Content-type: image/png"); Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953898 Share on other sites More sharing options...
`Karl Posted November 9, 2009 Author Share Posted November 9, 2009 just update the XY's for the type you want to change $x = array('28', '80', '135', '188', '240'); $y = array('8', '29', '52', '77', '100'); That will just move the "block" of text, I want to move each individual text on it's own, so a lot needs re-coding. I have no idea how I'd do it though. And as for the header("Content-type: image/png"); I've added it, how would I make it work? Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953900 Share on other sites More sharing options...
MadTechie Posted November 9, 2009 Share Posted November 9, 2009 not a lot of coding but it kinda hard to workout what you want, breaking up the text block into parts then moving each part kinda lacks in detail.. what is the text your dealing with ? what does it look like at the moment? what are you trying to achieve ? Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953901 Share on other sites More sharing options...
`Karl Posted November 9, 2009 Author Share Posted November 9, 2009 Okay, a person inputs their username and the script gets their stats for the game from http://hiscore.runescape.com/index_lite.ws?player=, the information from there is then exploded. $lol['att'] = explode(",", $lulwut[1]); $lol['def'] = explode(",", $lulwut[2]); $lol['str'] = explode(",", $lulwut[3]); $lol['hp'] = explode(",", $lulwut[4]); $lol['rng'] = explode(",", $lulwut[5]); $lol['pry'] = explode(",", $lulwut[6]); $lol['mag'] = explode(",", $lulwut[7]); $lol['ck'] = explode(",", $lulwut[8]); $lol['wc'] = explode(",", $lulwut[9]); $lol['flt'] = explode(",", $lulwut[10]); $lol['fsh'] = explode(",", $lulwut[11]); $lol['fm'] = explode(",", $lulwut[12]); $lol['cra'] = explode(",", $lulwut[13]); $lol['smi'] = explode(",", $lulwut[14]); $lol['min'] = explode(",", $lulwut[15]); $lol['her'] = explode(",", $lulwut[16]); $lol['ag'] = explode(",", $lulwut[17]); $lol['th'] = explode(",", $lulwut[18]); $lol['sl'] = explode(",", $lulwut[19]); $lol['frm'] = explode(",", $lulwut[20]); $lol['rc'] = explode(",", $lulwut[21]); $lol['hun'] = explode(",", $lulwut[22]); $lol['cs'] = explode(",", $lulwut[23]); $lol['sum'] = explode(",", $lulwut[24]); $lol['att'] = Attack Level $lol['def'] = Defence Level etc This information is then put on to the sig using this code foreach($lol as $s_key => $value){ $value[1] = str_replace('-1', '1', $value[1]); imagestring($image, $fsize, $x[$row], $y[$column], $value[1], $fcolour); $row++; if($row == '5'){ $row = '0'; $column++; } } imagestring($image, $fsize, $x[$row], $y[$column], $value[1], $fcolour); That imagestring is the same, no matter which signature they're using. $x[$row] $y[$column] are both defined under each signature type. There are 5 rows and 6 columns of text, each move according to the x and y co-ords. What I want to do is remove this: foreach($lol as $s_key => $value){ $value[1] = str_replace('-1', '1', $value[1]); imagestring($image, $fsize, $x[$row], $y[$column], $value[1], $fcolour); $row++; if($row == '5'){ $row = '0'; $column++; } } So that under each type I can customize the location of each stat, meaning have x and y co-ords for each of these: $lol['att'] = Attack Level $lol['def'] = Defence Level http://pure-warfare.com/statsigs/sig.php?username=mmmmetallica&type=1 There's an example, as you can see, it's harder to get the text to fit in on each sig when it's in rows and columns, rather than moving each number individually. Hope this explains a bit more. Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953903 Share on other sites More sharing options...
MadTechie Posted November 9, 2009 Share Posted November 9, 2009 Okay well i got all that from the code! Your example is missing the png header! (as stated) you could just add an if statement, ie if($s_key == "att"){ imagestring($image, $fsize, 20, 10, $value[1], $fcolour); continue; } if($s_key == "def"){ imagestring($image, $fsize, 30, 40, $value[1], $fcolour); continue; } imagestring($image, $fsize, $x[$row], $y[$column], $value[1], $fcolour); Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953906 Share on other sites More sharing options...
`Karl Posted November 9, 2009 Author Share Posted November 9, 2009 But that wouldn't work for each type of signature individually. Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953907 Share on other sites More sharing options...
`Karl Posted November 9, 2009 Author Share Posted November 9, 2009 Managed to do it, thanks for the help, much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/180813-solved-imagestring-help/#findComment-953912 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.