Parsing a text file to display certain data on my website in php?
Hi! ^^
Im trying to figure out how to display parts of a .db file created by the scorch2000 server to display a player name, games played, score and maybe more... here is the text file format example: playername1 password email #ofgames score setting1 setting2 setting3 playername2 password email #ofgames score setting1 setting2 setting3 playername3 password email #ofgames score setting1 setting2 setting3 playername4 password email #ofgames score setting1 setting2 setting3 playername5 password email #ofgames score setting1 setting2 setting3 I dont want to display everything, of course ^^, but how do i get the player name, the number of games he played and his score to display it in a webpage in this fasion: Name Games Played Score joe blow1 25 9876890 joe blow2 31 8989767 joe blow2 26 7989767 joe blow2 17 5989767 joe blow2 13 4989767 and by highest score because the log doesin't put them in in score order.... :( please help, i asked the maker because he has one runing already but no answer back, well the game is pretty old so i didn't really expect an answer anyways and tryed to figure it out but i dont know functions in php, this is to include in a php-nuke block (this i know how to do :) here is an example of a working page at the developper website: http://scorch2000.com/top100.html thank you |
I'll send you the bill later.
PHP Code:
|
^^ thanks!
Seriously if you have a paypal account it would be my pleasure to give you a little something :) , im not rich but i'll give you what i can....
you can send your info here admin@excelclan.com if you wish,, like i said it would be a pleasure :) because this is actually the first code i know that is tailor made for this classic game server so i thank you VERY much and is very much appreciated ^^ Thanks again |
Woooooooooooooooow this looks nice! hihihihi ^^
|
1 Attachment(s)
Quote:
This works great but puts all of the line in playername1,, how do i display only the player name in that field, then in the next the numbers of games he player then after that the score in the next field? or how does the script work? sorry about that :( here is what it looks like http://www.excelclan.info/games/scor...layerstats.php Also i cant copy paste the players.db file because it only copies the first word of the file in notepad++ because of the NUL symbols (dont know why) so i have attached a picture of the file.... |
ok i figured out that $line_arr = explode(' ', $buffer); this is the value that takes in to account that after the space it becomes the next value, but in this log file there is a NUL symbol, what is this?, what can i put between the quotes in $line_arr = explode('HERE', $buffer); to represent that NUL symbol?
|
ok
ok the problem is that the server removes those NUL symbols and i loose the spaces,, is there a way to read that file with this script while keeping the spaces?
or can i copy this file to the location of this script, covert it to another format and read it,, but how or with what do i convert it?, i know how to copy it with cron and all but what program on an ubuntu server can i use to convert this file to unicode or a format wich keeps the spaces? thanks |
What is the format of the db file?
I use the function explode(' ', $buffer) that separates the words by space. For example. The line Code:
something1 this is a phrase something2 Code:
something1 Code:
something1,this is a phrase,something2 PHP Code:
PHP Code:
Code:
something1 It's also possible that the db file separates phrases with tabs. If that's the case simple change the explode line to PHP Code:
You mentioned the NUL symbol: Try: PHP Code:
|
1 Attachment(s)
Notepad++ tells me that this is an ANSI Windows format, it is generated by the game server wich uses java.
I tryed the "\0" found that out on wikipedia but still shows the same thing... all together... also tryed with your suggested "\t" (tabs), no go :( |
can you zip it and atatch it?
|
I attached it to my last post,, i changed the extension to txt from db,, but if you open it with notepad++ you see the NUL symbols....
thank you very much ^^ |
here it is in a zip format with the extention .db, arff cant attach zip files.... but i posted it in txt format above...
|
Ok. Let me check
|
Ok. The end of line is 0x0A and the words are separated by 0x00
I also sorted the results by Score PHP Code:
|
kewwwwlll!,, ok i checked the link you provided on the explode() argument but i cant see anything that explains on how to print only chunks of a line, for example mine has 14 values,, but how do i only print the name, the numbers of games played and the score?, because the other values are passwords and e-mails i wouldn't want to display that to the public.....
if you dont feel like explaining can you provide me with the argument i can use to do this? |
All times are GMT -5. The time now is 02:28 AM. |