Jump to content
php.lv forumi

Unikalie apmeklejumi


mukards

Recommended Posts

Varat iedot kodu

Gatavu kodu tev neviens nedos...

1. Shii tema ir apspriesta Ljoti daudz reizu

2. i-Nets pilns ar gataviem skriptiem

3. Noteikt vai apmeklejums ir pilnigi unikals Vispar nav iespejams jo:

IP 99,99% korporativo kompju ir vienada --> viena IP vairakiem kompjiem...

Kukijus ir iespejams izdzeest ...

-----

Nu ja vajag tikai diena tad der parbaude peec IP un atstaat kukiju ... daudzmaz precizi buus (ne 100%, bet uz to pusi ...)

Link to comment
Share on other sites

///////////////////////////////////////////////////////////

/*

CREATE TABLE `prefix_stat` (

`id` int(10) NOT NULL auto_increment,

`date` date NOT NULL,

`added` datetime NOT NULL,

`ip` varchar(128) NOT NULL,

`url` varchar(128) NOT NULL,

`url_r` varchar(128) NOT NULL,

`platform` varchar(128) NOT NULL,

`browser` varchar(128) NOT NULL,

`version` varchar(128) NOT NULL,

`times` int(5) NOT NULL,

PRIMARY KEY (`id`)

) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

 

*/

 

 

// function reads ip and other server variable

function get_info($get_ip = false)

{

$return['ip'] = $_SERVER["REMOTE_ADDR"];

$return['url'] = $_SERVER["REQUEST_URI"];

$return['url_r'] = isset($_SERVER["HTTP_REFERER"]) ? $_SERVER["HTTP_REFERER"] : '';

//require_once('browscap/php-local-browscap.php');

//$browser=get_browser_local(null, true);

$browser = get_browser(null, true);

//dmp($browser);

$return['platform'] = $browser['platform'];

$return['browser'] = $browser['browser'];

$return['version'] = $browser['version'];

return $return;

}

 

//////////////////////////////////////////////////////////////////

function module_statistic()

{

$u = get_info();

$thisUser = sql1("

SELECT id FROM #__stat WHERE

`date`=DATE(NOW()) AND `ip`='".$u['ip']."' AND `platform`='".$u['platform']."' AND `browser`='".$u['browser']."' AND `version`='".$u['version']."'

");

if($thisUser)

{

squp("

UPDATE #__stat SET `times`=`times`+1

WHERE

`date`=DATE(NOW()) AND `ip`='".$u['ip']."' AND `platform`='".$u['platform']."' AND `browser`='".$u['browser']."' AND `version`='".$u['version']."'

");

}

else

{

sqin("

INSERT INTO #__stat (`date`, `added`, `ip`, `url`, `url_r`, `platform`, `browser`, `version`, `times`)

VALUES (DATE(NOW()), NOW(), '".$u['ip']."', '".$u['url']."', '".$u['url_r']."', '".$u['platform']."', '".$u['browser']."', '".$u['version']."', '1')

");

}

list($total) = sql1("

SELECT COUNT(id) AS `all` FROM #__stat

");

list($today) = sql1("

SELECT COUNT(id) AS `all` FROM #__stat

WHERE `date`=DATE(NOW())

");

$return['total'] = $total;

$return['today'] = $today;

return $return;

 

}

 

 

 

 

$statisticDatas = module_statistic();

 

pieprasiijumus tikai jaaparraksta, jo es izmantoju vienu klasi. tad ieliec savaa index failaa un viss gatavs. ar goole analytics gandriiz viens vienaa sakriit.

Link to comment
Share on other sites

×
×
  • Create New...