1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-06 06:38:00 +02:00

Log Plugin improvements/fixes - now uses jQuery

This commit is contained in:
Cameron
2012-12-04 17:00:40 -08:00
parent b03275934b
commit eaac6875e9
5 changed files with 1467 additions and 55 deletions

View File

@@ -15,7 +15,7 @@
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
if (isset($pref['statActivate']) && $pref['statActivate']) if (vartrue($pref['statActivate']))
{ {
if(!$pref['statCountAdmin'] && ADMIN) if(!$pref['statCountAdmin'] && ADMIN)
{ {
@@ -31,10 +31,12 @@ if (isset($pref['statActivate']) && $pref['statActivate'])
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 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']; $err_flag .= "&err_referer=".$_SERVER['HTTP_REFERER'];
} }
/*
$logJS = " $logJS = "
function rstr2b64(input) function rstr2b64(input)
{ {
var b64pad = \"=\"; /* base-64 pad character. \"=\" for strict RFC compliance */ var b64pad = \"=\"; // base-64 pad character. \"=\" for strict RFC compliance
var tab = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\"; var tab = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/\";
var output = \"\"; var output = \"\";
var len = input.length; var len = input.length;
@@ -59,6 +61,7 @@ logString = rstr2b64(logString);
document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"".e_PLUGIN_ABS."log/log.php?lv='+logString + '\">' ); document.write('<link rel=\"stylesheet\" type=\"text/css\" href=\"".e_PLUGIN_ABS."log/log.php?lv='+logString + '\">' );
"; ";
*/
$logJS = " $logJS = "
@@ -102,7 +105,7 @@ $(function() {
url: url, url: url,
data: {'lv' :logString}, data: {'lv' :logString},
success: function() { success: function() {
alert(logString); // alert(logString);
} }
}); });
}); });

File diff suppressed because it is too large Load Diff

View File

@@ -26,6 +26,14 @@
// Normally the file is 'silent' - if any errors occur, not sure where they'll appear - (file type now text/html instead of text/css) // Normally the file is 'silent' - if any errors occur, not sure where they'll appear - (file type now text/html instead of text/css)
*/ */
//error_reporting(0); //error_reporting(0);
$_E107['minimum'] = true;
require_once("../../class2.php");
if (!e107::isInstalled('log'))
{
header('Location: '.e_BASE.'index.php');
exit;
}
define('log_INIT', TRUE); define('log_INIT', TRUE);
// Array of page names which should have individual query values recorded. // Array of page names which should have individual query values recorded.
@@ -35,7 +43,11 @@ $pageUnique = array('page' => 1, 'content' => array('content'));
//$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING'])); //$logVals = urldecode(base64_decode($_SERVER['QUERY_STRING']));
$logVals = urldecode(base64_decode($_GET['lv'])); $logVals = urldecode(base64_decode($_GET['lv']));
file_put_contents(e_LOG."test.log",print_r($logVals,true)); // , FILE_APPEND | LOCK_EX
parse_str($logVals, $vals); parse_str($logVals, $vals);
// We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1: // We MUST have a timezone set in PHP >= 5.3. This should work for PHP >= 5.1:
@@ -61,7 +73,7 @@ $ref = addslashes(strip_tags((isset($vals['referer']) ? $vals['referer'] : '')))
$logQry = isset($vals['qry']) && $vals['qry']; $logQry = isset($vals['qry']) && $vals['qry'];
$date = date('z.Y', time()); $date = date('z.Y', time());
$logPfile = 'logs/logp_'.$date.'.php'; $logPfile = e_LOG.'logp_'.$date.'.php';
//$logString = "Colour: {$colour} Res: {$res} Self: {$self} Referrer: {$ref} ErrCode: {$vals['err_direct']}\n"; //$logString = "Colour: {$colour} Res: {$res} Self: {$self} Referrer: {$ref} ErrCode: {$vals['err_direct']}\n";
//$logfp = fopen('logs/rcvstring.txt', 'a+'); fwrite($logfp, $logString); fclose($logfp); //$logfp = fopen('logs/rcvstring.txt', 'a+'); fwrite($logfp, $logString); fclose($logfp);
@@ -204,63 +216,65 @@ if ($p_handle)
// Get current IP address - return as a hex-encoded string // Get current IP address - return as a hex-encoded string
function getip() if(!function_exists('getip'))
{ {
$ip = $_SERVER['REMOTE_ADDR']; function getip()
if (getenv('HTTP_X_FORWARDED_FOR'))
{ {
if (preg_match("#^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})#", getenv('HTTP_X_FORWARDED_FOR'), $ip3)) $ip = $_SERVER['REMOTE_ADDR'];
{ if (getenv('HTTP_X_FORWARDED_FOR'))
$ip2 = array('#^0\..*#',
'#^127\..*#', // Local loopbacks
'#^192\.168\..*#', // RFC1918 - Private Network
'#^172\.(?:1[6789]|2\d|3[01])\..*#', // RFC1918 - Private network
'#^10\..*#', // RFC1918 - Private Network
'#^169\.254\..*#', // RFC3330 - Link-local, auto-DHCP
'#^2(?:2[456789]|[345][0-9])\..*#' // Single check for Class D and Class E
);
$ip = preg_replace($ip2, $ip, $ip3[1]);
}
}
if ($ip == "")
{
$ip = "x.x.x.x";
}
if (strpos($ip, ':') === FALSE)
{ // Its an IPV4 address - return it as 32-character packed hex string
$ipa = explode(".", $ip);
return str_repeat('0000',5).'ffff'.sprintf('%02x%02x%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]);
}
else
{ // Its IPV6
if (strpos($ip,'.') !== FALSE)
{ // IPV4 'tail' to deal with
$temp = strrpos($ip,':') +1;
$ipa = explode('.',substr($ip,$temp));
$ip = substr($ip,0, $temp).sprintf('%02x%02x:%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]);
}
// Now 'normalise' the address
$temp = explode(':',$ip);
$s = 8 - count($temp); // One element will of course be the blank
foreach ($temp as $f)
{ {
if ($f == '') if (preg_match("#^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})#", getenv('HTTP_X_FORWARDED_FOR'), $ip3))
{
$ip2 = array('#^0\..*#',
'#^127\..*#', // Local loopbacks
'#^192\.168\..*#', // RFC1918 - Private Network
'#^172\.(?:1[6789]|2\d|3[01])\..*#', // RFC1918 - Private network
'#^10\..*#', // RFC1918 - Private Network
'#^169\.254\..*#', // RFC3330 - Link-local, auto-DHCP
'#^2(?:2[456789]|[345][0-9])\..*#' // Single check for Class D and Class E
);
$ip = preg_replace($ip2, $ip, $ip3[1]);
}
}
if ($ip == "")
{
$ip = "x.x.x.x";
}
if (strpos($ip, ':') === FALSE)
{ // Its an IPV4 address - return it as 32-character packed hex string
$ipa = explode(".", $ip);
return str_repeat('0000',5).'ffff'.sprintf('%02x%02x%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]);
}
else
{ // Its IPV6
if (strpos($ip,'.') !== FALSE)
{ // IPV4 'tail' to deal with
$temp = strrpos($ip,':') +1;
$ipa = explode('.',substr($ip,$temp));
$ip = substr($ip,0, $temp).sprintf('%02x%02x:%02x%02x', $ipa[0], $ipa[1], $ipa[2], $ipa[3]);
}
// Now 'normalise' the address
$temp = explode(':',$ip);
$s = 8 - count($temp); // One element will of course be the blank
foreach ($temp as $f)
{ {
$ret .= '0000'; // Always put in one set of zeros for the blank if ($f == '')
if ($s > 0)
{ {
$ret .= str_repeat('0000',$s); $ret .= '0000'; // Always put in one set of zeros for the blank
$s = 0; if ($s > 0)
{
$ret .= str_repeat('0000',$s);
$s = 0;
}
}
else
{
$ret .= sprintf('%04x',hexdec($f));
} }
} }
else return $ret;
{
$ret .= sprintf('%04x',hexdec($f));
}
} }
return $ret;
} }
} }
?> ?>

View File

@@ -11,7 +11,7 @@
if (!defined('log_INIT')) { exit; } if (!defined('log_INIT')) { exit; }
$logIfile = "logs/logi_{$date}.php"; $logIfile = e_LOG."logi_{$date}.php";
$i_handle = fopen($logIfile, 'r+'); $i_handle = fopen($logIfile, 'r+');
if($i_handle && flock( $i_handle, LOCK_EX ) ) if($i_handle && flock( $i_handle, LOCK_EX ) )
{ {

View File

@@ -1181,6 +1181,8 @@ class siteStats
if (!is_array($selection)) $selection = array(1); if (!is_array($selection)) $selection = array(1);
$text = ''; $text = '';
foreach ($selection as $act) foreach ($selection as $act)
{ {
unset($statBrowser); unset($statBrowser);
@@ -1250,7 +1252,7 @@ class siteStats
} }
$total = array_sum($browserArray); $total = array_sum($browserArray);
$text .= "<table class='fborder' style='width: 100%;'>\n $text .= "<table class='fborder' style='width: 100%;'>\n
<tr><td class='fcaption' colspan='4' style='text-align:center'>".$this->browser_headings[$act].$pars['hdg_extra']."</td></tr>\n <tr><td class='fcaption' colspan='4' style='text-align:center'>".$this->browser_headings[$act].$pars['hdg_extra']."</td></tr>\n
<tr><td class='fcaption' style='width: 20%;'> <tr><td class='fcaption' style='width: 20%;'>
@@ -1901,6 +1903,8 @@ class siteStats
$utotal += $fvalue['unq']; $utotal += $fvalue['unq'];
} }
print_a($dayarray);;
$text = "<table class='fborder' style='width: 100%;'>\n<tr>\n<td class='fcaption' style='width: 30%;'>".ADSTAT_L33." ".($amount+1)." ".ADSTAT_L40."</td>\n<td class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L34."</td>\n</tr>\n"; $text = "<table class='fborder' style='width: 100%;'>\n<tr>\n<td class='fcaption' style='width: 30%;'>".ADSTAT_L33." ".($amount+1)." ".ADSTAT_L40."</td>\n<td class='fcaption' style='width: 70%;' colspan='2'>".ADSTAT_L34."</td>\n</tr>\n";
foreach($dayarray as $date => $total) foreach($dayarray as $date => $total)