The analysis and display of dens

I want to be praised by "creativity" again. In December I have described, how it is the easiest to collect broad gullies. Now I shall show, as they can be analyzed.

What there was in the table? Date, the address from a root of a virtual host ($php_self), a browser, referer, an ip-address of the user and the host name. The line was inserted so:



@mysql_query (" insert into logs (date, ip, host, address, referer, browser) values (now (), ' $remote_addr ',' ". gethostbyaddr ($remote_addr). " '', $php_self ',' $http_referer ',' $http_user_agent ') ");


And what we want to see in statistics? We shall simply see different variants: visitings on days, distribution of visitings on time of day. Then the same two samples, only not for all dens, and for the main page. Distribution on days of week, attendance for last weeks and months. Quantity{amount} of the visitors who have come from other sites. It happens to see interestingly, how much visitors came from the certain link in different days. Distribution on time for the certain day (week, month). Addresses where leave from such page.


To systematize it not so it is difficult, as it seems. All vysheopisanoe is stacked in eight variants of a grouping of the table. The address, referer, a browser (alas, comparison of lines "http_user_agent", including both versions, and OS here turns out, instead of separate browsers. Here on an input{entrance} to not do without processing), day, week, month, day of week, hour.


On statistics on the countries, cities and as routes of users we do not raise - additional processing too is necessary.


Let's add to a choice of a grouping a choice of restriction on days (the last n days) and as conditions of sample for a field where which can be entered into a text field, and we shall receive system in which it is stacked those samples and distributions which I have described.


Actually, not so simply appeared to make the list vyborok and to lead it  to convenient for processing in the program to a kind. Eventually, I have taken and have pushed all searches in a file which element looks so:



$selection [0] = array (

  "name" => " the schedule on days ",

  "select" => array (" date_format (date, ' %e. % m. % y ') as dday ", " count (date) as visits "),

  "group" => array ("dday"),

  "order" => array (" date desc "),

  "type" => 1

);


The element "name" is a name for krutilki, "type" - type of the table. Types of tables two - simply the list and the list with "columns". If the list is sorted by quantity{amount} of visitings columns basically are not necessary, and for convenience of perception{recognition}, for example, the schedule of visitings on days, the schedule is desirable. It is possible to not make comments on other elements.


In search are taken into account as both time restrictions, and a condition which was entered by the user. A variable $type - number{room} of required sample.



$days = intval ($days);

if ($days> 0)

  $selection [$type] ["where"] [] = " date> date_sub (now (), interval $days day) ";


$where = stripslashes (trim ($where));

if (strlen ($where)> 0)

  $selection [$type] ["where"] [] = "($where)";


After that the form is drawn (in krutilkakh by the first lines the chosen values are deduced. Then the search by which the total of lines is learned{found out} is under construction. It, it is necessary to recognize, the slippery place because in him of any simplifications, it is simple as against the basic search, here simply is absent sorting. But the quantity{amount} of lines is learned{found out} " in a forehead " - all same gets out and is then done{made} mysql_num_rows. If who will have ideas, can send me or publish the analyzer (only the link to me put, please).



$amount_request = "select." implode (",", $selection [$type] ["select"]). " from logs ";

if (sizeof ($selection [$type] ["where"])> 0)

  $amount_request. = "where." implode ("and", $selection [$type] ["where"]);

$amount_request. = " group by ". implode (",", $selection [$type] ["group"]);


$request = "select." implode (",", $selection [$type] ["select"]). " from logs ";

if (sizeof ($selection [$type] ["where"])> 0)

$request. = "where." implode ("and", $selection [$type] ["where"]);

$request. = " group by ". implode (",", $selection [$type] ["group"]). " order by ". implode (",", $selection [$type] ["order"]). " ". get_limit ($page, $amount, $in_page);


As you can see, I use the module of a paginal conclusion of searches described in the previous{last} release (get_limit).


But it is not enough to give unlimited opportunities of construction of searches., we admit{allow}, I look at statistics refererov on popularity and I want to see, as people went to me with hackzone.ru [http://www.hackzone.ru/hack/]. What to do{make}? To choose the necessary parameters krutilok and to write in a text field " referer like ' %hackzone % ' " well simply vlom!


It appears, it too is simple for making. Two hours of cogitative efforts and editing of the text, also has left a certain similarity of an opportunity of detailed elaboration of sample. I press " the list refererov " in bookmarks (in bookmarks because in the address the parameter " referer not like ' http: // detail.phpclub.net % ' " is passed), I receive the table, in her in line "hackzone.ru" I press on the link and it, distribution zashedshikh from this site on days. It is possible to press other link and to receive distribution on time of day - somehow.


What else to do{make} samples - depends on your imagination. If written does not suffice, it is possible to add the. I promise in process of forces to update and improve the program.


Basically, having broad gullies at itself by office or domestic machine, it is possible to do{make} with them everything, that it is necessary for soul. It is necessary to write only obrabotchik. Delov!:) On spylog [http://www.spylog.ru/] I do not apply. At least, for myself I have written such thing which allows to do{make} much of that, everything to soul. And, by the way, to not load the superfluous information and advertising Spajlog-informera and other.