diff options
Diffstat (limited to 'html/includes')
-rwxr-xr-x | html/includes/config.php | 6 | ||||
-rwxr-xr-x | html/includes/functions.php | 2 | ||||
-rw-r--r-- | html/includes/renderer-general-import.php | 16 | ||||
-rw-r--r-- | html/includes/renderer-general-output.php | 50 |
4 files changed, 33 insertions, 41 deletions
diff --git a/html/includes/config.php b/html/includes/config.php index 2e5a8e1..d489552 100755 --- a/html/includes/config.php +++ b/html/includes/config.php @@ -1,9 +1,9 @@ <?php
// Database connection details
-$dbname = "";
-$hostname = "";
-$uname = "";
+$dbname = "utstats";
+$hostname = "localhost";
+$uname = "root";
$upass = "";
// The key needed to run the import script
diff --git a/html/includes/functions.php b/html/includes/functions.php index d060edd..cefc1cc 100755 --- a/html/includes/functions.php +++ b/html/includes/functions.php @@ -1,6 +1,6 @@ <?php
// Connect to database
-$GLOBALS["___mysqli_link"] = mysqli_connect($hostname, $uname, $upass, $dbname);
+$GLOBALS["___mysqli_link"] = mysqli_connect($hostname, $uname, $upass, $dbname);
// Error reporting
// error_reporting(E_ALL & ~E_NOTICE);
diff --git a/html/includes/renderer-general-import.php b/html/includes/renderer-general-import.php index ceba873..7337cfa 100644 --- a/html/includes/renderer-general-import.php +++ b/html/includes/renderer-general-import.php @@ -56,7 +56,7 @@ function generateTeamLabels() { /* Generate the chart with pickups */ -function renderDataPickups($uid,$team=true,$playerRedWins=true,$topFraggers) { +function renderDataPickups($uid, $team=true, $playerRedWins=true, $topFraggers=null) { global $matchid; global $renderer_color; global $renderer_folder; @@ -67,14 +67,14 @@ function renderDataPickups($uid,$team=true,$playerRedWins=true,$topFraggers) { $q_pickups = mysqli_query($GLOBALS["___mysqli_link"], "SELECT SUM(pu_belt), SUM(pu_keg), SUM(pu_pads), SUM(pu_armour), SUM(pu_amp) FROM uts_player as p WHERE matchid = ".mysqli_real_escape_string($GLOBALS["___mysqli_link"], $matchid)." GROUP BY team") or die(mysqli_error($GLOBALS["___mysqli_link"])); - while($r_pickups = mysqli_fetch_row($q_pickups)) { + while ($r_pickups = mysqli_fetch_row($q_pickups)) { $preData[] = $r_pickups; } $pickupitems = array('belt','keg','pads','armour','amp'); $itemsPickedUp = array(); - if($team || $playerRedWins) { + if ($team || $playerRedWins) { $teamOneId = 0; $teamTwoId = 1; } else { @@ -84,23 +84,23 @@ function renderDataPickups($uid,$team=true,$playerRedWins=true,$topFraggers) { // Process data to convert these to percentages // Normal numbers don't plot nicely (fe. pads getting much higher pickups due to lower spawn time - for($i=0;$i<count($pickupitems);$i++) { - if($preData[0][$i]>0) { + for ($i=0;$i<count($pickupitems);$i++) { + if ($preData[0][$i]>0) { $percValue = round($preData[0][$i]/($preData[0][$i]+$preData[1][$i])*100,0); $data[$teamOneId][] = $percValue; $data[$teamTwoId][] = 100-$percValue; $itemsPickedUp[] = $pickupitems[$i]; - } else if($preData[1][$i]>0) { + } else if ($preData[1][$i]>0) { $data[$teamOneId][] = 0; $data[$teamTwoId][] = 100; $itemsPickedUp[] = $pickupitems[$i]; } } - if(count($itemsPickedUp)>2) { - if($team) + if (count($itemsPickedUp)>2) { + if ($team) $labels = generateTeamLabels(); else $labels = generateLabelsFraggers($topFraggers); diff --git a/html/includes/renderer-general-output.php b/html/includes/renderer-general-output.php index 8ae0a15..d73d83f 100644 --- a/html/includes/renderer-general-output.php +++ b/html/includes/renderer-general-output.php @@ -3,23 +3,22 @@ require_once('encoding.php'); use \ForceUTF8\Encoding; -function renderChart($target,$layout,$color,$title,$data,$labels,$categories,$width,$height,$charttype) { - +function renderChart($target, $layout, $color, $title, $data, $labels, $categories, $width, $height, $charttype) { // Add categories if required - if(!empty($categories) && count($categories)>0) { + if (!empty($categories) && count($categories)>0) { $categoriesString = "categories: ".json_encode($categories).", "; $categoriesStringPos = strpos($layout,"{",strpos($layout,"xAxis"))+1; - if($categoriesStringPos !== false) + if ($categoriesStringPos !== false) $layout = substr_replace($layout,$categoriesString,$categoriesStringPos,0); } // Replace title if required - if(!empty($title) && strlen($title)>0) { + if (!empty($title) && strlen($title)>0) { $titleStringPosStart = strpos($layout,":",strpos($layout,"text"))+1; $titleStringPosEnd = strpos($layout,"}",strpos($layout,"text"))-1; - if($categoriesStringPos !== false) - $layout = substr_replace($layout,json_encode($title),$titleStringPosStart,$titleStringPosEnd-$titleStringPosStart); + if ($categoriesStringPos !== false) + $layout = substr_replace($layout, json_encode($title), $titleStringPosStart, $titleStringPosEnd - $titleStringPosStart); } $chart = " @@ -30,7 +29,7 @@ function renderChart($target,$layout,$color,$title,$data,$labels,$categories,$wi chart: { renderTo: '$target' "; - if($charttype == RENDERER_CHARTTYPE_RADAR) + if ($charttype == RENDERER_CHARTTYPE_RADAR) $chart .= ", polar: true, type: 'area'"; // Encoding::toUTF8() required for $data & $labels in offline use @@ -43,7 +42,7 @@ function renderChart($target,$layout,$color,$title,$data,$labels,$categories,$wi return $chart; } -function jsonEncodeMultiSeries($data,$labels,$color,$charttype) { +function jsonEncodeMultiSeries($data, $labels, $color, $charttype) { $countSeries = count($data); for($i=0;$i<$countSeries;$i++) { @@ -74,19 +73,17 @@ function jsonEncodeMultiSeries($data,$labels,$color,$charttype) { } - $jsonData .= jsonEncodeSingleSerie($data[$i],$labels,$color,$charttypeSingle,$layoutSerie,$colorTransparant); + $jsonData .= jsonEncodeSingleSerie($data[$i], $labels, $color, $charttypeSingle, $layoutSerie, $colorTransparant); - if($i<($countSeries-1)) - $jsonData .= ","; + if ($i<($countSeries-1)) + $jsonData .= ","; } return $jsonData; } - - -function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie='',$colorTransparant=false) { +function jsonEncodeSingleSerie($data, $labels, $color, $charttype, $layoutSerie='', $colorTransparant=false) { global $renderer_color; global $renderer_color_transparancy; @@ -119,37 +116,33 @@ function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie='',$ data: ".json_encode($data[$i])." }"; if($i<($countSeries-1)) - $jsonData .= ","; + $jsonData .= ","; } } else if(countSeries==1) { - $jsonData .= "data: { ".$layoutSerie.json_encode($data[0])." }"; + $jsonData .= "data: { ".$layoutSerie.json_encode($data[0])." }"; } return $jsonData; } -function jsonEncodeRadarSerie($data,$labels,$color,$charttype) { - return jsonEncodeSingleSerie($data,$labels,$color,$charttype,'',true); +function jsonEncodeRadarSerie($data, $labels, $color, $charttype) { + return jsonEncodeSingleSerie($data, $labels, $color, $charttype, '', true); } - -function jsonEncodeSeries($data,$labels,$color,$charttype) { - - if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) - return jsonEncodeMultiSeries($data,$labels,$color,$charttype); +function jsonEncodeSeries($data, $labels, $color, $charttype) { + if ($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) + return jsonEncodeMultiSeries($data, $labels, $color, $charttype); else - return jsonEncodeSingleSerie($data,$labels,$color,$charttype); + return jsonEncodeSingleSerie($data, $labels, $color, $charttype); } - -/** +/* Functions to render block in which the graphs are shown */ function renderHeaderBlock($category) { - return ' <table class="box" border="0" cellpadding="0" cellspacing="0"> <thead> @@ -189,7 +182,6 @@ function hex2rgb($hex) { } $rgb = array($r, $g, $b); return implode(",", $rgb); // returns the rgb values separated by commas - } ?> |