Beispiel #1
0
 public static function init()
 {
     // hent innstillinger
     self::$settings = cache::fetch("settings");
     if (!self::$settings) {
         // hent ny data
         require PATH_APP . "/scripts/update_db_settings.php";
     }
     // hent bydeler
     self::$bydeler = cache::fetch("bydeler");
     if (!self::$bydeler) {
         // hent ny data
         require PATH_APP . "/scripts/update_db_bydeler.php";
     }
     // hent ranker
     self::$ranks = cache::fetch("ranks");
     if (!self::$ranks) {
         // hent ny data
         require PATH_APP . "/scripts/update_db_ranks.php";
     }
 }
Beispiel #2
0
<?php

// denne filen henter informasjon om rankene og lagrer til cache
game::$ranks = array("items" => array(), "items_number" => array(), "pos" => array(), "pos_max" => 0);
// hent rankene
$result = \Kofradia\DB::get()->query("SELECT id, name, points, rank_max_health, rank_max_energy FROM ranks ORDER BY points");
// sett opp data
$i = 0;
$last_id = 0;
while ($row = $result->fetch()) {
    // oppdater need_points til den forrige raden
    if ($last_id) {
        game::$ranks['items'][$last_id]['need_points'] = $row['points'] - game::$ranks['items'][$last_id]['points'];
        game::$ranks['items_number'][$i]['need_points'] = $row['points'] - game::$ranks['items'][$last_id]['points'];
    }
    $row['number'] = ++$i;
    game::$ranks['items'][$row['id']] = $row;
    game::$ranks['items_number'][$i] = game::$ranks['items'][$row['id']];
    $last_id = $row['id'];
}
// oppdater need_points til den siste raden
if ($last_id) {
    game::$ranks['items'][$last_id]['need_points'] = 0;
    game::$ranks['items_number'][$i]['need_points'] = 0;
}
// hent rankene for posisjonene
$result = \Kofradia\DB::get()->query("SELECT pos, name FROM ranks_pos ORDER BY pos");
$i = 0;
while ($row = $result->fetch()) {
    $row['number'] = ++$i;
    game::$ranks['pos'][$row['pos']] = $row;