You are not logged in.
#76 08 Dec 2006 9:26 pm
Re: BF2 Rank
that script generates an image just like photoshop does. instead of saving it to a file, it sends it to the web browser. there is no way for the web browser to know that the web server didn't open up an image file and send it. they're all binary data at that point. if you save the dynamic image as a file, and open it up in a hex editor, you'll see that it actually has the image type info written in the first little bit of the file itself (it will say like jpeg or png or whatever), so you can verify for yourself that the dynamic image is infact the same type of image that photoshop would generate (photoshop uses the same type of code to create whatever you do in it... albeit much more complex code).
forum software checks for a file extension in [img] blocks. this is a bug (or feature depending on your point of view) in the forum software because files don't need a file extension to be a valid file type. Microsoft windows uses file extensions to classify files, but there are other operating systems that dont require that (files typically have descriptive info in their file header that can be used to accurately identify the type of file most of the time).
you can make the forum software *think* that its getting a static file with an image extension, but thats done on the server level with a thing called mod_rewrite (a feature of apache web server). this post talks more about that. mod_rewrite allows the web server to look at the requested URL, and check it to see if what has been requested is a "fake" "file" or "directory" and re-routes the request (rewrites it) to get the correct dynamic data. the browser thinks its getting a static file, and the server is able to generate the dynamic data, and both sides are happy.
apache web server uses a file named .htaccess (among other things) to check for "re-written" URL's. In the post I linked to, I have my "rewrite rules" listed so that the dynamic rank avatar, can be referenced as a static image. you can do the same for the signatures you generate.
Offline
#77 09 Nov 2007 11:42 am
- Butcher
- Moderator
- From: Norway
- Registered: Jul 2006
- Posts: 308
Re: BF2 Rank
Did anyone ever make a way to do this by PID? Since BF2s.com went down (indefinately it seems), some people have been wanting to use the one on bamboocommandos.com, and a lot of them are checking stats through the links from http://www.bamboocommandos.com/status/b … tatus.php, which sends the link with NICK, and not PID, but cause of EA, it also transports prefixes, and not only pure name. I tried replacing all NICK variables with PID in a copy of the index file (fast and easy method I reckoned), but that obviously didn't work.
Just can't find where it checks is_valid_player, so I can change that to have him check PID instead of NICK, any ideas?
Last edited by Butcher (09 Nov 2007 11:43 am)
Offline
#78 09 Nov 2007 12:55 pm
Re: BF2 Rank
I modified the bf2_player.php file to let you use a nick or pid. you can use it the same as you did before, but now you can pass in the nick or pid to the object's constructor:
Code:
$bf2_player = new bf2_player("[OinK]_MadHatter");
or
Code:
$bf2_player = new bf2_player("45647367");
download this, and replace your existing bf2_player.php file with this one.
Offline
#79 09 Nov 2007 3:17 pm
- Butcher
- Moderator
- From: Norway
- Registered: Jul 2006
- Posts: 308
Re: BF2 Rank
I replaced it, and made a new version of the index file, now called index2.php, which look like this:
Code:
<?php if($_POST['pid']) { $pid = $_POST['pid']; header("Location: index2.php?pid=$pid"); exit(); } else if($_GET['pid']) { include("bf2/bf2_player.php"); include("globals.php"); $bf2_player = new bf2_player($_GET['pid']); if($bf2_player->is_valid_player) { $nick = $bf2_player->stats['nick']; $pid = $bf2_player->stats['pid']; $gs = $bf2_player->stats['scor']; $rank = $bf2_player->stats['rank']; $rkk = $bf2_player->stats['vkl-0'] + $bf2_player->stats['vkl-1'] + $bf2_player->stats['vkl-2'] + $bf2_player->stats['vkl-3'] + $bf2_player->stats['vkl-4'] + $bf2_player->stats['vkl-5'] + $bf2_player->stats['vkl-6']; $sc = $bf2_player->stats['suic']; $lbp = date('d F Y G:i', $bf2_player->stats['lbtl']); $trp = $bf2_player->stats['loss'] + $bf2_player->stats['wins']; $kdr = $bf2_player->stats['kill']." / ".$bf2_player->stats['deth']; $nscore = $rank_table[$rank+1] - $gs; $progress = 0; if($gs != 0) { $progress = ((($gs - $rank_table[$rank]) / ($rank_table[$rank + 1] - $rank_table[$rank])) * PERCENT); } if($progress > 100) { $progress = 100; } //replace the html like tags we put in the template $file_contents = file_get_contents('templates/stats.tpl'); $file_contents = str_replace('<nick/>', $nick, $file_contents); $file_contents = str_replace('<rkk/>', number_format($rkk), $file_contents); $file_contents = str_replace('<gs/>', number_format($gs), $file_contents); $file_contents = str_replace('<sc/>', number_format($sc), $file_contents); $file_contents = str_replace('<tmp/>', number_format($trp), $file_contents); $file_contents = str_replace('<lbp/>', $lbp, $file_contents); $file_contents = str_replace('<kdr/>', $kdr, $file_contents); $file_contents = str_replace('<nrp/>', number_format($nscore), $file_contents); $file_contents = str_replace('<progress/>', round($progress, 2), $file_contents); $file_contents = str_replace('<rank/>', $rank, $file_contents); $file_contents = str_replace('<rank_title/>', $rank_text_table[$rank], $file_contents); $file_contents = str_replace('<rank_img_url>', 'http://bamboocommandos.com/prank/' . urlencode($_GET['nick']) . '.jpg', $file_contents); //print the final text out echo $file_contents; } else { readfile("templates/empty.tpl"); exit(); } } else { readfile("templates/empty.tpl"); } ?>
But when running http://www.bamboocommandos.com/prank/index2.php?pid=44547275, it doesn't parse it through as it would a nick.
Offline
#80 09 Nov 2007 3:59 pm
Re: BF2 Rank
I don't have the time to look at it right this second, but its running fine over here:
http://sanity-free.org/prank/index.php?nick=44547275
I'll take a look later tonight or tomorrow
Offline
#81 09 Nov 2007 4:09 pm
- Butcher
- Moderator
- From: Norway
- Registered: Jul 2006
- Posts: 308
Re: BF2 Rank
No problem, not in a hurry. Weird though, since we are using the same file.
Last edited by Butcher (09 Nov 2007 4:11 pm)
Offline
#82 09 Nov 2007 7:34 pm
Re: BF2 Rank
try replacing
Code:
} else { readfile("templates/empty.tpl"); exit(); } } else { readfile("templates/empty.tpl"); }
with
Code:
} else { echo "Not Valid Player"; } } else { echo "Display empty template"; }
in index2.php and try this link (http://www.bamboocommandos.com/prank/in … d=44547275) again.
if the Not valid player shows up, then delete the bf2_player.php on the server then upload the one I uploaded here. if this shows up, most likely the right file never was completely uploaded.
if the "Display empty template" shows up, then something's messed up with the server because that link should place pid into the $_GET request variable.
I noticed that you're going to need to alter the image generating code too (so that it accepts the pid, since I noticed that it won't work with a pid)
Offline
#83 10 Nov 2007 3:32 am
- Butcher
- Moderator
- From: Norway
- Registered: Jul 2006
- Posts: 308
Re: BF2 Rank
Yeah, the rank images are doing some vodoo thing as well, I can show any .gif or .png picture, but no .jpg. To fix the rank image, I only needed to switch $_GET['nick'] to $_GET['pid'], since the new bf2_player.php was changed to work with PIDs. It worked by deleting old bf2_player.php and uploading new one, must not have uploaded correctly last time.
Offline
#84 09 Apr 2008 7:26 am
Re: BF2 Rank
Hi all,
Coool site,
Just what ive been looking for.
Im just wondering is there like a final version zip file like the one Butcher uses on his site now?
Let me explain, I too run a clan site and right now only have a few members but would really like the option for members to create a sig within then site and be able to post it as a sig in the forums.
Now im not a complete html noobie but php and c++++++ coding is way beyond my limits.
A final zip that looks like butchers would be great so long as theres a few help files for changing anything that realtes to BC site.
My website is actually a free one and I dont have access to upload files but I do have webspace where php etc... is enable and was thinking I can use an Iframe to insert it into the website?
this one is what im after
http://sanity-free.org/prank/index.php?nick=44547275
Last edited by blister (09 Apr 2008 7:28 am)
Offline
#85 09 Apr 2008 3:04 pm
Re: BF2 Rank
I can't personally hand out butcher's code, but I can give you the module he uses that I wrote, and can walk you through how to use it.
http://sanity-free.org/misc/bf2.zip is the core php code that pulls the stats.
basically what you do is create an index.php file that contains the following core code:
Code:
<?php if($_POST['nick']) { $nick = $_POST['nick']; header("Location: index.php?nick=$nick"); exit(); }else if($_GET['nick']) { $bf2_player = new bf2_player($_GET['nick']); if($bf2_player->is_valid_player) { // FROM HERE YOU HAVE A VALID PLAYER'S STATS LOADED // YOU CAN ACCESS STATS FROM $bf2_player->stats['something'] // WHERE 'something' IS A ONE OF THE STATS COLUMN VALUES // LISTED IN THE LINK BELOW // HERE YOU SIMPLY ADD THE VALUES PULLED TO YOUR HTML } } ?>
stats columns (not all of them listed here are actually available) are listed here http://bf2tech.org/index.php/Getplayerinfo_columns
I have exponentially less time now to do up something for you like I did for butcher, but on the off chance that I do I'll post it here. he may be able to help you out more (if he comes around anytime in the near future). I'm sure you could PM or email him from here if you wanted to.
Offline
#87 10 Apr 2008 10:36 pm
- winsr
- Extreme Member
- Registered: Mar 2007
- Posts: 90
Re: BF2 Rank
hi dude, i have made a windows program that generates sigs and downloads stats for bf2 and bf2142... (thanks to madhatter of course), if you are insterested let me know.
More information can be found here.. http://www.totalgamingnetwork.com/main/ … hp?t=35097 (images on site do not match current version of the program... actually i think better images are on this site.)
Offline
#88 11 Apr 2008 5:09 am
- Butcher
- Moderator
- From: Norway
- Registered: Jul 2006
- Posts: 308
Re: BF2 Rank
If you get confused or need help, don't hesitate asking for help. And I'd be happy to share my version of it, and a large benefit of the online script is that it can dynamically make the image based on the GET variable sent to it, rather than making thousands of images for every bugger who uses it.
Offline
#89 15 Apr 2008 5:59 am
Re: BF2 Rank
I think im in over my head
I finally got a bit of time to look through the script and i gotta say "im completely lost"
I did try out your software winsr but i couldnt get it to produce a sig and would really like the ability for my clan members to be able view stats and create a sig via the clans site..
any help much appreciated
Offline
#90 15 Apr 2008 10:36 am
Re: BF2 Rank
ok, I modified the system we did for butcher, and zipped it up here: http://sanity-free.org/misc/bf2stats.zip
Installation instructions:
now you should be able to view the basic stats page.
there are 2 template files (empty.tpl and stats.tpl) under the templates directory.
empty.tpl - is the page that is displayed before any stats are shown. This page can either be integrated into your existing website, or left alone (or themed). You can actually put anything in this file, as long as the FORM posts to the index.php page, and has an input element named "nick" that the user enters their bf2 nick into.
stats.tpl - this page is used to display the player's statistics. what the script does is it loads up this file, and looks for variables in the file and replaces them. simply add variables in your stats.tpl file in the following format:
Code:
${name}
where 'name' maps to the 'code' column of the getplayerinfo stats data.
for example, lets say I wanted to display the number of times a player has been banned. the 'code' listed on that page for bans is 'ban' (first row on that page). so if I wanted to display that on my stats template page, I'd add ${ban} to my HTML where I wanted the number of bans to be listed:
Code:
<html> <body> Number of bans: ${ban} </body> </html>
Now in this sample, butcher wanted to add some stats numbers that were actually calculated from raw stats. for example, he lists total rounds played, which is calculated by adding total wins to total losses. This is sort of tricky (unless you know PHP) if you want to add it to your stats pages, but I'm sure I could help out with that. The way I'm doing it in this sample is to add codes to what gamespy sends back. if you look in index.php for the line:
Code:
// add some extra's into the stats array so we can replace them in the html easily
you see some code examples of how I'm doing that.
for instance, we want to be able to display the titles of your rank; gamespy sends back a number. I've built up a table that lists the english version of that rank which is used to assign $bf2_player->stats['rank_title'] to the text version of the rank. what this has done is add a code to the list (namely a rank_title code written in PHP as: $bf2_player->stats['rank_title']) that's used by your template (as ${rank_title}) to insert the text version of your rank.
If you want to add custom stats that are calculated like this, simply add:
Code:
// replace "some value" with whatever calculated or extra info you want added to your stats page $bf2_player->stats['some_code_name'] = "some value";
to the index.php code where the rest of them are; then to your stats.tpl add
Code:
${some_code_name}
in your template HTML, and the actual value (in this instance, "some value" will replace ${some_code_name}) will be inserted when the page is built.
as for the image.php file, that one is not as easy to make generic. that will have to be hand coded more or less, since we're actually drawing the image each time its requested, and my code isn't all that easy to understand if you don't already know object oriented programming, and PHP. If you want to customize this, you'll pretty much have to tell me what you want and I'll code it for ya (within reason ).
anyway I think I've covered the basics, if I wasn't clear about something, or if something was just confusing, let me know.
good luck.
Offline
#92 16 Apr 2008 9:44 pm
Re: BF2 Rank
Ok so I just uploaded everything, updated the path on the index file to point to the image.php and when i preview it i get the following error messages.
Notice: Undefined index: nick in /home/*****/public_html/bf2stats/index.php on line 5
Notice: Undefined index: nick in /home/*****/public_html/bf2stats/index.php on line 15
But I do get the option to enter a nick! although after entering a nick and hitting submit I get the following error messages.
Notice: Undefined index: nick in /home/*****/public_html/bf2stats/index.php on line 5
Parse error: syntax error, unexpected T_PRIVATE, expecting ')' in /home/*****/public_html/bf2stats/bf2/defines.php on line 29
I didnt go any further with the installation just so its less confusing for everyone (me really )
suggestions?
Offline
#93 16 Apr 2008 11:58 pm
Re: BF2 Rank
ok, open defines.php
find
Code:
define('PRIVATE', 0);
and change it to
Code:
define('_PRIVATE', 0);
then, find
Code:
$rank_text_table = array( PRIVATE => 'Private',
change to
Code:
$rank_text_table = array( _PRIVATE => 'Private',
then, find
Code:
$rank_table = array( PRIVATE => 0,
and change to
Code:
$rank_table = array( _PRIVATE => 0,
next, open bf2/bf2_player.php
search for
flush();
replace that with
//flush();
there are 2 of these in there.
save, and re-run the script.
Offline
#94 24 Apr 2008 8:27 pm
Re: BF2 Rank
sorry for the wait,
busy man here
ok so ive updated the php and when i run it now on the empty page i get the following errors:
Notice: Undefined index: nick in /home/*****/public_html/bf2stats/index.php on line 5
Notice: Undefined index: nick in /home/*****/public_html/bf2stats/index.php on line 15
but I can now put in a name and get the top half dispalying, I just need to know now where/how sigs and the code are generated..
a screenie Here
showing how it looks so far....
I also still get the 1st error on the stats page after submitting!
anyhow thnx for your time & patience,
much appreciated
Last edited by blister (24 Apr 2008 8:28 pm)
Offline
#95 10 May 2008 10:12 am
Re: BF2 Rank
sorry for taking so long on this too. I noticed it one day but didn't have time to reply then I forgot to reply...
in index.php
find:
Code:
if($_POST['nick']) {
replace with:
Code:
if(isset($_POST['nick'])) {
then find:
Code:
} else if($_GET['nick']) {
replace with:
Code:
} else if(isset($_GET['nick'])) {
then find:
Code:
// add in the sig url $bf2_player->stats['sig_img_url'] = str_replace('${pid}', $bf2_player->stats['pid'], IMAGE_URL);
replace with:
Code:
// add in the sig url $bf2_player->stats['rank_img_url'] = str_replace('${pid}', $bf2_player->stats['pid'], IMAGE_URL);
and save / update and you should be good to go.
Offline
#96 10 May 2008 5:37 pm
Re: BF2 Rank
oh hey thnx man,
just noticed the email andd reminded me also (yes i forgot ) well ive actually been pretty busy myself setting up a new website and trying to get a ranked server filled daily...
I will take a look at this and let ya know how i get on no worries about the wait im easy
thanks
Offline
#97 12 May 2008 10:26 am
Re: BF2 Rank
Thnx all,
all working as it should now
If I could trouble you just a little longer, my clans website is based aroung nuke php and i would like to be able to include the stats as a block instead of it being in a page of its own, how easy would that be?
Offline
#98 12 May 2008 1:51 pm
Re: BF2 Rank
I run another site that uses an older version of phpnuke (that I've hacked the heck out of), and no it shouldn't be too hard.
If I remember I'll try to bundle it up into a block & module so you can see how it would work. I'm thinking the block would just be an input box that posts to the module. going deeper into php you could probably hack in a bf2 nick / pid into the user profile and display a link to that module from the user menu or something easy like that. its been a few years since I've played w/ the latest version of phpnuke so I don't know how hard / easy that would be.
Offline
#99 14 May 2008 9:18 am
- Butcher
- Moderator
- From: Norway
- Registered: Jul 2006
- Posts: 308
Re: BF2 Rank
Far as I remember, php-nuke uses phpBB, so adding a field to the user in the database should be easy, and then let people feed in their PID or nick, and if such is present, display the rank in a block as MadHatter says (php-nuke had/has some tutorials on how to create blocks/modules on their site I'm quite sure).
Offline
#100 16 May 2008 9:55 am
Re: BF2 Rank
That sounds like what i was thinking, shame im just a noobie with phpMadHatter :
If I remember I'll try to bundle it up into a block & module so you can see how it would work. I'm thinking the block would just be an input box that posts to the module.
anyhow no rush just when you have time
Offline