Пример #1
0
function print_solved_challenges($user_id)
{
    validate_id($user_id);
    section_head(lang_get('solved_challenges'));
    $submissions = db_query_fetch_all('
        SELECT
           s.added,
           ((SELECT COUNT(*) FROM submissions AS ss WHERE ss.correct = 1 AND ss.added < s.added AND ss.challenge=s.challenge)+1) AS pos,
           ch.id AS challenge_id,
           ch.available_from,
           ch.title,
           ch.points,
           ca.title AS category_title
        FROM submissions AS s
        LEFT JOIN challenges AS ch ON ch.id = s.challenge
        LEFT JOIN categories AS ca ON ca.id = ch.category
        WHERE
           s.correct = 1 AND
           s.user_id = :user_id AND
           ch.exposed = 1 AND
           ca.exposed = 1
        ORDER BY s.added DESC', array('user_id' => $user_id));
    if (count($submissions)) {
        echo '
      <table class="table table-striped table-hover">
        <thead>
          <tr>
            <th>', lang_get('challenge'), '</th>
            <th>', lang_get('solved'), '</th>
            <th>', lang_get('points'), '</th>
          </tr>
        </thead>
        <tbody>
       ';
        foreach ($submissions as $submission) {
            echo '
              <tr>
                <td>
                    <a href="', CONFIG_SITE_URL, 'challenge?id=', htmlspecialchars($submission['challenge_id']), '">
                    ', htmlspecialchars($submission['title']), '
                    </a> (', htmlspecialchars($submission['category_title']), ')
                </td>

                <td>
                    ', get_position_medal($submission['pos'], true), '
                    ', time_elapsed($submission['added'], $submission['available_from']), ' ', lang_get('after_release'), ' (', date_time($submission['added']), ')
                </td>

                <td>', number_format($submission['points']), '</td>
              </tr>
              ';
        }
        echo '
        </tbody>
      </table>
          ';
    } else {
        message_inline_blue(lang_get('no_challenges_solved'));
    }
}
/**
* Output transaction details via HTML code
*
* @param	string	$tx_id
*/
function tx_detail($tx_id)
{
    $raw_tx = getrawtransaction($tx_id);
    if (!isset($raw_tx["txid"])) {
        section_head("Error");
        section_subhead("This transaction is not in the blockchain");
        return;
    }
    section_head("Transaction: " . $raw_tx["txid"]);
    section_subhead("Detailed Description");
    detail_display("TX Version", $raw_tx["version"]);
    detail_display("TX Time", date("F j, Y, H:i:s", $raw_tx["time"]));
    detail_display("Lock Time", $raw_tx["locktime"]);
    detail_display("Confirmations", $raw_tx["confirmations"]);
    detail_display("Block Hash", blockhash_link($raw_tx["blockhash"]));
    //	Florin Coin Feature
    if (isset($raw_tx["tx-comment"]) && $raw_tx["tx-comment"] != "") {
        detail_display("TX Message", htmlspecialchars($raw_tx["tx-comment"]));
    }
    detail_display("HEX Data", $raw_tx["hex"], 50);
    section_head("Transaction Inputs");
    foreach ($raw_tx["vin"] as $key => $txin) {
        section_subhead("Input Transaction " . $key);
        if (isset($txin["coinbase"])) {
            detail_display("Coinbase", $txin["coinbase"]);
            detail_display("Sequence", $txin["sequence"]);
        } else {
            detail_display("TX ID", tx_link($txin["txid"]));
            detail_display("TX Output", $txin["vout"]);
            detail_display("TX Sequence", $txin["sequence"]);
            detail_display("Script Sig (ASM)", $txin["scriptSig"]["asm"], 50);
            detail_display("Script Sig (HEX)", $txin["scriptSig"]["hex"], 50);
        }
    }
    section_head("Transaction Outputs");
    foreach ($raw_tx["vout"] as $key => $txout) {
        section_subhead("Output Transaction " . $key);
        detail_display("TX Value", $txout["value"]);
        detail_display("TX Type", $txout["scriptPubKey"]["type"]);
        if (isset($txout["scriptPubKey"]["reqSigs"])) {
            detail_display("Required Sigs", $txout["scriptPubKey"]["reqSigs"]);
        }
        detail_display("Script Pub Key (ASM)", $txout["scriptPubKey"]["asm"], 50);
        detail_display("Script Pub Key (HEX)", $txout["scriptPubKey"]["hex"], 50);
        if (isset($txout["scriptPubKey"]["addresses"])) {
            foreach ($txout["scriptPubKey"]["addresses"] as $key => $address) {
            }
            detail_display("Address " . $key, $address);
        }
    }
    /* Commented as all the raw info is already presented above
    	section_head ("Raw Transaction Detail");
    	
    	echo "	<textarea name=\"rawtrans\" rows=\"25\" cols=\"80\" style=\"text-align:left;\">\n";
    	print_r ($raw_tx);
    	echo "	\n</textarea><br><br>\n";*/
}
Пример #3
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
head('Users');
menu_management();
section_head('Users');
echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Team</th>
          <th>Email</th>
          <th>Added</th>
          <th>Class</th>
          <th>Enabled</th>
          <th>Num IPs</th>
          <th>Manage</th>
        </tr>
      </thead>
      <tbody>
    ';
$values = array();
$search_for = array_get($_GET, 'search_for');
if ($search_for) {
    $values['search_for_team_name'] = '%' . $search_for . '%';
    $values['search_for_email'] = '%' . $search_for . '%';
}
$from = get_pager_from($_GET);
$num_users = db_count_num('users');
$results_per_page = 100;
Пример #4
0
<?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']));
Пример #5
0
<?php

require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Hints');
menu_management();
section_head('Hints', button_link('Add new hint', 'new_hint'), false);
echo '
    <table id="hints" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Challenge</th>
          <th>Added</th>
          <th>Hint</th>
          <th>Manage</th>
        </tr>
      </thead>
      <tbody>
    ';
$hints = db_query_fetch_all('
    SELECT
       h.id,
       h.added,
       h.body,
       c.title
    FROM hints AS h
    LEFT JOIN challenges AS c ON c.id = h.challenge');
foreach ($hints as $hint) {
    echo '
    <tr>
        <td>', htmlspecialchars($hint['title']), '</td>
Пример #6
0
     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);
     $user_total += $challenge['points'];
     $ctf_total += $challenge['category_total'];
 }
 echo 'Total: ', number_format($user_total), ' / ', number_format($ctf_total), ' (', round($user_total / $ctf_total * 100, 1), '%)';
 section_head('Solved challenges');
 $submissions = db_query_fetch_all('
     SELECT
        s.added,
        ((SELECT COUNT(*) FROM submissions AS ss WHERE ss.correct = 1 AND ss.added < s.added AND ss.challenge=s.challenge)+1) AS pos,
        ch.id AS challenge_id,
        ch.available_from,
        ch.title,
        ch.points,
        ca.title AS category_title
     FROM submissions AS s
     LEFT JOIN challenges AS ch ON ch.id = s.challenge
     LEFT JOIN categories AS ca ON ca.id = ch.category
     WHERE
        s.correct = 1 AND
        s.user_id = :user_id
Пример #7
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('IP log');
menu_management();
$where = array();
if (is_valid_ip(array_get($_GET, 'ip'))) {
    section_head('Teams using IP ' . $_GET['ip']);
    $where['ip'] = ip2long($_GET['ip']);
} else {
    if (is_valid_id(array_get($_GET, 'user_id'))) {
        section_head('IP log for user');
        $where['user_id'] = $_GET['user_id'];
    } else {
        message_error('Must supply either IP or user ID');
    }
}
echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Team name</th>
          <th>Hostname</th>
          <th>First used</th>
          <th>Last used</th>
          <th>Times used</th>
        </tr>
      </thead>
      <tbody>
    ';
Пример #8
0
<?php

require '../include/ctf.inc.php';
prefer_ssl();
head(lang_get('two_factor_auth_required'));
section_head(lang_get('two_factor_auth_required'));
form_start('actions/two_factor_auth');
form_input_text('Code', false, array('autocomplete' => 'off', 'autofocus' => true));
form_hidden('action', 'authenticate');
form_button_submit(lang_get('authenticate'));
form_end();
foot();
Пример #9
0
            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 u.user_type = :user_type
            GROUP BY u.id
            ORDER BY score DESC, tiebreaker ASC', array('user_type' => $user_type['id']));
            scoreboard($scores);
        }
    }
    echo '
        </div>  <!-- / span6 -->

        <div class="col-lg-6">
        ';
    section_head('Challenges');
    $categories = db_query_fetch_all('
        SELECT
           id,
           title,
           available_from,
           available_until
        FROM
           categories
        WHERE
           available_from < ' . $now . '
        ORDER BY title');
    foreach ($categories as $category) {
        echo '
        <table class="table table-striped table-hover">
          <thead>
Пример #10
0
<?php

require '../include/mellivora.inc.php';
login_session_refresh();
if (!isset($_GET['show'])) {
    message_error(lang_get('please_request_page'));
}
$menu_data = db_select_one('dynamic_menu', array('internal_page'), array('permalink' => $_GET['show']));
if (!is_valid_id($menu_data['internal_page'])) {
    message_error(lang_get('not_a_valid_link'));
}
$content = db_select_one('dynamic_pages', array('id', 'title', 'body', 'visibility', 'min_user_class'), array('id' => $menu_data['internal_page']));
if ($content['visibility'] == 'private') {
    enforce_authentication($content['min_user_class']);
}
head($content['title']);
if (cache_start($content['id'], CONFIG_CACHE_TIME_DYNAMIC, CONST_CACHE_DYNAMIC_PAGES_GROUP)) {
    section_head($content['title']);
    require CONST_PATH_THIRDPARTY . 'nbbc/nbbc.php';
    $bbc = new BBCode();
    $bbc->SetEnableSmileys(false);
    echo $bbc->parse($content['body']);
    cache_end($content['id'], CONST_CACHE_DYNAMIC_PAGES_GROUP);
}
foot();
Пример #11
0
        ca.title AS category_title
     FROM hints AS h
     LEFT JOIN challenges AS c ON c.id = h.challenge
     LEFT JOIN categories AS ca ON ca.id = c.category
     WHERE
       c.available_from < UNIX_TIMESTAMP() AND
       c.available_until > UNIX_TIMESTAMP() AND
       h.visible = 1 AND
       c.exposed = 1 AND
       ca.exposed = 1
     ORDER BY h.id DESC
 ');
 if (!count($hints)) {
     message_generic(lang_get('hints'), lang_get('no_hints_available'), false);
 }
 section_head('Hints');
 echo '
     <table id="files" class="table table-striped table-hover">
       <thead>
         <tr>
           <th>', lang_get('category'), '</th>
           <th>', lang_get('challenge'), '</th>
           <th>', lang_get('added'), '</th>
           <th>', lang_get('hint'), '</th>
         </tr>
       </thead>
       <tbody>
     ';
 foreach ($hints as $hint) {
     echo '
     <tr>
Пример #12
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
require CONFIG_PATH_THIRDPARTY . 'nbbc/nbbc.php';
$bbc = new BBCode();
$bbc->SetEnableSmileys(false);
head('Site management');
menu_management();
section_head('List news');
$news = db_query_fetch_all('SELECT * FROM news WHERE instanceID=\'' . $_SESSION["IID"] . '\' ORDER BY added DESC');
foreach ($news as $item) {
    echo '
        <div class="news-container">';
    section_head($item['title'] . ' <a href="edit_news.php?id=' . htmlspecialchars($item['id']) . '" class="btn btn-xs btn-primary">Edit</a>', '', false);
    echo '
        <div class="news-body">
                ', $item['body'], '
            </div>
        </div>
        ';
}
foot();
Пример #13
0
            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
              u.user_type = :user_type
            GROUP BY u.id
            ORDER BY score DESC, tiebreaker ASC', array('user_type' => $user_type['id']));
            scoreboard($scores);
        }
    }
    echo '
        </div>  <!-- / span6 -->

        <div class="col-lg-6">
        ';
    section_head(lang_get('challenges'));
    $categories = db_query_fetch_all('
        SELECT
           id,
           title,
           available_from,
           available_until
        FROM
           categories
        WHERE
           available_from < ' . $now . ' AND
           exposed = 1
        ORDER BY title');
    challenges($categories);
    echo '
        </div> <!-- / span6 -->
Пример #14
0
<?php

require '../include/mellivora.inc.php';
prefer_ssl();
enforce_authentication();
head('Expression of interest');
section_head('Expression of interest');
message_inline_bland("Like the look of our sponsors? They're all hiring. Please fill out the form below if you wish to be contacted with recruitment information. Each team member can fill out the form individually. We won't share your details with anyone but our sponsors. We won't spam you. Only addresses entered into this form will be shared.");
form_start('actions/recruit', 'form-signin');
echo '
    <input name="name" type="text" class="form-control" placeholder="Name (optional)">
    <input name="email" type="email" class="form-control" placeholder="Email address" required>
    <input name="city" type="text" class="form-control" placeholder="City (optional)">
    ';
country_select();
form_hidden('action', 'register');
echo '
    <button class="btn btn-primary" type="submit">Register interest</button>
    ';
form_end();
foot();
Пример #15
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
head('User types');
menu_management();
section_head('Users types');
echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Title</th>
          <th>Description</th>
          <th></th>
        </tr>
      </thead>
      <tbody>
    ';
$types = db_query_fetch_all('SELECT * FROM user_types ORDER BY title ASC');
foreach ($types as $type) {
    echo '
    <tr>
        <td>', htmlspecialchars($type['title']), '</td>
        <td>', short_description($type['description'], 50), '</td>
        <td><a href="edit_user_type.php?id=', htmlspecialchars($type['id']), '" class="btn btn-xs btn-primary">Edit</a></td>
    </tr>
    ';
}
echo '
      </tbody>
    </table>
Пример #16
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Email signup rules');
menu_management();
section_head('Email signup rules', button_link('Add new rule', 'new_restrict_email'), false);
message_inline_blue('Rules in list below are applied top-down. Rules further down on the list override rules above.
                     List is ordered by "priority". A higher "priority" value puts a rule further down the list.
                     Rules are PCRE regex. Example: ^.+@.+$');
echo '
    <table id="rules" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Rule</th>
          <th>Added</th>
          <th>Added by</th>
          <th>Type</th>
          <th>Priority</th>
          <th>Enabled</th>
          <th>Manage</th>
        </tr>
      </thead>
      <tbody>
    ';
$rules = db_query_fetch_all('
    SELECT
       re.id,
       re.added,
       re.added_by,
       re.rule,
Пример #17
0
     message_generic('Sorry', 'This challenge is not yet available', false);
 }
 $submissions = db_query_fetch_all('SELECT
         u.id AS user_id,
         u.team_name,
         s.added,
         c.available_from
       FROM users AS u
       LEFT JOIN submissions AS s ON s.user_id = u.id
       LEFT JOIN challenges AS c ON c.id = s.challenge
       WHERE
          u.competing = 1 AND
          s.challenge = :id AND
          s.correct = 1
       ORDER BY s.added ASC', array('id' => $_GET['id']));
 section_head($challenge['title']);
 $num_correct_solves = count($submissions);
 if (!$num_correct_solves) {
     echo 'This challenge has not yet been solved by any teams.';
 } else {
     $user_count = db_query_fetch_one('SELECT COUNT(*) AS num FROM users WHERE competing = 1');
     echo 'This challenge has been solved by ', number_format($num_correct_solves / $user_count['num'] * 100, 1), '% of users.';
     echo '
    <table class="challenge-table table table-striped table-hover">
    <thead>
    <tr>
      <th>Position</th>
      <th>Team</th>
      <th>Solved</th>
    </tr>
    </thead>
Пример #18
0
<?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();
Пример #19
0
}
$query = '
    FROM submissions AS s
    LEFT JOIN users AS u on s.user_id = u.id
    LEFT JOIN challenges AS c ON c.id = s.challenge
';
if (!empty($where)) {
    $query .= 'WHERE ' . implode('=? AND ', array_keys($where)) . '=? ';
}
if (array_get($_GET, 'user_id')) {
    section_head('User submissions', button_link('List all submissions', 'list_submissions?only_needing_marking=0'), false);
} else {
    if ($only_needing_marking) {
        section_head('Submissions in need of marking', button_link('List all submissions', 'list_submissions?only_needing_marking=0'), false);
    } else {
        section_head('All submissions', button_link('Show only submissions in need of marking', 'list_submissions?only_needing_marking=1'), false);
    }
}
$num_subs = db_query_fetch_one('
    SELECT
       COUNT(*) AS num
    ' . $query, array_values($where));
$from = get_pager_from($_GET);
$results_per_page = 70;
pager(CONFIG_SITE_ADMIN_URL . 'list_submissions', $num_subs['num'], $results_per_page, $from);
echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Challenge</th>
          <th>Team name</th>
Пример #20
0
<?php

require '../include/mellivora.inc.php';
validate_id(array_get($_GET, 'id'));
head(lang_get('user_details'));
if (cache_start(CONST_CACHE_NAME_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']));
    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), false);
    if (!$user['competing']) {
        message_inline_blue(lang_get('non_competing_user'));
    }
    print_solved_graph($_GET['id']);
    print_solved_challenges($_GET['id']);
    cache_end(CONST_CACHE_NAME_USER . $_GET['id']);
}
foot();
Пример #21
0
<?php

require '../include/ctf.inc.php';
prefer_ssl();
enforce_authentication();
head(lang_get('expression_of_interest'));
section_head(lang_get('expression_of_interest'));
message_inline_bland(lang_get('recruitment_text'));
form_start('actions/recruit', 'form-signin');
echo '
    <input name="name" type="text" class="form-control" placeholder="', lang_get('name_optional'), '">
    <input name="email" type="email" class="form-control" placeholder="', lang_get('email_address'), '" required>
    <input name="city" type="text" class="form-control" placeholder="', lang_get('city_optional'), '">
    ';
country_select();
form_hidden('action', 'register');
echo '
    <button class="btn btn-primary" type="submit">', lang_get('register_interest'), '</button>
    ';
form_end();
foot();
Пример #22
0
       ca.available_from < UNIX_TIMESTAMP() AND
       ca.exposed = 1
     ORDER BY ca.title ASC', array('user_id' => $_GET['id']));
 if (empty($challenges)) {
     message_generic(lang_get('no_information'), lang_get('no_solves'), false);
 }
 $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);
     $user_total += $challenge['points'];
     $ctf_total += $challenge['category_total'];
 }
 echo lang_get('total_solves'), ' ', number_format($user_total), ' / ', number_format($ctf_total), ' (', round($user_total / $ctf_total * 100, 1), '%)';
 section_head(lang_get('solved_challenges'));
 $submissions = db_query_fetch_all('
     SELECT
        s.added,
        ((SELECT COUNT(*) FROM submissions AS ss WHERE ss.correct = 1 AND ss.added < s.added AND ss.challenge=s.challenge)+1) AS pos,
        ch.id AS challenge_id,
        ch.available_from,
        ch.title,
        ch.points,
        ca.title AS category_title
     FROM submissions AS s
     LEFT JOIN challenges AS ch ON ch.id = s.challenge
     LEFT JOIN categories AS ca ON ca.id = ch.category
     WHERE
        s.correct = 1 AND
        s.user_id = :user_id AND
Пример #23
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
head('IP log');
menu_management();
// show a users IP log
if (isset($_GET['id']) && valid_id($_GET['id'])) {
    $user = db_select_one('users', array('team_name'), array('id' => $_GET['id']));
    section_head('IP log for team: <a href="' . CONFIG_SITE_URL . 'user?id=' . $_GET['id'] . '">' . htmlspecialchars($user['team_name']) . '</a>', '', false);
    user_ip_log($_GET['id']);
} else {
    if (isset($_GET['ip']) && valid_ip($_GET['ip'])) {
        section_head('Teams using IP ' . $_GET['ip']);
        echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Team name</th>
          <th>Hostname</th>
          <th>First used</th>
          <th>Last used</th>
          <th>Times used</th>
        </tr>
      </thead>
      <tbody>
    ';
        $entries = db_query_fetch_all('
        SELECT
           INET_NTOA(ipl.ip) AS ip,
           ipl.added,
Пример #24
0
<?php

require '../include/mellivora.inc.php';
login_session_refresh();
head('Home');
if (cache_start('home', CONFIG_CACHE_TIME_HOME)) {
    require CONFIG_PATH_THIRDPARTY . 'nbbc/nbbc.php';
    $bbc = new BBCode();
    $bbc->SetEnableSmileys(false);
    $news = db_query_fetch_all('SELECT * FROM news ORDER BY added DESC');
    foreach ($news as $item) {
        echo '
        <div class="news-container">';
        section_head($item['title']);
        echo '
            <div class="news-body">
                ', $bbc->parse($item['body']), '
            </div>
        </div>
        ';
    }
    cache_end('home');
}
foot();
Пример #25
0
<?php

require '../include/mellivora.inc.php';
prefer_ssl();
head('Two-factor authentication required');
section_head('Two-factor authentication required');
form_start('actions/two_factor_auth');
form_input_text('Code', false, array('autocomplete' => 'off', 'autofocus' => true));
form_hidden('action', 'authenticate');
form_button_submit('Authenticate');
form_end();
foot();
Пример #26
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Dynamic menu items');
menu_management();
section_head('Dynamic menu items', button_link('New menu item', 'new_dynamic_menu_item'), false);
$menu_items = db_query_fetch_all('SELECT
        dm.id,
        dm.title,
        dm.permalink,
        dm.visibility,
        dm.min_user_class,
        dm.url,
        dc.title AS link_title
    FROM
        dynamic_menu AS dm
    LEFT JOIN
        dynamic_pages AS dc ON dc.id = dm.internal_page
    ORDER BY dm.title ASC');
echo '
    <table id="dynamic_menus" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Title</th>
          <th>Links to</th>
          <th>visibility</th>
          <th>Min user class</th>
          <th>Manage</th>
        </tr>
      </thead>
Пример #27
0
<?php

require '../../include/ctf.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Dynamic pages');
menu_management();
section_head('Dynamic pages', button_link('New page', 'new_dynamic_page'), false);
$pages = db_select_all('dynamic_pages', array('id', 'title', 'visibility', 'min_user_class'), null, 'title ASC');
echo '
    <table id="dynamic_pages" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Title</th>
          <th>visibility</th>
          <th>Min user class</th>
          <th>Manage</th>
        </tr>
      </thead>
      <tbody>
    ';
foreach ($pages as $item) {
    echo '
    <tr>
        <td>', htmlspecialchars($item['title']), '</td>
        <td>', visibility_enum_to_name($item['visibility']), '</td>
        <td>', user_class_name($item['min_user_class']), '</td>
        <td><a href="' . CONFIG_SITE_ADMIN_URL . 'edit_dynamic_page?id=', $item['id'], '" class="btn btn-xs btn-primary">Edit</a></td>
    </tr>
    ';
}
echo '
Пример #28
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Submissions');
menu_management();
if (!isset($_GET['all'])) {
    $_GET['all'] = 0;
}
if ($_GET['all']) {
    section_head('All submissions', button_link('Show only submissions in need of marking', 'list_submissions?all=0'), false);
} else {
    section_head('Submissions in need of marking', button_link('List all submissions', 'list_submissions?all=1'), false);
}
$num_subs = db_query_fetch_one('
    SELECT
       COUNT(*) AS num
    FROM submissions AS s
    LEFT JOIN challenges AS c ON c.id = s.challenge
    ' . ($_GET['all'] ? '' : 'WHERE c.automark = 0 AND s.marked = 0') . '
');
$from = get_pager_from($_GET);
$results_per_page = 70;
pager(CONFIG_SITE_ADMIN_URL . 'list_submissions?' . (isset($_GET['all']) ? 'all=' . $_GET['all'] : ''), $num_subs['num'], $results_per_page, $from);
echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Challenge</th>
          <th>Team name</th>
          <th>Added</th>
Пример #29
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
head('Exceptions');
menu_management();
section_head('Exceptions');
echo '
    <table id="hints" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Message</th>
          <th>Added</th>
          <th>User</th>
          <th>IP</th>
          <th>Trace</th>
          <th>User agent</th>
        </tr>
      </thead>
      <tbody>
    ';
$from = get_pager_from($_GET);
$num_exceptions = db_count_num('exceptions');
$results_per_page = 30;
pager(CONFIG_SITE_ADMIN_URL . 'list_exceptions/', $num_exceptions, $results_per_page, $from);
$exceptions = db_query_fetch_all('
    SELECT
       e.id,
       e.message,
       e.added,
       e.added_by,
Пример #30
0
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONFIG_UC_MODERATOR);
head('Submissions');
menu_management();
if (!isset($_GET['all'])) {
    $_GET['all'] = 0;
}
if ($_GET['all']) {
    section_head('All submissions');
} else {
    section_head('Submissions in need of marking', '<a href="list_submissions?all=1">List all submissions</a>', false);
}
$num_subs = db_query_fetch_one('
    SELECT
       COUNT(*) AS num
    FROM submissions AS s
    LEFT JOIN challenges AS c ON c.id = s.challenge
    ' . ($_GET['all'] ? '' : 'WHERE c.automark = 0 AND s.marked = 0') . '
');
$from = get_pager_from($_GET);
$results_per_page = 1000;
if (verifySA()) {
    $submissions = db_query_fetch_all('
    SELECT
       s.id,
       u.id AS user_id,
       u.team_name,
       s.added,
       s.correct,