function scoreboard($scores) { echo ' <table class="team-table table table-striped table-hover"> <thead> <tr> <th>#</th> <th>', lang_get('team'), '</th> <th class="text-center">', lang_get('country'), '</th> <th>', lang_get('points'), '</th> </tr> </thead> <tbody> '; $i = 1; foreach ($scores as $score) { echo ' <tr> <td>', number_format($i++), '</td> <td class="team-name"> <a href="user?id=', htmlspecialchars($score['user_id']), '"> <span class="team_', htmlspecialchars($score['user_id']), '"> ', htmlspecialchars($score['team_name']), ' </span> </a> </td> <td class="text-center"> ', country_flag_link($score['country_name'], $score['country_code']), ' </td> <td>', number_format($score['score']), '</td> </tr> '; } echo ' </tbody> </table> '; }
<?php require '../include/mellivora.inc.php'; login_session_refresh(); if (strlen(array_get($_GET, 'code')) != 2) { message_error(lang_get('please_supply_country_code')); } $country = db_select_one('countries', array('id', 'country_name', 'country_code'), array('country_code' => $_GET['code'])); if (!$country) { message_error(lang_get('please_supply_country_code')); } head($country['country_name']); if (cache_start(CONST_CACHE_NAME_COUNTRY . $_GET['code'], CONFIG_CACHE_TIME_COUNTRIES)) { section_head(htmlspecialchars($country['country_name']) . country_flag_link($country['country_name'], $country['country_code'], true), '', false); $scores = db_query_fetch_all(' SELECT u.id AS user_id, u.team_name, u.competing, co.id AS country_id, co.country_name, co.country_code, SUM(c.points) AS score, MAX(s.added) AS tiebreaker FROM users AS u LEFT JOIN countries AS co ON co.id = u.country_id LEFT JOIN submissions AS s ON u.id = s.user_id AND s.correct = 1 LEFT JOIN challenges AS c ON c.id = s.challenge WHERE u.competing = 1 AND co.id = :country_id GROUP BY u.id ORDER BY score DESC, tiebreaker ASC', array('country_id' => $country['id']));
require '../include/mellivora.inc.php'; validate_id($_GET['id']); head('User details'); if (cache_start('user_' . $_GET['id'], CONFIG_CACHE_TIME_USER)) { $user = db_query_fetch_one(' SELECT u.team_name, u.competing, co.country_name, co.country_code FROM users AS u LEFT JOIN countries AS co ON co.id = u.country_id WHERE u.id = :user_id', array('user_id' => $_GET['id'])); section_head(htmlspecialchars($user['team_name']), country_flag_link($user['country_name'], $user['country_code'], true), false); if (!$user['competing']) { message_inline_blue('This user is listed as a non-competitor.'); } $challenges = db_query_fetch_all(' SELECT ca.title, (SELECT SUM(ch.points) FROM challenges AS ch JOIN submissions AS s ON s.challenge = ch.id AND s.user_id = :user_id AND s.correct = 1 WHERE ch.category = ca.id GROUP BY ch.category) AS points, (SELECT SUM(ch.points) FROM challenges AS ch WHERE ch.category = ca.id GROUP BY ch.category) AS category_total FROM categories AS ca ORDER BY ca.title ASC', array('user_id' => $_GET['id'])); $user_total = 0; $ctf_total = 0; foreach ($challenges as $challenge) { echo '<strong>', htmlspecialchars($challenge['title']), '</strong>, ', number_format($challenge['points']), ' / ', number_format($challenge['category_total']), ' (', round($challenge['points'] / max(1, $challenge['category_total']) * 100), '%)'; progress_bar($challenge['points'] / max(1, $challenge['category_total']) * 100);
<?php require '../../include/mellivora.inc.php'; enforce_authentication(CONST_USER_CLASS_MODERATOR); validate_id(array_get($_GET, 'id')); head(lang_get('user_details')); $user = db_query_fetch_one(' SELECT u.id, u.team_name, u.email, u.competing, co.country_name, co.country_code FROM users AS u LEFT JOIN countries AS co ON co.id = u.country_id WHERE u.id = :user_id', array('user_id' => $_GET['id'])); if (empty($user)) { message_generic(lang_get('sorry'), lang_get('no_user_found'), false); } section_head(htmlspecialchars($user['team_name']), country_flag_link($user['country_name'], $user['country_code'], true) . button_link('Edit user', 'edit_user?id=' . htmlspecialchars($user['id'])) . ' ' . button_link('Email user', 'new_email?to=' . htmlspecialchars($user['email'])), false); if (!$user['competing']) { message_inline_blue(lang_get('non_competing_user')); } print_solved_graph($_GET['id']); print_solved_challenges($_GET['id']); print_user_ip_log($_GET['id'], 5); print_user_submissions($_GET['id'], 5); print_user_exception_log($_GET['id'], 5); foot();
u.class, u.enabled, co.country_name, co.country_code, COUNT(ipl.id) AS num_ips FROM users AS u LEFT JOIN ip_log AS ipl ON ipl.user_id = u.id LEFT JOIN countries AS co ON co.id = u.country_id GROUP BY u.id ORDER BY u.team_name ASC LIMIT ' . $from . ', ' . $results_per_page); foreach ($users as $user) { echo ' <tr> <td> ', country_flag_link($user['country_name'], $user['country_code']), ' <a href="', CONFIG_SITE_URL, 'user?id=', htmlspecialchars($user['id']), '">', htmlspecialchars($user['team_name']), '</a> </td> <td>', htmlspecialchars($user['email']), '</td> <td>', date_time($user['added']), '</td> <td>', user_class_name($user['class']), '</td> <td>', $user['enabled'] ? 'Yes' : 'No', '</td> <td><a href="list_ip_log.php?id=', htmlspecialchars($user['id']), '">', number_format($user['num_ips']), '</a></td> <td> <a href="edit_user.php?id=', htmlspecialchars($user['id']), '" class="btn btn-xs btn-primary">Edit</a> </td> </tr> '; } echo ' </tbody>