Home
Home Page
Krossbrauzernoe alignment on the center (table height=100 %)
Lists a la MS Word
Features of links « upwards pages »
Tables and borders
We get rid from cellpadding and cellspacing
Optimum use MySQL
Competent job with files: exclusive blocking of files
How to learn{find out} the size of a file on any web - server
Regular expressions
Processing of lines in RNR
Creation of system of the account of visitings
Tracking a content on dynamic sites
CSS: advice{councils} and receptions, a part 2
CSS: advice{councils} and receptions, a part 1
Ten rules of a spelling of a safe code on PHP
About tags and metatags
Potential vulnerability of php-scripts
Removal{Distance} of a line from a file
The generator of passwords
Links
 

Creation of system of the account of visitings

You can have question, what for it is necessary? The services suggest more than ten Russian and huge set of foreign systems of statistics. So what for once again to strain, write and debug scripts, to create bases and, in general, to make any telodvizhenija when, having spent 10 minutes, we shall receive high-grade system of statistics which suggests us, simply, boundless quantity{amount} of the data on users of our site?


The reasons two. First, "external" system of statistics create an appreciable delay in loading page. Second, it is interesting to one to learn{find out} more about graphic system of the user, to another - about versions of a browser, and to the third - time lead{carried out} by the user on his  site. But, as it appears, one system gives inormaciju about the graphic system, the second - about time of visitings, the third - in general, does not give such inormacii, but most precisely counts quantity{amount} of visitors. What to do{make}? We with you on page also start to put one, two, and then and all five counters then, time of loading of the helpful information will make no more than 10 % from time of loading of a site. It will lead to to that the visitor will spit and will leave (the Internet big) or information on him will not get in systems of statistics. Here that we also come to comprehension of that the system is necessary the.


It gives what advantages? First, speed of loading. Figures of statistics can be deduced{removed} the text that will not detain loading, and processing of statistics will be the page that will not bring in additional delays on an establishment of communication{connection} with the removed server is made on the same server, as. Second, such system, initially, will correspond{meet} to our searches. We want - we shall take into account parameters of graphic system of users, we want - we shall consider, how much time has come for last 15 seconds Vasja Pupkin. Thirdly, as such system is an integral part of a site it will not be lost any hit!


Here I shall not be results concrete scripts because it will be very bulky, and it is not necessary, you, in fact, came to understand all it? I shall state only main principles.


For realization of similar system I used sludujuhhee the software:


Databases: mySQL

Script: PHP

Vebserver: Apache.


First we shall be defined{determined}, we want to take into account what parameters. For myself I think important to know, how much users have come on a site, how much is hit they have brought, what pages have visited and whence came also time of each hit.


It is possible to deduce{remove} from these data a lot of the statistical information. So this ascetic set of me quite arranges. Proceeding from this, I have created three tables in a database:


hits: Stores{Keeps} the detailed information on hits for the current day. Contains the following fields:

Name         The comment

host         An alphabetic domain name of the user

addr         IP the address of the user

referer         The link on which there has come the user

page         On what page of a site there has come the user

timest         Time of a hit.


hitsbypage: stores{keeps} inormaciju for all period on visitings pages of a site. Contains the following fields:

Name         The comment

page         Page

hits         Quantity{amount} it is hit

hosts         Quantity{amount} of hosts


referers: stores{keeps} the information on links on which come on a site. Contains the following fields:

Name         The comment

href         Actually, the link

hits         Quantity{amount} of visitings from this link


hitsbydate: stores{keeps} the information on hits and hosts on days. Contains the following fields:

Name         The comment

date         Date

hits         Quantity{amount} it is hit

hosts         Quantity{amount} of hosts


There is a question, whence to take all these data? Vebserver, at an establishment of a session establishes the certain variable environments which are accessible from scripts in language PHP. First of all us the following interest:

Variable         Value         

$REQUEST_URI         The address of required page         

$REMOTE_HOST         The domain of the user (if it is established)         

$REMOTE_ADDR         IP the address of the user         

$HTTP_REFERER         The link on which there has come the user (if those was, i.e. the user has not typed{collected} the address of a site in a browser or has chosen from the list of selected sites)         


Now we shall consider logic of job of the system. We check, whether value of a field $HTTP_REFERER new (does not contain in the table referers) is. If new it is added it  in the necessary table and we establish{install} quantity{amount} it is hit for him  in 1. If such link already was, that, simply, we increase quantity{amount} is hit.


Similarly we check the address of required page.


Further we check, whether there were hits today. If it is hit nebylo, means, began new day and this first visiting today. Hence, we delete all data from the table hits as to store{keep} the information in her unprofitably. Then we bring new date in the table hitsbydate and we establish{install} quantity{amount} it is hit also hosts for the given date in 1. If new day has not come{stepped} yet, that, having checked up, whether is IP the address unique for today, we increase fields hits and hosts in the table hitsbydate.


And, at last, we bring the information in the table hits.


That's all. All necessary information is stored{kept} in bases on the server and is accessible at any moment to carrying out of the further statistical analysis.