diff --git a/e107_plugins/log/e_meta.php b/e107_plugins/log/e_meta.php index b04ca5606..faf3a08de 100644 --- a/e107_plugins/log/e_meta.php +++ b/e107_plugins/log/e_meta.php @@ -15,7 +15,7 @@ if (!defined('e107_INIT')) { exit; } -if (isset($pref['statActivate']) && $pref['statActivate']) +if (vartrue($pref['statActivate'])) { 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 $err_flag .= "&err_referer=".$_SERVER['HTTP_REFERER']; } + + /* $logJS = " 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 output = \"\"; var len = input.length; @@ -59,6 +61,7 @@ logString = rstr2b64(logString); document.write('' ); "; +*/ $logJS = " @@ -102,7 +105,7 @@ $(function() { url: url, data: {'lv' :logString}, success: function() { - alert(logString); + // alert(logString); } }); }); diff --git a/e107_plugins/log/js/awesomechart.js b/e107_plugins/log/js/awesomechart.js new file mode 100644 index 000000000..7a8fa7a8d --- /dev/null +++ b/e107_plugins/log/js/awesomechart.js @@ -0,0 +1,1391 @@ +/* +* Copyright 2011 Georgios Migdos +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +Array.prototype.numericSortReverse = function(data){ + this.sort(function(a, b){ + return data[b] - data[a]; + }); +} + +Array.prototype.max = function() { + var max = this[0]; + var len = this.length; + for (var i = 1; i < len; i++){ + if (this[i] > max){ + max = this[i]; + } + } + return max; +} + +Array.prototype.min = function() { + var min = this[0]; + var len = this.length; + for (var i = 1; i < len; i++){ + if (this[i] < min){ + min = this[i]; + } + } + return min; +} + +function AwesomeChart(canvasElementId){ + var canvas = (typeof canvasElementId === 'string') ? document.getElementById(canvasElementId) : canvasElementId; + this.ctx = canvas.getContext('2d'); + this.width = this.ctx.canvas.width; + this.height = this.ctx.canvas.height; + + this.numberOfDecimals = 0; + + this.proportionalSizes = true; + this.widthSizeFactor = this.width/400; + this.heightSizeFactor = this.height/400; + + this.chartType = 'bar'; + this.randomColors = false; + + this.animate = false; + this.animationFrames = 60; + + this.marginTop = 10; + this.marginBottom = 10; + this.marginLeft = 10; + this.marginRight = 10; + + this.labelMargin = 10; + this.dataValueMargin = 20; + this.titleMargin = 10; + this.yAxisLabelMargin = 5; + + this.data = new Array(); + this.labels = new Array(); + this.colors = new Array(); + this.title = null; + + this.backgroundFillStyle = 'rgba(255,255,255,0)'; + this.borderStrokeStyle = 'rgba(255,255,255,0)'; + this.borderWidth = 1.0; + + this.labelFillStyle = 'rgb(220, 36, 0)'; + this.labelFont = 'sans-serif'; + this.labelFontHeight = 12; + this.labelFontStyle = ''; + + this.dataValueFillStyle = '#333'; + this.dataValueFont = 'sans-serif'; + this.dataValueFontHeight = 15; + this.dataValueFontStyle = ''; + + this.titleFillStyle = '#333'; + this.titleFont = 'sans-serif'; + this.titleFontHeight = 16; + this.titleFontStyle = 'bold'; + + this.yAxisLabelFillStyle = '#333'; + this.yAxisLabelFont = 'sans-serif'; + this.yAxisLabelFontHeight = 10; + this.yAxisLabelFontStyle = ''; + + var lingrad = this.ctx.createLinearGradient(0,0,0,this.height); + lingrad.addColorStop(0.2, '#fdfdfd'); + lingrad.addColorStop(0.8, '#ededed'); + + this.chartBackgroundFillStyle = lingrad; + this.chartBorderStrokeStyle = '#999'; + this.chartBorderLineWidth = 1; + this.chartHorizontalLineStrokeStyle = '#999'; + this.chartHorizontalLineWidth = 1; + this.chartVerticalLineStrokeStyle = '#999'; + this.chartVerticalLineWidth = 1; + + this.chartMarkerSize = 5; + + this.chartPointRadius = 4; + this.chartPointFillStyle = 'rgb(150, 36, 0)'; + + this.chartLineStrokeStyle = 'rgba(150, 36, 0, 0.5)'; + this.chartLineWidth = 2; + + this.barFillStyle = 'rgb(220, 36, 0)'; + this.barStrokeStyle = '#fff'; + this.barBorderWidth = 2.0; + this.barShadowColor = 'rgba(0, 0, 0, 0.5)'; + this.barShadowBlur = 5; + this.barShadowOffsetX = 3.0; + this.barShadowOffsetY = 0.0; + + this.barHGap = 20; + this.barVGap = 20; + + this.explosionOffset = 20; + + this.pieFillStyle = 'rgb(220, 36, 0)'; + this.pieStrokeStyle = '#fff'; + this.pieBorderWidth = 2.0; + this.pieShadowColor = 'rgba(0, 0, 0, 0.5)'; + this.pieShadowBlur = 5; + this.pieShadowOffsetX = 3.0; + this.pieShadowOffsetY = 0.0; + + this.pieStart = 0; + this.pieTotal = null; + + this.generateRandomColor = function(){ + var rgb = new Array(); + for(var i=0; i<3; i++){ + rgb.push(Math.ceil(Math.random()*150 + 50)); + } + return 'rgb('+rgb.join(",")+')'; + } + + /*Set the chart's data in the format: + * + * { + * "label-1": data-value-1, + * "label-2": data-value-2, + * "label-3": data-value-3, + * .... + * "label-N": data-value-N, + * } + * + */ + this.setChartDataFromJSON = function(jsonObj){ + for(var p in jsonObj){ + this.labels.push(p); + this.data.push(jsonObj[p]); + } + } + + + this.draw = function(){ + var context = this.ctx; + context.lineCap = 'round'; + var minFactor = Math.min(this.widthSizeFactor, this.heightSizeFactor); + + if(this.proportionalSizes){ + this.labelMargin = this.labelMargin * this.heightSizeFactor; + this.dataValueMargin = this.dataValueMargin * this.heightSizeFactor; + this.titleMargin = this.titleMargin * this.heightSizeFactor; + this.yAxisLabelMargin = this.yAxisLabelMargin * this.heightSizeFactor; + + this.labelFontHeight = this.labelFontHeight * minFactor; + this.dataValueFontHeight = this.dataValueFontHeight * minFactor; + this.titleFontHeight = this.titleFontHeight * minFactor; + this.yAxisLabelFontHeight = this.yAxisLabelFontHeight * minFactor; + + this.barHGap = this.barHGap * this.widthSizeFactor; + this.barVGap = this.barHGap * this.heightSizeFactor; + this.explosionOffset = this.explosionOffset * minFactor; + } + + if(this.randomColors){ + for(var i=0; i=0){ + context.textBaseline = 'bottom'; + context.fillText(this.labels[i], x + barWidth/2, barBottomY - barHeight - this.labelMargin, barWidth); + }else{ + context.textBaseline = 'top'; + context.fillText(this.labels[i], x + barWidth/2, barBottomY - barHeight + this.labelMargin, barWidth); + } + } + + //Draw the data value: + + context.font = this.dataValueFontStyle + ' ' + this.dataValueFontHeight + 'px '+ this.dataValueFont; + context.fillStyle = this.dataValueFillStyle; + context.textAlign = 'center'; + if(di>=0){ + context.textBaseline = 'bottom'; + context.fillText(di, x + barWidth/2, barBottomY - barHeight - this.labelMargin - this.dataValueMargin, barWidth); + }else{ + context.textBaseline = 'top'; + context.fillText(di, x + barWidth/2, barBottomY - barHeight + this.labelMargin + this.dataValueMargin, barWidth); + } + + + //Update x: + + x = x + barWidth + this.barHGap; + } + } + + + + this.animateBarChart = function() { + var aw = this, + numFrames = this.animationFrames, + currentFrame = 0, + + maxData = this.data.max(), + minData = this.data.min(), + + barMaxTopY = this.marginTop + this.labelMargin + this.labelFontHeight + this.dataValueMargin + this.dataValueFontHeight, + barMinTopY = barBottomY = this.height - this.marginBottom; + + if(this.title!=null){ + barMaxTopY += this.titleFontHeight + this.titleMargin; + } + + if(minData<0){ + barMinTopY = this.height - this.marginBottom - this.labelMargin - this.labelFontHeight - this.dataValueMargin - this.dataValueFontHeight; + + barBottomY = barMinTopY + ((this.height - this.marginBottom - barMaxTopY - this.labelMargin - this.labelFontHeight - this.dataValueMargin - this.dataValueFontHeight) * minData) / (Math.abs(minData)+maxData); + } + + var chartAreaHeight = barMinTopY - barMaxTopY, + changeOfMarginBottom = 0, + changeOfMarginTop = 0; + + var belowZeroMaxBarHeight = 0; + if(minData<0){ + var maxBarHeight = Math.max(Math.abs(barBottomY - barMaxTopY), Math.abs(barBottomY - barMinTopY)), + maxBarAbsData = Math.max(Math.abs(minData), Math.abs(maxData)); + belowZeroMaxBarHeight = Math.abs(minData * maxBarHeight / maxBarAbsData + this.labelMargin + this.labelFontHeight); + } + + this.marginBottom += belowZeroMaxBarHeight; + if(this.title!=null){ + this.titleMargin += chartAreaHeight - belowZeroMaxBarHeight; + }else{ + this.marginTop += chartAreaHeight - belowZeroMaxBarHeight; + } + changeOfMarginBottom = belowZeroMaxBarHeight / numFrames; + changeOfMarginTop = (chartAreaHeight - belowZeroMaxBarHeight) / numFrames; + + var updateBarChart = function() { + if(currentFrame++ < numFrames) { + + aw.marginBottom -= changeOfMarginBottom; + + if(aw.title!=null){ + aw.titleMargin -= changeOfMarginTop; + }else{ + aw.marginTop -= changeOfMarginTop; + } + + aw.ctx.clearRect(0, 0, aw.width, aw.height); + aw.drawBarChart(); + aw.drawTitleAndBorders(); + + // Standard + if (typeof(window.requestAnimationFrame) == 'function') { + window.requestAnimationFrame(updateBarChart); + + // IE 10+ + } else if (typeof(window.msRequestAnimationFrame) == 'function') { + window.msRequestAnimationFrame(updateBarChart); + + // Chrome + } else if (typeof(window.webkitRequestAnimationFrame) == 'function') { + window.webkitRequestAnimationFrame(updateBarChart); + + // Firefox + } else if (window.mozRequestAnimationFrame) { // Seems rather slow in FF6 - so disabled + window.mozRequestAnimationFrame(updateBarChart); + + // Default fallback to setTimeout + } else { + setTimeout(updateBarChart, 16.6666666); + } + } + } + + updateBarChart(); + + } + + + + this.drawVerticalBarChart = function(){ + var context = this.ctx; + + context.save(); + context.translate(this.width/2, this.height/2); + context.rotate(Math.PI/2); + context.translate(-this.width/2, -this.height/2); + + //Calculate bar size: + + var n = this.data.length; + var maxData = this.data.max(); + var minData = this.data.min(); + + var marginLeft = this.marginLeft; + if(this.title!=null){ + marginLeft += this.titleFontHeight + this.titleMargin; + } + + var barWidth = (this.width - marginLeft - this.marginRight - (n-1) * this.barHGap) / n; + + context.font = this.labelFontStyle + ' ' + this.labelFontHeight + 'px '+ this.labelFont; + var maxLabelWidth = 0; + var labelWidth = 0; + for(var i=0; imaxLabelWidth){ + maxLabelWidth = labelWidth; + } + } + + context.font = this.dataValueFontStyle + ' ' + this.dataValueFontHeight + 'px '+ this.dataValueFont; + var maxDataValueWidth = 0; + var dataValueWidth = 0; + for(var i=0; imaxDataValueWidth){ + maxDataValueWidth = dataValueWidth; + } + } + + var barMaxTopY = this.marginTop + Math.max( (this.labelMargin + maxLabelWidth), (this.dataValueMargin + maxDataValueWidth) ); + + var barMinTopY = this.height - this.marginBottom; + + var barBottomY = this.height - this.marginBottom; + + if(minData<0){ + + barMinTopY = this.height - this.marginBottom - this.labelMargin - this.labelFontHeight - this.dataValueMargin - this.dataValueFontHeight; + + barBottomY = barMinTopY + ((this.height - this.marginBottom - barMaxTopY - this.labelMargin - this.labelFontHeight - this.dataValueMargin - this.dataValueFontHeight) * minData) / (Math.abs(minData)+maxData); + + } + + + var maxBarHeight = Math.max(Math.abs(barBottomY - barMaxTopY), Math.abs(barBottomY - barMinTopY)); + var maxBarAbsData = Math.max(Math.abs(minData), Math.abs(maxData)); + + var x = marginLeft; + var y = barBottomY; + var barHeight = 0; + + var di = 0; + + for(var i=0; i=0){ + context.textAlign = 'left'; + context.fillText(this.labels[i], this.labelMargin, 0); + }else{ + context.textAlign = 'right'; + context.fillText(this.labels[i], -this.labelMargin, 0); + } + } + + //Draw the data value: + + context.font = this.dataValueFontStyle + ' ' + this.dataValueFontHeight + 'px '+ this.dataValueFont; + context.fillStyle = this.dataValueFillStyle; + context.textBaseline = 'bottom'; + if(di>=0){ + context.textAlign = 'left'; + context.fillText(di, this.labelMargin, 0); + }else{ + context.textAlign = 'right'; + context.fillText(di, -this.labelMargin, 0); + } + + context.restore(); + + //Update x: + + x = x + barWidth + this.barHGap; + } + + context.restore(); + + } + + + + this.animateVerticalBarChart = function() { + var aw = this, + numFrames = this.animationFrames, + currentFrame = 0, + + maxData = this.data.max(), + minData = this.data.min(), + dataLen = this.data.length, + + context = this.ctx, + + marginLeft = this.marginLeft + marginTop = this.marginTop + marginTopCurrent = 0; + + + if(this.title!=null){ + marginLeft += this.titleFontHeight + this.titleMargin; + } + + var barWidth = (this.width - marginLeft - this.marginRight - (dataLen-1) * this.barHGap) / dataLen; + + context.font = this.labelFontStyle + ' ' + this.labelFontHeight + 'px '+ this.labelFont; + var maxLabelWidth = 0; + var labelWidth = 0; + for(var i=0; imaxLabelWidth){ + maxLabelWidth = labelWidth; + } + } + + context.font = this.dataValueFontStyle + ' ' + this.dataValueFontHeight + 'px '+ this.dataValueFont; + var maxDataValueWidth = 0; + var dataValueWidth = 0; + for(var i=0; imaxDataValueWidth){ + maxDataValueWidth = dataValueWidth; + } + } + + var barMaxTopY = this.marginTop + Math.max( (this.labelMargin + maxLabelWidth), (this.dataValueMargin + maxDataValueWidth) ); + + var barMinTopY = this.height - this.marginBottom; + + var barBottomY = this.height - this.marginBottom; + + if(minData<0){ + + barMinTopY = this.height - this.marginBottom - this.labelMargin - this.labelFontHeight - this.dataValueMargin - this.dataValueFontHeight; + + barBottomY = barMinTopY + ((this.height - this.marginBottom - barMaxTopY - this.labelMargin - this.labelFontHeight - this.dataValueMargin - this.dataValueFontHeight) * minData) / (Math.abs(minData)+maxData); + + } + + + var maxBarHeight = Math.max(Math.abs(barBottomY - barMaxTopY), Math.abs(barBottomY - barMinTopY)); + var maxBarAbsData = Math.max(Math.abs(minData), Math.abs(maxData)); + + + var belowZeroMaxBarHeight = 0; + if(minData<0){ + belowZeroMaxBarHeight = Math.abs(minData * maxBarHeight / maxBarAbsData); + } + + var chartAreaHeight = maxData * maxBarHeight / maxBarAbsData + belowZeroMaxBarHeight, + changeOfMarginBottom = 0, + changeOfMarginTop = 0; + + this.marginBottom += belowZeroMaxBarHeight; + this.marginTop += chartAreaHeight - belowZeroMaxBarHeight; + changeOfMarginBottom = belowZeroMaxBarHeight / numFrames; + changeOfMarginTop = (chartAreaHeight - belowZeroMaxBarHeight) / numFrames; + + var updateVerticalBarChart = function() { + if(currentFrame++ < numFrames) { + + aw.marginBottom -= changeOfMarginBottom; + aw.marginTop -= changeOfMarginTop; + + aw.ctx.clearRect(0, 0, aw.width, aw.height); + aw.drawVerticalBarChart(); + + marginTopCurrent = aw.marginTop; + aw.marginTop = marginTop; + aw.drawTitleAndBorders(); + aw.marginTop = marginTopCurrent; + + // Standard + if (typeof(window.requestAnimationFrame) == 'function') { + window.requestAnimationFrame(updateVerticalBarChart); + + // IE 10+ + } else if (typeof(window.msRequestAnimationFrame) == 'function') { + window.msRequestAnimationFrame(updateVerticalBarChart); + + // Chrome + } else if (typeof(window.webkitRequestAnimationFrame) == 'function') { + window.webkitRequestAnimationFrame(updateVerticalBarChart); + + // Firefox + } else if (window.mozRequestAnimationFrame) { // Seems rather slow in FF6 - so disabled + window.mozRequestAnimationFrame(updateVerticalBarChart); + + // Default fallback to setTimeout + } else { + setTimeout(updateVerticalBarChart, 16.6666666); + } + } + } + + updateVerticalBarChart(); + + } + + + + this.drawPieChart = function(ring){ + var context = this.ctx; + context.lineWidth = this.pieBorderWidth; + + var dataSum = 0, + dataSumForStartAngle = 0, + dataLen = this.data.length; + + for (var i=0; imaxLabelWidth){ + maxLabelWidth = labelWidth; + } + } + + radius = radius - maxLabelWidth - this.labelMargin; + + var startAngle = this.pieStart* doublePI / dataSumForStartAngle; + var currentAngle = startAngle; + var endAngle = 0; + var incAngleBy = 0; + + for(var i=0; iMath.PI/2) && (mAngle<=3*(Math.PI/2)) ){ + var translateXBy = radius + this.labelMargin + context.measureText(this.labels[i]).width / 2; + context.translate(translateXBy, 0); + context.rotate(Math.PI); + context.translate(-translateXBy, 0); + } + context.textBaseline = 'middle'; + context.fillText(this.labels[i], radius+this.labelMargin, 0); + } + + context.restore(); + currentAngle = endAngle; + } + } + + + + this.drawExplodedPieChart = function(){ + var context = this.ctx; + context.lineWidth = this.pieBorderWidth; + + var dataSum = 0, + dataSumForStartAngle = 0, + dataLen = this.data.length; + + for (var i=0; imaxLabelWidth){ + maxLabelWidth = labelWidth; + } + } + + radius = radius - maxLabelWidth - this.labelMargin; + + var currentAngle = this.pieStart* doublePI / dataSumForStartAngle; + var endAngle = 0; + var incAngleBy = 0; + var halfAngle = 0; + var mAngle = 0; + for(var i=0; iMath.PI/2) && (mAngle<=3*(Math.PI/2)) ){ + var translateXBy = radius + this.labelMargin + context.measureText(this.labels[i]).width / 2; + context.translate(translateXBy, 0); + context.rotate(Math.PI); + context.translate(-translateXBy, 0); + } + context.textBaseline = 'middle'; + context.fillText(this.labels[i], radius+this.labelMargin, 0); + } + + + // Restore the context: + + context.restore(); + currentAngle = endAngle; + + } + + } + + + + this.animatePieChart = function(pieType){ + var dataSum = 0, + pieTotalReal = this.pieTotal, + aw = this, + numFrames = this.animationFrames, + currentFrame = 0, + pieAreaWidth = this.width - this.marginLeft - this.marginRight, + pieAreaHeight = this.height - this.marginTop - this.marginBottom, + marginTop = this.marginTop, + marginLeft = this.marginLeft; + + if(this.title){ + pieAreaHeight = pieAreaHeight - this.titleFontHeight - this.titleMargin; + marginTop += this.titleFontHeight + this.titleMargin; + }; + + for(var i=0; imaxYAxisLabelWidth){ + maxYAxisLabelWidth = yAxisLabelWidth; + } + } + + var perCentMaxWidth = context.measureText("100%").width; + + // Calculate the chart size and position: + + var chartWidth = this.width - this.marginLeft - this.marginRight - 2*this.chartMarkerSize - maxYAxisLabelWidth - perCentMaxWidth - 2*this.yAxisLabelMargin; + var chartHeight = this.height - this.marginTop - this.marginBottom; + + var chartTopLeftX = this.marginLeft + this.chartMarkerSize + maxYAxisLabelWidth + this.yAxisLabelMargin; + var chartTopLeftY = this.marginTop; + + + if(this.title){ + chartHeight -= this.titleFontHeight + this.titleMargin; + chartTopLeftY += this.titleFontHeight + this.titleMargin; + } + + + // Draw the chart's background: + + context.save(); + + context.translate(chartTopLeftX, chartTopLeftY); + + context.fillStyle = this.chartBackgroundFillStyle; + context.fillRect(0,0,chartWidth,chartHeight); + + + // Draw the markers, horizontal lines, and axis' labels: + + var yStep = chartHeight / 10; + var lineY = 0; + + context.lineWidth = this.chartHorizontalLineWidth; + context.font = this.yAxisLabelFontStyle + ' ' + this.yAxisLabelFontHeight + 'px '+ this.yAxisLabelFont; + + for(var i=0; i<=10; i++){ + lineY = i*yStep; + + if( i>0 && i<10){ + + context.strokeStyle = this.chartHorizontalLineStrokeStyle; + context.beginPath(); + context.moveTo(0,lineY); + context.lineTo(chartWidth,lineY); + context.stroke(); + + } + + context.strokeStyle = this.chartBorderStrokeStyle; + context.beginPath(); + context.moveTo(-this.chartMarkerSize,lineY); + context.lineTo(0,lineY); + context.stroke(); + + context.beginPath(); + context.moveTo(chartWidth,lineY); + context.lineTo(chartWidth+this.chartMarkerSize,lineY); + context.stroke(); + + context.fillStyle = this.yAxisLabelFillStyle; + context.textAlign = 'right'; + context.textBaseline = 'middle'; + context.fillText(yAxisValues[10-i], -this.chartMarkerSize-this.yAxisLabelMargin, lineY); + + context.textAlign = 'left'; + context.fillText( ((10-i)*10)+'%', chartWidth+this.chartMarkerSize+this.yAxisLabelMargin, lineY); + } + + // Draw the bars: + + context.save(); + + context.translate(0, chartHeight); + + var barWidth = (chartWidth-2*this.barHGap) / n; + var barHeight = 0; + + var halfBarWidth = barWidth/2; + + var y = 0; + var x = this.barHGap; + var x1 = x; + var y1 = 0; + var x2 = 0; + var y2 = 0; + + for(var i=0; i=0){ + context.textBaseline = 'bottom'; + context.fillText(this.labels[indices[i]], x + halfBarWidth, - barHeight - this.labelMargin, barWidth); + }else{ + context.textBaseline = 'top'; + context.fillText(this.labels[indices[i]], x + halfBarWidth, - barHeight + this.labelMargin, barWidth); + } + } + + // Draw the data value: + + context.font = this.dataValueFontStyle + ' ' + this.dataValueFontHeight + 'px '+ this.dataValueFont; + context.fillStyle = this.dataValueFillStyle; + context.textAlign = 'center'; + if(this.data[indices[i]]>=0){ + context.textBaseline = 'bottom'; + context.fillText(this.data[indices[i]], x + halfBarWidth, - barHeight - this.labelMargin - this.dataValueMargin, barWidth); + }else{ + context.textBaseline = 'top'; + context.fillText(this.data[indices[i]], x + halfBarWidth, - barHeight + this.labelMargin + this.dataValueMargin, barWidth); + } + + + // Update x: + + x = x + barWidth; + + } + + // Draw the points: + + x = this.barHGap; + x1 = x; + y1 = 0; + x2 = 0; + y2 = 0; + + context.fillStyle = this.chartPointFillStyle; + context.beginPath(); + context.arc(x1, y1, this.chartPointRadius, 0, 2*Math.PI, false); + context.fill(); + + for(var i=0; i 1, 'content' => array('content')); //$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); // 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']; $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"; //$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 -function getip() +if(!function_exists('getip')) { - $ip = $_SERVER['REMOTE_ADDR']; - if (getenv('HTTP_X_FORWARDED_FOR')) + function getip() { - 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) + $ip = $_SERVER['REMOTE_ADDR']; + if (getenv('HTTP_X_FORWARDED_FOR')) { - 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 ($s > 0) + if ($f == '') { - $ret .= str_repeat('0000',$s); - $s = 0; + $ret .= '0000'; // Always put in one set of zeros for the blank + if ($s > 0) + { + $ret .= str_repeat('0000',$s); + $s = 0; + } + } + else + { + $ret .= sprintf('%04x',hexdec($f)); } } - else - { - $ret .= sprintf('%04x',hexdec($f)); - } + return $ret; } - return $ret; } } - ?> \ No newline at end of file diff --git a/e107_plugins/log/loginfo.php b/e107_plugins/log/loginfo.php index 123006fa4..744ccad9c 100644 --- a/e107_plugins/log/loginfo.php +++ b/e107_plugins/log/loginfo.php @@ -11,7 +11,7 @@ if (!defined('log_INIT')) { exit; } -$logIfile = "logs/logi_{$date}.php"; +$logIfile = e_LOG."logi_{$date}.php"; $i_handle = fopen($logIfile, 'r+'); if($i_handle && flock( $i_handle, LOCK_EX ) ) { diff --git a/e107_plugins/log/stats.php b/e107_plugins/log/stats.php index e96bc932b..5078d15e9 100644 --- a/e107_plugins/log/stats.php +++ b/e107_plugins/log/stats.php @@ -1181,6 +1181,8 @@ class siteStats if (!is_array($selection)) $selection = array(1); $text = ''; + + foreach ($selection as $act) { unset($statBrowser); @@ -1250,7 +1252,7 @@ class siteStats } $total = array_sum($browserArray); - + $text .= "\n ".$this->browser_headings[$act].$pars['hdg_extra']."\n @@ -1901,6 +1903,8 @@ class siteStats $utotal += $fvalue['unq']; } + print_a($dayarray);; + $text = "\n\n".ADSTAT_L33." ".($amount+1)." ".ADSTAT_L40."\n".ADSTAT_L34."\n\n"; foreach($dayarray as $date => $total)