SitePoint Sponsor |
|
User Tag List
Results 1 to 10 of 10
-
Apr 22, 2009, 19:41 #1
- Join Date
- Aug 2008
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
How to make dynamic signutures with stats
I was wondering how would i make a image like
http://www.fpstactics.com/sig/custom/killa/1912428.jpg
I know this is coded with PHP
But how would i make this, i think all the codes are pulled from
http://clan.subagames.com/charstat_cf.aspx?usn=1912999
But witch codes?
Also how would i make a engine which would allow my users to make there own by inserting there USN? (number at the end of the link)
Kind of like
http://www.fpstactics.com/gaming_signatures.php
Thanks in advance
NOTE: I have host monster
-
Apr 22, 2009, 21:14 #2
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
You fetch the contents of the page:
PHP Code:$html = file_get_contents("http://clan.subagames.com/charstat_cf.aspx?usn=1912999");
http://www.php.net/preg_match
http://www.regular-expressions.info/tutorial.html
Then use PHP's image manipulation functions to create the image and output it to the browser.
http://us.php.net/gdTry Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Apr 23, 2009, 14:11 #3
- Join Date
- Aug 2008
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Hey can you do a tut on how to do this? i get lost with the first link
(For Subagames)
-
Apr 23, 2009, 14:19 #4
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
The second link is a tutorial for writing patterns for the first link. If you want someone to code the whole thing for you, then put out a Looking to Hire listing in the marketplace.
Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Apr 23, 2009, 15:29 #5
- Join Date
- Mar 2008
- Posts
- 1,149
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
You can use the GD library to draw the signature:
http://php.net/gd
Take a look at the many examples and test them out to get the hang of how it works.
When you know how to work the API, design something nice in your favorite graphics editor, export it to a PNG file, load it in with GD in your script, and manually position all the text and such. After you're all done, you might want to convert the PNG file to a GD file (you can do that with PHP's GD library too) for performance reasons (though I don't know if it has a noticeable effect).
To take in a USN, you just use $_GET like you would normally. In the image you linked, it doesn't have a query part in the URL though. If you use Apache, you can use mod_rewrite to fake URLs and make them redirect to your script (#####.png => signature.php?usn=#####). Shove this into a .htaccess file:
Code:RewriteEngine on RewriteRule ^([0-9]+)\.png$ signature.php?usn=$1 [QSA,L]
-
Apr 23, 2009, 15:45 #6
- Join Date
- Aug 2008
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Ok so this is what they use for the kill count
<tr>
<td align="left" valign="top" class="stylenav13">Total Kills</td>
<td align="left" valign="top"><span id="ctl00_Main_lbl_enemy_kill_cnt">9805</span></td>
</tr>
so would i type in
$html = file_get_contents("http://clan.subagames.com/charstat_cf.aspx?usn=1912999ctl00_Main_lbl_enemy_kill_cnt");
?
Also can someone explain the php GD and what it dose? (or link me to a more nooby guide)
Thanks in advance
-
Apr 23, 2009, 15:47 #7
- Join Date
- Aug 2000
- Location
- Philadephia, PA
- Posts
- 20,578
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
No, you don't change the URL, it's not that easy.
You write a regular expression which matches the 9805 in $html.Try Improvely, your online marketing dashboard.
→ Conversion tracking, click fraud detection, A/B testing and more
-
Apr 23, 2009, 16:09 #8
- Join Date
- Aug 2008
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
So how do i trigger a regex? (regular expression?)
-
Apr 23, 2009, 16:10 #9
- Join Date
- Aug 2008
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
The 9805 changes so would i have to make something like
int preg_match ( string $<td align="left" valign="top"><span id="ctl00_Main_lbl_enemy_kill_cnt">9805</span></td>
, string $<span id="ctl00_Main_lbl_enemy_kill_cnt">
[, array &$match[, int $flags [, int $offset ]]] )
?
-
Apr 23, 2009, 16:19 #10
- Join Date
- Aug 2008
- Posts
- 26
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
<html>
<?php
$html = file_get_contents("http://clan.subagames.com/charstat_cf.aspx?usn=1912428");
$subject = "0-9";
$pattern = '<span id="ctl00_Main_lbl_enemy_kill_cnt">9805</span>';
preg_match($pattern, substr($subject,3), $matches, PREG_OFFSET_CAPTURE);
print_r($matches);
?>
</html>
Sorry im spaming :3
Ok so far i get
Make the file name name.php
then
<html>
<?php
$html = file_get_contents("http://clan.subagames.com/charstat_cf.aspx?usn=1912428");
?>
</html>
And thats itLast edited by Naromaru; Apr 23, 2009 at 16:34. Reason: Upps wrong code placement
Bookmarks