"; /* function core_head() { $bar = (file_exists(THEME."images/bar.png") ? THEME."images/bar.png" : e_IMAGE."generic/bar.png"); return ""; } */ require_once(HEADERF); if(!check_class($pref['statUserclass'])) { $text = "
".ADSTAT_L4."
"; $ns->tablerender(ADSTAT_L6, $text); require_once(FOOTERF); exit; } if (!$pref['statActivate']) { $text = (ADMIN ? "
".ADSTAT_L41."
" : "
".ADSTAT_L5."
"); $ns->tablerender(ADSTAT_L6, $text); require_once(FOOTERF); exit; } $qs = explode('.', e_QUERY, 3); $action = varset($qs[0],1); $sec_action = varset($qs[1],FALSE); $order = varset($qs[1],0); // Sort order $toremove = varset($qs[2],''); $order = intval($order); $stat = new siteStats(); if($stat -> error) { $ns->tablerender(ADSTAT_L6, $stat -> error); require_once(FOOTERF); exit; } $oses_map = array ( "Windows" => "windows", "Mac" => "mac", "Linux" => "linux", "BeOS" => "beos", "FreeBSD" => "freebsd", "NetBSD" => "netbsd", "Unspecified"=> "unspecified", "OpenBSD" => "openbsd", "Unix" => "unix", "Spiders" => "spiders", ); $browser_map = array ( 'Netcaptor' => "netcaptor", 'Internet Explorer' => "explorer", 'Firefox' => "firefox", 'Opera' => "opera", 'AOL' => "aol", 'Netscape' => "netscape", 'Mozilla' => "mozilla", 'Mosaic' => "mosaic", 'K-Meleon' => "k-meleon", 'Konqueror' => "konqueror", 'Avant Browser' => "avantbrowser", 'AvantGo' => "avantgo", 'Proxomitron' => "proxomitron", 'Safari' => "safari", 'Lynx' => "lynx", 'Links' => "links", 'Galeon' => "galeon", 'ABrowse' => "abrowse", 'Amaya' => "amaya", 'ANTFresco' => "ant", 'Aweb' => "aweb", 'Beonex' => "beonex", 'Blazer' => "blazer", 'Camino' => "camino", 'Chimera' => "chimera", 'Columbus' => "columbus", 'Crazy Browser' => "crazybrowser", 'Curl' => "curl", 'Deepnet Explorer' => "deepnet", 'Dillo' => "dillo", 'Doris' => "doris", 'ELinks' => "elinks", 'Epiphany' => "epiphany", 'Firebird' => "firebird", 'IBrowse' => "ibrowse", 'iCab' => "icab", 'ICEbrowser' => "ice", 'iSiloX' => "isilox", 'Lotus Notes' => "lotus", 'Lunascape' => "lunascape", 'Maxthon' => "maxthon", 'mBrowser' => "mbrowser", 'Multi-Browser' => "multibrowser", 'Nautilus' => "nautilus", 'NetFront' => "netfront", 'NetPositive' => "netpositive", 'OmniWeb' => "omniweb", 'Oregano' => "oregano", 'PhaseOut' => "phaseout", 'PLink' => "plink", 'Phoenix' => "phoenix", 'Proxomitron' => "proxomitron", 'Shiira' => "shiira", 'Sleipnir' => "sleipnir", 'SlimBrowser' => "slimbrowser", 'StarOffice' => "staroffice", 'Sunrise' => "sunrise", 'Voyager' => "voyager", 'w3m' => "w3m", 'Webtv' => "webtv", 'Xiino' => "xiino", ); $country["arpa"] = "ARPANet"; $country["com"] = "Commercial Users"; $country["edu"] = "Education"; $country["gov"] = "Government"; $country["int"] = "Organisation established by an International Treaty"; $country["mil"] = "Military"; $country["net"] = "Network"; $country["org"] = "Organisation"; $country["ad"] = "Andorra"; $country["ae"] = "United Arab Emirates"; $country["af"] = "Afghanistan"; $country["ag"] = "Antigua & Barbuda"; $country["ai"] = "Anguilla"; $country["al"] = "Albania"; $country["am"] = "Armenia"; $country["an"] = "Netherland Antilles"; $country["ao"] = "Angola"; $country["aq"] = "Antarctica"; $country["ar"] = "Argentina"; $country["as"] = "American Samoa"; $country["at"] = "Austria"; $country["au"] = "Australia"; $country["aw"] = "Aruba"; $country["az"] = "Azerbaijan"; $country["ba"] = "Bosnia-Herzegovina"; $country["bb"] = "Barbados"; $country["bd"] = "Bangladesh"; $country["be"] = "Belgium"; $country["bf"] = "Burkina Faso"; $country["bg"] = "Bulgaria"; $country["bh"] = "Bahrain"; $country["bi"] = "Burundi"; $country["bj"] = "Benin"; $country["bm"] = "Bermuda"; $country["bn"] = "Brunei Darussalam"; $country["bo"] = "Bolivia"; $country["br"] = "Brasil"; $country["bs"] = "Bahamas"; $country["bt"] = "Bhutan"; $country["bv"] = "Bouvet Island"; $country["bw"] = "Botswana"; $country["by"] = "Belarus"; $country["bz"] = "Belize"; $country["ca"] = "Canada"; $country["cc"] = "Cocos (Keeling) Islands"; $country["cf"] = "Central African Republic"; $country["cg"] = "Congo"; $country["ch"] = "Switzerland"; $country["ci"] = "Ivory Coast"; $country["ck"] = "Cook Islands"; $country["cl"] = "Chile"; $country["cm"] = "Cameroon"; $country["cn"] = "China"; $country["co"] = "Colombia"; $country["cr"] = "Costa Rica"; $country["cs"] = "Czechoslovakia"; $country["cu"] = "Cuba"; $country["cv"] = "Cape Verde"; $country["cx"] = "Christmas Island"; $country["cy"] = "Cyprus"; $country["cz"] = "Czech Republic"; $country["de"] = "Germany"; $country["dj"] = "Djibouti"; $country["dk"] = "Denmark"; $country["dm"] = "Dominica"; $country["do"] = "Dominican Republic"; $country["dz"] = "Algeria"; $country["ec"] = "Ecuador"; $country["ee"] = "Estonia"; $country["eg"] = "Egypt"; $country["eh"] = "Western Sahara"; $country["er"] = "Eritrea"; $country["es"] = "Spain"; $country["et"] = "Ethiopia"; $country["fi"] = "Finland"; $country["fj"] = "Fiji"; $country["fk"] = "Falkland Islands (Malvibas)"; $country["fm"] = "Micronesia"; $country["fo"] = "Faroe Islands"; $country["fr"] = "France"; $country["fx"] = "France (European Territory)"; $country["ga"] = "Gabon"; $country["gb"] = "Great Britain"; $country["gd"] = "Grenada"; $country["ge"] = "Georgia"; $country["gf"] = "Guyana (French)"; $country["gh"] = "Ghana"; $country["gi"] = "Gibralta"; $country["gl"] = "Greenland"; $country["gm"] = "Gambia"; $country["gn"] = "Guinea"; $country["gp"] = "Guadeloupe (French)"; $country["gq"] = "Equatorial Guinea"; $country["gr"] = "Greece"; $country["gs"] = "South Georgia & South Sandwich Islands"; $country["gt"] = "Guatemala"; $country["gu"] = "Guam (US)"; $country["gw"] = "Guinea Bissau"; $country["gy"] = "Guyana"; $country["hk"] = "Hong Kong"; $country["hm"] = "Heard & McDonald Islands"; $country["hn"] = "Honduras"; $country["hr"] = "Croatia"; $country["ht"] = "Haiti"; $country["hu"] = "Hungary"; $country["id"] = "Indonesia"; $country["ie"] = "Ireland"; $country["il"] = "Israel"; $country["in"] = "India"; $country["io"] = "British Indian Ocean Territories"; $country["iq"] = "Iraq"; $country["ir"] = "Iran"; $country["is"] = "Iceland"; $country["it"] = "Italy"; $country["jm"] = "Jamaica"; $country["jo"] = "Jordan"; $country["jp"] = "Japan"; $country["ke"] = "Kenya"; $country["kg"] = "Kyrgyz Republic"; $country["kh"] = "Cambodia"; $country["ki"] = "Kiribati"; $country["km"] = "Comoros"; $country["kn"] = "Saint Kitts Nevis Anguilla"; $country["kp"] = "Korea (North)"; $country["kr"] = "Korea (South)"; $country["kw"] = "Kuwait"; $country["ky"] = "Cayman Islands"; $country["kz"] = "Kazachstan"; $country["la"] = "Laos"; $country["lb"] = "Lebanon"; $country["lc"] = "Saint Lucia"; $country["li"] = "Liechtenstein"; $country["lk"] = "Sri Lanka"; $country["lr"] = "Liberia"; $country["ls"] = "Lesotho"; $country["lt"] = "Lithuania"; $country["lu"] = "Luxembourg"; $country["lv"] = "Latvia"; $country["ly"] = "Libya"; $country["ma"] = "Morocco"; $country["mc"] = "Monaco"; $country["md"] = "Moldova"; $country["mg"] = "Madagascar"; $country["mh"] = "Marshall Islands"; $country["mk"] = "Macedonia"; $country["ml"] = "Mali"; $country["mm"] = "Myanmar"; $country["mn"] = "Mongolia"; $country["mo"] = "Macau"; $country["mp"] = "Northern Mariana Islands"; $country["mq"] = "Martinique (French)"; $country["mr"] = "Mauretania"; $country["ms"] = "Montserrat"; $country["mt"] = "Malta"; $country["mu"] = "Mauritius"; $country["mv"] = "Maldives"; $country["mw"] = "Malawi"; $country["mx"] = "Mexico"; $country["my"] = "Malaysia"; $country["mz"] = "Mozambique"; $country["na"] = "Namibia"; $country["nc"] = "New Caledonia (French)"; $country["ne"] = "Niger"; $country["nf"] = "Norfolk Island"; $country["ng"] = "Nigeria"; $country["ni"] = "Nicaragua"; $country["nl"] = "Netherlands"; $country["no"] = "Norway"; $country["np"] = "Nepal"; $country["nr"] = "Nauru"; $country["nt"] = "Saudiarab. Irak)"; $country["nu"] = "Niue"; $country["nz"] = "New Zealand"; $country["om"] = "Oman"; $country["pa"] = "Panama"; $country["pe"] = "Peru"; $country["pf"] = "Polynesia (French)"; $country["pg"] = "Papua New Guinea"; $country["ph"] = "Philippines"; $country["pk"] = "Pakistan"; $country["pl"] = "Poland"; $country["pm"] = "Saint Pierre & Miquelon"; $country["pn"] = "Pitcairn"; $country["pr"] = "Puerto Rico (US)"; $country["pt"] = "Portugal"; $country["pw"] = "Palau"; $country["py"] = "Paraguay"; $country["qa"] = "Qatar"; $country["re"] = "Reunion (French)"; $country["ro"] = "Romania"; $country["ru"] = "Russian Federation"; $country["rw"] = "Rwanda"; $country["sa"] = "Saudi Arabia"; $country["sb"] = "Salomon Islands"; $country["sc"] = "Seychelles"; $country["sd"] = "Sudan"; $country["se"] = "Sweden"; $country["sg"] = "Singapore"; $country["sh"] = "Saint Helena"; $country["si"] = "Slovenia"; $country["sj"] = "Svalbard & Jan Mayen"; $country["sk"] = "Slovakia"; $country["sl"] = "Sierra Leone"; $country["sm"] = "San Marino"; $country["sn"] = "Senegal"; $country["so"] = "Somalia"; $country["sr"] = "Suriname"; $country["st"] = "Sao Tome & Principe"; $country["su"] = "Soviet Union"; $country["sv"] = "El Salvador"; $country["sy"] = "Syria"; $country["sz"] = "Swaziland"; $country["tc"] = "Turks & Caicos Islands"; $country["td"] = "Chad"; $country["tf"] = "French Southern Territories"; $country["tg"] = "Togo"; $country["th"] = "Thailand"; $country["tj"] = "Tadjikistan"; $country["tk"] = "Tokelau"; $country["tm"] = "Turkmenistan"; $country["tn"] = "Tunisia"; $country["to"] = "Tonga"; $country["tp"] = "East Timor"; $country["tr"] = "Turkey"; $country["tt"] = "Trinidad & Tobago"; $country["tv"] = "Tuvalu"; $country["tw"] = "Taiwan"; $country["tz"] = "Tanzania"; $country["ua"] = "Ukraine"; $country["ug"] = "Uganda"; $country["uk"] = "United Kingdom"; $country["um"] = "US Minor outlying Islands"; $country["us"] = "United States"; $country["uy"] = "Uruguay"; $country["uz"] = "Uzbekistan"; $country["va"] = "Vatican City State"; $country["vc"] = "St Vincent & Grenadines"; $country["ve"] = "Venezuela"; $country["vg"] = "Virgin Islands (British)"; $country["vi"] = "Virgin Islands (US)"; $country["vn"] = "Vietnam"; $country["vu"] = "Vanuatu"; $country["wf"] = "Wallis & Futuna Islands"; $country["ws"] = "Samoa"; $country["ye"] = "Yemen"; $country["yt"] = "Mayotte"; $country["yu"] = "Yugoslavia"; $country["za"] = "South Africa"; $country["zm"] = "Zambia"; $country["zr"] = "Zaire"; $country["zw"] = "Zimbabwe"; /* stats displayed will depend on the query string. For example, ?1.2.4 will render today's stats, all time stats and browser stats */ /* 1: today's stats 2: all time total and unique 3: browsers 4: operating systems 5: domains 6: screen resolution/colour depth 7: referers 8: search engine strings */ function display_pars($rec_pars, $disp_pars = '*') { global $pref; switch ($rec_pars) { case 1 : return array(1); case 2 : if (varset($pref['statPrevMonth'],0)) return array(2,3,1); else return array(2,1); case 3 : return array(2,3,1); default : return array(); } } $text = ''; if ((ADMIN == TRUE) && ($sec_action == "rem")) { $toremove = rawurldecode($toremove); if ($stat -> remove_entry($toremove)) { $text .= "
".ADSTAT_L45.$toremove."
".ADSTAT_L46."
"; } else { $text .= "
".ADSTAT_L47.$toremove."
"; } } $action = intval($action); switch($action) { case 1: $text .= $stat -> renderTodaysVisits(FALSE); break; case 2: $text .= $stat -> renderAlltimeVisits(FALSE); break; case 12: if (ADMIN == TRUE) $text .= $stat -> renderTodaysVisits(TRUE); break; case 13: if (ADMIN == TRUE) $text .= $stat -> renderAlltimeVisits(TRUE); break; case 3 : // 'Normal' render case 14 : // 'Consolidated' render if($pref['statBrowser']) { $text .= $stat -> renderBrowsers(display_pars($pref['statBrowser']), $action==3); } else { $text .= ADSTAT_L7; } break; case 4: // 'Normal' render case 15 : // 'Consolidated' render if($pref['statOs']) { $text .= $stat -> renderOses(display_pars($pref['statOs']), $action==4); } else { $text .= ADSTAT_L7; } break; case 5: if($pref['statDomain']) { $text .= $stat -> renderDomains(display_pars($pref['statDomain'])); } else { $text .= ADSTAT_L7; } break; case 6: if($pref['statScreen']) { $text .= $stat -> renderScreens(display_pars($pref['statScreen'])); } else { $text .= ADSTAT_L7; } break; case 7: if ($pref['statRefer']) { $text .= $stat -> renderRefers(display_pars($pref['statRefer'])); } else { $text .= ADSTAT_L7; } break; case 8: if ($pref['statQuery']) { $text .= $stat -> renderQueries(display_pars($pref['statQuery'])); } else { $text .= ADSTAT_L7; } break; case 9: if ($pref['statRecent']) { $text .= $stat -> recentVisitors(); } else { $text .= ADSTAT_L7; } break; case 10: $text .= $stat -> renderDaily(); break; case 11: $text .= $stat -> renderMonthly(); break; default : $text .= $stat -> renderTodaysVisits(FALSE); } /* render links 1 - Todays visits 2 - All-time 3 - Browser stats 4 - OS Stats 5 - Domain Stats 6 - Screen resolution 7 - Referral stats 8 - Search strings 9 - Recent visitors 10 - Daily Stats 11 - Monthly stats 12 - Today's error page visits 13 - All-time error page visits 14 - Consolidated browser view (not listed as a menu option) 15 - Consolidated OS view (not listed as a menu option) */ $path = e_PLUGIN."log/stats.php"; $links = "
". ($action != 1 ? "".ADSTAT_L8."" : "".ADSTAT_L8."")." | ". ($action != 2 ? "".ADSTAT_L9."" : "".ADSTAT_L9."")." | ". ($action != 10 ? "".ADSTAT_L10."" : "".ADSTAT_L10."")." | ". ($action != 11 ? "".ADSTAT_L11."" : "".ADSTAT_L11."")." | ". ($action != 3 && $pref['statBrowser'] ? "".ADSTAT_L12." | " : ($pref['statBrowser'] ? "".ADSTAT_L12." | " : "")). ($action != 4 && $pref['statOs'] ? "".ADSTAT_L13." | " : ($pref['statOs'] ? "".ADSTAT_L13." | " : "")). ($action != 5 && $pref['statDomain'] ? "".ADSTAT_L14." | " : ($pref['statDomain'] ? "".ADSTAT_L14." | " : "")). ($action != 6 && $pref['statScreen'] ? "".ADSTAT_L15." | " : ($pref['statScreen'] ? "".ADSTAT_L15." | " : "")). ($action != 7 && $pref['statRefer'] ? "".ADSTAT_L16." | " : ($pref['statRefer'] ? "".ADSTAT_L16." | " : "")). ($action != 8 && $pref['statQuery'] ? "".ADSTAT_L17." | " : ($pref['statQuery'] ? "".ADSTAT_L17." | " : "")). ($action != 9 && $pref['statRecent'] ? "".ADSTAT_L18." | " : ($pref['statRecent'] ? "".ADSTAT_L18." | " : "")); if (ADMIN == TRUE) $links .= ($action != 12 ? "".ADSTAT_L43."" : "".ADSTAT_L43."")." | ". ($action != 13 ? "".ADSTAT_L44."" : "".ADSTAT_L44.""); $links .= "


"; $ns->tablerender(ADSTAT_L6, $links.$text); require_once(FOOTERF); function make_bits($prefix, $act) { $ret = array(); $now = getdate(); $ret['hdg_extra'] = ''; switch ($act) { case 1 : $ret['query'] = "log_id='{$prefix}'"; break; case 2 : $ret['query'] = "log_id='{$prefix}:".date("Y-m")."'"; $ret['hdg_extra'] = " (".$now['mon']."-".$now['year'].")"; break; case 3 : $now['mon']--; if ($now['mon']==0) { $now['mon'] = 12; $now['year']--; } $ret['query'] = "log_id='{$prefix}:".sprintf("%04d-%02d",$now['year'],$now['mon'])."'"; $ret['hdg_extra'] = " (".$now['mon']."-".$now['year'].")"; break; default: $ret = "Invalid selection: {$act}
"; } return $ret; } class siteStats { var $browser_headings = array(1 => ADSTAT_L50, 2 => ADSTAT_L51, 3 => ADSTAT_L52); var $dbPageInfo; var $fileInfo; var $fileBrowserInfo; var $fileOsInfo; var $fileScreenInfo; var $fileDomainInfo; var $fileReferInfo; var $fileQueryInfo; var $fileRecent; var $error; var $order; var $bar; var $filesiteTotal; var $filesiteUnique; function siteStats() { /* constructor */ global $sql; /* get today's logfile ... */ $logfile = e_PLUGIN."log/logs/logp_".date("z.Y", time()).".php"; if(is_readable($logfile)) { require($logfile); } $logfile = e_PLUGIN."log/logs/logi_".date("z.Y", time()).".php"; if(is_readable($logfile)) { require($logfile); } $this -> filesiteTotal = $siteTotal; $this -> filesiteUnique = $siteUnique; /* set order var */ global $order; $this -> order = $order; $this -> fileInfo = $pageInfo; $this -> fileBrowserInfo = $browserInfo; $this -> fileOsInfo = $osInfo; $this -> fileScreenInfo = $screenInfo; $this -> fileDomainInfo = $domainInfo; $this -> fileReferInfo = $refInfo; $this -> fileQueryInfo = $searchInfo; $this -> fileRecent = $visitInfo; /* get main stat info from database */ if($sql -> db_Select("logstats", "*", "log_id='pageTotal'")){ $row = $sql -> db_Fetch(); $this -> dbPageInfo = unserialize($row[2]); } else { $this -> dbPageInfo = array(); } /* temp consolidate today's info (if it exists)... */ if(is_array($pageInfo)) { foreach($pageInfo as $key => $info) { $key = preg_replace("/\?.*/", "", $key); if(array_key_exists($key, $this -> dbPageInfo)) { $this -> dbPageInfo[$key]['ttlv'] += $info['ttl']; $this -> dbPageInfo[$key]['unqv'] += $info['unq']; } else { $this -> dbPageInfo[$key]['url'] = $info['url']; $this -> dbPageInfo[$key]['ttlv'] = $info['ttl']; $this -> dbPageInfo[$key]['unqv'] = $info['unq']; } } } $this -> bar = (file_exists(THEME."images/bar.png") ? THEME."images/bar.png" : e_IMAGE."generic/bar.png"); /* end constructor */ } function arraySort($array, $column, $order = SORT_DESC) { /* sorts multi-dimentional array based on which field is passed */ $i=0; foreach($array as $info) { $sortarr[]=$info[$column]; $i++; } array_multisort($sortarr, $order, $array, $order); return($array); /* end method */ } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderTodaysVisits($do_errors = FALSE) { /* renders information for today only */ $do_errors = $do_errors && ADMIN && getperms("P"); // Now run through and keep either the non-error pages, or the error pages, according to $do_errors $totalArray = array(); $totalv = 0; $totalu = 0; foreach ($this -> fileInfo as $k => $v) { $found = (strpos($k,'error/') === 0); if ($do_errors XOR !$found) { $totalArray[$k] = $v; $total += $v['ttlv']; } } $totalArray = $this -> arraySort($totalArray, "ttl"); foreach($totalArray as $key => $info) { $totalv += $info['ttl']; $totalu += $info['unq']; } $text = "\n\n\n\n\n\n"; foreach($totalArray as $key => $info) { if($info['ttl']) { $percentage = round(($info['ttl']/$totalv) * 100, 2); $text .= "\n\n\n\n\n"; } } $text .= "
".ADSTAT_L19."".ADSTAT_L20."%
".$key." ".$this -> bar($percentage, $info['ttl']." [".$info['unq']."]")."".$percentage."%
".ADSTAT_L21." [".ADSTAT_L22."]{$totalv} [{$totalu}]
"; return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderAlltimeVisits($do_errors = FALSE) { /* renders information for alltime, total and unique */ global $sql, $action; $sql -> db_Select("logstats", "*", "log_id='pageTotal' "); $row = $sql -> db_Fetch(); $pageTotal = unserialize($row['log_data']); $total = 0; $can_delete = ADMIN && getperms("P"); $do_errors = $do_errors && $can_delete; foreach($this -> fileInfo as $url => $tmpcon) { $pageTotal[$url]['url'] = $tmpcon['url']; $pageTotal[$url]['ttlv'] += $tmpcon['ttl']; $pageTotal[$url]['unqv'] += $tmpcon['unq']; } // Now run through and keep either the non-error pages, or the error pages, according to $do_errors $totalArray = array(); foreach ($pageTotal as $k => $v) { $found = (strpos($k,'error/') === 0); if ($do_errors XOR !$found) { $totalArray[$k] = $v; $total += $v['ttlv']; } } $totalArray = $this -> arraySort($totalArray, "ttlv"); $text .= "\n \n\n \n\n\n"; foreach($totalArray as $key => $info) { if($info['ttlv']) { if (!$info['url'] && (($key == 'index') || (strpos($key,':index') !== FALSE))) $info['url'] = e_BASE.'index.php'; // Avoids empty link $percentage = round(($info['ttlv']/$total) * 100, 2); $text .= "\n"; } } $text .= "\n
".ADSTAT_L19."".ADSTAT_L23."%
".($can_delete ? "".ADSTAT_L39." " : "")." ".$key." "; $text .= " ".$this->bar($percentage, $info['ttlv'])." ".$percentage."%
".ADSTAT_L21."{$total}
"; $uniqueArray = array(); $totalv = 0; foreach ($this -> dbPageInfo as $k => $v) { $found = (strpos($k,'error/') === 0); if ($do_errors XOR !$found) { $uniqueArray[$k] = $v; $totalv += $v['unqv']; } } $uniqueArray = $this -> arraySort($uniqueArray, "unqv"); $text .= "
\n\n\n\n\n\n"; foreach($uniqueArray as $key => $info) { if($info['ttlv']) { if (!$info['url'] && (($key == 'index') || (strpos($key,':index') !== FALSE))) $info['url'] = e_BASE.'index.php'; // Avoids empty link $percentage = round(($info['unqv']/$totalv) * 100, 2); $text .= "\n"; } } $text .= "\n
Page".ADSTAT_L24."%
".$key." ".$this -> bar($percentage, $info['unqv'])." ".$percentage."%
".ADSTAT_L21."$totalv
"; return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ // List browsers. $selection is an array of the info required - '2' = current month's stats, '1' = all-time stats (default) // If $show_version is FALSE, browsers are consolidated across versions - e.g. 1 line for Firefox using info from $browser_map function renderBrowsers($selection, $show_version=TRUE) { global $sql, $browser_map; if (!$selection) $selection = array(1); if (!is_array($selection)) $selection = array(1); $text = ''; // echo "Show browsers; expanded = ".($show_version ? 'TRUE' : 'FALSE')."
"; foreach ($selection as $act) { unset($statBrowser); $statBrowser = array(); $pars = make_bits('statBrowser',$act); // Get the query, plus maybe date for heading if (!is_array($pars)) return $pars; // Return error if necessary if ($entries = $sql -> db_Select("logstats", "*", $pars['query'])) { $row = $sql -> db_Fetch(); $statBrowser = unserialize($row['log_data']); } else { continue; // No data - terminate this loop } /* temp consolidate today's data ... */ if (($act == 1) || ($act == 2)) { foreach($this -> fileBrowserInfo as $name => $count) { $statBrowser[$name] += $count; } } if ($show_version == FALSE) { $temp_array = array(); foreach ($statBrowser as $b_full=>$v) { $b_type = ''; foreach ($browser_map as $name => $file) { if(stripos($b_full, $name) === 0) { // Match here $b_type = $name; break; } } if (!$b_type) $b_type = $b_full; // Default is an unsupported browser - use the whole name if (array_key_exists($b_type,$temp_array)) { $temp_array[$b_type] += $v; } else { $temp_array[$b_type] = $v; // New browser found } } $statBrowser = $temp_array; unset($temp_array); } if ($this -> order) { ksort($statBrowser); reset ($statBrowser); $browserArray = $statBrowser; } else { $browserArray = $this -> arraySort($statBrowser, 0); } $total = array_sum($browserArray); $text .= "\n \n \n\n \n\n"; if (count($browserArray)) { foreach($browserArray as $key => $info) { $image = ""; foreach ($browser_map as $name => $file) { if(strstr($key, $name)) { $image = "{$file}.png"; break; } } if($image == "") { $image = "unknown.png"; } $percentage = round(($info/$total) * 100, 2); $text .= "". ($entries == 1 ? "" : "")." \n"; } $text .= "\n"; } else { $text .= "\n"; } $text .= "
".$this->browser_headings[$act].$pars['hdg_extra']."
".ADSTAT_L26." ".ADSTAT_L21."%
".($image ? " " : "").$key."".$this -> bar($percentage, $info)."".$this -> bar($percentage, $info)."".$percentage."%
".ADSTAT_L21."{$total}
".ADSTAT_L25."

"; } return $text; } /* ------------------------------------------------------- Show operating systems. Only show different versions of the operating system if $show_version == TRUE Uses $oses_map -----------------------------------------------------------*/ function renderOses($selection, $show_version=TRUE) { global $sql, $oses_map; if (!$selection) $selection = array(1); if (!is_array($selection)) $selection = array(1); $text = ''; // echo "Show OSes; expanded = ".($show_version ? 'TRUE' : 'FALSE')."
"; $statOs = array(); foreach ($selection as $act) { $pars = make_bits('statOs',$act); // Get the query, plus maybe date for heading if (!is_array($pars)) return $pars; // Return error if necessary if ($entries = $sql -> db_Select("logstats", "*", $pars['query'])) { $row = $sql -> db_Fetch(); $statOs = unserialize($row['log_data']); } else { continue; // No data - terminate this loop } /* temp consolidate today's data ... */ if (($act == 1) || ($act == 2)) { foreach($this -> fileOsInfo as $name => $count) { $statOs[$name] += $count; } } if ($show_version == FALSE) { $temp_array = array(); foreach ($statOs as $b_full=>$v) { $b_type = ''; foreach ($oses_map as $name => $file) { if(stripos($b_full, $name) === 0) { // Match here $b_type = $name; break; } } if (!$b_type) $b_type = $b_full; // Default is an unsupported browser - use the whole name if (array_key_exists($b_type,$temp_array)) { $temp_array[$b_type] += $v; } else { $temp_array[$b_type] = $v; // New browser found } } $statOs = $temp_array; unset($temp_array); } if($this -> order) { ksort($statOs); reset ($statOs); $osArray = $statOs; } else { $osArray = $this -> arraySort($statOs, 0); } $total = array_sum($osArray); $text .= "\n \n \n\n \n\n\n"; if (count($osArray)) { foreach($osArray as $key => $info) { $image = ""; if(strstr($key, "Windows")) { $image = "windows.png"; } if(strstr($key, "Mac")) { $image = "mac.png"; } if(strstr($key, "Linux")) { $image = "linux.png"; } if(strstr($key, "BeOS")) { $image = "beos.png"; } if(strstr($key, "FreeBSD")) { $image = "freebsd.png"; } if(strstr($key, "NetBSD")) { $image = "netbsd.png"; } if(strstr($key, "Unspecified")) { $image = "unspecified.png"; } if(strstr($key, "OpenBSD")) { $image = "openbsd.png"; } if(strstr($key, "Unix")) { $image = "unix.png"; } if(strstr($key, "Spiders")) { $image = "spiders.png"; } $percentage = round(($info/$total) * 100, 2); $text .= "". ($entries == 1 ? "" : "")." \n"; } $text .= "\n"; } else { $text .= "\n"; } $text .= "
".$this->browser_headings[$act].$pars['hdg_extra']."
".ADSTAT_L27."".ADSTAT_L21."%
".($image ? " " : "").$key."".$this -> bar($percentage, $info)."".$this -> bar($percentage, $info)."".$percentage."%
".ADSTAT_L21."{$total} 
".ADSTAT_L25."

"; } return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderDomains($selection) { global $sql; if (!$selection) $selection = array(1); if (!is_array($selection)) $selection = array(1); $text = ''; $statDom = array(); foreach ($selection as $act) { $pars = make_bits('statDomain',$act); // Get the query, plus maybe date for heading if (!is_array($pars)) return $pars; // Return error if necessary if ($entries = $sql -> db_Select("logstats", "*", $pars['query'])) { $row = $sql -> db_Fetch(); $statDom = unserialize($row['log_data']); } else { continue; // No data - terminate this loop } /* temp consolidate today's data ... */ if (($act == 1) || ($act == 2)) { foreach($this -> fileDomainInfo as $name => $count) { $statDom[$name] += $count; } } if($this -> order) { ksort($statDom); reset ($statDom); $domArray = $statDom; } else { $domArray = $this -> arraySort($statDom, 0); } $total = array_sum($domArray); $text .= "\n \n \n\n \n\n\n"; if (count($domArray)) { foreach($domArray as $key => $info) { if($key = $this -> getcountry($key)) { $percentage = round(($info/$total) * 100, 2); $text .= "\n"; } } $text .= "\n"; } else { $text .= "\n"; } $text .= "
".$this->browser_headings[$act].$pars['hdg_extra']."
".ADSTAT_L28."".ADSTAT_L21."%
".$key." ".$this -> bar($percentage, $info)." ".$percentage."%
".ADSTAT_L21."$total
".ADSTAT_L25."

"; } return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderScreens($selection) { global $sql; if (!$selection) $selection = array(1); if (!is_array($selection)) $selection = array(1); $text = ''; $statScreen = array(); foreach ($selection as $act) { $pars = make_bits('statScreen',$act); // Get the query, plus maybe date for heading if (!is_array($pars)) return $pars; // Return error if necessary if ($entries = $sql -> db_Select("logstats", "*", $pars['query'])) { $row = $sql -> db_Fetch(); $statScreen = unserialize($row['log_data']); } else { continue; // No data - terminate this loop } /* temp consolidate today's data ... */ if (($act == 1) || ($act == 2)) { foreach($this -> fileScreenInfo as $name => $count) { $statScreen[$name] += $count; } } if($this -> order) { $nsarray = array(); foreach($statScreen as $key => $info) { if(preg_match("/(\d+)x/", $key, $match)) { $nsarray[$key] = array('width' => $match[1], 'info' => $info); } } $nsarray = $this -> arraySort($nsarray, 'width', SORT_ASC); reset($nsarray); $screenArray = array(); foreach($nsarray as $key => $info) { $screenArray[$key] = $info['info']; } } else { $screenArray = $this -> arraySort($statScreen, 0); } $total = array_sum($screenArray); $text .= "\n \n \n\n\n\n\n"; if (count($screenArray)) { foreach($screenArray as $key => $info) { if(strstr($key, "@") && !strstr($key, "undefined") && preg_match("/(\d+)x(\d+)@(\d+)/", $key)) { $percentage = round(($info/$total) * 100, 2); $text .= "". ($entries == 1 ? "" : "")." \n"; } } $text .= "\n"; } else { $text .= "\n"; } $text .= "
".$this->browser_headings[$act].$pars['hdg_extra']."
".ADSTAT_L29."".ADSTAT_L21."%
".$key."".$this -> bar($percentage, $info)."".$this -> bar($percentage, $info)."".$percentage."%
".ADSTAT_L21."{$total}
".ADSTAT_L25."

"; } return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderRefers($selection) { global $sql, $pref; if (!$selection) $selection = array(1); if (!is_array($selection)) $selection = array(1); $text = ''; $statRefer = array(); foreach ($selection as $act) { $pars = make_bits('statReferer',$act); // Get the query, plus maybe date for heading if (!is_array($pars)) return $pars; // Return error if necessary if ($entries = $sql -> db_Select("logstats", "*", $pars['query'])) { $row = $sql -> db_Fetch(); $statRefer = unserialize($row['log_data']); } else { continue; // No data - terminate this loop } /* temp consolidate today's data ... */ if (($act == 1) || ($act == 2)) { foreach($this -> fileReferInfo as $name => $count) { $statRefer[$name]['url'] = $count['url']; $statRefer[$name]['ttl'] += $count['ttl']; } } $statArray = $this -> arraySort($statRefer, 'ttl'); $total = 0; foreach ($statArray as $key => $info) { $total += $info['ttl']; } $text .= "\n \n \n\n\n\n\n"; $count = 0; if (count($statArray)) { foreach($statArray as $key => $info) { $percentage = round(($info['ttl']/$total) * 100, 2); if (!$this -> order && strlen($key) > 50) { $key = substr($key, 0, 50)." ..."; } $text .= "\n"; $count++; if($count == $pref['statDisplayNumber']) { break; } } $text .= "\n"; } else { $text .= "\n"; } $text .= "
".$this->browser_headings[$act].$pars['hdg_extra']."
".ADSTAT_L30."".ADSTAT_L21."%
".$key." ".$this -> bar($percentage, $info['ttl'])." ".$percentage."%
".ADSTAT_L21."{$total}
".ADSTAT_L25."

"; } return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderQueries($selection) { global $sql; if (!$selection) $selection = array(1); if (!is_array($selection)) $selection = array(1); $text = ''; $statQuery = array(); foreach ($selection as $act) { $pars = make_bits('statQuery',$act); // Get the query, plus maybe date for heading if (!is_array($pars)) return $pars; // Return error if necessary if ($entries = $sql -> db_Select("logstats", "*", $pars['query'])) { $row = $sql -> db_Fetch(); $statQuery = unserialize($row['log_data']); } else { continue; // No data - terminate this loop } /* temp consolidate today's data ... */ if (($act == 1) || ($act == 2)) { foreach ($this -> fileQueryInfo as $name => $count) { $statQuery[$name] += $count; } } $queryArray = $this -> arraySort($statQuery, 0); $total = array_sum($queryArray); $text .= "\n \n \n\n\n\n\n"; $count = 1; if (count($queryArray)) { foreach ($queryArray as $key => $info) { $percentage = round(($info/$total) * 100, 2); $key = str_replace("%20", " ", $key); $text .= "\n"; $count ++; if($count == $pref['statDisplayNumber']) { break; } } $text .= "\n"; } else { $text .= "\n"; } $text .= "
".$this->browser_headings[$act].$pars['hdg_extra']."
".ADSTAT_L31."".ADSTAT_L21."%
".$key." ".$this -> bar($percentage, $info)." ".$percentage."%
".ADSTAT_L21."{$total}
".ADSTAT_L25."

"; } return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function recentVisitors() { if(!is_array($this -> fileRecent) || !count($this -> fileRecent)) { return "
".ADSTAT_L25.".
"; } $gen = new convert; $recentArray = array_reverse($this -> fileRecent, TRUE); $text = "\n\n\n\n\n"; foreach($recentArray as $key => $info) { if(is_array($info)) { $host = $info['host']; $datestamp = $info['date']; $os = $info['os']; $browser = $info['browser']; $screen = $info['screen']; $referer = $info['referer']; } else { list($host, $datestamp, $os, $browser, $screen, $referer) = explode(chr(1), $info); } $datestamp = $gen -> convert_date($datestamp, "long"); $text .= "\n"; } $text .= "
".ADSTAT_L18."Information
$datestamp Host: $host
".ADSTAT_L26.": $browser
".ADSTAT_L27.": $os
".ADSTAT_L29.": $screen".($referer ? "
".ADSTAT_L32.": $referer" : "")."
"; return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderDaily() { global $sql, $siteTotal, $siteUnique; $td = date("Y-m-j", time()); $dayarray[$td] = array(); $pagearray = array(); $qry = " SELECT * from #logstats WHERE log_id REGEXP('[[:digit:]]+\-[[:digit:]]+\-[[:digit:]]+') ORDER BY CONCAT(LEFT(log_id,4), SUBSTRING(log_id, 6, 2), LPAD(SUBSTRING(log_id, 9), 2, '0')) DESC LIMIT 0,14 "; if($amount = $sql -> db_Select_gen($qry)) { $array = $sql -> db_getList(); $ttotal = 0; $utotal = 0; foreach($array as $key => $value) { extract($value); if(is_array($log_data)) { $entries[0] = $log_data['host']; $entries[1] = $log_data['date']; $entries[2] = $log_data['os']; $entries[3] = $log_data['browser']; $entries[4] = $log_data['screen']; $entries[5] = $log_data['referer']; } else { $entries = explode(chr(1), $log_data); } $dayarray[$log_id]['daytotal'] = $entries[0]; $dayarray[$log_id]['dayunique'] = $entries[1]; unset($entries[0]); unset($entries[1]); foreach($entries as $entry) { if($entry) { list($url, $total, $unique) = explode("|", $entry); if(strstr($url, "/")) { $urlname = preg_replace("/\.php|\?.*/", "", substr($url, (strrpos($url, "/")+1))); } else { $urlname = preg_replace("/\.php|\?.*/", "", $url); } $dayarray[$log_id][$urlname] = array('url' => $url, 'total' => $total, 'unique' => $unique); $pagearray[$urlname]['total'] += $total; $pagearray[$urlname]['unique'] += $unique; $ttotal += $total; $utotal += $unique; } } } } foreach($this -> fileInfo as $fkey => $fvalue) { $dayarray[$td][$fkey]['total'] += $fvalue['ttl']; $dayarray[$td][$fkey]['unique'] += $fvalue['unq']; $dayarray[$td]['daytotal'] += $fvalue['ttl']; $dayarray[$td]['dayunique'] += $fvalue['unq']; $pagearray[$fkey]['total'] += $fvalue['ttl']; $pagearray[$fkey]['unique'] += $fvalue['unq']; $ttotal += $fvalue['ttl']; $utotal += $fvalue['unq']; } $text = "\n\n\n\n\n"; foreach($dayarray as $date => $total) { list($year, $month, $day) = explode("-", $date); $date = strftime ("%A, %B %d", mktime (0,0,0,$month,$day,$year)); $barWidth = round(($total['daytotal']/$ttotal) * 100, 2); $text .= "\n"; } $text .= "
".ADSTAT_L33." ".($amount+1)." ".ADSTAT_L40."".ADSTAT_L34."
$date ".$this -> bar($barWidth, $total['daytotal'])."
"; $text .= "
\n\n\n\n\n"; foreach($dayarray as $date => $total) { list($year, $month, $day) = explode("-", $date); $date = strftime ("%A, %B %d", mktime (0,0,0,$month,$day,$year)); $barWidth = round(($total['dayunique']/$utotal) * 100, 2); $text .= "\n"; } $text .= "
".ADSTAT_L35." ".($amount+1)." ".ADSTAT_L40."".ADSTAT_L34."
$date ".$this -> bar($barWidth, $total['dayunique'])."
"; $text .= "
\n\n\n\n\n"; $newArray = $this -> arraySort($pagearray, "total"); foreach($newArray as $key => $total) { $barWidth = round(($total['total']/$ttotal) * 100, 2); $text .= "\n"; } $text .= "
".ADSTAT_L33." ".($amount+1)." ".ADSTAT_L36."".ADSTAT_L34."
$key ".$this -> bar($barWidth, $total['total'])."
"; $text .= "
\n\n\n\n\n"; $newArray = $this -> arraySort($pagearray, "unique"); foreach($newArray as $key => $total) { $barWidth = round(($total['unique']/$utotal) * 100, 2); $text .= "\n"; } $text .= "
".ADSTAT_L35." ".($amount+1)." ".ADSTAT_L36."".ADSTAT_L34."
$key ".$this -> bar($barWidth, $total['unique'])."
"; return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function renderMonthly() { global $sql; if(!$entries = $sql -> db_Select("logstats", "*", "log_id REGEXP('^[[:digit:]]+\-[[:digit:]]+$') ORDER BY CONCAT(LEFT(log_id,4), RIGHT(log_id,2)) DESC")) { return ADSTAT_L42; } $array = $sql -> db_getList(); $monthTotal = array(); $mtotal = 0; $utotal = 0; foreach($array as $info) { $date = $info['log_id']; $stats = unserialize($info['log_data']); foreach($stats as $key => $total) { $monthTotal[$date]['totalv'] += $total['ttlv']; $monthTotal[$date]['uniquev'] += $total['unqv']; $mtotal += $total['ttlv']; $utotal += $total['unqv']; } } $tmpArray = $this -> arraySort($monthTotal, "totalv"); $text .= "\n\n\n\n\n"; foreach($monthTotal as $date => $total) { list($year, $month) = explode("-", $date); $date = strftime ("%B %Y", mktime (0,0,0,$month,1,$year)); $barWidth = round(($total['totalv']/$mtotal) * 100, 2); $text .= "". ($entries == 1 ? "" : "")." \n"; } $text .= "
".ADSTAT_L37."".ADSTAT_L34."
$date".$this -> bar($barWidth, $total['totalv'])."".$this -> bar($barWidth, $total['totalv'])."
"; $text .= "
\n\n\n\n\n"; foreach($monthTotal as $date => $total) { $barWidth = round(($total['uniquev']/$utotal) * 100, 2); list($year, $month) = explode("-", $date); $date = strftime ("%B %Y", mktime (0,0,0,$month,1,$year)); $text .= "". ($entries == 1 ? "" : "")." \n"; } $text .= "
".ADSTAT_L38."".ADSTAT_L34."
$date".$this -> bar($barWidth, $total['uniquev'])."".$this -> bar($barWidth, $total['uniquev'])."
"; return $text; } /* -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ function getWidthRatio ($array, $column) { $tmpArray = $this -> arraySort($array, $column); $data = each($tmpArray); $maxValue = $data[1]['totalv']; echo "maxValue ".$maxValue."
"; $ratio = 0; while($maxValue > 100) { $maxValue = ($maxValue / 2); $ratio ++; } if(!$ratio) { return 1; } echo "ratio ".$ratio."
"; return $ratio; } function getcountry($dom) { global $country; return $country[$dom]; } function bar($percen, $val) { return "
".$val; } function remove_entry($toremove) { // Note - only removes info from the database - not from the current page file global $sql; if ($sql -> db_Select("logstats", "*", "log_id='pageTotal'")) { $row = $sql -> db_Fetch(); $dbPageInfo = unserialize($row[2]); unset($dbPageInfo[$toremove]); $dbPageDone = serialize($dbPageInfo); $sql -> db_Update("logstats", "log_data='{$dbPageDone}' WHERE log_id='pageTotal' "); // $this -> renderAlltimeVisits(); return TRUE; } return FALSE; } } ?>