1
0
mirror of https://github.com/e107inc/e107.git synced 2025-10-12 21:45:11 +02:00

Renormalized all text file line endings

This commit is contained in:
Deltik
2019-03-29 19:13:32 -05:00
parent 6fd0a6a8a2
commit 1f824faa69
180 changed files with 77527 additions and 77527 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1,106 +1,106 @@
<?php
/*
* e107 website system
*
* Copyright 2001-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Site access logging
*
*
*/
if (!defined('e107_INIT')) { exit; }
if (vartrue($pref['statActivate']))
{
if(!$pref['statCountAdmin'] && ADMIN) // don't count admin visits
{
return;
}
// Page to log here
if(USER_AREA)
{
require_once(e_PLUGIN.'log/consolidate.php');
$lgc = new logConsolidate();
$lgc->run();
$err_flag = '';
if (defined('ERR_PAGE_ACTIVE'))
{ // We've got an error - set a flag to log it
$err_flag = "&err_direct=".ERR_PAGE_ACTIVE;
if (is_numeric(e_QUERY)) $err_flag .= '/'.substr(e_QUERY,0,10); // This should pick up the error code - and limit numeric length to upset the malicious
$err_flag .= "&err_referer=".$_SERVER['HTTP_REFERER'];
}
}
if(USER_AREA)
{
$logJS = "
$(function() {
function rstr2b64(input)
{
var b64pad = \"=\"; /* base-64 pad character. \"=\" for strict RFC compliance */
var tab = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";
var output = \"\";
var len = input.length;
for(var i = 0; i < len; i += 3)
{
var triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > input.length * 8) output += b64pad;
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
}
}
return output;
}
var ref =\"\"+escape(top.document.referrer);
var eeself = escape(window.location.href);
var colord = window.screen.colorDepth;
var res = window.screen.width + \"x\" + window.screen.height;
var logString = 'referer=' + ref + '&colour=' + colord + '&eself=' + eeself + '&res=' + res + '".$err_flag."';
logString = rstr2b64(logString);
var url = '".SITEURLBASE.e_PLUGIN_ABS."log/log.php';
var dataText = 'lv='+logString;
$.ajax({
type: 'get',
url: url,
data: {'lv' :logString},
success: function(e) {
if(e)
{
// alert(e);
}
}
});
});
";
e107::js('footer-inline', $logJS, 'jquery');
}
}
<?php
/*
* e107 website system
*
* Copyright 2001-2015 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Site access logging
*
*
*/
if (!defined('e107_INIT')) { exit; }
if (vartrue($pref['statActivate']))
{
if(!$pref['statCountAdmin'] && ADMIN) // don't count admin visits
{
return;
}
// Page to log here
if(USER_AREA)
{
require_once(e_PLUGIN.'log/consolidate.php');
$lgc = new logConsolidate();
$lgc->run();
$err_flag = '';
if (defined('ERR_PAGE_ACTIVE'))
{ // We've got an error - set a flag to log it
$err_flag = "&err_direct=".ERR_PAGE_ACTIVE;
if (is_numeric(e_QUERY)) $err_flag .= '/'.substr(e_QUERY,0,10); // This should pick up the error code - and limit numeric length to upset the malicious
$err_flag .= "&err_referer=".$_SERVER['HTTP_REFERER'];
}
}
if(USER_AREA)
{
$logJS = "
$(function() {
function rstr2b64(input)
{
var b64pad = \"=\"; /* base-64 pad character. \"=\" for strict RFC compliance */
var tab = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";
var output = \"\";
var len = input.length;
for(var i = 0; i < len; i += 3)
{
var triplet = (input.charCodeAt(i) << 16)
| (i + 1 < len ? input.charCodeAt(i+1) << 8 : 0)
| (i + 2 < len ? input.charCodeAt(i+2) : 0);
for(var j = 0; j < 4; j++)
{
if(i * 8 + j * 6 > input.length * 8) output += b64pad;
else output += tab.charAt((triplet >>> 6*(3-j)) & 0x3F);
}
}
return output;
}
var ref =\"\"+escape(top.document.referrer);
var eeself = escape(window.location.href);
var colord = window.screen.colorDepth;
var res = window.screen.width + \"x\" + window.screen.height;
var logString = 'referer=' + ref + '&colour=' + colord + '&eself=' + eeself + '&res=' + res + '".$err_flag."';
logString = rstr2b64(logString);
var url = '".SITEURLBASE.e_PLUGIN_ABS."log/log.php';
var dataText = 'lv='+logString;
$.ajax({
type: 'get',
url: url,
data: {'lv' :logString},
success: function(e) {
if(e)
{
// alert(e);
}
}
});
});
";
e107::js('footer-inline', $logJS, 'jquery');
}
}
?>

View File

@@ -1,311 +1,311 @@
<?php
/*
* e107 website system
*
* Copyright 2001-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Site access logging - 'receiver'
*/
/* File to log page accesses - called with
e_PLUGIN_ABS."log/log.php?base64encode(referer=' + ref + '&color=' + colord + '&eself=' + eself + '&res=' + res + '\">' );)";
referer= ref
color= colord
eself= eself
res= res
err_direct - optional error flag
err_referer - referrer if came via error page
qry = 1 to log query part as well
// Normally the file is 'silent' - if any errors occur, any error message appears in the page header.
*/
//error_reporting(0);
// error_reporting(E_ALL);
define('e_MINIMAL',true);
require_once("../../class2.php"); // More secure to include it.
header('Cache-Control: no-cache, must-revalidate'); // See if this discourages browser caching
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
define('LOGSTATS_DEBUG', false);
// @example url: e107_plugins/log/log.php?lv=cmVmZXJlcj1odHRwJTNBLy9sb2NhbGhvc3QlM0E4MDgwL2UxMDdfMi4wL3N0YXRzJmNvbG91cj0yNCZlc2VsZj1odHRwJTNBLy9sb2NhbGhvc3QlM0E4MDgwL2UxMDdfMi4wL2UxMDdfcGx1Z2lucy9sb2cvc3RhdHMucGhwJTNGMiZyZXM9MTkyMHgxMjAw
if(LOGSTATS_DEBUG === true)
{
echo "Debug is Active";
}
if (!vartrue($pref['statActivate']))
{
if(LOGSTATS_DEBUG === true)
{
echo "Stats log is inactive";
}
exit();
}
//print_r(base64_decode($_GET['lv']));
define('LOGSTATS_INIT', true);
// Array of page names which should have individual query values recorded.
// The top level array index is the page name.
// If the top level value is an array, it must be an array of query string beginnings to match.
$pageUnique = array('page' => 1, 'content' => array('content'));
//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING']));
//$logVals = urldecode(base64_decode($_GET['lv']));
// --------------- Reworked for v2.x ------------------------
$logVals = base64_decode($_GET['lv']);
$logVals = filter_var($logVals, FILTER_SANITIZE_URL);
$logVals .= "&ip=".USERIP;
$logVals .= "&iphost=". @gethostbyaddr(USERIP);
$logVals .= "&lan=".e_LAN;
$logVals .= "&agent=".filter_var($_SERVER['HTTP_USER_AGENT'],FILTER_SANITIZE_STRING);
parse_str($logVals, $vals);
$vals['referer'] = urldecode($vals['referer']);
$vals['eself'] = urldecode($vals['eself']);
if(empty($_SESSION['log_userLoggedPages']) || !in_array($vals['eself'],$_SESSION['log_userLoggedPages']))
{
$_SESSION['log_userLoggedPages'][] = $vals['eself'];
$logVals .= "&unique=1";
}
else
{
$logVals .= "&unique=0";
}
$logVals = str_replace('%3A',':',$logVals); // make the URLs a bit cleaner, while keeping any urlqueries encoded.
$lg = e107::getAdminLog();
$lg->addDebug(print_r($logVals, true));
$lg->toFile('SiteStats','Statistics Log', true);
e107::getEvent()->trigger('user_log_stats',$vals);
// ------------------------------------ ---------------------
// We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1:
// @todo may be able to remove this check once minimum PHP version finalised
if (function_exists('date_default_timezone_get'))
{
date_default_timezone_set(@date_default_timezone_get()); // Just set a default - it should default to UTC if no timezone set
}
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logVals."\n"); fclose($logfp);
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, print_r($vals, TRUE)."\n"); fclose($logfp);
$colour = strip_tags((isset($vals['colour']) ? $vals['colour'] : ''));
$res = strip_tags((isset($vals['res']) ? $vals['res'] : ''));
$self = strip_tags((isset($vals['eself']) ? $vals['eself'] : ''));
$ref = addslashes(strip_tags((isset($vals['referer']) ? $vals['referer'] : '')));
$logQry = isset($vals['qry']) && $vals['qry'];
$date = date('z.Y', time());
$logPfile = e_LOG.'logp_'.$date.'.php';
//$logString = "Colour: {$colour} Res: {$res} Self: {$self} Referrer: {$ref} ErrCode: {$vals['err_direct']}\n";
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logString); fclose($logfp);
// vet resolution and colour depth some more - avoid dud values
if ($res && preg_match("#.*?((\d+)\w+?(\d+))#", $res, $match))
{
$res = $match[2].'x'.$match[3];
}
else
{
$res = '??'; // Can't decode resolution
}
if ($colour && preg_match("#.*?(\d+)#",$colour,$match))
{
$colour = intval($match[1]);
}
else
{
$colour='??';
}
if ($err_code = strip_tags((isset($vals['err_direct']) ? $vals['err_direct'] : '')))
{
$ref = addslashes(strip_tags(isset($vals['err_referer']) ? $vals['err_referer'] : ''));
// Uncomment the next two lines to create a separate CSV format log of invalid accesses - error code, entered URL, referrer
// $log_string = $err_code.",".$self.",".$ref;
// $logfp = fopen(e_LOG."errpages.csv", 'a+'); fwrite($logfp, $log_string."\n\r"); fclose($logfp);
$err_code .= ':';
}
if(strstr($ref, 'admin'))
{
$ref = FALSE;
}
$screenstats = $res.'@'.$colour;
$agent = $_SERVER['HTTP_USER_AGENT'];
$ip = e107::getIPHandler()->ipDecode(USERIP);
$oldref = $ref; // backup for search string being stripped off for referer
if($ref && !strstr($ref, $_SERVER['HTTP_HOST']))
{
if(preg_match("#http://(.*?)($|/)#is", $ref, $match))
{
$ref = $match[0];
}
}
$pageDisallow = "cache|file|eself|admin";
$tagRemove = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)|(\.php)|(\.html)";
$tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)";
/*
function logGetPageKey($url,$logQry=false,$err_code='')
{
global $pageDisallow, $tagRemove;
preg_match("#/(.*?)(\?|$)(.*)#si", $url, $match);
$match[1] = isset($match[1]) ? $match[1] : '';
$pageName = substr($match[1], (strrpos($match[1], "/")+1));
$pageName = preg_replace("/".$tagRemove."/si", "", $pageName);
if($pageName == "")
{
return "index";
}
if(preg_match("/".$pageDisallow."/i", $pageName))
{
return false;
}
if ($logQry)
{
$pageName .= '+'.$match[3]; // All queries match
}
$pageName = $err_code.$pageName; // Add the error code at the beginning, so its treated uniquely
return $pageName;
}*/
require_once(e_PLUGIN."log/consolidate.php");
$lgc = new logConsolidate;
if(!$pageName = $lgc->getPageKey($self,false,$err_code,e_LAN))
{
if(LOGSTATS_DEBUG == true)
{
echo 'pageName was empty';
}
return;
}
if(LOGSTATS_DEBUG == true)
{
echo "<br />File: ".$logPfile;
}
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $pageName."\n"); fclose($logfp);
$p_handle = fopen($logPfile, 'r+');
if($p_handle && flock( $p_handle, LOCK_EX ) )
{
$log_file_contents = '';
while (!feof($p_handle)) // Assemble a string of data
{
$log_file_contents.= fgets($p_handle,1000);
}
$log_file_contents = str_replace(array('<'.'?php','?'.'>'),'',$log_file_contents);
if (eval($log_file_contents) === FALSE && getperms('0'))
{
echo "Error in log file contents: ".$logPfile;
}
}
elseif(getperms('0'))
{
echo "Couldn't log data to: ".$logPfile; // returned to js popup.
exit;
}
$flag = FALSE;
if(array_key_exists($pageName, $pageInfo))
{ // Existing page - just increment stats
$pageInfo[$pageName]['ttl'] ++;
}
else
{ // First access of page
$url = preg_replace("/".$tagRemove2."/si", "", $self);
if(preg_match("/".$pageDisallow."/i", $url)) return;
$pageInfo[$pageName] = array('url' => $url, 'ttl' => 1, 'unq' => 1);
$flag = TRUE;
}
if(!strstr($ipAddresses, $ip))
{ /* unique visit */
if(!$flag)
{
$pageInfo[$pageName]['unq'] ++;
}
$siteUnique ++;
$ipAddresses .= $ip."."; // IP address is stored as hex string
require_once('loginfo.php');
}
$siteTotal ++;
$info_data = var_export($pageInfo, true);
//$date_stamp = date("z:Y", time()); // Same as '$date' variable
$data = "<?php
/* e107 website system: Log file: {$date} */
\$ipAddresses = '{$ipAddresses}';
\$siteTotal = '{$siteTotal}';
\$siteUnique = '{$siteUnique}';
\$pageInfo = {$info_data};
?>";
if ($p_handle)
{
ftruncate($p_handle, 0 );
fseek( $p_handle, 0 );
fwrite($p_handle, $data);
fclose($p_handle);
}
if(LOGSTATS_DEBUG == true)
{
echo '<br />Script Completed';
}
<?php
/*
* e107 website system
*
* Copyright 2001-2013 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* Site access logging - 'receiver'
*/
/* File to log page accesses - called with
e_PLUGIN_ABS."log/log.php?base64encode(referer=' + ref + '&color=' + colord + '&eself=' + eself + '&res=' + res + '\">' );)";
referer= ref
color= colord
eself= eself
res= res
err_direct - optional error flag
err_referer - referrer if came via error page
qry = 1 to log query part as well
// Normally the file is 'silent' - if any errors occur, any error message appears in the page header.
*/
//error_reporting(0);
// error_reporting(E_ALL);
define('e_MINIMAL',true);
require_once("../../class2.php"); // More secure to include it.
header('Cache-Control: no-cache, must-revalidate'); // See if this discourages browser caching
header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
define('LOGSTATS_DEBUG', false);
// @example url: e107_plugins/log/log.php?lv=cmVmZXJlcj1odHRwJTNBLy9sb2NhbGhvc3QlM0E4MDgwL2UxMDdfMi4wL3N0YXRzJmNvbG91cj0yNCZlc2VsZj1odHRwJTNBLy9sb2NhbGhvc3QlM0E4MDgwL2UxMDdfMi4wL2UxMDdfcGx1Z2lucy9sb2cvc3RhdHMucGhwJTNGMiZyZXM9MTkyMHgxMjAw
if(LOGSTATS_DEBUG === true)
{
echo "Debug is Active";
}
if (!vartrue($pref['statActivate']))
{
if(LOGSTATS_DEBUG === true)
{
echo "Stats log is inactive";
}
exit();
}
//print_r(base64_decode($_GET['lv']));
define('LOGSTATS_INIT', true);
// Array of page names which should have individual query values recorded.
// The top level array index is the page name.
// If the top level value is an array, it must be an array of query string beginnings to match.
$pageUnique = array('page' => 1, 'content' => array('content'));
//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING']));
//$logVals = urldecode(base64_decode($_GET['lv']));
// --------------- Reworked for v2.x ------------------------
$logVals = base64_decode($_GET['lv']);
$logVals = filter_var($logVals, FILTER_SANITIZE_URL);
$logVals .= "&ip=".USERIP;
$logVals .= "&iphost=". @gethostbyaddr(USERIP);
$logVals .= "&lan=".e_LAN;
$logVals .= "&agent=".filter_var($_SERVER['HTTP_USER_AGENT'],FILTER_SANITIZE_STRING);
parse_str($logVals, $vals);
$vals['referer'] = urldecode($vals['referer']);
$vals['eself'] = urldecode($vals['eself']);
if(empty($_SESSION['log_userLoggedPages']) || !in_array($vals['eself'],$_SESSION['log_userLoggedPages']))
{
$_SESSION['log_userLoggedPages'][] = $vals['eself'];
$logVals .= "&unique=1";
}
else
{
$logVals .= "&unique=0";
}
$logVals = str_replace('%3A',':',$logVals); // make the URLs a bit cleaner, while keeping any urlqueries encoded.
$lg = e107::getAdminLog();
$lg->addDebug(print_r($logVals, true));
$lg->toFile('SiteStats','Statistics Log', true);
e107::getEvent()->trigger('user_log_stats',$vals);
// ------------------------------------ ---------------------
// We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1:
// @todo may be able to remove this check once minimum PHP version finalised
if (function_exists('date_default_timezone_get'))
{
date_default_timezone_set(@date_default_timezone_get()); // Just set a default - it should default to UTC if no timezone set
}
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logVals."\n"); fclose($logfp);
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, print_r($vals, TRUE)."\n"); fclose($logfp);
$colour = strip_tags((isset($vals['colour']) ? $vals['colour'] : ''));
$res = strip_tags((isset($vals['res']) ? $vals['res'] : ''));
$self = strip_tags((isset($vals['eself']) ? $vals['eself'] : ''));
$ref = addslashes(strip_tags((isset($vals['referer']) ? $vals['referer'] : '')));
$logQry = isset($vals['qry']) && $vals['qry'];
$date = date('z.Y', time());
$logPfile = e_LOG.'logp_'.$date.'.php';
//$logString = "Colour: {$colour} Res: {$res} Self: {$self} Referrer: {$ref} ErrCode: {$vals['err_direct']}\n";
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $logString); fclose($logfp);
// vet resolution and colour depth some more - avoid dud values
if ($res && preg_match("#.*?((\d+)\w+?(\d+))#", $res, $match))
{
$res = $match[2].'x'.$match[3];
}
else
{
$res = '??'; // Can't decode resolution
}
if ($colour && preg_match("#.*?(\d+)#",$colour,$match))
{
$colour = intval($match[1]);
}
else
{
$colour='??';
}
if ($err_code = strip_tags((isset($vals['err_direct']) ? $vals['err_direct'] : '')))
{
$ref = addslashes(strip_tags(isset($vals['err_referer']) ? $vals['err_referer'] : ''));
// Uncomment the next two lines to create a separate CSV format log of invalid accesses - error code, entered URL, referrer
// $log_string = $err_code.",".$self.",".$ref;
// $logfp = fopen(e_LOG."errpages.csv", 'a+'); fwrite($logfp, $log_string."\n\r"); fclose($logfp);
$err_code .= ':';
}
if(strstr($ref, 'admin'))
{
$ref = FALSE;
}
$screenstats = $res.'@'.$colour;
$agent = $_SERVER['HTTP_USER_AGENT'];
$ip = e107::getIPHandler()->ipDecode(USERIP);
$oldref = $ref; // backup for search string being stripped off for referer
if($ref && !strstr($ref, $_SERVER['HTTP_HOST']))
{
if(preg_match("#http://(.*?)($|/)#is", $ref, $match))
{
$ref = $match[0];
}
}
$pageDisallow = "cache|file|eself|admin";
$tagRemove = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)|(\.php)|(\.html)";
$tagRemove2 = "(\\\)|(\s)|(\')|(\")|(eself)|(&nbsp;)";
/*
function logGetPageKey($url,$logQry=false,$err_code='')
{
global $pageDisallow, $tagRemove;
preg_match("#/(.*?)(\?|$)(.*)#si", $url, $match);
$match[1] = isset($match[1]) ? $match[1] : '';
$pageName = substr($match[1], (strrpos($match[1], "/")+1));
$pageName = preg_replace("/".$tagRemove."/si", "", $pageName);
if($pageName == "")
{
return "index";
}
if(preg_match("/".$pageDisallow."/i", $pageName))
{
return false;
}
if ($logQry)
{
$pageName .= '+'.$match[3]; // All queries match
}
$pageName = $err_code.$pageName; // Add the error code at the beginning, so its treated uniquely
return $pageName;
}*/
require_once(e_PLUGIN."log/consolidate.php");
$lgc = new logConsolidate;
if(!$pageName = $lgc->getPageKey($self,false,$err_code,e_LAN))
{
if(LOGSTATS_DEBUG == true)
{
echo 'pageName was empty';
}
return;
}
if(LOGSTATS_DEBUG == true)
{
echo "<br />File: ".$logPfile;
}
//$logfp = fopen(e_LOG.'rcvstring.txt', 'a+'); fwrite($logfp, $pageName."\n"); fclose($logfp);
$p_handle = fopen($logPfile, 'r+');
if($p_handle && flock( $p_handle, LOCK_EX ) )
{
$log_file_contents = '';
while (!feof($p_handle)) // Assemble a string of data
{
$log_file_contents.= fgets($p_handle,1000);
}
$log_file_contents = str_replace(array('<'.'?php','?'.'>'),'',$log_file_contents);
if (eval($log_file_contents) === FALSE && getperms('0'))
{
echo "Error in log file contents: ".$logPfile;
}
}
elseif(getperms('0'))
{
echo "Couldn't log data to: ".$logPfile; // returned to js popup.
exit;
}
$flag = FALSE;
if(array_key_exists($pageName, $pageInfo))
{ // Existing page - just increment stats
$pageInfo[$pageName]['ttl'] ++;
}
else
{ // First access of page
$url = preg_replace("/".$tagRemove2."/si", "", $self);
if(preg_match("/".$pageDisallow."/i", $url)) return;
$pageInfo[$pageName] = array('url' => $url, 'ttl' => 1, 'unq' => 1);
$flag = TRUE;
}
if(!strstr($ipAddresses, $ip))
{ /* unique visit */
if(!$flag)
{
$pageInfo[$pageName]['unq'] ++;
}
$siteUnique ++;
$ipAddresses .= $ip."."; // IP address is stored as hex string
require_once('loginfo.php');
}
$siteTotal ++;
$info_data = var_export($pageInfo, true);
//$date_stamp = date("z:Y", time()); // Same as '$date' variable
$data = "<?php
/* e107 website system: Log file: {$date} */
\$ipAddresses = '{$ipAddresses}';
\$siteTotal = '{$siteTotal}';
\$siteUnique = '{$siteUnique}';
\$pageInfo = {$info_data};
?>";
if ($p_handle)
{
ftruncate($p_handle, 0 );
fseek( $p_handle, 0 );
fwrite($p_handle, $data);
fclose($p_handle);
}
if(LOGSTATS_DEBUG == true)
{
echo '<br />Script Completed';
}
?>

View File

@@ -1,7 +1,7 @@
CREATE TABLE logstats (
log_uniqueid int(11) NOT NULL auto_increment,
log_id varchar(50) NOT NULL default '',
log_data longtext NOT NULL,
PRIMARY KEY (log_uniqueid),
UNIQUE KEY log_id (log_id)
CREATE TABLE logstats (
log_uniqueid int(11) NOT NULL auto_increment,
log_id varchar(50) NOT NULL default '',
log_data longtext NOT NULL,
PRIMARY KEY (log_uniqueid),
UNIQUE KEY log_id (log_id)
) ENGINE=MyISAM;

View File

@@ -1,317 +1,317 @@
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*/
if (!defined('LOGSTATS_INIT')) { exit; }
$logIfile = e_LOG."logi_{$date}.php";
$i_handle = fopen($logIfile, 'r+');
if($i_handle && flock( $i_handle, LOCK_EX ) )
{
$log_file_contents = '';
while (!feof($i_handle))
{ // Assemble a string of data
$log_file_contents.= fgets($i_handle,1000);
}
$log_file_contents = str_replace(array('<'.'?php','?'.'>'),'',$log_file_contents);
if (eval($log_file_contents) === FALSE) echo "error in log file contents<br /><br /><br /><br />";
}
else
{
echo "Couldn't log data<br /><br /><br /><br />";
exit;
}
$browser = getBrowser($agent);
$os = getOs($agent);
if($screenstats && $screenstats != "@")
{
if(array_key_exists($screenstats, $screenInfo))
{
$screenInfo[$screenstats] ++;
}
else
{
$screenInfo[$screenstats] = 1;
}
}
if(array_key_exists($browser, $browserInfo))
{
$browserInfo[$browser] ++;
}
else
{
$browserInfo[$browser] = 1;
}
if(array_key_exists($os, $osInfo))
{
$osInfo[$os] ++;
}
else
{
$osInfo[$os] =1;
}
/* referer data ... */
if($ref && !strstr($ref, $_SERVER['HTTP_HOST']))
{
if(preg_match("#http://(.*?)($|/)#is", $ref, $match))
{
$refdom = $match[0];
if(array_key_exists($refdom, $refInfo))
{
$refInfo[$refdom]['ttl'] ++;
}
else
{
$refInfo[$refdom] = array('url' => $ref, 'ttl' => 1);
}
}
}
/* is the referal from Google? If so get search string ... */
if(preg_match("#q=(.*?)($|&)#is", $oldref, $match))
{
$schstr = trim($match[1]);
$schstr = htmlentities(urldecode($schstr));
if(array_key_exists($schstr, $searchInfo) && $schstr)
{
$searchInfo[$schstr] ++;
}
else
{
$searchInfo[$schstr] = 1;
}
}
if ($tmp = gethostbyaddr(getenv('REMOTE_ADDR')))
{
$host = trim(strtolower(substr($tmp, strrpos($tmp, ".")+1)));
if(!is_numeric($host) && !strstr($host, "calhost"))
{
if(array_key_exists($host, $domainInfo))
{
$domainInfo[$host] ++;
}
else
{
$domainInfo[$host] =1;
}
}
}
/* last 20 visitors */
if(count($visitInfo) >= 20)
{
$length = 20;
$offset = count($visitInfo)-$length;
$visitInfo = array_slice($visitInfo, $offset, $length);
}
$visitInfo[$tmp] = array(
'host' => trim($tmp),
'date' => time(),
'os' => trim($os),
'browser' => trim($browser),
'screen' => trim($screenstats),
'referer' => substr(trim($ref), 0, 255),
);
$data = "<?php
/* e107 website system: Log info file: ".date("z:Y", time())." */
";
$data .= '$domainInfo = '.var_export($domainInfo, true).";\n\n";
$data .= '$screenInfo = '.var_export($screenInfo, true).";\n\n";
$data .= '$browserInfo = '.var_export($browserInfo, true).";\n\n";
$data .= '$osInfo = '.var_export($osInfo, true).";\n\n";
$data .= '$refInfo = '.var_export($refInfo, true).";\n\n";
$data .= '$searchInfo = '.var_export($searchInfo, true).";\n\n";
$data .= '$visitInfo = '.var_export($visitInfo, true).";\n\n";
$data .= '?>';
if ($i_handle)
{
ftruncate($i_handle, 0);
fseek( $i_handle, 0 );
fwrite($i_handle, $data);
fclose($i_handle);
}
function getBrowser($agent)
{
//
// All "root" browsers must come at the end of the list, unfortunately.
// Otherwise, browsers based on them will never be seen.
//(But #1997)
// http://www.zytrax.com/tech/web/browser_ids.htm
$browsers = array(
"netcaptor" => array('name' => 'Netcaptor', 'rule' => 'netcaptor[ /]([0-9.]{1,10})'),
"opera" => array('name' => 'Opera Mini', 'rule' => 'Opera[ /]([0-9.]{1,10})(.*)Opera Mini'),
"opera1" => array('name' => 'Opera Mobile', 'rule' => 'Opera[ /]([0-9.]{1,10})(.*)Opera Mobi'),
"opera2" => array('name' => 'Opera', 'rule' => 'opera[ /]([0-9.]{1,10})'),
"chrome" => array('name' => 'Chrome', 'rule' => 'Chrome[ /]([0-9.+]{1,10})'),
"nokia" => array('name' => 'Nokia Browser', 'rule' => 'Nokia([^/]+)/([^ SP]+)'),
"nokia1" => array('name' => 'Nokia Browser', 'rule' => 'Series60|S60/([0-9.]{1,10})'),
"nokia2" => array('name' => 'Nokia Browser', 'rule' => 'Mozilla(.*)SymbianOS(.*)AppleWebKit'), // catch it or it'll become a safari hit!
"aol" => array('name' => 'AOL', 'rule' => 'aol[ /\-]([0-9.]{1,10})'),
"aol2" => array('name' => 'AOL', 'rule' => 'aol[ /\-]?browser'),
"mosaic" => array('name' => 'Mosaic', 'rule' => 'mosaic[ /]([0-9.]{1,10})'),
"k-meleon" => array('name' => 'K-Meleon', 'rule' => 'K-Meleon[ /]([0-9.]{1,10})'),
"konqueror" => array('name' => 'Konqueror', 'rule' => 'konqueror/([0-9.]{1,10})'),
"avantbrowser" => array('name' => 'Avant Browser', 'rule' => 'Avant[ ]?Browser'),
"avantgo" => array('name' => 'AvantGo', 'rule' => 'AvantGo[ /]([0-9.]{1,10})'),
"proxomitron" => array('name' => 'Proxomitron', 'rule' => 'Space[ ]?Bison/[0-9.]{1,10}'),
"lynx" => array('name' => 'Lynx', 'rule' => 'lynx/([0-9a-z.]{1,10})'),
"links" => array('name' => 'Links', 'rule' => 'Links[ /]\(([0-9.]{1,10})'),
"galeon" => array('name' => 'Galeon', 'rule' => 'galeon/([0-9.]{1,10})'),
"abrowse" => array('name' => 'ABrowse', 'rule' => 'abrowse/([0-9.]{1,10})'),
"amaya" => array('name' => 'Amaya', 'rule' => 'amaya/([0-9.]{1,10})'),
"ant" => array('name' => 'ANTFresco', 'rule' => 'ANTFresco[ /]([0-9.]{1,10})'),
"aweb" => array('name' => 'Aweb', 'rule' => 'Aweb[/ ]([0-9.]{1,10})'),
"beonex" => array('name' => 'Beonex', 'rule' => 'beonex/([0-9.]{1,10})'),
"blazer" => array('name' => 'Blazer', 'rule' => 'Blazer[/ ]([0-9.]{1,10})'),
"camino" => array('name' => 'Camino', 'rule' => 'camino/([0-9.+]{1,10})'),
"chimera" => array('name' => 'Chimera', 'rule' => 'chimera/([0-9.+]{1,10})'),
"columbus" => array('name' => 'Columbus', 'rule' => 'columbus[ /]([0-9.]{1,10})'),
"crazybrowser" => array('name' => 'Crazy Browser', 'rule' => 'Crazy Browser[ /]([0-9.]{1,10})'),
"curl" => array('name' => 'Curl', 'rule' => 'curl[ /]([0-9.]{1,10})'),
"deepnet" => array('name' => 'Deepnet Explorer', 'rule' => 'Deepnet Explorer[/ ]([0-9.]{1,10})'),
"dillo" => array('name' => 'Dillo', 'rule' => 'dillo/([0-9.]{1,10})'),
"doris" => array('name' => 'Doris', 'rule' => 'Doris/([0-9.]{1,10})'),
"elinks" => array('name' => 'ELinks', 'rule' => 'ELinks[ /][(]*([0-9.]{1,10})'),
"epiphany" => array('name' => 'Epiphany', 'rule' => 'Epiphany/([0-9.]{1,10})'),
"ibrowse" => array('name' => 'IBrowse', 'rule' => 'ibrowse[ /]([0-9.]{1,10})'),
"icab" => array('name' => 'iCab', 'rule' => 'icab[/ ]([0-9.]{1,10})'),
"ice" => array('name' => 'ICEbrowser', 'rule' => 'ICEbrowser/v?([0-9._]{1,10})'),
"isilox" => array('name' => 'iSiloX', 'rule' => 'iSilox/([0-9.]{1,10})'),
"lotus" => array('name' => 'Lotus Notes', 'rule' => 'Lotus[ -]?Notes[ /]([0-9.]{1,10})'),
"lunascape" => array('name' => 'Lunascape', 'rule' => 'Lunascape[ /]([0-9.]{1,10})'),
"maxthon" => array('name' => 'Maxthon', 'rule' => ' Maxthon[);]'),
"mbrowser" => array('name' => 'mBrowser', 'rule' => 'mBrowser[ /]([0-9.]{1,10})'),
"multibrowser" => array('name' => 'Multi-Browser', 'rule' => 'Multi-Browser[ /]([0-9.]{1,10})'),
"nautilus" => array('name' => 'Nautilus', 'rule' => '(gnome[ -]?vfs|nautilus)/([0-9.]{1,10})'),
"netfront" => array('name' => 'NetFront', 'rule' => 'NetFront[ /]([0-9.]{1,10})$'),
"netpositive" => array('name' => 'NetPositive', 'rule' => 'netpositive[ /]([0-9.]{1,10})'),
"omniweb" => array('name' => 'OmniWeb', 'rule' => 'omniweb/[ a-z]?([0-9.]{1,10})$'),
"oregano" => array('name' => 'Oregano', 'rule' => 'Oregano[0-9]?[ /]([0-9.]{1,10})$'),
"phaseout" => array('name' => 'PhaseOut', 'rule' => 'www.phaseout.net'),
"plink" => array('name' => 'PLink', 'rule' => 'PLink[ /]([0-9a-z.]{1,10})'),
"phoenix" => array('name' => 'Phoenix', 'rule' => 'Phoenix/([0-9.+]{1,10})'),
"proxomitron" => array('name' => 'Proxomitron', 'rule' => 'Space[ ]?Bison/[0-9.]{1,10}'),
"shiira" => array('name' => 'Shiira', 'rule' => 'Shiira/([0-9.]{1,10})'),
"sleipnir" => array('name' => 'Sleipnir', 'rule' => 'Sleipnir( Version)?[ /]([0-9.]{1,10})'),
"slimbrowser" => array('name' => 'SlimBrowser', 'rule' => 'Slimbrowser'),
"staroffice" => array('name' => 'StarOffice', 'rule' => 'staroffice[ /]([0-9.]{1,10})'),
"sunrise" => array('name' => 'Sunrise', 'rule' => 'SunriseBrowser[ /]([0-9.]{1,10})'),
"voyager" => array('name' => 'Voyager', 'rule' => 'voyager[ /]([0-9.]{1,10})'),
"w3m" => array('name' => 'w3m', 'rule' => 'w3m/([0-9.]{1,10})'),
"webtv" => array('name' => 'Webtv', 'rule' => 'webtv[ /]([0-9.]{1,10})'),
"xiino" => array('name' => 'Xiino', 'rule' => '^Xiino[ /]([0-9a-z.]{1,10})'),
"explorer" => array('name' => 'Internet Explorer', 'rule' => '\(compatible; MSIE[ /]([0-9.]{1,10})'),
"safari" => array('name' => 'Safari', 'rule' => 'safari/([0-9.]{1,10})'),
"firefox" => array('name' => 'Firefox', 'rule' => 'Firefox/([0-9.+]{1,10})'),
"netscape" => array('name' => 'Netscape', 'rule' => 'netscape[0-9]?/([0-9.]{1,10})'),
"netscape2" => array('name' => 'Netscape', 'rule' => '^mozilla/([0-4]\.[0-9.]{1,10})'),
"mozilla" => array('name' => 'Mozilla', 'rule' => '^mozilla/[5-9]\.[0-9.]{1,10}.+rv:([0-9a-z.+]{1,10})'),
"mozilla2" => array('name' => 'Mozilla', 'rule' => '^mozilla/([5-9]\.[0-9a-z.]{1,10})'),
"firebird" => array('name' => 'Firebird', 'rule' => 'Firebird/([0-9.+]{1,10})'),
);
$browser = "";
foreach($browsers as $key => $info)
{
if (preg_match("#".$info['rule']."#i", $agent, $results))
{
switch ($key)
{
case 'nokia':
case 'nokia1':
case 'nokia2':
if(strpos(strtolower($agent), 'series60') !== false || strpos($agent, 'S60') !== false )
{
$info['name'] = 'Nokia S60 OSS Browser';
}
return ($info['name'].(isset($results[2]) && $results[2] ? ' v'.$results[2] : ''));
break;
default:
return ($info['name'].(isset($results[1]) && $results[1] ? ' v'.$results[1] : ''));
break;
}
}
}
return ('Unknown');
}
function getOs($agent)
{
// http://www.zytrax.com/tech/web/browser_ids.htm
$os = array(
// mobile come first - latest rules could break the check
"android" => array('name' => 'Android', 'rule' => 'Android\s([0-9.]{1,10})'),
"symbian" => array('name' => 'Symbian', 'rule' => 'symbianOS[ /]?([0-9.]{1,10})'),
"symbian1" => array('name' => 'Symbian', 'rule' => 'series60[ /]'),
"symbian2" => array('name' => 'Symbian', 'rule' => 'Symbian OS Series'),
"windows7" => array('name' => 'Windows 7', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?6\.1'),
"windowsvista" => array('name' => 'Windows Vista', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?6\.0'),
"windows2003" => array('name' => 'Windows 2003', 'rule' => 'wi(n|ndows)[ \-]?(2003|nt[ /]?5\.2)'),
"windowsxp" => array('name' => 'Windows XP', 'rule' => 'Windows XP'),
"windowsxp2" => array('name' => 'Windows XP', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?5\.1'),
"windows2k" => array('name' => 'Windows 2000', 'rule' => 'wi(n|ndows)[ \-]?(2000|nt[ /]?5\.0)'),
"windows95" => array('name' => 'Windows 95', 'rule' => 'wi(n|ndows)[ \-]?95'),
"windowsce" => array('name' => 'Windows CE', 'rule' => 'wi(n|ndows)[ \-]?ce'),
"windowsme" => array('name' => 'Windows ME', 'rule' => 'win 9x 4\.90'),
"windowsme2" => array('name' => 'Windows ME', 'rule' => 'wi(n|ndows)[ \-]?me'),
"windowsnt" => array('name' => 'Windows NT', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?([0-4][0-9.]{1,10})'),
"windowsnt2" => array('name' => 'Windows NT', 'rule' => 'wi(n|ndows)[ \-]?nt'),
"windows98" => array('name' => 'Windows 98', 'rule' => 'wi(n|ndows)[ \-]?98'),
"windows" => array('name' => 'Windows', 'rule' => 'wi(n|n32|ndows)'),
"linux" => array('name' => 'Linux', 'rule' => 'mdk for ([0-9.]{1,10})'),
"linux2" => array('name' => 'Linux', 'rule' => 'linux[ /\-]([a-z0-9.]{1,10})'),
"linux3" => array('name' => 'Linux', 'rule' => 'linux'),
"macosx" => array('name' => 'MacOS X', 'rule' => 'Mac[ ]?OS[ ]?X'),
"macppc" => array('name' => 'MacOS PPC', 'rule' => 'Mac(_Power|intosh.+P)PC'),
"mac" => array('name' => 'MacOS', 'rule' => 'mac[^hk]'),
"amiga" => array('name' => 'Amiga', 'rule' => 'Amiga[ ]?OS[ /]([0-9.]{1,10})'),
"beos" => array('name' => 'BeOS', 'rule' => 'beos[ a-z]*([0-9.]{1,10})'),
"freebsd" => array('name' => 'FreeBSD', 'rule' => 'free[ \-]?bsd[ /]([a-z0-9.]{1,10})'),
"freebsd2" => array('name' => 'FreeBSD', 'rule' => 'free[ \-]?bsd'),
"irix" => array('name' => 'Irix', 'rule' => 'irix[0-9]*[ /]([0-9.]{1,10})'),
"netbsd" => array('name' => 'NetBSD', 'rule' => 'net[ \-]?bsd[ /]([a-z0-9.]{1,10})'),
"netbsd2" => array('name' => 'NetBSD', 'rule' => 'net[ \-]?bsd'),
"os2" => array('name' => 'OS/2 Warp', 'rule' => 'warp[ /]?([0-9.]{1,10})'),
"os22" => array('name' => 'OS/2 Warp', 'rule' => 'os[ /]?2'),
"openbsd" => array('name' => 'OpenBSD', 'rule' => 'open[ \-]?bsd[ /]([a-z0-9.]{1,10})'),
"openbsd2" => array('name' => 'OpenBSD', 'rule' => 'open[ \-]?bsd'),
"palm" => array('name' => 'PalmOS', 'rule' => 'Palm[ \-]?(Source|OS)[ /]?([0-9.]{1,10})'),
"palm2" => array('name' => 'PalmOS', 'rule' => 'Palm[ \-]?(Source|OS)')
);
foreach($os as $key => $info)
{
if (preg_match("#".$info['rule']."#i", $agent, $results))
{
if(strstr($key, "win"))
{
return ($info['name']);
}
else
{
return ($info['name']." ".$results[1]);
}
}
}
return ('Unspecified');
}
<?php
/*
* e107 website system
*
* Copyright (C) 2008-2010 e107 Inc (e107.org)
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* $Id$
*/
if (!defined('LOGSTATS_INIT')) { exit; }
$logIfile = e_LOG."logi_{$date}.php";
$i_handle = fopen($logIfile, 'r+');
if($i_handle && flock( $i_handle, LOCK_EX ) )
{
$log_file_contents = '';
while (!feof($i_handle))
{ // Assemble a string of data
$log_file_contents.= fgets($i_handle,1000);
}
$log_file_contents = str_replace(array('<'.'?php','?'.'>'),'',$log_file_contents);
if (eval($log_file_contents) === FALSE) echo "error in log file contents<br /><br /><br /><br />";
}
else
{
echo "Couldn't log data<br /><br /><br /><br />";
exit;
}
$browser = getBrowser($agent);
$os = getOs($agent);
if($screenstats && $screenstats != "@")
{
if(array_key_exists($screenstats, $screenInfo))
{
$screenInfo[$screenstats] ++;
}
else
{
$screenInfo[$screenstats] = 1;
}
}
if(array_key_exists($browser, $browserInfo))
{
$browserInfo[$browser] ++;
}
else
{
$browserInfo[$browser] = 1;
}
if(array_key_exists($os, $osInfo))
{
$osInfo[$os] ++;
}
else
{
$osInfo[$os] =1;
}
/* referer data ... */
if($ref && !strstr($ref, $_SERVER['HTTP_HOST']))
{
if(preg_match("#http://(.*?)($|/)#is", $ref, $match))
{
$refdom = $match[0];
if(array_key_exists($refdom, $refInfo))
{
$refInfo[$refdom]['ttl'] ++;
}
else
{
$refInfo[$refdom] = array('url' => $ref, 'ttl' => 1);
}
}
}
/* is the referal from Google? If so get search string ... */
if(preg_match("#q=(.*?)($|&)#is", $oldref, $match))
{
$schstr = trim($match[1]);
$schstr = htmlentities(urldecode($schstr));
if(array_key_exists($schstr, $searchInfo) && $schstr)
{
$searchInfo[$schstr] ++;
}
else
{
$searchInfo[$schstr] = 1;
}
}
if ($tmp = gethostbyaddr(getenv('REMOTE_ADDR')))
{
$host = trim(strtolower(substr($tmp, strrpos($tmp, ".")+1)));
if(!is_numeric($host) && !strstr($host, "calhost"))
{
if(array_key_exists($host, $domainInfo))
{
$domainInfo[$host] ++;
}
else
{
$domainInfo[$host] =1;
}
}
}
/* last 20 visitors */
if(count($visitInfo) >= 20)
{
$length = 20;
$offset = count($visitInfo)-$length;
$visitInfo = array_slice($visitInfo, $offset, $length);
}
$visitInfo[$tmp] = array(
'host' => trim($tmp),
'date' => time(),
'os' => trim($os),
'browser' => trim($browser),
'screen' => trim($screenstats),
'referer' => substr(trim($ref), 0, 255),
);
$data = "<?php
/* e107 website system: Log info file: ".date("z:Y", time())." */
";
$data .= '$domainInfo = '.var_export($domainInfo, true).";\n\n";
$data .= '$screenInfo = '.var_export($screenInfo, true).";\n\n";
$data .= '$browserInfo = '.var_export($browserInfo, true).";\n\n";
$data .= '$osInfo = '.var_export($osInfo, true).";\n\n";
$data .= '$refInfo = '.var_export($refInfo, true).";\n\n";
$data .= '$searchInfo = '.var_export($searchInfo, true).";\n\n";
$data .= '$visitInfo = '.var_export($visitInfo, true).";\n\n";
$data .= '?>';
if ($i_handle)
{
ftruncate($i_handle, 0);
fseek( $i_handle, 0 );
fwrite($i_handle, $data);
fclose($i_handle);
}
function getBrowser($agent)
{
//
// All "root" browsers must come at the end of the list, unfortunately.
// Otherwise, browsers based on them will never be seen.
//(But #1997)
// http://www.zytrax.com/tech/web/browser_ids.htm
$browsers = array(
"netcaptor" => array('name' => 'Netcaptor', 'rule' => 'netcaptor[ /]([0-9.]{1,10})'),
"opera" => array('name' => 'Opera Mini', 'rule' => 'Opera[ /]([0-9.]{1,10})(.*)Opera Mini'),
"opera1" => array('name' => 'Opera Mobile', 'rule' => 'Opera[ /]([0-9.]{1,10})(.*)Opera Mobi'),
"opera2" => array('name' => 'Opera', 'rule' => 'opera[ /]([0-9.]{1,10})'),
"chrome" => array('name' => 'Chrome', 'rule' => 'Chrome[ /]([0-9.+]{1,10})'),
"nokia" => array('name' => 'Nokia Browser', 'rule' => 'Nokia([^/]+)/([^ SP]+)'),
"nokia1" => array('name' => 'Nokia Browser', 'rule' => 'Series60|S60/([0-9.]{1,10})'),
"nokia2" => array('name' => 'Nokia Browser', 'rule' => 'Mozilla(.*)SymbianOS(.*)AppleWebKit'), // catch it or it'll become a safari hit!
"aol" => array('name' => 'AOL', 'rule' => 'aol[ /\-]([0-9.]{1,10})'),
"aol2" => array('name' => 'AOL', 'rule' => 'aol[ /\-]?browser'),
"mosaic" => array('name' => 'Mosaic', 'rule' => 'mosaic[ /]([0-9.]{1,10})'),
"k-meleon" => array('name' => 'K-Meleon', 'rule' => 'K-Meleon[ /]([0-9.]{1,10})'),
"konqueror" => array('name' => 'Konqueror', 'rule' => 'konqueror/([0-9.]{1,10})'),
"avantbrowser" => array('name' => 'Avant Browser', 'rule' => 'Avant[ ]?Browser'),
"avantgo" => array('name' => 'AvantGo', 'rule' => 'AvantGo[ /]([0-9.]{1,10})'),
"proxomitron" => array('name' => 'Proxomitron', 'rule' => 'Space[ ]?Bison/[0-9.]{1,10}'),
"lynx" => array('name' => 'Lynx', 'rule' => 'lynx/([0-9a-z.]{1,10})'),
"links" => array('name' => 'Links', 'rule' => 'Links[ /]\(([0-9.]{1,10})'),
"galeon" => array('name' => 'Galeon', 'rule' => 'galeon/([0-9.]{1,10})'),
"abrowse" => array('name' => 'ABrowse', 'rule' => 'abrowse/([0-9.]{1,10})'),
"amaya" => array('name' => 'Amaya', 'rule' => 'amaya/([0-9.]{1,10})'),
"ant" => array('name' => 'ANTFresco', 'rule' => 'ANTFresco[ /]([0-9.]{1,10})'),
"aweb" => array('name' => 'Aweb', 'rule' => 'Aweb[/ ]([0-9.]{1,10})'),
"beonex" => array('name' => 'Beonex', 'rule' => 'beonex/([0-9.]{1,10})'),
"blazer" => array('name' => 'Blazer', 'rule' => 'Blazer[/ ]([0-9.]{1,10})'),
"camino" => array('name' => 'Camino', 'rule' => 'camino/([0-9.+]{1,10})'),
"chimera" => array('name' => 'Chimera', 'rule' => 'chimera/([0-9.+]{1,10})'),
"columbus" => array('name' => 'Columbus', 'rule' => 'columbus[ /]([0-9.]{1,10})'),
"crazybrowser" => array('name' => 'Crazy Browser', 'rule' => 'Crazy Browser[ /]([0-9.]{1,10})'),
"curl" => array('name' => 'Curl', 'rule' => 'curl[ /]([0-9.]{1,10})'),
"deepnet" => array('name' => 'Deepnet Explorer', 'rule' => 'Deepnet Explorer[/ ]([0-9.]{1,10})'),
"dillo" => array('name' => 'Dillo', 'rule' => 'dillo/([0-9.]{1,10})'),
"doris" => array('name' => 'Doris', 'rule' => 'Doris/([0-9.]{1,10})'),
"elinks" => array('name' => 'ELinks', 'rule' => 'ELinks[ /][(]*([0-9.]{1,10})'),
"epiphany" => array('name' => 'Epiphany', 'rule' => 'Epiphany/([0-9.]{1,10})'),
"ibrowse" => array('name' => 'IBrowse', 'rule' => 'ibrowse[ /]([0-9.]{1,10})'),
"icab" => array('name' => 'iCab', 'rule' => 'icab[/ ]([0-9.]{1,10})'),
"ice" => array('name' => 'ICEbrowser', 'rule' => 'ICEbrowser/v?([0-9._]{1,10})'),
"isilox" => array('name' => 'iSiloX', 'rule' => 'iSilox/([0-9.]{1,10})'),
"lotus" => array('name' => 'Lotus Notes', 'rule' => 'Lotus[ -]?Notes[ /]([0-9.]{1,10})'),
"lunascape" => array('name' => 'Lunascape', 'rule' => 'Lunascape[ /]([0-9.]{1,10})'),
"maxthon" => array('name' => 'Maxthon', 'rule' => ' Maxthon[);]'),
"mbrowser" => array('name' => 'mBrowser', 'rule' => 'mBrowser[ /]([0-9.]{1,10})'),
"multibrowser" => array('name' => 'Multi-Browser', 'rule' => 'Multi-Browser[ /]([0-9.]{1,10})'),
"nautilus" => array('name' => 'Nautilus', 'rule' => '(gnome[ -]?vfs|nautilus)/([0-9.]{1,10})'),
"netfront" => array('name' => 'NetFront', 'rule' => 'NetFront[ /]([0-9.]{1,10})$'),
"netpositive" => array('name' => 'NetPositive', 'rule' => 'netpositive[ /]([0-9.]{1,10})'),
"omniweb" => array('name' => 'OmniWeb', 'rule' => 'omniweb/[ a-z]?([0-9.]{1,10})$'),
"oregano" => array('name' => 'Oregano', 'rule' => 'Oregano[0-9]?[ /]([0-9.]{1,10})$'),
"phaseout" => array('name' => 'PhaseOut', 'rule' => 'www.phaseout.net'),
"plink" => array('name' => 'PLink', 'rule' => 'PLink[ /]([0-9a-z.]{1,10})'),
"phoenix" => array('name' => 'Phoenix', 'rule' => 'Phoenix/([0-9.+]{1,10})'),
"proxomitron" => array('name' => 'Proxomitron', 'rule' => 'Space[ ]?Bison/[0-9.]{1,10}'),
"shiira" => array('name' => 'Shiira', 'rule' => 'Shiira/([0-9.]{1,10})'),
"sleipnir" => array('name' => 'Sleipnir', 'rule' => 'Sleipnir( Version)?[ /]([0-9.]{1,10})'),
"slimbrowser" => array('name' => 'SlimBrowser', 'rule' => 'Slimbrowser'),
"staroffice" => array('name' => 'StarOffice', 'rule' => 'staroffice[ /]([0-9.]{1,10})'),
"sunrise" => array('name' => 'Sunrise', 'rule' => 'SunriseBrowser[ /]([0-9.]{1,10})'),
"voyager" => array('name' => 'Voyager', 'rule' => 'voyager[ /]([0-9.]{1,10})'),
"w3m" => array('name' => 'w3m', 'rule' => 'w3m/([0-9.]{1,10})'),
"webtv" => array('name' => 'Webtv', 'rule' => 'webtv[ /]([0-9.]{1,10})'),
"xiino" => array('name' => 'Xiino', 'rule' => '^Xiino[ /]([0-9a-z.]{1,10})'),
"explorer" => array('name' => 'Internet Explorer', 'rule' => '\(compatible; MSIE[ /]([0-9.]{1,10})'),
"safari" => array('name' => 'Safari', 'rule' => 'safari/([0-9.]{1,10})'),
"firefox" => array('name' => 'Firefox', 'rule' => 'Firefox/([0-9.+]{1,10})'),
"netscape" => array('name' => 'Netscape', 'rule' => 'netscape[0-9]?/([0-9.]{1,10})'),
"netscape2" => array('name' => 'Netscape', 'rule' => '^mozilla/([0-4]\.[0-9.]{1,10})'),
"mozilla" => array('name' => 'Mozilla', 'rule' => '^mozilla/[5-9]\.[0-9.]{1,10}.+rv:([0-9a-z.+]{1,10})'),
"mozilla2" => array('name' => 'Mozilla', 'rule' => '^mozilla/([5-9]\.[0-9a-z.]{1,10})'),
"firebird" => array('name' => 'Firebird', 'rule' => 'Firebird/([0-9.+]{1,10})'),
);
$browser = "";
foreach($browsers as $key => $info)
{
if (preg_match("#".$info['rule']."#i", $agent, $results))
{
switch ($key)
{
case 'nokia':
case 'nokia1':
case 'nokia2':
if(strpos(strtolower($agent), 'series60') !== false || strpos($agent, 'S60') !== false )
{
$info['name'] = 'Nokia S60 OSS Browser';
}
return ($info['name'].(isset($results[2]) && $results[2] ? ' v'.$results[2] : ''));
break;
default:
return ($info['name'].(isset($results[1]) && $results[1] ? ' v'.$results[1] : ''));
break;
}
}
}
return ('Unknown');
}
function getOs($agent)
{
// http://www.zytrax.com/tech/web/browser_ids.htm
$os = array(
// mobile come first - latest rules could break the check
"android" => array('name' => 'Android', 'rule' => 'Android\s([0-9.]{1,10})'),
"symbian" => array('name' => 'Symbian', 'rule' => 'symbianOS[ /]?([0-9.]{1,10})'),
"symbian1" => array('name' => 'Symbian', 'rule' => 'series60[ /]'),
"symbian2" => array('name' => 'Symbian', 'rule' => 'Symbian OS Series'),
"windows7" => array('name' => 'Windows 7', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?6\.1'),
"windowsvista" => array('name' => 'Windows Vista', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?6\.0'),
"windows2003" => array('name' => 'Windows 2003', 'rule' => 'wi(n|ndows)[ \-]?(2003|nt[ /]?5\.2)'),
"windowsxp" => array('name' => 'Windows XP', 'rule' => 'Windows XP'),
"windowsxp2" => array('name' => 'Windows XP', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?5\.1'),
"windows2k" => array('name' => 'Windows 2000', 'rule' => 'wi(n|ndows)[ \-]?(2000|nt[ /]?5\.0)'),
"windows95" => array('name' => 'Windows 95', 'rule' => 'wi(n|ndows)[ \-]?95'),
"windowsce" => array('name' => 'Windows CE', 'rule' => 'wi(n|ndows)[ \-]?ce'),
"windowsme" => array('name' => 'Windows ME', 'rule' => 'win 9x 4\.90'),
"windowsme2" => array('name' => 'Windows ME', 'rule' => 'wi(n|ndows)[ \-]?me'),
"windowsnt" => array('name' => 'Windows NT', 'rule' => 'wi(n|ndows)[ \-]?nt[ /]?([0-4][0-9.]{1,10})'),
"windowsnt2" => array('name' => 'Windows NT', 'rule' => 'wi(n|ndows)[ \-]?nt'),
"windows98" => array('name' => 'Windows 98', 'rule' => 'wi(n|ndows)[ \-]?98'),
"windows" => array('name' => 'Windows', 'rule' => 'wi(n|n32|ndows)'),
"linux" => array('name' => 'Linux', 'rule' => 'mdk for ([0-9.]{1,10})'),
"linux2" => array('name' => 'Linux', 'rule' => 'linux[ /\-]([a-z0-9.]{1,10})'),
"linux3" => array('name' => 'Linux', 'rule' => 'linux'),
"macosx" => array('name' => 'MacOS X', 'rule' => 'Mac[ ]?OS[ ]?X'),
"macppc" => array('name' => 'MacOS PPC', 'rule' => 'Mac(_Power|intosh.+P)PC'),
"mac" => array('name' => 'MacOS', 'rule' => 'mac[^hk]'),
"amiga" => array('name' => 'Amiga', 'rule' => 'Amiga[ ]?OS[ /]([0-9.]{1,10})'),
"beos" => array('name' => 'BeOS', 'rule' => 'beos[ a-z]*([0-9.]{1,10})'),
"freebsd" => array('name' => 'FreeBSD', 'rule' => 'free[ \-]?bsd[ /]([a-z0-9.]{1,10})'),
"freebsd2" => array('name' => 'FreeBSD', 'rule' => 'free[ \-]?bsd'),
"irix" => array('name' => 'Irix', 'rule' => 'irix[0-9]*[ /]([0-9.]{1,10})'),
"netbsd" => array('name' => 'NetBSD', 'rule' => 'net[ \-]?bsd[ /]([a-z0-9.]{1,10})'),
"netbsd2" => array('name' => 'NetBSD', 'rule' => 'net[ \-]?bsd'),
"os2" => array('name' => 'OS/2 Warp', 'rule' => 'warp[ /]?([0-9.]{1,10})'),
"os22" => array('name' => 'OS/2 Warp', 'rule' => 'os[ /]?2'),
"openbsd" => array('name' => 'OpenBSD', 'rule' => 'open[ \-]?bsd[ /]([a-z0-9.]{1,10})'),
"openbsd2" => array('name' => 'OpenBSD', 'rule' => 'open[ \-]?bsd'),
"palm" => array('name' => 'PalmOS', 'rule' => 'Palm[ \-]?(Source|OS)[ /]?([0-9.]{1,10})'),
"palm2" => array('name' => 'PalmOS', 'rule' => 'Palm[ \-]?(Source|OS)')
);
foreach($os as $key => $info)
{
if (preg_match("#".$info['rule']."#i", $agent, $results))
{
if(strstr($key, "win"))
{
return ($info['name']);
}
else
{
return ($info['name']." ".$results[1]);
}
}
}
return ('Unspecified');
}