function makeCTFParams() { $cnx = __dbConnect(); if (!$cnx) { print "<b>DATABASE CONNECTION ERROR</b>"; exit(1); } $query = pg_query("SELECT * FROM main.ctf_map_def ORDER BY name"); if (!$query) { print "<b>DATABASE ERROR</b>"; exit(1); } $ctfMaps = array(); while ($r = pg_fetch_assoc($query)) { $ctfMaps[$r['id']] = $r; $query2 = pg_query("SELECT COUNT(*) FROM main.ctf_map_layout WHERE map={$r['id']} AND spawn_here"); if (!$query2) { print "<b>DATABASE ERROR</b>"; exit(1); } list($ctfMaps[$r['id']]['players']) = pg_fetch_array($query2); pg_free_result($query2); } pg_free_result($query); pg_close($cnx); $map = $ctfMaps[$_SESSION['lw_new_game']['ctfmap']]; $cParams = $_SESSION['lw_new_game']['ctfparams']; $params = array('usemap' => $map['id'], 'maxplayers' => $map['players'], 'norealloc' => 1, 'partialtechs' => 0, 'lockalliances' => $map['alliances'], 'alliancecap' => 0, 'victory' => 2, 'novacation' => 1); foreach ($cParams as $p => $v) { $params[$p] = $v; } return $params; }
public static function connect() { self::$uConnection = __dbConnect(false); if (!self::$uConnection) { $argh = "Error while accessing the database in user mode"; include 'cg_argh.inc'; exit(1); } self::$aConnection = __dbConnect(true); if (!self::$aConnection) { $argh = "Error while accessing the database in admin mode"; include 'cg_argh.inc'; exit(1); } }
<?php set_magic_quotes_runtime(false); session_start(); if (!is_array($_SESSION['lw_new_game']) || !$_SESSION['lw_new_game']['do_it_now'] || !$_SESSION['lw_new_game']['started']) { echo "Sorry, can't do that."; exit(0); } include "config.inc"; include 'as_manager.inc'; /* Insert "silent admins" into the new game's player table */ $cnx = __dbConnect(); if (!$cnx) { $argh = "Could not connect to the database"; } else { $ns = $_SESSION['lw_new_game']['found_id']; $error = false; foreach ($_SESSION['lw_new_game']['silent'] as $aId) { if (!pg_query($cnx, "INSERT INTO \"{$ns}\".player (userid, first_planet, hidden) VALUES ({$aId}, 1, TRUE)")) { $error = true; break; } } if ($error) { $argh = "Failed to insert silent admin data"; } else { $argh = null; } pg_close($cnx); } if (!is_null($argh)) {
function showActionLog() { $db = __dbConnect(); $entries = array(); $q = pg_query($db, "SELECT * FROM (" . "SELECT a1.name AS name1, a2.name AS name2, l.ts AS ts, 'WARN' AS atype " . "FROM main.dor_warning l, main.account a1, main.account a2 " . "WHERE a1.id = l.account1 AND a2.id = l.account2 " . "AND a1.status NOT IN ('QUIT', 'INAC', 'KICKED') " . "AND a2.status NOT IN ('QUIT', 'INAC', 'KICKED') " . "UNION SELECT a1.name AS name1, a2.name AS name2, l.ts AS ts, 'PUNISH' AS atype " . "FROM main.dor_warning l, main.account a1, main.account a2 " . "WHERE a1.id = l.account1 AND a2.id = l.account2 " . "AND a1.status NOT IN ('QUIT', 'INAC', 'KICKED') " . "AND a2.status NOT IN ('QUIT', 'INAC', 'KICKED')" . ") AS t ORDER BY t.ts DESC, t.name1 ASC, t.name2 ASC"); while ($r = pg_fetch_assoc($q)) { $entries[] = $r; } pg_close($db); ?> <h2>Actions performed by the Death of Rats</h2> <p> This page lists all the actions the Death of Rats has performed. </p> <table border="1"> <tr> <th>Time & date</th> <th>Account 1</th> <th>Account 2</th> <th align="left">Message</th> </tr> <?php $messages = array("WARN" => "Warned player", "PUNISH" => "Slaughtered player with a rat-sized scythe"); foreach ($entries as $entry) { ?> <tr> <td align="center"><?php echo gmstrftime("%H:%M:%S / %Y-%m-%d", $entry['ts']); ?> <td align="center"><?php echo htmlentities($entry['name1']); ?> </td> <td align="center"><?php echo htmlentities($entry['name2']); ?> </td> <td><?php echo $messages[$entry['atype']]; ?> </td> </tr> <?php } ?> </table> <?php }