$cols[$cnt] = "#708F00"; } elseif ($modname == "Gundam") { $cols[$cnt] = "#FFFFFF"; } elseif ($modname == "Spring Tanks") { $cols[$cnt] = "#FF00FF"; } elseif ($modname == "Kernel Panic") { $cols[$cnt] = "#2EFE2E"; } elseif ($modname == "Evolution RTS") { $cols[$cnt] = "#F7BE81"; } elseif ($modname == "Conflict Terra") { $cols[$cnt] = "#B404AE"; } elseif ($modname == "Cursed") { $cols[$cnt] = "#A80000"; } else { $greyshade = intval(220 / ($ngameswithoutspecificolor / 4 + 1)); //growing darkness $cols[$cnt] = "#" . dechex($greyshade) . dechex($greyshade) . dechex($greyshade); $ngameswithoutspecificolor++; } $cnt++; } } $pie = new PieGraph(400, 400, $vals); $pie->setColors($cols); $pie->setLegends($vars); $pie->set3dHeight(15); if ($fname != $today) { $pie->display($fname . $ext . ".png"); } else { $pie->display(); }
function UsersChartGB() { require 'lib/piegraph.class.php'; global $SAMSConf; global $DATE; $DB = new SAMSDB(); $sdate = $DATE->sdate(); $edate = $DATE->edate(); $bdate = $DATE->BeginDate(); $eddate = $DATE->EndDate(); $size = ""; if (isset($_GET["size"])) { $size = $_GET["size"]; } if (isset($_GET["sort"])) { $sort = $_GET["sort"]; } if (isset($_GET["desc"])) { $desc = $_GET["desc"]; } $QUERY = "SELECT sum(s_size) as user_size FROM cachesum WHERE s_date>='{$sdate}' AND s_date<='{$edate}'"; $num_rows = $DB->samsdb_query_value($QUERY); $row = $DB->samsdb_fetch_array(); $full_utraffic_size = $row['user_size']; $DB->free_samsdb_query(); $colors = array("#FF0000", "#0000FF", "#FFFF00", "#009000", "#C3690F", "#CC009C", "#99CC33", "#3C3CFF", "#C9960C", "#FF6F00", "#C6C63C", "#CC033C", "#00FFFF", "#636F66", "#6FFF00", "#96693F", "#009C9C", "#FFCC00", "#9F9F6F", "#CC60CC"); $usercolors = array(); if ($sort == "users") { $QUERY = "SELECT c.s_user,sum(c.s_size) as user_size,sum(c.s_hit) as hit_size, s.s_user_id as s_id FROM cachesum c, squiduser s WHERE c.s_user=s.s_nick AND c.s_date>='{$sdate}' AND c.s_date<='{$edate}' GROUP BY c.s_user, s.s_user_id ORDER BY user_size DESC;"; } else { $QUERY = "SELECT sum.sum_name as s_user,sum(sum.sum_size) as user_size, sum(sum.sum_hit) as hit_size, sum.sum_group_id as s_id FROM ( SELECT sum(c.s_size) as sum_size, sum(c.s_hit) as sum_hit, c.s_user as sum_user, s.s_group_id as sum_group_id, g.s_name as sum_name FROM cachesum c, squiduser s, sgroup g WHERE c.s_user=s.s_nick AND s.s_group_id=g.s_group_id AND s_date>='{$sdate}' AND s_date<='{$edate}' GROUP BY c.s_user, s.s_group_id, g.s_name ORDER BY g.s_name ) as sum GROUP BY s_user, sum.sum_group_id;"; } $num_rows = $DB->samsdb_query_value($QUERY); $count = 0; $sum_size = 0; $sum_hit = 0; $sum_pc = 0; $another_utraffic_size = 0; while ($row = $DB->samsdb_fetch_array()) { if ($row['user_size'] >= $full_utraffic_size / 100) { if ($count < count($colors)) { $usercolors[$count] = $colors[$count]; } else { $r = mt_rand(10, 240); $g = mt_rand(10, 240); $b = mt_rand(10, 240); $usercolors[$count] = "#" . sprintf("%X%X%X", mt_rand(20, 200), mt_rand(20, 200), mt_rand(20, 200)); } $user[$count] = $row['s_user']; $size[$count] = $row['user_size']; $count++; } else { $another_utraffic_size += $row['user_size']; } } if ($another_utraffic_size > 0) { $user[$count] = "another users"; $size[$count] = $another_utraffic_size; $count++; } $pie = new PieGraph(300, 200, $size); $pie->setColors($usercolors); // legends for the data $pie->setLegends($user); // Display creation time of the graph $pie->DisplayCreationTime(); // Height of the pie 3d effect $pie->set3dHeight(15); // Display the graph $pie->display(); }