2019-03-19 16:59:14

On people's webpages, I've seen stuff like, you are visitor number: 939393939, and, after a download link, downloaded: 123092414 times. How do I do this? Preferrably with javascript or css, php won't run for me

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2019-03-19 17:04:07

If you really want to... Personally I´d rather not give the spammers a good day. In your body, add PHP that opens a file, runs.txt, and reads the number contained there. Add 1 and write back.

echo("you are visitor number: "+$visiter_number);

2019-03-19 18:08:04

hmm, is there possibly a way to make it nto accept the same ip address that it has allready seen? Or is that a bit much?
I'm rather new to php and stuff, but I'l look at your suggestion to see if I can figure it out.

----------
“Yes, sir. I am attempting to fill a silent moment with non-relevant conversation.”
“You don’t tell me how to behave; you’re not my mother!”
“Could you please continue the petty bickering? I find it most intriguing.” – Data (Star Trek: The Next Generation)

2019-03-20 00:47:48

I haven't touched PHP for a long time. But I came to an idea of searching and comparing the IP before adding it. If no results were found, you go ahead. Otherwise you stop.

2019-03-22 03:31:27

Hi,
Just as a note:
You can't use Plus (+) for appending text in PHP. PHP behaves mathematically about it.
Dot (.) is the operator sign for appending text in PHP.

Co-founder of Sonorous Arts.
Check out Sonorous Arts on GitHub: https://github.com/sonorous-arts/

2019-03-22 05:02:40

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.

Reading is one form of escape. Running for your life is another. ― Lemony Snicket

2019-03-25 12:27:26

i righted an old php/ js skript for the counter visiters, but i'm not sure where s it any more, i'll search for it and i'll give it to you  if i founded, and  the cookies are only the way to    prevent  spamers  not to give   a large number of visits with just updating the page

And as anyone who's gone mountain climbing knows ,The serene snow-covered peaks that look so tranquil from a bdistance, Are the deadliest
sound is my vision
i rarely check my private messages on the forum, so if you want to contact me please use my email, or dm me  at oussama40121 on tw