FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Keep track of page-access
Show: Today's Messages :: Polls :: Message Navigator
Switch to threaded view of this topic Create a new topic Submit Reply
Keep track of page-access [message #172884] Fri, 11 March 2011 18:26 Go to next message
sl@exabyte is currently offline  sl@exabyte
Messages: 16
Registered: March 2011
Karma: 0
Junior Member
After some searching I intend to use AJAX and PHP to keep track of the
number of times an HTML file (just a single file) has been accessed.

Any comment ? Thanks.
Re: Keep track of page-access [message #172885 is a reply to message #172884] Fri, 11 March 2011 02:52 Go to previous messageGo to next message
spambait is currently offline  spambait
Messages: 35
Registered: September 2010
Karma: 0
Member
In article <ilc0t4$86l$1(at)news(dot)albasani(dot)net>, "sl@exabyte" <ecp_gen(at)my-rialto(dot)com> wrote:
> After some searching I intend to use AJAX and PHP to keep track of the
> number of times an HTML file (just a single file) has been accessed.
>
> Any comment ? Thanks.

Probably much easier to parse your server's access logs...
Re: Keep track of page-access [message #172887 is a reply to message #172884] Fri, 11 March 2011 04:17 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
sl@exabyte wrote:

> After some searching I intend to use AJAX and PHP to keep track of the
> number of times an HTML file (just a single file) has been accessed.

AJAX not necessary. Just use a bit of PHP in the file to do something
simple like update a database .. a counter.

Or as Doug says, look at your server logs.

--
-bts
-Four wheels carry the body; two wheels move the soul
Re: Keep track of page-access [message #172888 is a reply to message #172884] Fri, 11 March 2011 04:33 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 11/03/11 18:26, sl@exabyte wrote:
> After some searching I intend to use AJAX and PHP to keep track of the
> number of times an HTML file (just a single file) has been accessed.
>
> Any comment ? Thanks.

Use the server logs.

Or do you mean to keep track of people clicking on a link to another
website?

Rgds

Denis McMahon
Re: Keep track of page-access [message #172889 is a reply to message #172887] Fri, 11 March 2011 21:36 Go to previous messageGo to next message
sl@exabyte is currently offline  sl@exabyte
Messages: 16
Registered: March 2011
Karma: 0
Junior Member
Beauregard T. Shagnasty wrote:
> sl@exabyte wrote:
>
>> After some searching I intend to use AJAX and PHP to keep track of
>> the number of times an HTML file (just a single file) has been
>> accessed.
>
> AJAX not necessary. Just use a bit of PHP in the file to do something
> simple like update a database .. a counter.
>
> Or as Doug says, look at your server logs.

I suppose for PHP alone, the HTML file must end with ".php" extension.

For server logs alone, would it a problem if I need to keep the counter
over, say, a few years. I hope not to clear the log every month.
Re: Keep track of page-access [message #172890 is a reply to message #172888] Fri, 11 March 2011 21:37 Go to previous messageGo to next message
sl@exabyte is currently offline  sl@exabyte
Messages: 16
Registered: March 2011
Karma: 0
Junior Member
>
> Use the server logs.
>
> Or do you mean to keep track of people clicking on a link to another
> website?
>

I want to know, roughly, the number of times the HTML file is
accessed/opened.
Re: Keep track of page-access [message #172894 is a reply to message #172890] Fri, 11 March 2011 08:38 Go to previous messageGo to next message
Denis McMahon is currently offline  Denis McMahon
Messages: 634
Registered: September 2010
Karma: 0
Senior Member
On 11/03/11 21:37, sl@exabyte wrote:
>>
>> Use the server logs.
>>
>> Or do you mean to keep track of people clicking on a link to another
>> website?

> I want to know, roughly, the number of times the HTML file is
> accessed/opened.

If it is a file on your server, your server logs will record every
request for it, including requests that return status code 304.

What you could do is check the logs once a day, counting all accesses
date stamped for the previous day, and adding this figure to a running
total.

Rgds

Denis McMahon
Re: Keep track of page-access [message #172896 is a reply to message #172889] Fri, 11 March 2011 09:43 Go to previous messageGo to next message
Jo Schulze is currently offline  Jo Schulze
Messages: 15
Registered: January 2011
Karma: 0
Junior Member
sl@exabyte wrote:

> For server logs alone, would it a problem if I need to keep the
> counter over, say, a few years. I hope not to clear the log every
> month.

Usually, access logs are written by the webserver in a continious way
and are rotated (a new log started, the last one renamed and
compressed).
The idea is to regulary process the rotated logs to get the information
you want. Processing is a read only job, there is no "clear" in whatever
time interval. Yes, this can be done over years.

But it does not sound like you know much about the topic. I suggest you
collect some data:
1) Which webserver software is used on the machine (most likely Apache)
2) Where are the access logs?
3) How long is the rotation time interval?
Re: Keep track of page-access [message #172897 is a reply to message #172889] Fri, 11 March 2011 10:10 Go to previous messageGo to next message
Beauregard T. Shagnas is currently offline  Beauregard T. Shagnas
Messages: 154
Registered: September 2010
Karma: 0
Senior Member
sl@exabyte wrote:

> Beauregard T. Shagnasty wrote:
>> sl@exabyte wrote:
>>> After some searching I intend to use AJAX and PHP to keep track of
>>> the number of times an HTML file (just a single file) has been
>>> accessed.
>>
>> AJAX not necessary. Just use a bit of PHP in the file to do
>> something simple like update a database .. a counter.
>>
>> Or as Doug says, look at your server logs.
>
> I suppose for PHP alone, the HTML file must end with ".php"
> extension.

...and for PHP and AJAX, too. <g> No, it does not need to be a ".php"
file extension. You can direct your "filename.html" to be processed as
PHP, via a simple line in your .htaccess file. (Assuming an Apache
server)

> For server logs alone, would it a problem if I need to keep the
> counter over, say, a few years. I hope not to clear the log every
> month.

Answered by others...

But my choice would be a dozen lines of PHP and a MySQL database table.
For "just a counter" you could simply increment a number (field) in a
one-row table, or you could add and store a new row for each page hit,
including further information such as visitor's IP address, browser UA
string, etc.

--
-bts
-Four wheels carry the body; two wheels move the soul
Re: Keep track of page-access [message #172898 is a reply to message #172884] Fri, 11 March 2011 10:33 Go to previous messageGo to next message
alvaro.NOSPAMTHANX is currently offline  alvaro.NOSPAMTHANX
Messages: 277
Registered: September 2010
Karma: 0
Senior Member
El 11/03/2011 19:26, sl@exabyte escribió/wrote:
> After some searching I intend to use AJAX and PHP to keep track of the
> number of times an HTML file (just a single file) has been accessed.
>
> Any comment ? Thanks.

The client-side approach you suggest is nothing particularly rare (there
are many site stat services out there that use it, including Google
Analytics), although I'm not sure about why you plan to use AJAX (what
kind of updated information do you want to display in the page once it
has loaded?). However, the purpose of JavaScript-based tracking is
basically to collect information about your users (operating system,
desktop size, installed plug-ins...); for a simple counter it's just
overkill. A simple <img> to a PHP script that serves a 1x1 transparent
GIF can do the same and drops the requirement of using a JavaScript
enabled browser.

In any case, client-side tracking will only provide an approximation
since it'll be leaving apart many accesses: search engines and crawlers,
older phones and mobile devices, etc. Since you can already run PHP code
in your server, why don't you simply increment the counter when you
deliver the page, rather than waiting the browser to report back?

Possibilities:

- Add PHP to your HTML file and instruct the server to process it
through the PHP interpreter.
- Write a PHP script the delivers the HTML file.
- If using Apache, write a PHP script the delivers the HTML file and
hide it with a mod_rewrite redirection.

And last but not least, find the stats section at your hosting
provider's control panel.


--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
Re: Keep track of page-access [message #172900 is a reply to message #172884] Fri, 11 March 2011 12:49 Go to previous messageGo to next message
Jerry Stuckle is currently offline  Jerry Stuckle
Messages: 2598
Registered: September 2010
Karma: 0
Senior Member
On 3/11/2011 1:26 PM, sl@exabyte wrote:
> After some searching I intend to use AJAX and PHP to keep track of the
> number of times an HTML file (just a single file) has been accessed.
>
> Any comment ? Thanks.
>
>

Web server logs are easier and more reliable.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex(at)attglobal(dot)net
==================
Re: Keep track of page-access [message #172915 is a reply to message #172889] Fri, 11 March 2011 17:11 Go to previous messageGo to next message
Michael Fesser is currently offline  Michael Fesser
Messages: 215
Registered: September 2010
Karma: 0
Senior Member
.oO(sl@exabyte)

> For server logs alone, would it a problem if I need to keep the counter
> over, say, a few years. I hope not to clear the log every month.

Logfile analyzers like AWStats keep their stats as long as you want,
even if the raw logfiles are rotated regularly.

Micha
Re: Keep track of page-access [message #172930 is a reply to message #172897] Sat, 12 March 2011 22:16 Go to previous message
sl@exabyte is currently offline  sl@exabyte
Messages: 16
Registered: March 2011
Karma: 0
Junior Member
> But my choice would be a dozen lines of PHP and a MySQL database
> table. For "just a counter" you could simply increment a number
> (field) in a one-row table, or you could add and store a new row for
> each page hit, including further information such as visitor's IP
> address, browser UA string, etc.

Thanks folks.

I have a better idea now: server log or PHP, AJAX not necessary.
Re: Keep track of page-access [message #172943 is a reply to message #172930] Sat, 12 March 2011 18:36 Go to previous message
Twayne is currently offline  Twayne
Messages: 135
Registered: September 2010
Karma: 0
Senior Member
In news:ilf2n9$9fl$1(at)news(dot)albasani(dot)net,
sl@exabyte <ecp_gen(at)my-rialto(dot)com> typed:
::: But my choice would be a dozen lines of PHP and a MySQL
::: database table. For "just a counter" you could simply
::: increment a number (field) in a one-row table, or you
::: could add and store a new row for each page hit,
::: including further information such as visitor's IP
::: address, browser UA string, etc.
::
:: Thanks folks.
::
:: I have a better idea now: server log or PHP, AJAX not
:: necessary.

I've used PHP's simple counters and sessions to persist the data from page
to page and just increment the counter on each access. Works well IMO.

HTH,

Twayne`
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Ritual Abuse
Next Topic: Backslash before function name in PHP
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Sat Nov 30 23:09:07 GMT 2024

Total time taken to generate the page: 0.02583 seconds