|
|
|
|
@ -94,7 +94,6 @@ $TABLESTATS_REFERERS = $_configuration['statistics_database']."`.`track_c_ref |
|
|
|
|
*/ |
|
|
|
|
function decodeOpenInfos() { |
|
|
|
|
global $TABLETRACK_OPEN; |
|
|
|
|
|
|
|
|
|
// record initial value of ignore_user_abort |
|
|
|
|
$ignore = ignore_user_abort(); |
|
|
|
|
// prevent script from being stopped while executing, the following can be considered |
|
|
|
|
@ -129,8 +128,7 @@ function decodeOpenInfos() { |
|
|
|
|
// load list of countries |
|
|
|
|
$list_countries = loadCountries(); |
|
|
|
|
|
|
|
|
|
while ($row = Database::fetch_row ($query) ) |
|
|
|
|
{ |
|
|
|
|
while ($row = Database::fetch_row ($query)) { |
|
|
|
|
$remote_host = $row[0]; |
|
|
|
|
/*****Provider*****/ |
|
|
|
|
//extract provider |
|
|
|
|
@ -143,31 +141,25 @@ function decodeOpenInfos() { |
|
|
|
|
$country = extractCountry( $remote_host, $list_countries ); |
|
|
|
|
// increment country in the countries table |
|
|
|
|
$countries_array = addCountry( $country, $countries_array ); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
// update tables |
|
|
|
|
fillProvidersTable( $providers_array ); |
|
|
|
|
fillCountriesTable( $countries_array ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// provider and countries done |
|
|
|
|
|
|
|
|
|
//--Browsers and OS---------------------------------------------------// |
|
|
|
|
|
|
|
|
|
$sql = "SELECT open_agent |
|
|
|
|
FROM `$TABLETRACK_OPEN` |
|
|
|
|
WHERE open_remote_host != '' |
|
|
|
|
AND open_id <= '".$processBegin."' "; |
|
|
|
|
$query =Database::query( $sql ); |
|
|
|
|
if(Database::num_rows($query) != 0){ |
|
|
|
|
if(Database::num_rows($query) != 0) { |
|
|
|
|
// load lists |
|
|
|
|
// of browsers |
|
|
|
|
$list_browsers = loadBrowsers(); |
|
|
|
|
// of OS |
|
|
|
|
$list_os = loadOs(); |
|
|
|
|
|
|
|
|
|
while ($row = Database::fetch_row ($query)) |
|
|
|
|
{ |
|
|
|
|
while ($row = Database::fetch_row ($query)) { |
|
|
|
|
$agent = $row[0]; |
|
|
|
|
/*****Browser and OS*****/ |
|
|
|
|
// extract browser and OS |
|
|
|
|
@ -176,7 +168,6 @@ function decodeOpenInfos() { |
|
|
|
|
$browsers_array = addBrowser( $browser , $browsers_array ); |
|
|
|
|
$os_array = addOs( $os , $os_array ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
fillBrowsersTable( $browsers_array ); |
|
|
|
|
fillOsTable( $os_array ); |
|
|
|
|
} |
|
|
|
|
@ -191,29 +182,21 @@ function decodeOpenInfos() { |
|
|
|
|
$query = Database::query( $sql ); |
|
|
|
|
|
|
|
|
|
if(Database::num_rows($query) != 0) { |
|
|
|
|
|
|
|
|
|
$i=0; |
|
|
|
|
while ($row = Database::fetch_row ($query)) |
|
|
|
|
{ |
|
|
|
|
while ($row = Database::fetch_row ($query)) { |
|
|
|
|
$ref = $row[0]; |
|
|
|
|
$referers_array = addReferer( $ref , $referers_array ); |
|
|
|
|
} |
|
|
|
|
fillReferersTable( $referers_array ); |
|
|
|
|
} |
|
|
|
|
// referers done |
|
|
|
|
|
|
|
|
|
//-------------------------------------------------------------------// |
|
|
|
|
|
|
|
|
|
// end of process |
|
|
|
|
// cleaning of $TABLETRACK_OPEN table |
|
|
|
|
cleanProcessedRecords($processBegin); |
|
|
|
|
|
|
|
|
|
// reset to the initial value |
|
|
|
|
ignore_user_abort($ignore); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************** |
|
|
|
|
* |
|
|
|
|
* Utils |
|
|
|
|
@ -236,15 +219,9 @@ function cleanProcessedRecords( $limit ) { |
|
|
|
|
open_agent = '', |
|
|
|
|
open_referer ='' |
|
|
|
|
WHERE open_id <= '".$limit."'"; |
|
|
|
|
|
|
|
|
|
$query = Database::query( $sql ); |
|
|
|
|
|
|
|
|
|
Database::query("OPTIMIZE TABLE $TABLETRACK_OPEN"); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************** |
|
|
|
|
* |
|
|
|
|
* Provider |
|
|
|
|
@ -260,10 +237,8 @@ function cleanProcessedRecords( $limit ) { |
|
|
|
|
table |
|
|
|
|
*/ |
|
|
|
|
function extractProvider($remhost) { |
|
|
|
|
|
|
|
|
|
if($remhost == "Unknown") |
|
|
|
|
return $remhost; |
|
|
|
|
|
|
|
|
|
$explodedRemhost = explode(".", $remhost); |
|
|
|
|
$provider = $explodedRemhost[sizeof( $explodedRemhost )-2] |
|
|
|
|
."." |
|
|
|
|
@ -272,7 +247,6 @@ function extractProvider($remhost) { |
|
|
|
|
if($provider == "co.uk" || $provider == "co.jp") |
|
|
|
|
return $explodedRemhost[sizeof( $explodedRemhost )-3].$provider; |
|
|
|
|
else return $provider; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -287,13 +261,10 @@ function extractProvider($remhost) { |
|
|
|
|
- if the provider doesn't exist it will be added and set to 1 |
|
|
|
|
*/ |
|
|
|
|
function addProvider($provider,$providers_array) { |
|
|
|
|
if( isset( $providers_array[$provider] ) ) |
|
|
|
|
{ |
|
|
|
|
if(isset($providers_array[$provider])) { |
|
|
|
|
// add one unity to this provider occurrences |
|
|
|
|
$providers_array[$provider] = $providers_array[$provider] + 1; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// first occurrence of this provider |
|
|
|
|
$providers_array[$provider] = 1; |
|
|
|
|
} |
|
|
|
|
@ -309,25 +280,20 @@ function addProvider($provider,$providers_array) { |
|
|
|
|
function fillProvidersTable($providers_array) { |
|
|
|
|
global $TABLESTATS_PROVIDERS; |
|
|
|
|
|
|
|
|
|
if(is_array($providers_array)) |
|
|
|
|
{ |
|
|
|
|
foreach ( $providers_array as $prov=>$number ) |
|
|
|
|
{ |
|
|
|
|
if(is_array($providers_array)) { |
|
|
|
|
foreach ( $providers_array as $prov=>$number ) { |
|
|
|
|
$sql = "SELECT counter |
|
|
|
|
FROM `".$TABLESTATS_PROVIDERS."` |
|
|
|
|
WHERE `provider` = '".$prov."'"; |
|
|
|
|
$res = Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
|
|
|
|
|
// if this provider already exists in the DB |
|
|
|
|
if( $row = Database::num_rows($res) ) |
|
|
|
|
{ |
|
|
|
|
if($row = Database::num_rows($res)) { |
|
|
|
|
// update |
|
|
|
|
$sql2 = "UPDATE `".$TABLESTATS_PROVIDERS."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `provider` = '".$prov."'"; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// insert |
|
|
|
|
$sql2 = "INSERT INTO `".$TABLESTATS_PROVIDERS."` |
|
|
|
|
(`provider`,`counter`) |
|
|
|
|
@ -351,8 +317,7 @@ function fillProvidersTable($providers_array) { |
|
|
|
|
* @desc This function is used to build an array containing |
|
|
|
|
countries informations |
|
|
|
|
*/ |
|
|
|
|
function loadCountries() |
|
|
|
|
{ |
|
|
|
|
function loadCountries() { |
|
|
|
|
global $TABLESTATS_COUNTRIES; |
|
|
|
|
$sql = "SELECT code, country |
|
|
|
|
FROM `".$TABLESTATS_COUNTRIES."`"; |
|
|
|
|
@ -368,8 +333,6 @@ function loadCountries() |
|
|
|
|
mysql_free_result($res); |
|
|
|
|
return $list_countries; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
* @author Sebastien Piraux <piraux_seb@hotmail.com> |
|
|
|
|
@ -379,22 +342,17 @@ function loadCountries() |
|
|
|
|
* @desc this function will extract the country from a given remote |
|
|
|
|
host and increment the good value in the corresponding table |
|
|
|
|
*/ |
|
|
|
|
function extractCountry($remhost,$list_countries) |
|
|
|
|
{ |
|
|
|
|
function extractCountry($remhost,$list_countries) { |
|
|
|
|
if($remhost == "Unknown") |
|
|
|
|
return $remhost; |
|
|
|
|
// country code is the last value of remote host |
|
|
|
|
$explodedRemhost = explode(".",$remhost); |
|
|
|
|
$countryCode = $explodedRemhost[sizeof( $explodedRemhost )-1]; |
|
|
|
|
|
|
|
|
|
for($i = 0 ; $i < sizeof( $list_countries );$i++) |
|
|
|
|
{ |
|
|
|
|
for($i = 0 ; $i < sizeof( $list_countries );$i++) { |
|
|
|
|
if($list_countries[$i][0] == $countryCode) |
|
|
|
|
return $list_countries[$i][1]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
* @author Sebastien Piraux <piraux_seb@hotmail.com> |
|
|
|
|
@ -404,48 +362,34 @@ function extractCountry($remhost,$list_countries) |
|
|
|
|
* @desc this function will increment number of occurrence |
|
|
|
|
for $country in the countries' tables |
|
|
|
|
*/ |
|
|
|
|
function addCountry($country,$countries_array) |
|
|
|
|
{ |
|
|
|
|
if( isset( $countries_array[$country] ) ) |
|
|
|
|
{ |
|
|
|
|
function addCountry($country,$countries_array) { |
|
|
|
|
if(isset($countries_array[$country])) { |
|
|
|
|
// add one unity to this provider occurrences |
|
|
|
|
$countries_array[$country] = $countries_array[$country] + 1; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// first occurrence of this provider |
|
|
|
|
$countries_array[$country] = 1; |
|
|
|
|
} |
|
|
|
|
return $countries_array; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
* @author Sebastien Piraux <piraux_seb@hotmail.com> |
|
|
|
|
* @param countries_array : list of countries and their counter |
|
|
|
|
* @desc update the countries'table with new values |
|
|
|
|
*/ |
|
|
|
|
function fillCountriesTable($countries_array) |
|
|
|
|
{ |
|
|
|
|
function fillCountriesTable($countries_array) { |
|
|
|
|
global $TABLESTATS_COUNTRIES; |
|
|
|
|
if(is_array($countries_array) ) |
|
|
|
|
{ |
|
|
|
|
foreach ( $countries_array as $country=>$number ) |
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
if(is_array($countries_array)) { |
|
|
|
|
foreach ( $countries_array as $country=>$number ) { |
|
|
|
|
// update |
|
|
|
|
$sql = "UPDATE `".$TABLESTATS_COUNTRIES."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `country` = '".$country."'"; |
|
|
|
|
|
|
|
|
|
Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*************************************************************************** |
|
|
|
|
* |
|
|
|
|
* Agent : Browser and OS |
|
|
|
|
@ -458,8 +402,7 @@ function fillCountriesTable($countries_array) |
|
|
|
|
* @desc This function is used to build an array containing |
|
|
|
|
browser informations |
|
|
|
|
*/ |
|
|
|
|
function loadBrowsers() |
|
|
|
|
{ |
|
|
|
|
function loadBrowsers() { |
|
|
|
|
|
|
|
|
|
$buffer = split ("#","Gecko|Gecko#Mozilla/3|Mozilla 3.x#Mozilla/4.0|Mozilla 4.0x#Mozilla/4.5|Mozilla 4.5x#Mozilla/4.6|Mozilla 4.6x#Mozilla/4.7|Mozilla 4.7x#Mozilla/5.0|Mozilla 5.0x#MSIE 1.2|MSIE 1.2#MSIE 3.01|MSIE 3.x#MSIE 3.02|MSIE 3.x#MSIE 4.0|MSIE 4.x#MSIE 4.01|MSIE 4.x#MSIE 4.5|MSIE 4.5#MSIE 5.0b1|MSIE 5.0x#MSIE 5.0b2|MSIE 5.0x#MSIE 5.0|MSIE 5.0x#MSIE 5.01|MSIE 5.0x#MSIE 5.1|MSIE 5.1#MSIE 5.1b1|MSIE 5.1#MSIE 5.5|MSIE 5.5#MSIE 5.5b1|MSIE 5.5#MSIE 5.5b2|MSIE 5.5#MSIE 6.0|MSIE 6#MSIE 6.0b|MSIE 6#MSIE 6.5a|MSIE 6.5#Lynx/2.8.0|Lynx 2#Lynx/2.8.1|Lynx 2#Lynx/2.8.2|Lynx 2#Lynx/2.8.3|Lynx 2#Lynx/2.8.4|Lynx 2#Lynx/2.8.5|Lynx 2#HTTrack 3.0x|HTTrack#OmniWeb/4.0.1|OmniWeb#Opera 3.60|Opera 3.60#Opera 4.0|Opera 4#Opera 4.01|Opera 4#Opera 4.02|Opera 4#Opera 5|Opera 5#Opera/3.60|Opera 3.60#Opera/4|Opera 4#Opera/5|Opera 5#Opera/6|Opera 6#Opera 6|Opera 6#Netscape6|NS 6#Netscape/6|NS 6#Netscape7|NS 7#Netscape/7|NS 7#Konqueror/2.0|Konqueror 2#Konqueror/2.0.1|Konqueror 2#Konqueror/2.1|Konqueror 2#Konqueror/2.1.1|Konqueror 2#Konqueror/2.1.2|Konqueror 2#Konqueror/2.2|Konqueror 2#Teleport Pro|Teleport Pro#WebStripper|WebStripper#WebZIP|WebZIP#Netcraft Web|NetCraft#Googlebot|Googlebot#WebCrawler|WebCrawler#InternetSeer|InternetSeer#ia_archiver|ia archiver"); |
|
|
|
|
|
|
|
|
|
@ -480,8 +423,7 @@ function loadBrowsers() |
|
|
|
|
* @desc This function is used to build an array containing |
|
|
|
|
OS informations |
|
|
|
|
*/ |
|
|
|
|
function loadOs() |
|
|
|
|
{ |
|
|
|
|
function loadOs() { |
|
|
|
|
$buffer = split ("#","Windows 95|Win 95#Windows_95|Win 95#Windows 98|Win 98#Windows NT|Win NT#Windows NT 5.0|Win 2000#Windows NT 5.1|Win XP#Windows 2000|Win 2000#Windows XP|Win XP#Windows ME|Win Me#Win95|Win 95#Win98|Win 98#WinNT|Win NT#linux-2.2|Linux 2#Linux|Linux#Linux 2|Linux 2#Macintosh|Mac#Mac_PPC|Mac#Mac_PowerPC|Mac#SunOS 5|SunOS 5#SunOS 6|SunOS 6#FreeBSD|FreeBSD#beOS|beOS#InternetSeer|InternetSeer#Googlebot|Googlebot#Teleport Pro|Teleport Pro"); |
|
|
|
|
$i=0; |
|
|
|
|
foreach( $buffer as $buffer1 ) { |
|
|
|
|
@ -491,7 +433,6 @@ function loadOs() |
|
|
|
|
return $list_os; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
* @author Sebastien Piraux <piraux_seb@hotmail.com> |
|
|
|
|
* @param remhost : must be $_SERVER['HTTP_USER_AGENT'] |
|
|
|
|
* @param list_browsers : browsers list :x |
|
|
|
|
@ -501,29 +442,24 @@ function loadOs() |
|
|
|
|
* @desc this function will extract browser and OS from |
|
|
|
|
$_SERVER['HTTP_USER_AGENT'] |
|
|
|
|
*/ |
|
|
|
|
function extractAgent( $user_agent, $list_browsers, $list_os ) |
|
|
|
|
{ |
|
|
|
|
function extractAgent( $user_agent, $list_browsers, $list_os ) { |
|
|
|
|
// default values, if nothing corresponding found |
|
|
|
|
$viewable_browser = "Unknown"; |
|
|
|
|
$viewable_os = "Unknown"; |
|
|
|
|
|
|
|
|
|
// search for corresponding pattern in $_SERVER['HTTP_USER_AGENT'] |
|
|
|
|
// for browser |
|
|
|
|
for($i = 0; $i < count( $list_browsers ); $i++) |
|
|
|
|
{ |
|
|
|
|
for($i = 0; $i < count( $list_browsers ); $i++) { |
|
|
|
|
$pos = strpos( $user_agent, $list_browsers[$i][0] ); |
|
|
|
|
if( $pos !== false ) |
|
|
|
|
{ |
|
|
|
|
if( $pos !== false ) { |
|
|
|
|
$viewable_browser = $list_browsers[$i][1]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// for os |
|
|
|
|
for($i = 0; $i < count($list_os); $i++) |
|
|
|
|
{ |
|
|
|
|
for($i = 0; $i < count($list_os); $i++) { |
|
|
|
|
$pos = strpos( $user_agent, $list_os[$i][0] ); |
|
|
|
|
if( $pos !== false ) |
|
|
|
|
{ |
|
|
|
|
if( $pos !== false ) { |
|
|
|
|
$viewable_os = $list_os[$i][1]; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@ -541,20 +477,15 @@ function extractAgent( $user_agent, $list_browsers, $list_os ) |
|
|
|
|
the corresponding value |
|
|
|
|
- if the browser doesn't exist it will be added and set to 1 |
|
|
|
|
*/ |
|
|
|
|
function addBrowser($browser,$browsers_array) |
|
|
|
|
{ |
|
|
|
|
if( isset( $browsers_array[$browser] ) ) |
|
|
|
|
{ |
|
|
|
|
function addBrowser($browser,$browsers_array) { |
|
|
|
|
if(isset( $browsers_array[$browser])) { |
|
|
|
|
// add one unity to this provider occurrences |
|
|
|
|
$browsers_array[$browser] = $browsers_array[$browser] + 1; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// first occurrence of this provider |
|
|
|
|
$browsers_array[$browser] = 1; |
|
|
|
|
} |
|
|
|
|
return $browsers_array; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -567,20 +498,15 @@ function addBrowser($browser,$browsers_array) |
|
|
|
|
the corresponding value |
|
|
|
|
- if the os doesn't exist it will be added and set to 1 |
|
|
|
|
*/ |
|
|
|
|
function addOs($os,$os_array) |
|
|
|
|
{ |
|
|
|
|
if( isset( $os_array[$os] ) ) |
|
|
|
|
{ |
|
|
|
|
function addOs($os,$os_array) { |
|
|
|
|
if(isset($os_array[$os])) { |
|
|
|
|
// add one unity to this provider occurrences |
|
|
|
|
$os_array[$os] = $os_array[$os] + 1; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// first occurrence of this provider |
|
|
|
|
$os_array[$os] = 1; |
|
|
|
|
} |
|
|
|
|
return $os_array; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
@ -589,35 +515,29 @@ function addOs($os,$os_array) |
|
|
|
|
* @param browsers_array : list of browsers and their counter |
|
|
|
|
* @desc update the browsers'table with new values |
|
|
|
|
*/ |
|
|
|
|
function fillBrowsersTable($browsers_array) |
|
|
|
|
{ |
|
|
|
|
function fillBrowsersTable($browsers_array) { |
|
|
|
|
global $TABLESTATS_BROWSERS; |
|
|
|
|
if ( is_array($browsers_array ) ) |
|
|
|
|
{ |
|
|
|
|
foreach ( $browsers_array as $browser=>$number ) |
|
|
|
|
{ |
|
|
|
|
$sql = "SELECT counter |
|
|
|
|
FROM `".$TABLESTATS_BROWSERS."` |
|
|
|
|
WHERE `browser` = '".$browser."'"; |
|
|
|
|
$res = Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
|
|
|
|
|
// if this provider already exists in the DB |
|
|
|
|
if( $row = Database::num_rows($res) ) |
|
|
|
|
{ |
|
|
|
|
// update |
|
|
|
|
$sql2 = "UPDATE `".$TABLESTATS_BROWSERS."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `browser` = '".$browser."'"; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// insert |
|
|
|
|
$sql2 = "INSERT INTO `".$TABLESTATS_BROWSERS."` |
|
|
|
|
(`browser`,`counter`) |
|
|
|
|
VALUES ('".$browser."','".$number."')"; |
|
|
|
|
if (is_array($browsers_array)) { |
|
|
|
|
foreach ( $browsers_array as $browser=>$number ) { |
|
|
|
|
$sql = "SELECT counter |
|
|
|
|
FROM `".$TABLESTATS_BROWSERS."` |
|
|
|
|
WHERE `browser` = '".$browser."'"; |
|
|
|
|
$res = Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
|
|
|
|
|
// if this provider already exists in the DB |
|
|
|
|
if($row = Database::num_rows($res)) { |
|
|
|
|
// update |
|
|
|
|
$sql2 = "UPDATE `".$TABLESTATS_BROWSERS."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `browser` = '".$browser."'"; |
|
|
|
|
} else { |
|
|
|
|
// insert |
|
|
|
|
$sql2 = "INSERT INTO `".$TABLESTATS_BROWSERS."` |
|
|
|
|
(`browser`,`counter`) |
|
|
|
|
VALUES ('".$browser."','".$number."')"; |
|
|
|
|
} |
|
|
|
|
Database::query($sql2,__FILE__, __LINE__); |
|
|
|
|
} |
|
|
|
|
Database::query($sql2,__FILE__, __LINE__); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -627,35 +547,29 @@ function fillBrowsersTable($browsers_array) |
|
|
|
|
* @param os_array : list of os and their counter |
|
|
|
|
* @desc update the os'table with new values |
|
|
|
|
*/ |
|
|
|
|
function fillOsTable($os_array) |
|
|
|
|
{ |
|
|
|
|
function fillOsTable($os_array) { |
|
|
|
|
global $TABLESTATS_OS; |
|
|
|
|
if ( is_array($os_array) ) |
|
|
|
|
{ |
|
|
|
|
foreach ( $os_array as $os=>$number ) |
|
|
|
|
{ |
|
|
|
|
$sql = "SELECT counter |
|
|
|
|
FROM `".$TABLESTATS_OS."` |
|
|
|
|
WHERE `os` = '".$os."'"; |
|
|
|
|
$res = Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
|
|
|
|
|
// if this provider already exists in the DB |
|
|
|
|
if( $row = Database::num_rows($res) ) |
|
|
|
|
{ |
|
|
|
|
// update |
|
|
|
|
$sql2 = "UPDATE `".$TABLESTATS_OS."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `os` = '".$os."'"; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
// insert |
|
|
|
|
$sql2 = "INSERT INTO `".$TABLESTATS_OS."` |
|
|
|
|
(`os`,`counter`) |
|
|
|
|
VALUES ('".$os."','".$number."')"; |
|
|
|
|
if (is_array($os_array)) { |
|
|
|
|
foreach ($os_array as $os=>$number) { |
|
|
|
|
$sql = "SELECT counter |
|
|
|
|
FROM `".$TABLESTATS_OS."` |
|
|
|
|
WHERE `os` = '".$os."'"; |
|
|
|
|
$res = Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
|
|
|
|
|
// if this provider already exists in the DB |
|
|
|
|
if($row = Database::num_rows($res)) { |
|
|
|
|
// update |
|
|
|
|
$sql2 = "UPDATE `".$TABLESTATS_OS."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `os` = '".$os."'"; |
|
|
|
|
} else { |
|
|
|
|
// insert |
|
|
|
|
$sql2 = "INSERT INTO `".$TABLESTATS_OS."` |
|
|
|
|
(`os`,`counter`) |
|
|
|
|
VALUES ('".$os."','".$number."')"; |
|
|
|
|
} |
|
|
|
|
Database::query($sql2,__FILE__, __LINE__); |
|
|
|
|
} |
|
|
|
|
Database::query($sql2,__FILE__, __LINE__); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -664,8 +578,6 @@ function fillOsTable($os_array) |
|
|
|
|
* Referers |
|
|
|
|
* |
|
|
|
|
***************************************************************************/ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
* @author Sebastien Piraux <piraux_seb@hotmail.com> |
|
|
|
|
@ -676,51 +588,38 @@ function fillOsTable($os_array) |
|
|
|
|
the corresponding value |
|
|
|
|
- if the referer doesn't exist it will be added and set to 1 |
|
|
|
|
*/ |
|
|
|
|
function addReferer($referer,$referers_array) |
|
|
|
|
{ |
|
|
|
|
if( isset( $referers_array[$referer] ) ) |
|
|
|
|
{ |
|
|
|
|
function addReferer($referer,$referers_array) { |
|
|
|
|
if(isset($referers_array[$referer])) { |
|
|
|
|
// add one unity to this provider occurrences |
|
|
|
|
$referers_array[$referer] = $referers_array[$referer] + 1; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// first occurrence of this provider |
|
|
|
|
$referers_array[$referer] = 1; |
|
|
|
|
} |
|
|
|
|
return $referers_array; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
|
|
* @author Sebastien Piraux <piraux_seb@hotmail.com> |
|
|
|
|
* @param referers_array : list of referers and their counter |
|
|
|
|
* @desc update the referers'table with new values |
|
|
|
|
*/ |
|
|
|
|
function fillReferersTable($referers_array) |
|
|
|
|
{ |
|
|
|
|
function fillReferersTable($referers_array) { |
|
|
|
|
global $TABLESTATS_REFERERS; |
|
|
|
|
if (is_array($referers_array) ) |
|
|
|
|
{ |
|
|
|
|
foreach ( $referers_array as $referer=>$number ) |
|
|
|
|
{ |
|
|
|
|
if (is_array($referers_array)) { |
|
|
|
|
foreach ( $referers_array as $referer=>$number ) { |
|
|
|
|
$sql = "SELECT counter |
|
|
|
|
FROM `".$TABLESTATS_REFERERS."` |
|
|
|
|
WHERE `referer` = '".$referer."'"; |
|
|
|
|
$res = Database::query($sql,__FILE__, __LINE__); |
|
|
|
|
|
|
|
|
|
// if this provider already exists in the DB |
|
|
|
|
if( $row = Database::num_rows($res) ) |
|
|
|
|
{ |
|
|
|
|
if($row = Database::num_rows($res)) { |
|
|
|
|
// update |
|
|
|
|
$sql2 = "UPDATE `".$TABLESTATS_REFERERS."` |
|
|
|
|
SET `counter` = counter + '$number' |
|
|
|
|
WHERE `referer` = '".$referer."'"; |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
} else { |
|
|
|
|
// insert |
|
|
|
|
$sql2 = "INSERT INTO `".$TABLESTATS_REFERERS."` |
|
|
|
|
(`referer`,`counter`) |
|
|
|
|
@ -730,6 +629,4 @@ function fillReferersTable($referers_array) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
?> |