function admin_games() { $tpl = new smarty(); $tpl->assign('icons', get_icons()); $tpl->assign('games', get_games()); ob_start(); $tpl->display(DESIGN . '/tpl/admin/games.html'); $content = ob_get_contents(); ob_end_clean(); main_content(GAMES, $content, '', 1); }
// case crosstable case 'alltournaments': echo "<table style='width: 100%'><tr><th colspan='10'>All Tournaments</th></tr><tr>\n<th style='background: url(); background-color:FFFFFF'>ID</th>\n<th style='background: url(); background-color:FFFFFF'>Tournament Name</th>\n<th style='background: url(); background-color:FFFFFF'>Rating Range</th>\n<th style='background: url(); background-color:FFFFFF'>Created By</th>\n<th style='background: url(); background-color:FFFFFF'>Created</th>\n<th style='background: url(); background-color:FFFFFF'>Winner</th>\n<th style='background: url(); background-color:FFFFFF'>Games</th>\n</tr>"; $tw = mysql_query("SELECT id,time,creator,min_rating,max_rating,name,winner,players\n FROM tournaments\n WHERE players = 4\n AND name NOT LIKE '%Group%' and name NOT LIKE '% Finals'\n ORDER BY id DESC"); while ($dis = mysql_fetch_array($tw)) { echo "<tr><td>" . $dis['id'] . "<br></td>"; //echo "<td>".$dis['name']."<br></td>"; echo "<td><a href='tournaments.php?action=view&id=" . $dis['id'] . "'>" . stripslashes($dis['name']) . "</a><br></td>"; echo "<td>" . $dis['min_rating'] . " - " . $dis['max_rating'] . "<br></td>"; $crtr = get_userdata($dis['creator']); echo "<td>" . $crtr['firstName'] . "<br></td>"; $datst = date("m.d.y", $dis['time']); echo "<td>" . $datst . "<br></td>"; $winn = get_userdata($dis['winner']); echo "<td>" . $winn['firstName'] . "<br></td>"; $games = get_games($dis['id']); echo "<td>"; if (count($games) == 0) { echo "0 / 1"; } else { $count = 0; while (list($key, $val) = each($games)) { $gs = mysql_query("SELECT gameMessage FROM games WHERE gameID = '{$val}'"); $g = mysql_fetch_array($gs); if ($g['gameMessage'] != '') { $count++; } } echo $count . " / 12"; } echo "</td></tr>";
function get_games($id = '', $games = array()) { $query = "SELECT * FROM {$db_prefix}games WHERE tournament "; if ($id == '') $query .= "<> 0"; else { $query .= "='$id'"; $t = mysql_query("SELECT * FROM tournaments WHERE id = '$id'"); $t = mysql_fetch_array($t); } if ($t['players'] == 4 || !$t['players']) { $sql = mysql_query($query); while($row = mysql_fetch_array($sql)) { $games[] = $row['gameID']; } // while } elseif ($t['players'] == 16) { // Holy shit, we got a BIG tournament $b = mysql_query("SELECT * FROM tournaments WHERE big = '$id' AND name not like '%Finals'"); echo mysql_error(); while ($big = mysql_fetch_array($b)) { if (!isset($games)) $games = array(); $players = get_games($big['id'], $games); } // while } return $games; }