Example #1
0
function ranking_getContent()
{
    global $template;
    // open template
    $template->setFile('rankingPlayer.tmpl');
    $template->setShowResource(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;
    }
    $numRows = rankingPlayer_getMaxRows();
    $offset = 0;
    $row = array();
    if ($numRows > 0) {
        $search = Request::getVar('search', '');
        $page = Request::getVar('page', 0);
        if ($search !== '') {
            $offset = rankingPlayer_checkOffsetBySearch($search, $numRows);
            if ($offset < 0) {
                $offset = 0;
                $template->addVar('status_msg', array('type' => 'error', 'message' => 'Der gesuchte Spieler wurde nicht gefunden'));
            }
        } else {
            $offset = rankingPlayer_checkOffsetByPage($_SESSION['player']->playerID, $page, $numRows);
        }
        $row = rankingPlayer_getRowsByOffset($offset);
    }
    $template->addVars(array('page' => ceil($offset / RANKING_ROWS) + 1, 'max_pages' => ceil($numRows / RANKING_ROWS), 'rows_per_page' => RANKING_ROWS, 'religious' => array('ugapercent' => $ugapercent, 'aggapercent' => $aggapercent), 'row' => $row));
}
Example #2
0
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));
}
Example #3
0
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 .= "&amp;order=" . $order;
        $down_link .= "&amp;order=" . $order;
    }
    if ($direct) {
        $up_link .= "&amp;direct=" . $direct;
        $down_link .= "&amp;direct=" . $direct;
    }
    $up = array('link' => $up_link);
    $down = array('link' => $down_link);
    // Header links
    $link_rank = "?modus=" . RANKING . "&amp;order=rank";
    $link_name = "?modus=" . RANKING . "&amp;order=name";
    $link_caves = "?modus=" . RANKING . "&amp;order=caves";
    $link_points = "?modus=" . RANKING . "&amp;order=points";
    $link_tribe = "?modus=" . RANKING . "&amp;order=tribe";
    $link_fame = "?modus=" . RANKING . "&amp;order=fame";
    if ($direct) {
        $link_rank .= "&amp;direct=" . $direct;
        $link_name .= "&amp;direct=" . $direct;
        $link_caves .= "&amp;direct=" . $direct;
        $link_points .= "&amp;direct=" . $direct;
        $link_tribe .= "&amp;direct=" . $direct;
        $link_fame .= "&amp;direct=" . $direct;
    }
    if ($order == "rank" && $direct == "ASC") {
        $link_rank = "?modus=" . RANKING . "&amp;order=rank&amp;direct=DESC";
    }
    if ($order == "rank" && $direct == "DESC") {
        $link_rank = "?modus=" . RANKING . "&amp;order=rank&amp;direct=ASC";
    }
    if ($order == "name" && $direct == "ASC") {
        $link_name = "?modus=" . RANKING . "&amp;order=name&amp;direct=DESC";
    }
    if ($order == "name" && $direct == "DESC") {
        $link_name = "?modus=" . RANKING . "&amp;order=name&amp;direct=ASC";
    }
    if ($order == "caves" && $direct == "ASC") {
        $link_caves = "?modus=" . RANKING . "&amp;order=caves&amp;direct=DESC";
    }
    if ($order == "caves" && $direct == "DESC") {
        $link_caves = "?modus=" . RANKING . "&amp;order=caves&amp;direct=ASC";
    }
    if ($order == "points" && $direct == "ASC") {
        $link_points = "?modus=" . RANKING . "&amp;order=points&amp;direct=DESC";
    }
    if ($order == "points" && $direct == "DESC") {
        $link_points = "?modus=" . RANKING . "&amp;order=points&amp;direct=ASC";
    }
    if ($order == "tribe" && $direct == "ASC") {
        $link_tribe = "?modus=" . RANKING . "&amp;order=tribe&amp;direct=DESC";
    }
    if ($order == "tribe" && $direct == "DESC") {
        $link_tribe = "?modus=" . RANKING . "&amp;order=tribe&amp;direct=ASC";
    }
    if ($order == "fame" && $direct == "ASC") {
        $link_fame = "?modus=" . RANKING . "&amp;order=fame&amp;direct=DESC";
    }
    if ($order == "fame" && $direct == "DESC") {
        $link_fame = "?modus=" . RANKING . "&amp;order=fame&amp;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);
}
Example #4
0
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */
/** Set flag that this is a parent file */
define("_VALID_UA", 1);
require_once "../../config.inc.php";
require_once "include/config.inc.php";
require_once "include/params.inc.php";
require_once "include/db.inc.php";
require_once "include/ranking.inc.php";
$config = new Config();
$db = DbConnect();
$religions = ranking_getReligiousDistribution();
$ugaCount = isset($religions['uga']) ? $religions['uga'] : 0;
$aggaCount = isset($religions['agga']) ? $religions['agga'] : 0;
if ($ugaCount + $aggaCount != 0) {
    $uga_part = round($ugaCount / ($ugaCount + $aggaCount) * 100);
    $agga_part = round($aggaCount / ($ugaCount + $aggaCount) * 100);
} else {
    $uga_part = 0;
    $agga_part = 0;
}
$filename = reldis_getFilename($uga_part, $agga_part);
if (!file_exists($filename)) {
    reldis_createFile($filename, $uga_part, $agga_part);
}
header("Location: {$filename}");
################################################################################