Page 1 of 1
hit counter
Posted: Mon Dec 14, 2015 1:22 pm
by Vegan
I was thinking that a simple hit counter would be one way to track various users
the classes are adblock users, users who are not using it and the worst, repeat offenders
so I suspect an array can handle the 3 cases
so now I need a mechanism to read the file, ideally the file is in docroot, so the filename may need to be massaged a bit
Code: Select all
$phile = fopen("survey.txt", "r") or die("error opening survey.txt")
inhaling the file into the array
so is this the right track for an array?
Re: hit counter
Posted: Mon Dec 14, 2015 1:41 pm
by requinix
You want a file? A database would be better for this. No worrying about concurrency and file locking.
Re: hit counter
Posted: Wed Dec 16, 2015 6:47 am
by Vegan
only 3 boxes to increment, can PHP lock a file for a write then release it fast?
Re: hit counter
Posted: Wed Dec 16, 2015 7:36 am
by Celauran
http://php.net/manual/en/function.flock.php
Doesn't make it the right tool for the job
Re: hit counter
Posted: Sat Dec 19, 2015 5:19 pm
by Vegan
Re: hit counter
Posted: Sat Dec 19, 2015 5:22 pm
by Celauran
As requinix already pointed out, a database makes much more sense here.
Re: hit counter
Posted: Sat Dec 19, 2015 6:00 pm
by Christopher
Vegan wrote:ideally the file is in docroot, so the filename may need to be massaged a bit
I agree that this is what databases are made for. Ideally files like this are not in a publicly accessible directory. If you insist on using a file (I know how you are), I'd recommend a file for each counter. See if you can find a Perl style counter script in PHP with file locking and retry.
Re: hit counter
Posted: Tue Dec 22, 2015 6:10 pm
by Vegan
I am sticking with NoSQL as I do not feel like spending cash speculatively
Amazon has some new ads, all JS based so I am stuffing them into a bunch of PHP #includes
i am testing some on the home page, and on a few others, to see if I can make a few more pesos
Re: hit counter
Posted: Wed Dec 23, 2015 10:57 am
by Christopher
Vegan wrote:I am sticking with NoSQL as I do not feel like spending cash speculatively
Just to clarify for anyone else reading:
1. You are not actually using a NoSQL solution -- which are key based record stores that use a server just like SQL databases' do. You are using a file based solution. And as mentioned above, there are even file based SQL solutions like SQLite.
2. Databases come standard with almost all kinds of hosting at no extra cost .. so there is no speculation involved.
Vegan wrote:Amazon has some new ads, all JS based so I am stuffing them into a bunch of PHP #includes
Well ... that's a solution ...
Vegan wrote:i am testing some on the home page, and on a few others, to see if I can make a few more pesos
Excellent!
Re: hit counter
Posted: Thu Dec 24, 2015 12:05 pm
by Vegan
Given the capabilities with PHP are rather extensive, all I can do is work on ideas and try to find solutions.
I was thinking the PHP SWITCH and some string massaging would be as good as any.
GPU ads are on my site in many places, but now that i have more regions to serve, I can use PHP switch for some ads that apply to other locales
Re: hit counter
Posted: Fri Dec 25, 2015 7:47 pm
by Christopher
Vegan wrote:Given the capabilities with PHP are rather extensive, all I can do is work on ideas and try to find solutions.
I couldn't have said it better or worse ...
Vegan wrote:I was thinking the PHP SWITCH and some string massaging would be as good as any.
We discussed using some simple convention using locales to select ads -- rather than a switch(). There almost always a data driven approach that is superior to using switch().
Vegan wrote:GPU ads are on my site in many places, but now that i have more regions to serve, I can use PHP switch for some ads that apply to other locales
Congrats on having more regions!
Re: hit counter
Posted: Sun Dec 27, 2015 7:46 am
by Vegan
One of the problems I face, Amazon makes it harder than need be to serve the global market
This forces me to consider strategies galore. This way I have a clearer understanding of solutions for the problem.
one problem, amazons ad widget does not work past 4 wide which is fine for postage stamp web sites, my site is designed for widescreen users
https://hardcore-games.azurewebsites.net/wp/hw/psu.php is an example of the maximum width and even the JS function for custom width does not help
I would have been happier with 8 wide so I could work on a new footer
excel and php both like csv type containers, which is fine if i want to use excel to make a pie chart