Re: You are visitor number: 140923580912480

If you want to do it in _javascript_, just make a _javascript_ server instead of a PHP server. That's right, you can have _javascript_ server-side code now with NodeJS, so just make a NodeJS app with your server code in _javascript_, it would completely replace php.

Now for your counters thing, I understand there are two counters your are interested in:
1) The visitor number tells them that they are the nth visitor
2) The download counter which says how many times the file was downloaded

For the visitor counter, the tricky part is that you have to track a user. Using the IP address is not a good idea, because there can be a ton of devices hihdden behind a public address. The easiest way is to set a cookie with their visitor number. The flow goes like this:
1) I go to your website with my chrome browser for the first time
2) The server receives the get request and sees that I have no visitor cookie set
3) The server returns me the web page with a "set cookie" instruction to my browser, chrome then sets a cookie for that domain with the value provided, say 1000 because I'm the 1000 visitor. Note that the server also wrote in the page that I'm the 1000 visitor.
4) If I then browse the website, my visitor cookie will automatically be passed along all requests I make to your server
5) If the server receives a request and sees that my visitor cookie is set, then they use that value to write on the page my visitor number.

You need to watch out though for people who disable cookies. Take the accuracy of this with a grain of salt, no one has a perfect system anyway. Now how does the server know which value to set the visitor cookie to? You need to persist that information, whether it's in a .txt file or with a database. Every time the server sets a cookie, it must increment that value.

For the downloads, you need a counter for every file that is downloadable. This would be easier with a database, because you can add new files eventually. In the database, have a record for every file with the download count for it. When you add a new file, create a record in the database with a counter of 0.

Every time your server receives a get for a file to download, then read the counter, return it and increment it. You can use MongoDB as a database, it's really fast and easy to use, especially with _javascript_.

-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : cartertemm via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : redfox via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : brian . kurosawa via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Reza . jdp via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Origine via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : oussamabengatrane via Audiogames-reflector

Reply via email to