function ranking_getContent($caveID, $offset) { global $template; // open template $template->setFile('rankingPlayer.tmpl'); $template->setShowRresource(false); $religions = ranking_getReligiousDistribution(); if (!isset($religions['uga'])) { $religions['uga'] = 0; } if (!isset($religions['agga'])) { $religions['agga'] = 0; } if ($religions['uga'] + $religions['agga'] != 0) { $ugapercent = round($religions['uga'] / ($religions['uga'] + $religions['agga']) * 100); $aggapercent = round($religions['agga'] / ($religions['uga'] + $religions['agga']) * 100); } else { $ugapercent = 0; $aggapercent = 0; } $row = ranking_getRowsByOffset($caveID, $offset); $template->addVars(array('offset_up' => $offset - RANKING_ROWS > 0 ? $offset - RANKING_ROWS : 0, 'offset_down' => $offset + RANKING_ROWS, 'religious' => array('ugapercent' => $ugapercent, 'aggapercent' => $aggapercent), 'row' => $row)); }
function ranking_getContent($caveID, $offset) { global $no_resource_flag, $config, $params; $no_resource_flag = 1; $religions = ranking_getReligiousDistribution(); if ($religions['uga'] + $religions['agga'] != 0) { $ugapercent = round($religions['uga'] / ($religions['uga'] + $religions['agga']) * 100); $aggapercent = round($religions['agga'] / ($religions['uga'] + $religions['agga']) * 100); } else { $ugapercent = 0; $aggapercent = 0; } // ADDED by chris--- for ranking sorting $order = $params->POST->order; if ($order != "rank" && $order != "caves" && $order != "name" && $order != "points" && $order != "tribe" && $order != "fame") { $order = "rank"; } $direct = $params->POST->direct; if ($direct != "ASC" && $direct != "DESC") { $direct = "ASC"; } $row = ranking_getRowsByOffset($caveID, $offset, $order, $direct); // ADDED by chris--- for ranking sorting // $up = array('link' => "?modus=" . RANKING . "&offset=" . ($offset - RANKING_ROWS)); // $down = array('link' => "?modus=" . RANKING . "&offset=" . ($offset + RANKING_ROWS)); $up_link = "?modus=" . RANKING . "&offset=" . ($offset - RANKING_ROWS); $down_link = "?modus=" . RANKING . "&offset=" . ($offset + RANKING_ROWS); if ($order) { $up_link .= "&order=" . $order; $down_link .= "&order=" . $order; } if ($direct) { $up_link .= "&direct=" . $direct; $down_link .= "&direct=" . $direct; } $up = array('link' => $up_link); $down = array('link' => $down_link); // Header links $link_rank = "?modus=" . RANKING . "&order=rank"; $link_name = "?modus=" . RANKING . "&order=name"; $link_caves = "?modus=" . RANKING . "&order=caves"; $link_points = "?modus=" . RANKING . "&order=points"; $link_tribe = "?modus=" . RANKING . "&order=tribe"; $link_fame = "?modus=" . RANKING . "&order=fame"; if ($direct) { $link_rank .= "&direct=" . $direct; $link_name .= "&direct=" . $direct; $link_caves .= "&direct=" . $direct; $link_points .= "&direct=" . $direct; $link_tribe .= "&direct=" . $direct; $link_fame .= "&direct=" . $direct; } if ($order == "rank" && $direct == "ASC") { $link_rank = "?modus=" . RANKING . "&order=rank&direct=DESC"; } if ($order == "rank" && $direct == "DESC") { $link_rank = "?modus=" . RANKING . "&order=rank&direct=ASC"; } if ($order == "name" && $direct == "ASC") { $link_name = "?modus=" . RANKING . "&order=name&direct=DESC"; } if ($order == "name" && $direct == "DESC") { $link_name = "?modus=" . RANKING . "&order=name&direct=ASC"; } if ($order == "caves" && $direct == "ASC") { $link_caves = "?modus=" . RANKING . "&order=caves&direct=DESC"; } if ($order == "caves" && $direct == "DESC") { $link_caves = "?modus=" . RANKING . "&order=caves&direct=ASC"; } if ($order == "points" && $direct == "ASC") { $link_points = "?modus=" . RANKING . "&order=points&direct=DESC"; } if ($order == "points" && $direct == "DESC") { $link_points = "?modus=" . RANKING . "&order=points&direct=ASC"; } if ($order == "tribe" && $direct == "ASC") { $link_tribe = "?modus=" . RANKING . "&order=tribe&direct=DESC"; } if ($order == "tribe" && $direct == "DESC") { $link_tribe = "?modus=" . RANKING . "&order=tribe&direct=ASC"; } if ($order == "fame" && $direct == "ASC") { $link_fame = "?modus=" . RANKING . "&order=fame&direct=DESC"; } if ($order == "fame" && $direct == "DESC") { $link_fame = "?modus=" . RANKING . "&order=fame&direct=ASC"; } // ------------------------------------------------------ $hidden = array(array('name' => "modus", 'value' => RANKING)); // ADDED by chris--- for ranking points $points = getRankingPoints($params->SESSION->player->playerID); $template = tmpl_open($params->SESSION->player->getTemplatePath() . 'ranking.ihtml'); tmpl_set($template, array('modus' => RANKING_TRIBE, 'UP' => $up, 'DOWN' => $down, 'HIDDEN' => $hidden, 'update' => getUpdateTime(), 'points_military' => $points[military_rank], 'points_resources' => $points[resources_rank], 'points_buildings' => $points[buildings_rank], 'points_sciences' => $points[sciences_rank], 'RELIGIOUS_DISTRIBUTION' => array('ugapercent' => $ugapercent, 'aggapercent' => $aggapercent), 'link_rank' => $link_rank, 'link_caves' => $link_caves, 'link_points' => $link_points, 'link_tribe' => $link_tribe, 'link_fame' => $link_fame, 'link_name' => $link_name)); for ($i = 0; $i < sizeof($row); ++$i) { tmpl_iterate($template, 'ROWS'); if ($i % 2) { tmpl_set($template, 'ROWS/ROW_ALTERNATE', $row[$i]); } else { tmpl_set($template, 'ROWS/ROW', $row[$i]); } } return tmpl_parse($template); }
ranking_getReligiousDistribution(); echo "Erstes Mal: "; resultMeasure(); for ($i = 0; $i < 9; $i++) { ranking_getReligiousDistribution(); } resultMeasure(10); echo "<br>\n"; echo "ranking_getRowsByOffset() - 20 Einträge<br>\n"; define("RANKING_ROWS", 20); initMeasure(); ranking_getRowsByOffset(0, 100); echo "Erstes Mal: "; resultMeasure(); for ($i = 0; $i < 9; $i++) { ranking_getRowsByOffset(0, 100); } resultMeasure(10); echo "<br>\n"; echo "<br>\n############### Game Rules ################\n<br><br>\n"; echo "FORMULA_PARSER.INC.PHP Including and instatiation of rules<br>\n"; initMeasure(); include INC_DIR . "formula_parser.inc.php"; resultMeasure(); echo "<br>\n"; /////////////////// measuring functions /////////////////////// function initMeasure() { global $db; stopwatch('start'); if ($db) {