Example #1
0
/**
*----------------------------------------------------------*
| Author: Osure Ronald Osure                               |
| Author url: {@link http://sureronald.blogspot.com}       |
| License: GNU/GPL                                         |
| Description: Arena applet control center                 |
|                                                          |
*----------------------------------------------------------*
*/
//Access is within framework?
defined('IN_APP') or die('Restricted Access!');
if (@$action == 'arena') {
    //Get the arena helper class
    require_once 'arenaAppletHelper.php';
    $arn = new arenaAppletHelper(time());
    ?>
	<!--Arena Events-->
	<link type="text/css" media="screen" rel="stylesheet" href="theme/jquery.colorbox/colorbox.css" />
	<script type="text/javascript" src="js/jquery.colorbox-min.js"></script>
	<script src="js/jquery.countdown.min.js" type="text/javascript"></script>
	<script src="js/countdown.custom.js" type="text/javascript"></script>
	<script src="js/server.time.js" type="text/javascript"></script>
	<?php 
    //Check if there's an active match
    if (!$arn->active_match()) {
        system_messages(0, "There is no active match");
        return;
    }
    //Check if user logged in i.e to entice him/her to login
    if (!$login) {
	$(".match-timer-info").tooltip({
	track: true, 
	delay: 0, 
	showURL: false, 
	showBody: " - ", 
	extraClass: "pretty", 
	fixPNG: true, 
	opacity: 0.95, 
	left: -120,
	fade: 250
});
});
	</script>
	<?php 
require_once 'arenaAppletHelper.php';
$arn = new arenaAppletHelper(time());
$query = "SELECT * FROM " . $_pre . "matches WHERE start_time>" . time() . " ORDER BY start_time LIMIT 1";
$db->setQuery($query);
$first_match = $db->fetch_assoc();
/** Only show the timer if there's no active match else show the link */
if ($db->foundRows > 0 && !$arn->active_match()) {
    //Show countdown timer
    $time_rem = $first_match['start_time'] - time() + 1;
    echo "<h3 class='active_match'>ACTIVE MATCH</h3><hr class='h3-bottom-line' />";
    echo "<script type='text/javascript'>";
    echo "\$(function(){\$('#countdown-timer').countdown({ layout:\"<span class='match-timer-info'>{ {$first_match['title']} } <span class='countdown-timer-text'>{d<}{dn} {dl} and {d>}\"+ \n    '{hnn} {hl}, {mnn} {ml}, {snn} {sl}</span></span>',\n    until:+{$time_rem}, serverSync: serverTime,expiryText:\"<span class='match-timer-info' title='CodeZone match {$first_match['id']}: {$first_match['title']} - Start time: " . date("j \\of\f F Y, \\a\\t g:i:s a", $first_match['start_time']) . ", Difficulty: {$first_match['difficulty']}, Duration: {$first_match['duration']} seconds and " . ($first_match['match_ranked'] == 1 ? "Affects ranking" : "Does not affect ranking") . "'><a class='match-timer-a' href='index.php?a=arena&amp;m=" . base64_encode($first_match['title']) . "'>CodeZone match {$first_match['id']} { {$first_match['title']} }</a></span>\",onExpiry: function(){ \$('#match_notes').slideUp('slow');  }}); \n});";
    echo "</script>";
    echo "<div id='countdown-timer'></div>";
    echo "<div id='match_notes' class='font_size_10'><span><a href='index.php?a=register_match&m_id={$first_match['id']}'>Register here to participate</a></span> | <span class='notify'>Registration closes when the match starts!</span></div>";
}
//Show link to arena if there's an active match