Page 1 of 2

[PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 23 Jul 2007 11:57
by f*ckfish
TMN Color Parser and Data Fetcher v0.5 (for PHP)
by (OoR-F)~f*ckfish aka Alexander P.
http://fish.stabb.de

These are two little classes that really come in handy if you try to create TMN related statistic pages. The usage of classes helps to hold your own sourcecode short and you don't have to care how they work, just include and use them as seen in the example below.

Download

NOTE: There's an updated version of the Color Parser taking care of the new Forever tags (TMF Color Parser)

TMN Color Parser and Data Fetcher All Versions
Download includes fully working usage examples

Update v1.2
  • Just added a parameter to be able strip the colors when using the image draw function
Update v1.1
  • Xymph beautified the code and enhanced the functionality of the DataFetcher, so I included his final version here. Thanks =)
Update v1.0
  • Fixed a lot of bugs in the ColorParser, be sure to check out the new version (removed problems with whitespaces and some weird other stuff that occured)
  • Now one file for all php versions
The Color Parser

This class converts TMN Strings to valid HTML and preserves styles and colors.
I'm aware of the mass of scripts available that convert color and style coded TMN Strings to HTML but my parser has a few other features. At first it also implements the $n-Tag by changing the letter spacing and font size, haven't seen that in another script before. Another nice feature is the ability to easily render the string onto on an image like a signature for example.

HTML

Implements every tag except the shadow tag because there is no css feature doing something similar at the moment.

Image

Implements the wide, italic and of course the color tags. I'll implement more, if I find the time for that ;-)
See it in action in the example below

The Data Fetcher

This class takes a TMN login, automatically gathers information from the known Nadeo sites and provides them in an easy-to-understand manner (see Example).

Example

This example shows the simplicity of the usage of the classes:

Code: Select all

<?
     //include classes
     require_once('./classes/TMNDataFetcher.php');
     require_once('./classes/ColorParser.php');

     //instantiate classes, the rest will be done automatically
     $data = new TMNDataFetcher('gluexxxkeks', true);
     $cp= new ColorParser();

     //output the desired information
     echo $data->login."<br>".
          $cp->toHTML($data->nickname)."<br>".
          $data->worldrank."<br>";
?>
This example simply puts out the login "gluexxxkeks", the correctly HTML color coded nickname and the worldrank. See all the information the Data Fetcher gathers in the screenshot below.

Screenshot

I only captured my local browser but you can also click here for a realtime preview ;-)
Also don't care for the login on the screen, I just searched for a login colored nickname that was in a team and online at the moment.
The background behind the nick is only to show that there is an image, you can render it on everything, maybe a prepared signature background or whatever...
This screen shows all the information the Data Fetcher gathers and also the functionality of the Color Parser to render to HTML and images.

Image

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 12 Aug 2007 12:09
by f*ckfish
The download link changed, see my first post.

Bye,
Fish

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 18 Aug 2007 09:17
by f*ckfish
Since the original version was buggy as hell I threw in a little update (see first post). If you are already using this tool you should definetly consider to update, there were some very stupid bugs in the source :oops:

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 02 Mar 2008 21:03
by f*ckfish
I finally managed to include Xymphs enhanced version of the DataFetcher. Thanks a lot for your work :D

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 02 Mar 2008 23:08
by Xymph
Yowza. :lol: You're welcome.

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 10 Mar 2008 19:20
by f*ckfish
By request I added a parameter to be able strip the colors when using the image draw function .
Download link as always in the first post.

Error in Data Fetcher

Posted: 26 Jun 2008 06:32
by PsyZo
Hi,
thanx for your work, but I get an error in TMNDataFetcher class:

In method getData() the first file_get_contens() return this:

Code: Select all

Array
(
    [0] => 5
    [1] => 

NOTICE in line 28 of file /home/scripts/game_Host_new/GetPlayerInfos.php

Aborting...


)
the second this:

Code: Select all

Array
(
    [0] => 12
    [1] => 
)
The first file_get_contents use this parameter:

Code: Select all

http://game.trackmanianations.com/online_game/getplayerinfos.php?ver=0.1.7.9&lang=en&login=MyLogin
the second this:

Code: Select all

http://ladder.trackmanianations.com/ladder/getstats.php?ver=0.1.7.9&laddertype=g&login=MyLogin
These are not the stats, or :wink: ? Can smb help me, please?

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 06:39
by f*ckfish
Yepp, your login is not a valid TMN login. That's where the errors come from.

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 07:02
by PsyZo
Thank you for your very quick answer.
I'm a little bit confused now :? , i've tried with many TMNF accounts, always the same error.

Is there a different between TMN and TMNF accounts? Do only TMN accounts work?

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 09:04
by Shaigan
Yes, only old united or nations accounts, and not united forever nor nations forever accounts...

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 09:35
by PsyZo
Shaigan wrote:Yes, only old united or nations accounts, and not united forever nor nations forever accounts...
Thx. That isn't good.
So is there a way to get informations with TMUF/TMNF accounts?

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 10:54
by Shaigan
Wait tm-ladder.free.fr come back, the API should follow.

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 11:27
by PsyZo
thanks a lot, i'll be waiting

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 26 Jun 2008 11:30
by [SA.fr] Tybos
Hi,

I am using the Color Parser class to print TMUF map names. Since Nadeo introduced new name features (and especially the $o one : bold text with semi-large spacing), the printing of some map names is "polluted" with "o"s.
Can we imagine to add this feature in Color Parser ?

Anyway, thank you very much for these very useful classes.

Tybos

EDIT : I apologize, I think I found what I needed here.
Nice work, thanks.

Re: [PHP/HTML] TMN Color Parser and Data Fetcher

Posted: 04 Jul 2008 06:41
by hal|Sascha
I'm using the colorparser for the hal-ko replaydatabase and it works great! Nice work :thumbsup: