예제 #1
0
function form_start($action = '', $class = '', $enctype = '')
{
    echo '
    <form method="post" class="', $class ? $class : 'form-horizontal', '"', $enctype ? ' enctype="' . $enctype . '"' : '', '', $action ? ' action="' . CONFIG_SITE_URL . $action . '"' : '', ' role="form">
    ';
    form_xsrf_token();
}
예제 #2
0
파일: search.php 프로젝트: dirvuk/mellivora
<?php

require '../../include/mellivora.inc.php';
enforce_authentication(CONST_USER_CLASS_MODERATOR);
head('Site management');
menu_management();
section_subhead('Search');
form_start(CONFIG_SITE_ADMIN_RELPATH . 'actions/search');
form_input_text('Search for');
$opts[] = array('id' => 'users', 'name' => 'Users');
$opts[] = array('id' => 'ip_log', 'name' => 'IP log');
form_select($opts, 'Search in', 'id', 'users', 'name');
form_button_submit('Search');
form_xsrf_token();
form_end();
foot();
예제 #3
0
function form_logout()
{
    echo '
    <form action="/actions/logout" method="post">
        ', form_xsrf_token(), '
        <input type="submit" value="Log out" />
    </form>
    ';
}
예제 #4
0
function print_user_submissions($user_id, $limit = false)
{
    validate_id($user_id);
    section_subhead('Submissions', ($limit ? 'Limited to ' . $limit . ' results ' : '') . button_link('Show all for user', 'list_submissions?user_id=' . $user_id), false);
    echo '
    <table id="files" class="table table-striped table-hover">
      <thead>
        <tr>
          <th>Challenge</th>
          <th>Added</th>
          <th>Flag</th>
          <th>Correct</th>
          <th>Manage</th>
        </tr>
      </thead>
      <tbody>
    ';
    $submissions = db_query_fetch_all('
        SELECT
           s.id,
           u.id AS user_id,
           u.team_name,
           s.added,
           s.correct,
           s.flag,
           c.id AS challenge_id,
           c.title AS challenge_title
        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
        WHERE user_id = :user_id
        ORDER BY s.added DESC
        LIMIT ' . $limit, array('user_id' => $user_id));
    foreach ($submissions as $submission) {
        echo '
    <tr>
        <td><a href="', CONFIG_SITE_URL, 'challenge.php?id=', htmlspecialchars($submission['challenge_id']), '">', htmlspecialchars($submission['challenge_title']), '</a></td>
        <td>', time_elapsed($submission['added']), ' ago</td>
        <td>', htmlspecialchars($submission['flag']), '</td>
        <td>
            ', $submission['correct'] ? '<img src="' . CONFIG_SITE_URL_STATIC_RESOURCES . 'img/accept.png" alt="Correct!" title="Correct!" />' : '<img src="' . CONFIG_SITE_URL_STATIC_RESOURCES . 'img/stop.png" alt="Wrong!" title="Wrong!" />', '
        </td>
        <td>
            <form method="post" action="actions/list_submissions" class="discreet-inline">';
        form_xsrf_token();
        echo '
                <input type="hidden" name="action" value="', $submission['correct'] ? 'mark_incorrect' : 'mark_correct', '" />
                <input type="hidden" name="id" value="', htmlspecialchars($submission['id']), '" />
                <button type="submit" class="btn btn-sm btn-', $submission['correct'] ? 'warning' : 'success', '">Mark ', $submission['correct'] ? 'incorrect' : 'correct', '</button>
            </form>

            <form method="post" action="actions/list_submissions" class="discreet-inline">';
        form_xsrf_token();
        echo '
                <input type="hidden" name="action" value="delete" />
                <input type="hidden" name="id" value="', htmlspecialchars($submission['id']), '" />
                <button type="submit" class="btn btn-sm btn-danger">Delete</button>
            </form>
        </td>
    </tr>
    ';
    }
    echo '
      </tbody>
    </table>
     ';
}
예제 #5
0
function form_logout()
{
    echo '
    <form action="/actions/logout" method="post">
        ', form_xsrf_token(), '
        <button type="submit" id="logout-button">', lang_get('log_out'), '</button>
    </form>
    ';
}