Open txt files from a directory, compare the values, and output the top 15 in PHP

Posted by Anon on Stack Overflow See other posts from Stack Overflow or by Anon
Published on 2010-04-02T03:43:38Z Indexed on 2010/04/02 3:53 UTC
Read the original article Hit count: 237

Filed under:
|

Hello, I recently designed a referral game website for the fun of it.

There's a simple MySQL user system with a email verification. It's using the UserCake user management system.

On top of this i added a php page that the user could give to "victims" that when they visit it they get "infected" and can infect other users or "victims". This page uses GET to get the username from the url. I have a folder that when a user registers it creates a file with 4 digits and then the username. (ex; 0000Username.txt) All the numbers are the same, it's just so that if a user discovers the folder they won't be able to find the files. There is also a txt file in the same format with IPS in the name. (ex; 0000IPSUsername.txt) The file when visited gets the username from the url, then checks if the text file for that username exists. If the username is present in the url, and a valid user it opens the IPS file and adds the IP of the visitor, then opens the user text file, takes the value and adds one to it, and saves. At the end it makes the difference between saying "You are infected, Username has infected (amount) people." or just you have been infected.

Now to what i need!

I need to add a hi-scores to the website so people can compete to be the one with the most "infections".

I thought i could use readdir to get a list of the files and open them with the value in an array, but i need it to also strip the username from the file name. It would be best if it just saves to a text file like "Username | value" because then i can add echo's of the html tags and have it include the file in the page i want it to be one.

Many thanks in advance.

© Stack Overflow or respective owner

Related posts about php

Related posts about html