What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP Images... I can't make one. :(

Pages: (4): « First « 1 2 3 [ 4 ] Last »
PHP Images... I can't make one. :(
Author: Message:
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
I found a way to put the values at the right place... instead of $line, I put the real value.
01-22-2005 12:35 AM
Profile E-Mail PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
35 / Male / Flag
Joined: Mar 2004
RE: PHP Images... I can't make one. :(
quote:
Originally posted by Guillaume
code:
<?
$handle = fopen("http://www.bungie.net/Stats/PlayerStats.aspx?player=guyguyme2003", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);



$match = InsideTags('<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">','</div></div>',$contents); // uses a regular expression and gets the stuff inbetween those two points and returns it


$rumble_pit = $match[1][0];
$team_skirmish = $match[1][1];
$head_to_head = $match[1][2];
$big_team_battle = $match[1][3];
$team_slayer = $match[1][4];


function InsideTags($tag1,$tag2,$html){ //function to grab text inbetween two points
$tag2 = str_replace('/', "\/" ,$tag2);
preg_match_all("/$tag1(.*)$tag2/i", $html, $match);
return $match;
}


header("Content-type: image/png");
$im = @imagecreatefromjpeg("http://guillaumelforum.theglassprison.net/halo2/Halo%202%20Stats_files/statsforimg.jpg");
$text_color = imagecolorallocate($im, 255, 255, 255);
$line = 42;
imagestring($im, 1, 102, $line, $rumble_pit, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $team_skirmish, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $head_to_head, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $big_team_battle, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $team_slayer, $text_color);
imagepng($im);
imagedestroy($im);

?>




err is that still how to script works? is there no caching? you know everytime that script is loaded it downloads the whole stats page ?

you need to set up a caching system how i would do it is check if the cache exists then if it does i would check the  current time (time() ) agiesnt the file time of the cache file ( filemtime($cache) )
if the cache is past 30min or so (the time() produces funky unix time use something like $blah = time() -  filemtime($cache); to get seconds scince last update )

then if its like 30min past last update download the stats again and write it to a file (use fwrite) .

If its not 30min past use fread to read the cache file then load it into your script and use that for stats insted.


post if you dont quite get me and ill post some sample code :P but look up some of the terms i used like fwrite and search it on http://php.net

but atleast try to make some of the code :)
or post here for help
[Image: dt2.0v2.png]      Happy Birthday, WDZ
01-22-2005 11:11 AM
Profile PM Web Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
quote:
Originally posted by -dt-
quote:
Originally posted by Guillaume
code:
<?
$handle = fopen("http://www.bungie.net/Stats/PlayerStats.aspx?player=guyguyme2003", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);



$match = InsideTags('<div class="ExpBar" style="width:50"><div class="ExpBarText" style="left:20">','</div></div>',$contents); // uses a regular expression and gets the stuff inbetween those two points and returns it


$rumble_pit = $match[1][0];
$team_skirmish = $match[1][1];
$head_to_head = $match[1][2];
$big_team_battle = $match[1][3];
$team_slayer = $match[1][4];


function InsideTags($tag1,$tag2,$html){ //function to grab text inbetween two points
$tag2 = str_replace('/', "\/" ,$tag2);
preg_match_all("/$tag1(.*)$tag2/i", $html, $match);
return $match;
}


header("Content-type: image/png");
$im = @imagecreatefromjpeg("http://guillaumelforum.theglassprison.net/halo2/Halo%202%20Stats_files/statsforimg.jpg");
$text_color = imagecolorallocate($im, 255, 255, 255);
$line = 42;
imagestring($im, 1, 102, $line, $rumble_pit, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $team_skirmish, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $head_to_head, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $big_team_battle, $text_color);
$line = $line + 10;
imagestring($im, 1, 102, $line, $team_slayer, $text_color);
imagepng($im);
imagedestroy($im);

?>




err is that still how to script works? is there no caching? you know everytime that script is loaded it downloads the whole stats page ?

you need to set up a caching system how i would do it is check if the cache exists then if it does i would check the  current time (time() ) agiesnt the file time of the cache file ( filemtime($cache) )
if the cache is past 30min or so (the time() produces funky unix time use something like $blah = time() -  filemtime($cache); to get seconds scince last update )

then if its like 30min past last update download the stats again and write it to a file (use fwrite) .

If its not 30min past use fread to read the cache file then load it into your script and use that for stats insted.


post if you dont quite get me and ill post some sample code :P but look up some of the terms i used like fwrite and search it on http://php.net

but atleast try to make some of the code :)
or post here for help
I'll give it a shot.

This post was edited on 01-22-2005 at 03:49 PM by Moo.
01-22-2005 03:48 PM
Profile E-Mail PM Find Quote Report
Moo
Full Member
***

Avatar

Posts: 395
Reputation: 19
Joined: Jun 2004
O.P. RE: PHP Images... I can't make one. :(
Allright! I got a good one!
01-22-2005 04:25 PM
Profile E-Mail PM Find Quote Report
Pages: (4): « First « 1 2 3 [ 4 ] Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On