예제 #1
0
function print_submit_interval($challenge)
{
    echo $challenge['min_seconds_between_submissions'] ? '<span class="glyphicon glyphicon-calendar"></span> ' . lang_get('minimum_time_between_submissions', array('time' => seconds_to_pretty_time($challenge['min_seconds_between_submissions']))) . ' ' : '';
}
예제 #2
0
 $submissions = db_select_all('submissions', array('correct', 'added'), array('user_id' => $_SESSION['id'], 'challenge' => $_POST['challenge']));
 // make sure user isn't "accidentally" submitting a correct flag twice
 $latest_submission_attempt = 0;
 $num_attempts = 0;
 foreach ($submissions as $submission) {
     $latest_submission_attempt = max($submission['added'], $latest_submission_attempt);
     if ($submission['correct']) {
         message_error('You may only submit a correct flag once.');
     }
     $num_attempts++;
 }
 // get challenge information
 $challenge = db_select_one('challenges', array('flag', 'category', 'case_insensitive', 'automark', 'available_from', 'available_until', 'num_attempts_allowed', 'min_seconds_between_submissions'), array('id' => $_POST['challenge']));
 $seconds_since_submission = $time - $latest_submission_attempt;
 if ($seconds_since_submission < $challenge['min_seconds_between_submissions']) {
     message_generic('Sorry', 'You may not submit another solution for this challenge for another ' . seconds_to_pretty_time($challenge['min_seconds_between_submissions'] - $seconds_since_submission));
 }
 if ($challenge['num_attempts_allowed'] && $num_attempts >= $challenge['num_attempts_allowed']) {
     message_generic('Sorry', 'You\'ve already tried ' . $challenge['num_attempts_allowed'] . ' times. Sorry!');
 }
 if ($challenge['available_from'] && $time < $challenge['available_from']) {
     message_generic('Sorry', 'This challenge hasn\'t started yet.');
 }
 if ($challenge['available_until'] && $time > $challenge['available_until']) {
     message_generic('Sorry', 'This challenge has expired.');
 }
 $correct = false;
 // automark the submission
 if ($challenge['automark']) {
     // lots of people submit with trailing whitespace..
     // we probably never want automarked keys with whitespace
예제 #3
0
        if ($remaining_submissions) {
            if ($challenge['num_submissions'] && !$challenge['automark'] && !$challenge['marked']) {
                message_inline_blue('Your submission is awaiting manual marking.');
            }
            echo '
            <div class="challenge-submit">
                <form method="post" class="form-flag" action="actions/challenges">
                    <textarea name="flag" type="text" class="form-control" placeholder="Please enter flag for challenge: ', htmlspecialchars($challenge['title']), '"></textarea>
                    <input type="hidden" name="challenge" value="', htmlspecialchars($challenge['id']), '" />
                    <input type="hidden" name="action" value="submit_flag" />';
            form_xsrf_token();
            if (CONFIG_RECAPTCHA_ENABLE_PRIVATE) {
                display_captcha();
            }
            echo '  <p>
                        ', $challenge['min_seconds_between_submissions'] ? 'Minimum of ' . seconds_to_pretty_time($challenge['min_seconds_between_submissions']) . ' between submissions. ' : '', '
                        ', $challenge['num_attempts_allowed'] ? number_format($remaining_submissions) . ' submissions remaining. ' : '', '
                        Available for another ', time_remaining($challenge['available_until']), '.
                    </p>
                    <button class="btn btn-sm btn-primary" type="submit">Submit flag</button>
                </form>
            </div>
            ';
        } else {
            message_inline_red("You have no remaining submission attempts. If you've made an erroneous submission, please contact the organizers.");
        }
    }
    echo '
    </div> <!-- / challenge-container -->';
}
foot();
예제 #4
0
function time_elapsed($to, $from = false)
{
    if ($from === false) {
        $to = time() - $to;
    } else {
        $to = $to - $from;
    }
    return seconds_to_pretty_time($to);
}
예제 #5
0
function print_submit_interval($challenge)
{
    echo $challenge['min_seconds_between_submissions'] ? '<span class="glyphicon glyphicon-calendar"></span> Minimum of ' . seconds_to_pretty_time($challenge['min_seconds_between_submissions']) . ' between submissions. ' : '';
}