/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getMethodGuardian($starttimestamp); arsort($data); return $data; }
/** * @return null|object|Leaderboard * get singleton instance */ public static function getInstance() { if (!self::$instance) { self::$instance = new Leaderboard(); } return self::$instance; }
function update_leaderboard($leaderboard) { $loaded_leaderboard = new Leaderboard($leaderboard); $loaded_leaderboard->randMatchmaking($loaded_leaderboard->getBotNum(), 2); $loaded_leaderboard->randMatchmaking($loaded_leaderboard->getBotNum(), 4); $loaded_leaderboard->randMatchmaking($loaded_leaderboard->getBotNum(), 8); }
public static function leaderboard() { $schools = array("Bentley University", "Columbia College Chicago", "University of Rochester"); $counts = [7, 30, 90, 180]; foreach ($counts as $count) { $schoolCount[$count] = Leaderboard::getSchoolCountDaysBefore($schools, $count); } $schoolCount[0] = Leaderboard::getSchoolCountSince($schools, 0); self::render('stats/leaderboard', ['schools' => $schools, 'counts' => $schoolCount]); }
/** * export/download top 10 player into pdf * role: administrator */ public function get_player_top_10() { if (authenticate::is_authorized()) { $model_report = new ReportGenerator(); $model_leaderboard = Leaderboard::getInstance(); $model_report->get_report_top_10($model_leaderboard->get_top10_ranking()); $model_report->print_report(); } else { transport("administrator"); } }
/** * after user has logged in, player will redirected this page. * if the player session exist then player click home in navigation then redirected here too. * role: player * redirected from: Controller.Page.index() if user session is exist * Controller.Player.login() if credential is granted * Controller.Player.logout() if destroy current session is failed * Controller.Player.update_profile() if profile is updated * Controller.Player.update_avatar() if avatar is changed */ public function sign() { if (Authenticate::is_player()) { $model_leaderboard = Leaderboard::getInstance(); $this->framework->view->page = "index"; $this->framework->view->section = PageController::SIGN; $this->framework->view->content = "/frontend/pages/index"; $this->framework->view->summary = $model_leaderboard->get_player_ranking(); $this->framework->view->show("frontend/template"); } else { transport("page"); } }
/** * export/download overall report into pdf * role: administrator */ public function get_overall() { if (Authenticate::is_authorized()) { $model_player = Player::getInstance(); $model_feedback = Feedback::getInstance(); $model_administrator = Administrator::getInstance(); $model_leaderboard = Leaderboard::getInstance(); $model_report = new ReportGenerator(); $model_report->get_report_overall($model_player->get_player_report(), $model_feedback->retrieve_feedback_report(), $model_administrator->retrieve_traffic_report(), $model_leaderboard->get_top10_ranking()); $model_report->print_report(); } else { transport("administrator"); } }
/** * retrieve player ranking and global ranking. * route : player */ public function retrieve_leaderboard() { if (Authenticate::is_player()) { if (isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_leaderboard = Leaderboard::getInstance(); $player_ranking = $this->model_leaderboard->get_player_ranking(); $global_ranking = $this->model_leaderboard->get_global_ranking(); $binding = array("result_var" => "session_ready", "leaderboard_player_var" => json_encode($player_ranking), "leaderboard_global_var" => json_encode($global_ranking)); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
function testRankedInList() { $leaderboard = new Leaderboard('leaderboard'); for ($i = 1; $i <= Leaderboard::DEFAULT_PAGE_SIZE; $i++) { $leaderboard->addMember("member_{$i}", $i); } $this->assertEquals(Leaderboard::DEFAULT_PAGE_SIZE, $leaderboard->totalMembers()); $members = array('member_1', 'member_5', 'member_10'); $rankedMembers = $leaderboard->rankedInList($members); $this->assertEquals(3, count($rankedMembers)); $this->assertEquals(25, $rankedMembers[0]['rank']); $this->assertEquals(1, $rankedMembers[0]['score']); $this->assertEquals(21, $rankedMembers[1]['rank']); $this->assertEquals(5, $rankedMembers[1]['score']); $this->assertEquals(16, $rankedMembers[2]['rank']); $this->assertEquals(10, $rankedMembers[2]['score']); }
function render($twig, $sdata = array()) { // time or score leaderboards if (isset($_GET['times'])) { $times = true; } else { $times = false; } // page defaults to 0 if (isset($_GET['page']) && (int) $_GET['page'] > 0) { $page = $_GET['page']; } else { $page = 0; } // get a leaderboard object $leaderboards_today = new Leaderboard(); // and populate it with either today's entries or entries from a given day if (isset($_GET['date'])) { $today = $leaderboards_today->createGlobal($_GET['date'], 'rank', 'ASC', $page * 30, 30, $times); } else { $today = $leaderboards_today->createGlobal(0, 'rank', 'ASC', $page * 30, 30, $times); } // it might happen that some leaderboards aren't ready yet // for the days to come if ($today) { $today = $today->toArray(); } else { echo $twig->render('index.php', $sdata); return false; } // get yesterday's leaderboards $leaderboards_yesterday = new Leaderboard(); $yesterday = $leaderboards_yesterday->createGlobal(1, 'rank', 'ASC', 0, 5, $times)->toArray(); // get global stats $global = $leaderboards_today->globalStats; // prev and next dates $first_daily = new DateTime('2015-10-30'); $date = new DateTime($leaderboards_today->date); $date->sub(new DateInterval('P1D')); $prevdate = $date >= $first_daily ? $date->format('Y-m-d') : $leaderboards_today->date; // $date->add(new DateInterval('P2D')); $nextdate = $date->format('Y-m-d'); // get user's friends ranks if available if (isset($_SESSION['steamid']) && $sdata['friends']) { $f = new Friends(); $friends = $f->getFriendsRanks($_SESSION['steamid'], $leaderboards_today->dayid); // if no friends have already played today's daily // return a full list of friends if (!$friends) { $friends = $sdata['friends']; } } if ($_SESSION['admin'] > 0) { unset($_SESSION['date']); } // where the wild things are $kids = ceil($global['cleanruns'] / 30) - 1; // get today's challenge from db $challenge = $leaderboards_today->challenge; // create the css class used for both the char and objective icons switch ($challenge['char_id']) { case 0: $daily_char = 'isaac'; break; case 1: $daily_char = 'maggie'; break; case 2: $daily_char = 'cain'; break; case 3: $daily_char = 'judas'; break; case 4: $daily_char = 'xxx'; break; case 5: $daily_char = 'eve'; break; case 6: $daily_char = 'samson'; break; case 7: $daily_char = 'azazel'; break; case 8: $daily_char = 'lazarus'; break; case 9: $daily_char = 'eden'; break; case 10: $daily_char = 'thelost'; break; case 11: $daily_char = 'lazarus2'; break; case 12: $daily_char = 'judas2'; break; case 13: $daily_char = 'lilith'; break; case 14: $daily_char = 'keeper'; break; default: $daily_char = 'question-mark'; break; } // endfloor switch ($challenge['endlevel']) { case 6: $daily_floor = 'mom'; break; case 8: $daily_floor = 'womb'; break; case 101: $daily_floor = 'cathedral'; break; case 111: $daily_floor = 'chest'; break; case 100: $daily_floor = 'sheol'; break; case 110: $daily_floor = 'darkroom'; break; case 257: $daily_floor = 'greed'; break; default: $daily_floor = 'question-mark'; break; } // mega satan flag if ($challenge['megasatan']) { $daily_floor = 'mega-satan'; } // hard mode flag if ($challenge['hard']) { $daily_floor .= '-hard'; } // challenge array $challenge = array('char' => $daily_char, 'floor' => $daily_floor); // send out to render $data = array('location' => $times ? 'times' : 'scores', 'date' => $leaderboards_today->date, 'challenge' => $challenge, 'prevdate' => $prevdate, 'nextdate' => $nextdate, 'scores' => $today, 'scores_yesterday' => $yesterday, 'kids' => $kids, 'friends' => $friends, 'global' => $global, 'page' => $page + 1); if (isset($_GET['json'])) { print json_encode($today); } else { echo $twig->render('index.php', array_merge($sdata, $data)); } }
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getImagesAdded($starttimestamp); arsort($data); return $data; }
<?php require_once 'leaderboard.php'; $deviceTypeFilter = htmlentities($_GET['deviceType']); $leaderboard = new Leaderboard($deviceTypeFilter); $scores = $leaderboard->getLeaderboard(); $i = 0; $rank = 0; $curScore = 0; $scoresArr = array(); foreach ($scores as $entry) { $score = (int) $entry['Score']; $scoreDate = $entry['ScoreAddedOn']; $playerName = $entry['PlayerName']; $deviceType = $entry['DeviceType']; if ($score != $curScore) { $rank++; $curScore = $score; } $scoresArr[$i]['rank'] = $rank; $scoresArr[$i]['name'] = $playerName; $scoresArr[$i]['device'] = $deviceType; $scoresArr[$i]['date'] = date("d/m/Y", strtotime($scoreDate)); $scoresArr[$i]['score'] = $score; $i++; } unset($i);
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getQCPatrols($starttimestamp); arsort($data); return $data; }
/** * load game data every play game. * role: player * @return string */ public function load_data() { if (Authenticate::is_player()) { if (true || isset($_POST['token']) && Authenticate::is_valid_token($_POST['token'])) { $this->model_product = Product::getInstance(); $this->model_material = Material::getInstance(); $this->model_asset = Asset::getInstance(); $this->model_supplier = Supplier::getInstance(); $this->model_employee = Employee::getInstance(); $this->model_achievement = Achievement::getInstance(); $this->model_journal = Journal::getInstance(); $this->model_memorycard = Memorycard::getInstance(); $this->model_leaderboard = Leaderboard::getInstance(); /* * retrieve data each component. * log this event, wrap it up and convert to json format. */ $game = $this->model_memorycard->load_game_data(); $work_history = $this->model_memorycard->get_work_stress_history(); $total_work = $this->model_memorycard->get_total_work(); $candidate = $this->model_employee->get_candidate(); $employee = $this->model_employee->get_player_employee(); $material = $this->model_material->get_material_data(); $player_material = $this->model_material->get_player_material(); $asset = $this->model_asset->get_asset_data(); $player_asset = $this->model_asset->get_player_asset(); $product = $this->model_product->get_product_data(); $player_product = $this->model_product->get_player_product(); $product_material = $this->model_product->get_product_material(); $supplier = $this->model_supplier->get_supplier_data(); $achievement = $this->model_achievement->get_achievement(); $account = $this->model_journal->get_account(); $simulation = $this->model_memorycard->get_simulation(); $star = $this->model_leaderboard->get_player_ranking(); $binding = array("result_var" => "session_ready", "game_var" => json_encode($game, JSON_PRETTY_PRINT), "candidate_var" => json_encode($candidate, JSON_PRETTY_PRINT), "employee_var" => json_encode($employee, JSON_PRETTY_PRINT), "product_var" => json_encode($product, JSON_PRETTY_PRINT), "player_product_var" => json_encode($player_product, JSON_PRETTY_PRINT), "product_material_var" => json_encode($product_material, JSON_PRETTY_PRINT), "material_var" => json_encode($material, JSON_PRETTY_PRINT), "player_material_var" => json_encode($player_material, JSON_PRETTY_PRINT), "asset_var" => json_encode($asset, JSON_PRETTY_PRINT), "player_asset_var" => json_encode($player_asset, JSON_PRETTY_PRINT), "supplier_var" => json_encode($supplier, JSON_PRETTY_PRINT), "achievement_var" => json_encode($achievement, JSON_PRETTY_PRINT), "account_var" => json_encode($account, JSON_PRETTY_PRINT), "simulation_var" => json_encode($simulation, JSON_PRETTY_PRINT), "work_history_var" => json_encode($work_history, JSON_PRETTY_PRINT), "work_total_var" => $total_work, "star" => $star["star"]); $log = Log::getInstance(); $log->logging_game_load(json_encode($binding)); binding_data($binding); } else { transport("error404"); } } else { $binding = array("result_var" => "no_session"); binding_data($binding); } }
function getrankings($code) { $result = Leaderboard::getStaticRankTableInJSON($code); return json_decode($result['ranktable'], true); }
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getArticlesRepaired($starttimestamp, 'topic'); arsort($data); return $data; }
$alrighty = true; if (file_exists('../../data/logs/' . $gameid . '.xml')) { $xml = simplexml_load_file('../../data/logs/' . $gameid . '.xml'); foreach ($xml->event as $event) { if ((int) $event->logger == $botid && $event->severity == 1) { // error found $alrighty = false; break; } } if ($alrighty) { SQL("UPDATE bots SET state = 'ok', runError = '0' WHERE id = ?", $botid); $tablesToAdd = SQL("SELECT leaderboardID FROM compiling_bots_leaderboards WHERE botID = ?", $botid); for ($i = 0; $i < count($tablesToAdd); $i++) { $leaderboard = SQL("SELECT * FROM leaderboards WHERE id = ?", $tablesToAdd[$i]["leaderboardID"]); $loaded_leaderboard = new Leaderboard($leaderboard[0]); $loaded_leaderboard->addBot($botid); } SQL("DELETE FROM compiling_bots_leaderboards WHERE botID = ?", $botid); } else { SQL("UPDATE bots SET state = 'runtime', runError = ? WHERE id = ?", $gameid, $botid); } } } else { SQL("UPDATE bots SET state='runtime', runError = ? WHERE id = ?", $gameid, $botid); } } } else { SQL("UPDATE bots SET state = 'compilation', compError = ? WHERE id = ?", $stderr, $botid); } }
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getRCEdits($starttimestamp); //for some reason we shouldn't be sorting if its RC data //arsort($data); return $data; }
needLogin(); if (isset($_GET["leaderboardID"]) && isset($_GET["botID"]) && isset($_GET["action"])) { //validate $lbID = $_GET["leaderboardID"]; $botID = $_GET["botID"]; $action = $_GET["action"]; if (is_numeric($lbID) && is_numeric($botID) && ($action == "1" || $action == "0")) { //get bot and add to leaderboard $res = SQL("SELECT COUNT(*) FROM bots WHERE id = ? AND accountID = ?", $botID, $_SESSION["accountID"]); if ($res == null) { echo 0; exit; } $leaderboard = SQL("SELECT * FROM leaderboards WHERE id = ?", $lbID); if ($leaderboard == null) { echo 0; exit; } $loaded_leaderboard = new Leaderboard($leaderboard[0]); if ($action == "1") { $loaded_leaderboard->addBot($botID); } else { $loaded_leaderboard->removeBot($botID); } echo '1'; } else { die("Invalid request"); } } else { die("Invalid request"); }
/** * * Gets data from the Leaderboard class for this widget */ function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getArticlesNABed($starttimestamp); arsort($data); return $data; }
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getRequestedTopics($starttimestamp); arsort($data); return $data; }
public static function RefreshRanks($data) { if (isset($data['dayid'])) { $dayid = $data['dayid']; } elseif (isset($data['date'])) { $date = $data['date']; $lb = new Leaderboard(); $dayid = $lb->getLeaderboardId($date)[0]; } if ($dayid == 0) { return false; } if (isset($data['nodamage'])) { self::FlagNoDamage($dayid); } if (isset($data['rush'])) { self::Flag2Fast2Furious($dayid, $data['minutes']); } self::$db = Application::$db; // recompute players hax values /*$stmt = self::$db->query(" UPDATE players AS p INNER JOIN ( SELECT steamid, COUNT(*) AS hax FROM scores WHERE hidden = 1 GROUP BY steamid ) h USING(steamid) SET p.hax = h.hax, p.last_updated = p.last_updated"); */ // recompute score ranks $stmt = self::$db->query("SET @rank = 0"); $stmt = self::$db->prepare("\r\n UPDATE scores AS s\r\n JOIN (\r\n SELECT hash,\r\n CASE\r\n WHEN (hax < 3 AND\r\n hidden != 1 AND\r\n hidden != 3)\r\n THEN (@rank := @rank+1)\r\n ELSE 999999\r\n END AS rank\r\n FROM scores\r\n JOIN players AS p USING (steamid)\r\n WHERE dayid = :dayid\r\n ORDER BY score DESC\r\n ) AS r USING (hash)\r\n SET s.rank = r.rank,\r\n s.last_updated = s.last_updated"); $stmt->execute(array(':dayid' => $dayid)); // recompute time ranks $stmt = self::$db->query("SET @rank = 0"); $stmt = self::$db->prepare("\r\n UPDATE times AS t\r\n JOIN (\r\n SELECT hash,\r\n CASE\r\n WHEN (hax < 3 AND\r\n hidden != 1 AND\r\n hidden != 3)\r\n THEN (@rank := @rank+1)\r\n ELSE 999999\r\n END AS rank\r\n FROM times\r\n JOIN players AS p USING (steamid)\r\n WHERE (dayid = :dayid)\r\n ORDER BY floor DESC,\r\n time ASC\r\n ) AS r USING (hash)\r\n SET t.rank = r.rank"); $stmt->execute(array(':dayid' => $dayid)); }
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getNfdsReviewed($starttimestamp); arsort($data); return $data; }
/** * * Gets data from the Leaderboard class for this widget */ public function getLeaderboardData(&$dbr, $starttimestamp) { $data = Leaderboard::getSpellchecked($starttimestamp); arsort($data); return $data; }
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * A self hosted Open source PHP Leaderboard. Post, fetch and display high scores. * @link http://ukelelestudio.com */ //Permissive mode header('Access-Control-Allow-Origin: *'); header('Access-Control-Allow-Headers: Access-Control-Allow-Origin'); $f3 = (require 'lib/base.php'); $f3->config('config.ini'); $f3->set('AUTOLOAD', 'app/;app/inc/'); $f3->set('DEBUG', 3); $leaderboard = Leaderboard::instance(); $leaderboardC2 = LeaderboardC2::instance(); $construct2 = Json2Construct2::instance(); $crypt = Cryptme::instance(); $util = Utils::instance(); $f3->set('leaderboard', $leaderboard); $f3->set('leaderboardC2', $leaderboard); $f3->set('construct2', $construct2); $f3->set('cryptme', $crypt); $f3->set('util', $util); $sanidad = Sanidad::instance($f3); $f3->set('sanidad', $sanidad); //Routing $f3->route('GET /addscore/@game/@key/@playername/@score', 'leaderboardC2->addScore'); $f3->route('GET /getlastrank/@game/@playername', 'leaderboardC2->getLastRank'); $f3->route('GET /getbestrank/@game/@playername', 'leaderboardC2->getBestRank');