示例#1
0
function dynamic_menu_content()
{
    $cache_name = user_is_logged_in() ? 'logged_in_' . $_SESSION['class'] : 'guest';
    if (cache_start($cache_name, CONFIG_CACHE_TIME_DYNAMIC, CONST_CACHE_DYNAMIC_MENU_GROUP)) {
        $entries = db_query_fetch_all('SELECT
                title,
                internal_page,
                permalink,
                url,
                visibility
            FROM
                dynamic_menu
            WHERE
                ' . (user_is_logged_in() ? 'min_user_class <= ' . $_SESSION['class'] . ' AND (visibility = "private" OR visibility = "both")' : 'visibility = "public" OR visibility = "both"') . '
            ORDER BY priority DESC');
        foreach ($entries as $entry) {
            echo '
            <li>
                <a href="', $entry['internal_page'] ? CONFIG_SITE_URL . 'content?show=' . $entry['permalink'] : htmlspecialchars($entry['url']), '">', htmlspecialchars($entry['title']), '</a>
            </li>
            ';
        }
        cache_end($cache_name, CONST_CACHE_DYNAMIC_MENU_GROUP);
    }
}
示例#2
0
文件: json.php 项目: dirvuk/mellivora
<?php

require '../include/mellivora.inc.php';
login_session_refresh();
header('Content-type: application/json');
if (!isset($_GET['view'])) {
    echo json_error(lang_get('please_request_view'));
    exit;
}
if ($_GET['view'] == 'scoreboard') {
    if (cache_start(CONST_CACHE_NAME_SCORES_JSON, CONFIG_CACHE_TIME_SCORES)) {
        json_scoreboard(array_get($_GET, 'user_type'));
        cache_end(CONST_CACHE_NAME_SCORES_JSON);
    }
} else {
    echo json_error(lang_get('please_request_view'));
    exit;
}
示例#3
0
        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>
       <tbody>
       ';
        $i = 1;
        foreach ($submissions as $submission) {
            echo '
              <tr>
                <td>', number_format($i), ' ', get_position_medal($i), '</td>
                <td class="team-name"><a href="user.php?id=', htmlspecialchars($submission['user_id']), '">', htmlspecialchars($submission['team_name']), '</a></td>
                <td>', time_elapsed($submission['added'], $submission['available_from']), ' after release (', date_time($submission['added']), ')</td>
              </tr>
              ';
            $i++;
        }
        echo '
       </tbody>
       </table>
         ';
    }
    cache_end('challenge_' . $_GET['id']);
}
foot();
示例#4
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();
示例#5
0
    }
    section_head('Hints');
    echo '
        <table id="files" class="table table-striped table-hover">
          <thead>
            <tr>
              <th>Category</th>
              <th>Challenge</th>
              <th>Added</th>
              <th>Hint</th>
            </tr>
          </thead>
          <tbody>
        ';
    foreach ($hints as $hint) {
        echo '
        <tr>
            <td>', htmlspecialchars($hint['category_title']), '</td>
            <td>', htmlspecialchars($hint['title']), '</td>
            <td>', time_elapsed($hint['added']), ' ago</td>
            <td>', htmlspecialchars($hint['body']), '</td>
        </tr>
        ';
    }
    echo '
          </tbody>
        </table>
         ';
    cache_end('hints');
}
foot();
示例#6
0
     ';
 } else {
     // write out challenge description
     if ($challenge['description']) {
         echo '
         <div class="challenge-description">
             ', $bbc->parse($challenge['description']), '
         </div> <!-- / challenge-description -->';
     }
     // write out hints
     if (cache_start(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id'], CONFIG_CACHE_TIME_HINTS)) {
         $hints = db_select_all('hints', array('body'), array('visible' => 1, 'challenge' => $challenge['id']));
         foreach ($hints as $hint) {
             message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
         }
         cache_end(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id']);
     }
     // write out files
     $files = cache_array_get(CONST_CACHE_NAME_FILES . $challenge['id'], CONFIG_CACHE_TIME_FILES);
     if (!is_array($files)) {
         $files = db_select_all('files', array('id', 'title', 'size', 'md5', 'download_key'), array('challenge' => $challenge['id']));
         cache_array_save($files, CONST_CACHE_NAME_FILES . $challenge['id']);
     }
     if (count($files)) {
         print_attachments($files);
     }
     // only show the hints and flag submission form if we're not already correct and if the challenge hasn't expired
     if (!$challenge['correct_submission_added'] && $time < $challenge['available_until']) {
         if ($remaining_submissions) {
             if ($challenge['num_submissions'] && !$challenge['automark'] && $challenge['marked']) {
                 message_inline_blue('Your submission is awaiting manual marking.');
示例#7
0
if (strlen(array_get($_GET, 'code')) != 2) {
    message_error('Please supply a valid country code');
}
$country = db_select_one('countries', array('id', 'country_name', 'country_code'), array('country_code' => $_GET['code']));
if (!$country) {
    message_error('No country found with that code');
}
head($country['country_name']);
if (cache_start('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']));
    scoreboard($scores);
    cache_end('country_' . $_GET['code']);
}
foot();
示例#8
0
 }
 // write out hints
 if (cache_start(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id'], CONFIG_CACHE_TIME_HINTS)) {
     $hints = db_select_all('hints', array('body'), array('visible' => 1, 'challenge' => $challenge['id']));
     foreach ($hints as $hint) {
         message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
     }
     cache_end(CONST_CACHE_NAME_CHALLENGE_HINTS . $challenge['id']);
 }
 // write out files
 if (cache_start(CONST_CACHE_NAME_FILES . $challenge['id'], CONFIG_CACHE_TIME_FILES)) {
     $files = db_select_all('files', array('id', 'title', 'size', 'md5'), array('challenge' => $challenge['id']));
     if (count($files)) {
         print_attachments($files);
     }
     cache_end(CONST_CACHE_NAME_FILES . $challenge['id']);
 }
 // only show the hints and flag submission form if we're not already correct and if the challenge hasn't expired
 if (!$challenge['correct_submission_added'] && $time < $challenge['available_until']) {
     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="flag-input 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) {
示例#9
0
    }
    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>
            <td>', htmlspecialchars($hint['category_title']), '</td>
            <td>', htmlspecialchars($hint['title']), '</td>
            <td>', time_elapsed($hint['added']), ' ago</td>
            <td>', htmlspecialchars($hint['body']), '</td>
        </tr>
        ';
    }
    echo '
          </tbody>
        </table>
         ';
    cache_end(CONST_CACHE_NAME_HINTS);
}
foot();
示例#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
            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 -->
    </div> <!-- / row -->
    ';
    cache_end(CONST_CACHE_NAME_SCORES);
}
foot();
示例#12
0
         echo '
             </ul>
         </div> <!-- / challenge-files -->';
     }
     cache_end('files_' . $challenge['id']);
 }
 // only show the hints and flag submission form if we're
 // not already correct and if the challenge hasn't expired
 if (!$challenge['correct'] && $time < $challenge['available_until']) {
     // write out hints
     if (cache_start('hints_challenge_' . $challenge['id'], CONFIG_CACHE_TIME_HINTS)) {
         $hints = db_select_all('hints', array('body'), array('visible' => 1, 'challenge' => $challenge['id']));
         foreach ($hints as $hint) {
             message_inline_yellow('<strong>Hint!</strong> ' . $bbc->parse($hint['body']), false);
         }
         cache_end('hints_challenge_' . $challenge['id']);
     }
     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();
         }
示例#13
0
        echo lang_get('challenge_solved_by_percentage', array('solve_percentage' => number_format($num_correct_solves / $user_count['num'] * 100, 1)));
        echo '
       <table class="challenge-table table table-striped table-hover">
       <thead>
       <tr>
         <th>', lang_get('position'), '</th>
         <th>', lang_get('team'), '</th>
         <th>', lang_get('solved'), '</th>
       </tr>
       </thead>
       <tbody>
       ';
        $i = 1;
        foreach ($submissions as $submission) {
            echo '
              <tr>
                <td>', number_format($i), ' ', get_position_medal($i), '</td>
                <td class="team-name"><a href="user.php?id=', htmlspecialchars($submission['user_id']), '">', htmlspecialchars($submission['team_name']), '</a></td>
                <td>', time_elapsed($submission['added'], $submission['available_from']), ' ', lang_get('after_release'), ' (', date_time($submission['added']), ')</td>
              </tr>
              ';
            $i++;
        }
        echo '
       </tbody>
       </table>
         ';
    }
    cache_end(CONST_CACHE_NAME_CHALLENGE . $_GET['id']);
}
foot();
示例#14
0
<?php

require '../include/mellivora.inc.php';
login_session_refresh();
send_cache_headers('home', CONFIG_CACHE_TIME_HOME);
head('Home');
if (cache_start(CONST_CACHE_NAME_HOME, CONFIG_CACHE_TIME_HOME)) {
    require CONST_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(CONST_CACHE_NAME_HOME);
}
foot();
示例#15
0
     }
     cache_end('hints_challenge_' . $challenge['id']);
 }
 if ($remaining_submissions) {
     if ($challenge['num_submissions'] && !$challenge['automark'] && $challenge['marked']) {
         message_inline_blue('Your submission is awaiting manual marking.');
     }
     // write out files
     if (cache_start('files_' . $challenge['id'], CONFIG_CACHE_TIME_FILES)) {
         $files = db_select_all('files', array('id', 'title', 'size'), array('challenge' => $challenge['id']));
         $filesDuplicate = db_select_all('files', array('id', 'title', 'size'), array('challenge' => $challenge['cloneOf']));
         if (count($files) || count($filesDuplicate)) {
             print_attachments($files);
             print_attachments($filesDuplicate);
         }
         cache_end('files_' . $challenge['id']);
     }
     echo '
     <div class="challenge-submit">
         <form method="post" class="form-flag" action="actions/challenges">
             <textarea name="flag" type="text" class="flag-input 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 '<button class="btn btn-sm btn-primary" type="submit" data-countdown="', max($challenge['latest_submission_added'] + $challenge['min_seconds_between_submissions'], 0), '" data-countdown-done="Submit flag">Submit flag</button>';
     if (should_print_metadata($challenge)) {
         echo '<div class="challenge-submit-metadata">';
         print_submit_metadata($challenge);
示例#16
0
            echo '
              <tr>
                <td>
                    <a href="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']), ' after release (', date_time($submission['added']), ')
                </td>

                <td>', number_format($submission['points']), '</td>
              </tr>
              ';
        }
        echo '
        </tbody>
      </table>
          ';
    } else {
        echo '
      <div class="alert alert-info">
          No challenges solved, yet!
      </div>
      ';
    }
    cache_end('user_' . $_GET['id']);
}
foot();
示例#17
0
                FROM users AS u
                JOIN submissions AS s ON s.user_id = u.id
                WHERE
                   u.competing = 1 AND
                   s.correct = 1 AND
                   s.challenge=:challenge
                ORDER BY s.added ASC
                LIMIT 3', array('challenge' => $challenge['id']));
            if (count($users)) {
                $pos = 1;
                foreach ($users as $user) {
                    echo get_position_medal($pos++), '<a href="user?id=', htmlspecialchars($user['id']), '">', htmlspecialchars($user['team_name']), '</a><br />';
                }
            } else {
                echo '<i>Unsolved</i>';
            }
            echo '
                </td>
            </tr>';
        }
        echo '
        </tbody>
        </table>';
    }
    echo '
        </div> <!-- / span6 -->
    </div> <!-- / row -->
    ';
    cache_end('scores');
}
foot();
示例#18
0
<?php

require '../include/mellivora.inc.php';
login_session_refresh();
header('Content-type: application/json');
if (!isset($_GET['view'])) {
    echo json_error('please request a view');
    exit;
}
if ($_GET['view'] == 'scoreboard') {
    if (cache_start('scores_json', CONFIG_CACHE_TIME_SCORES)) {
        json_scoreboard(array_get($_GET, 'user_type'));
        cache_end('scores_json');
    }
} else {
    echo json_error('not a valid view');
    exit;
}
示例#19
0
        </thead>
        <tbody>
       ';
        foreach ($submissions as $submission) {
            echo '
              <tr>
                <td>
                    <a href="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'));
    }
    cache_end(CONST_CACHE_NAME_USER . $_GET['id']);
}
foot();
示例#20
0
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']));
    scoreboard($scores);
    cache_end(CONST_CACHE_NAME_COUNTRY . $_GET['code']);
}
foot();
示例#21
0
        ', lang_get('account_signup_information', array('password_information' => CONFIG_ACCOUNTS_EMAIL_PASSWORD_ON_SIGNUP ? lang_get('email_password_on_signup') : '')), '
    </p>
    <form method="post" id="registerForm" class="form-signin" action="actions/register">
        <input name="team_name" type="text" class="form-control" placeholder="Team name" minlength="', CONFIG_MIN_TEAM_NAME_LENGTH, '" maxlength="', CONFIG_MAX_TEAM_NAME_LENGTH, '" required />
        <input name="', md5(CONFIG_SITE_NAME . 'USR'), '" type="email" class="form-control" placeholder="Email address" required />
        ', !CONFIG_ACCOUNTS_EMAIL_PASSWORD_ON_SIGNUP ? '<input name="' . md5(CONFIG_SITE_NAME . 'PWD') . '" type="password" class="form-control" placeholder="Password" required />' : '';
    if (cache_start(CONST_CACHE_NAME_REGISTER, CONFIG_CACHE_TIME_REGISTER)) {
        $user_types = db_select_all('user_types', array('id', 'title', 'description'));
        if (!empty($user_types)) {
            echo '<select name="type" class="form-control">
            <option disabled selected>-- Please select team type --</option>';
            foreach ($user_types as $user_type) {
                echo '<option value="', htmlspecialchars($user_type['id']), '">', htmlspecialchars($user_type['title'] . ' - ' . $user_type['description']), '</option>';
            }
            echo '</select>';
        }
        country_select();
        cache_end(CONST_CACHE_NAME_REGISTER);
    }
    if (CONFIG_RECAPTCHA_ENABLE_PUBLIC) {
        display_captcha();
    }
    echo '
    <input type="hidden" name="action" value="register" />
    <button class="btn btn-primary btn-lg" type="submit">Register team</button>
</form>
';
} else {
    message_inline_blue('Registration is currently closed, but you can still <a href="interest">register your interest for upcoming events</a>.', false);
}
foot();
示例#22
0
文件: faq.php 项目: xctcc/congtu
?>
.</div>
					</div>

					<div class="faq_box">
						<div class="title"><?php 
echo _T("site_faq_q9");
?>
</div>
						<div class="answer" id="faq-9"><?php 
echo _T("site_faq_a9");
?>
</div>
					</div>

					<div class="faq_box">
						<div class="title"><?php 
echo _T("site_faq_q10");
?>
</div>
						<div class="answer" id="faq-10"><?php 
echo _T("site_faq_a10");
?>
</div>
					</div>
			</div>
		</div>
<?php 
require CFROOTPATH . 'footer.php';
cache_end();
示例#23
0
            <?php 
    if ($config['allow_public_access'] || $admin) {
        echo $page;
    } else {
        echo msg('The public access is locked');
    }
    ?>
            
        </div>
    </aside>
    
<?php 
    #*************************************************************
    #Cache: end (we keep the the generation time out)
    if (!$admin) {
        $contenu = cache_end($nom_page_cache, 0);
    }
}
if (isset($_GET['embed'])) {
    exit($contenu);
} else {
    if (isset($_GET['rss'])) {
        header("Content-Type: application/rss+xml");
        exit($contenu);
    } else {
        echo $contenu;
    }
}
#*************************************************************
?>
<div style="clear:both"> </div>