Tournament, Ladders & Leagues Forum Side Blocks for vBulletin v4.x.x

Instructions

  1. AdminCP -> Forums & Moderators -> Forum Blocks Manager
  2. Add Block
  3. Select Block Type: Custom HTML/PHP
    Continue
  4. Title: <whatever you want>
    Description: <whatever you want>
    Cache Time (in minutes): 5
    Content Type: PHP
    Content: <Use Code Below>
    Template to use: block_html
    Click SAVE
  5. Repeat above steps for each Forum Block you require

Live Match Finder: PHP Code: (Premium Only)

$my_output = '';
$array2 = $array = array();
$players_query = vB::$db->query_read("
SELECT p.*, l.title AS laddertitle, u.username
FROM " . TABLE_PREFIX . "tmnt_ladder_players AS p
LEFT JOIN " . TABLE_PREFIX . "tmnt_ladders AS l
ON (p.lid = l.id)
LEFT JOIN " . TABLE_PREFIX . "user AS u
ON (p.userid = u.userid)
WHERE p.warlight > '".TIMENOW."'
AND p.pot = 0
AND l.archive = 0
LIMIT 0, 10
");
while($player = vB::$db->fetch_array($players_query))
{
$my_output .= '<div class="blockrow"><a href="ladders.php?do=view&id='.$player['lid'].'">'.$player['laddertitle'].'</a>: <a href="'.fetch_seo_url('member', $player).'">'.$player['username'].'</a> <a href="ladders.php?do=insertchal&lid='.$player['lid'].'&u2='.$player['userid'].'">[Challenge]</a></div>';
}
if (!$my_output)
{
$my_output .= 'No players have enabled Live Match. <br><br> <a href="ladders.php?do=matchfinder">Try using the Match Finder</a>';
}
return $my_output;

Match Finder: PHP Code:

$my_output = '';
$games = vB::$db->query_read("
SELECT games.*, ladders.title AS laddertitle, IF (games.pot>0,t.teamname,u.username) AS username
FROM " . TABLE_PREFIX . "tmnt_ladder_games AS games
LEFT JOIN " . TABLE_PREFIX . "tmnt_ladders AS ladders
ON (ladders.id = games.lid)
LEFT JOIN " . TABLE_PREFIX . "user AS u
ON (games.pot = 0 AND games.u = u.userid)
LEFT JOIN " . TABLE_PREFIX . "tmnt_teams AS t
ON (games.pot = 1 AND games.u = t.teamid)
WHERE
games.u2 = 0
AND games.finished = 0
AND games.accepted = 0
AND games.dateline > ".TIMENOW."
ORDER BY games.dateline ASC
LIMIT 0, 10
");
while($game = vB::$db->fetch_array($games))
{
$game['time'] = vbdate($this->registry->options['timeformat'], $game['dateline']);
$game['date'] = vbdate($this->registry->options['dateformat'], $game['dateline'], true);
$my_output .= '<div class="blockrow"><a href="ladders.php?do=view&amp;id=' . $game['lid'] . '&amp;sh=5">' . $game['laddertitle'] . ': ' . $game['date'] . ' '.$game['time'].'</div>';
}
if (!$my_output)
{
$my_output .= 'No games found. <br><br> <a href="ladders.php?do=matchfinder">Try using the Match Finder</a>';
}
return $my_output;

King of the Hill: PHP Code:

$my_output = '';
$king = vB::$db->query_first("
SELECT k.*, IF (k.pot>0,t.teamname,u.username) AS username
FROM " . TABLE_PREFIX . "tmnt_kings AS k
LEFT JOIN " . TABLE_PREFIX . "user AS u
ON (k.pot = 0 AND k.king_userid = u.userid)
LEFT JOIN " . TABLE_PREFIX . "tmnt_teams AS t
ON (k.pot = 1 AND k.king_userid = t.teamid)
WHERE
k.king_userid > 0
");
if ($king)
{
$my_output .= '<div style="text-align: center;"><img src="images/competitions/crown2.png" alt="" border="0" style="vertical-align: middle;" /> ' . $king[username] . ' <img src="images/competitions/crown2.png" alt="" border="0" style="vertical-align: middle;" /><br /><a href="kings.php?do=view&amp;id='.$king['id'].'">Challenge King</a></div>';
}
return $my_output;