- includes/db.php now defines PQS_TIMEZONE and sets it on include; the 9 files
that hardcoded date_default_timezone_set('America/Chicago') drop the call
(main pages already load db.php; display includes now require it).
- console.php: pod load and the 16 pod-checkbox lines collapsed into loops over
a $pods array (fixed 16 kept - hardware max). Output unchanged.
Verified: timezone resolves to America/Chicago via the constant; console commit,
config update, and pod-checkbox rendering all correct; registration suite green.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
299 lines
14 KiB
PHP
299 lines
14 KiB
PHP
<html>
|
|
<head>
|
|
<title>PQS - Registration Console</title>
|
|
<link href="css/main.css" rel="stylesheet" type="text/css">
|
|
<link href="css/tooltip.css" rel="stylesheet" type="text/css">
|
|
<script type="text/javascript" src="js/jquery.js"></script>
|
|
<script type="text/javascript" src="js/jquery.qtip.js"></script>
|
|
<script type="text/javascript">
|
|
var auto_refreshqueue = setInterval(function() {
|
|
$.ajaxSetup({ cache: false });
|
|
$('#queuediv').load('includes/getreg.php<?php if (isset($_GET['missionid'])) {$missionid = $_GET['missionid'];echo"?mid=$missionid";} ?>');
|
|
}, 1000);
|
|
|
|
|
|
</script>
|
|
</head>
|
|
<body style='background: #000;'>
|
|
<?php
|
|
//var_dump($_GET);
|
|
//var_dump($_POST);
|
|
//var_dump($_SESSION);
|
|
include_once("includes/config.php");
|
|
require_once("includes/db.php");
|
|
require_once("includes/queue.php");
|
|
$tdate = date('Ymd');
|
|
$ttime = date('Hi');
|
|
$missionsize = $_SESSION['mechpods'];
|
|
$action = "";
|
|
$playerid = 0;
|
|
$missionid = 0;
|
|
$merc = 0;
|
|
$callsign = "";
|
|
$nummissions = 0;
|
|
$mech = "";
|
|
$server = $_SERVER['SERVER_ADDR'] ?? '';
|
|
|
|
if (isset($_GET['build'])) {
|
|
$buildmissions = (int)($_GET['buildmissions'] ?? 0);
|
|
for ($b = 0; $b < $buildmissions; $b++) {
|
|
pqs_exec("INSERT INTO pqs_mission (MissionDate, MissionSize, numplayers, nummercs, MissionTime) VALUES (?, ?, 0, 0, ?)",
|
|
'iii', array((int)$tdate, (int)$missionsize, (int)$ttime));
|
|
}
|
|
}
|
|
|
|
if (isset($_GET['clearcurrent'])) {
|
|
pqs_db()->query("TRUNCATE TABLE pqs_currentmission");
|
|
}
|
|
|
|
if (isset($_GET['lock'])) {
|
|
if (isset($_GET['missionid'])) {
|
|
$missionid = (int)$_GET['missionid'];
|
|
} else {
|
|
$missionid = (int) pqs_val("SELECT MIN(MissionID) FROM pqs_queue");
|
|
}
|
|
if ($missionid > 0) {
|
|
pqs_exec("UPDATE pqs_mission SET locked=1 WHERE MissionID=?", 'i', array($missionid));
|
|
}
|
|
}
|
|
|
|
if (isset($_POST['edit'])) {
|
|
$playerid = (int)($_POST['playerid'] ?? 0);
|
|
$callsign = isset($_POST['callsign']) ? $_POST['callsign'] : '';
|
|
$mech = isset($_POST['mech']) ? $_POST['mech'] : '';
|
|
pqs_exec("UPDATE pqs_queue SET Callsign=?, mech=?, Updated=1 WHERE id=?", 'ssi', array($callsign, $mech, $playerid));
|
|
}
|
|
|
|
if (isset($_POST['add'])) {
|
|
// Add one player to the next N missions after $missionid (atomic).
|
|
require_once("includes/queue.php");
|
|
$callsign = isset($_POST['callsign']) ? $_POST['callsign'] : '';
|
|
$mech = isset($_POST['mech']) ? $_POST['mech'] : '';
|
|
$merc = isset($_POST['merc']) ? (int)$_POST['merc'] : 0;
|
|
$startmission = isset($_POST['missionid']) ? (int)$_POST['missionid'] : 0;
|
|
$nummissions = isset($_POST['nummissions']) ? (int)$_POST['nummissions'] : 0;
|
|
pqs_add_player_to_missions($startmission, $nummissions, $callsign, $mech, $merc);
|
|
}
|
|
|
|
if (isset($_POST['new'])) {
|
|
// Add one player to a specific mission (atomic).
|
|
require_once("includes/queue.php");
|
|
$callsign = isset($_POST['callsign']) ? $_POST['callsign'] : '';
|
|
if ($callsign === '') { $callsign = 'empty'; }
|
|
$mech = isset($_POST['mech']) ? $_POST['mech'] : '';
|
|
$missionid = isset($_POST['missionid']) ? (int)$_POST['missionid'] : 0;
|
|
pqs_add_player_to_mission($missionid, $callsign, $mech);
|
|
}
|
|
|
|
if (isset($_POST['editgame'])) {
|
|
$newtype = (int)($_POST['newtype'] ?? 0);
|
|
$newmap = (int)($_POST['newmap'] ?? 0);
|
|
$missionid = (int)($_GET['missionid'] ?? 0);
|
|
pqs_exec("UPDATE pqs_mission SET GameType=?, map=? WHERE MissionID=?", 'iii', array($newtype, $newmap, $missionid));
|
|
}
|
|
|
|
if (isset($_GET['action'])) {
|
|
$action = $_GET['action'];
|
|
$playerid = (int)($_GET['playerid'] ?? 0);
|
|
$missionid = (int)($_GET['missionid'] ?? 0);
|
|
$mech = $_GET['mech'] ?? '';
|
|
$oldmap = (int)($_GET['oldmap'] ?? 0);
|
|
$oldtype = (int)($_GET['oldtype'] ?? 0);
|
|
$callsign = "";
|
|
$nextmission = $missionid + 1;
|
|
switch ($action) {
|
|
case "edit":
|
|
$row = pqs_row("SELECT * FROM pqs_queue WHERE ID = ?", 'i', array($playerid));
|
|
$callsign = $row['CallSign'] ?? '';
|
|
$mech = $row['Mech'] ?? '';
|
|
|
|
echo "<form action='registration.php";if (isset($_GET['missionid'])) {$missionid = (int)$_GET['missionid'];echo"?missionid=$missionid";};echo"' method='post'>";
|
|
echo "<table align='center'><tr><td align='center'>";
|
|
echo "<div id='editqueue' class='queuedivreg'>";
|
|
echo "<table border='0' align='center'><tr>";
|
|
echo "<td colspan='3' class='queuedisplayhead' align='center'>Edit Player $callsign</td></tr>";
|
|
echo "<tr><td width='40%' align='center' class='consoledisplayhead'>Callsign</td><td width='40%' align='center' class='consoledisplayhead'>Mech</td><td width='20%' align='center' class='consoledisplayhead'</td></tr>";
|
|
echo "<tr><td width='40%' align='center'><input class='editqueue' type='text' name='callsign' value='$callsign' size='18' maxlength='16' /></td>";
|
|
echo "<td width='40%' align='center'>";
|
|
echo "<select class='editqueue' name='mech'>";
|
|
|
|
foreach (pqs_rows('SELECT * FROM pqs_mechinfo ORDER BY mechname') as $m) {
|
|
$mn = $m['MechName'];
|
|
$sel = ($mn == $mech) ? ' selected' : '';
|
|
echo "<option value='$mn'$sel>$mn</option>";
|
|
}
|
|
|
|
echo "</td>";
|
|
echo "<td width='20%' align='center'><input type='submit' name='submit' class='button' id='submit_btnlock' value='Edit Player' />";
|
|
echo "<input type='hidden' name='playerid' value='$playerid'>";
|
|
echo "<input type='hidden' name='edit' value='commit'>";
|
|
echo "</table></div>";
|
|
echo "</td></tr></table></form>";
|
|
break;
|
|
|
|
case "delete":
|
|
pqs_remove_player($playerid);
|
|
break;
|
|
|
|
case "add":
|
|
$row = pqs_row("SELECT * FROM pqs_queue WHERE ID = ?", 'i', array($playerid));
|
|
$callsign = str_replace("'", "'", $row['CallSign'] ?? '');
|
|
$mech = $row['Mech'] ?? '';
|
|
$merc = $row['Merc'] ?? 0;
|
|
$missionid = (int)($row['MissionID'] ?? 0);
|
|
echo "<form action='registration.php";if (isset($_GET['missionid'])) {$missionid = (int)$_GET['missionid'];echo"?missionid=$missionid";};echo"' method='post'>";
|
|
echo "<table width='650' align='center'>";
|
|
echo "<tr><td align='center'>";
|
|
echo "<div id='editqueue' class='queuedivreg'>";
|
|
echo "<table border='0' align='center'><tr>";
|
|
echo "<td colspan='1' width='100%' class='queuedisplayhead' align='center'>Add $callsign to multiple missions</td></tr>";
|
|
echo "<tr><td class='queuedisplayhead' ><font size='4'># Missions: </font><input class='editqueue' type='text' name='nummissions' size='3' /></td></tr>";
|
|
echo "<tr><td align='center'><input type='submit' name='submit' class='button' id='submit_btnlock' value='Add missions' /></tr>";
|
|
echo "<input type='hidden' name='playerid' value='$playerid'>";
|
|
echo "<input type='hidden' name='callsign' value='$callsign'>";
|
|
echo "<input type='hidden' name='mech' value='$mech'>";
|
|
echo "<input type='hidden' name='merc' value='$merc'>";
|
|
echo "<input type='hidden' name='missionid' value='$missionid'>";
|
|
echo "<input type='hidden' name='add' value='commit'>";
|
|
echo "</table></div>";
|
|
echo "</td></tr></table></form>";
|
|
break;
|
|
|
|
case "editgame":
|
|
echo "<form name='editgame' action='registration.php";if (isset($_GET['missionid'])) {$missionid = (int)$_GET['missionid'];echo"?missionid=$missionid";};echo"' method='post'>";
|
|
echo "<input type='hidden' name='editgame' value='editgame'>";
|
|
echo "<table align='center'><tr><td align='center'>";
|
|
echo "<div id='edittype' class='queuedivreg'>";
|
|
echo "<table border='0' align='center'>";
|
|
echo "<tr><td width='15' class='consoledisplayhead'>Edit : $missionid </td>";
|
|
echo "<td width='40%' align='center'>";
|
|
echo "<select class='edittype' name='newtype' onchange='changeIt(this.options[this.selectedIndex].value)'>";
|
|
|
|
foreach (pqs_rows("SELECT * FROM pqs_gametype") as $t) {
|
|
$sel = ($t['TypeID'] == $oldtype) ? ' selected' : '';
|
|
echo "<option value='{$t['TypeID']}'$sel>{$t['TypeName']}</option>\n\t\t\t\t\t";
|
|
}
|
|
|
|
echo "</td>";
|
|
echo "<td width='30%' align='center'>";
|
|
echo "<select class='editmap' name='newmap'>";
|
|
|
|
foreach (pqs_rows("SELECT * FROM pqs_mapinfo") as $mp) {
|
|
$sel = ($mp['MapID'] == $oldmap) ? ' selected' : '';
|
|
echo "<option value='{$mp['MapID']}'$sel>{$mp['MapName']}</option>";
|
|
}
|
|
|
|
echo "</td>";
|
|
echo "<td width='15%' align='center'><input type='submit' name='submit' class='button' id='submit_btnlock' value='Edit' />";
|
|
echo "<input type='hidden' name='missionid' value='$missionid'>";
|
|
echo "</table></div>";
|
|
echo "</td></tr></table></form>";
|
|
break;
|
|
}
|
|
}
|
|
|
|
echo "<table width='650' align='center'>";
|
|
echo "<tr><td align='center'><a class='queuedisplayhead' href='registration.php?clearcurrent=1'><font size='3'>Clear Current Queue</font></a> | ";
|
|
echo "<a class='queuedisplayhead' href='history.php' target='_blank'><font size='3'>Open History Window</font></a> | ";
|
|
echo "<a class='queuedisplayhead' href='registration.php?lock=yes";if (isset($_GET['missionid'])) {$missionid = $_GET['missionid'];echo "&missionid=$missionid";} echo "'><font size='3'>Lock Mission</font></a> | ";
|
|
echo "<a class='queuedisplayhead' href='registration.php'><font size='3'>Back to Current Queue</font></a>";
|
|
echo "</td></tr>";
|
|
echo "<tr><td align='center'>";
|
|
echo "<div id='queuediv' class='queuedivreg'></div>";
|
|
echo "</td></tr>";
|
|
|
|
// add player form
|
|
if($missionid==0){
|
|
$missionid = (int) pqs_val('SELECT MIN(MissionID) FROM pqs_queue');
|
|
}
|
|
echo "<form action='registration.php";if (isset($_GET['missionid'])) {$missionid = $_GET['missionid'];echo"?missionid=$missionid";};echo"' method='post'>";
|
|
echo "<table align='center'><tr><td align='center'>";
|
|
echo "<div id='addqueue' class='queuedivreg'>";
|
|
echo "<table border='0' align='center'>";
|
|
|
|
|
|
echo "<tr><td width='10%' align='center'><a class='queuedisplayhead' href='registration.php'><font size='2'>Back to Current</font></a></td><td width='10%' class='consoledisplayhead' align='left'>M: $missionid</td><td width='40%' class='consoledisplayhead' align='center'>CS: <input class='editqueue' type='text' name='callsign' size='16' maxlength='16' /><input type='hidden' name='missionid' value='$missionid'></td>";
|
|
echo "<td width='30%' align='center'>";
|
|
echo "<select class='addqueue' name='mech'>";
|
|
foreach (pqs_rows('SELECT * FROM pqs_mechinfo ORDER BY mechname') as $m) {
|
|
echo "<option value='{$m['MechName']}'>{$m['MechName']}</option>\n\t\t";
|
|
}
|
|
echo "</td><td align='center' width='10'><input type='submit' name='new' class='button' id='action' value='new' /></td></tr></table>";
|
|
echo "</tr></table></form>";
|
|
|
|
// search form
|
|
echo "<table align='center'><tr><td align='center'>";
|
|
echo "<form action='registration.php' method='get'>";
|
|
|
|
echo "<div id='searchqueue' class='queuedivreg'>";
|
|
echo "<table border='0' align='center'>";
|
|
echo "<tr><td width='40%' align='center' class='consoledisplayhead'>Search in Mission(s)</td>";
|
|
echo "<td width='40%' align='center'><input class='editqueue' type='text' name='callsign' size='18' maxlength='16' />";
|
|
echo "</td><td align='center' width='20%'><input type='submit' name='search' class='button' id='action' value='search' /></td></tr></table>";
|
|
echo "</form>";
|
|
echo "</table>";
|
|
|
|
// create missions
|
|
echo "<table align='center'><tr><td align='center'>";
|
|
echo "<form action='registration.php' method='get'>";
|
|
|
|
echo "<div id='searchqueue' class='queuedivreg'>";
|
|
echo "<table border='0' align='center'>";
|
|
echo "<tr><td width='40%' align='center' class='consoledisplayhead'>Build Missions </td>";
|
|
echo "<td width='40%' align='center'><input class='editqueue' type='text' name='buildmissions' size='8' maxlength='3' />";
|
|
echo "</td><td align='center' width='20%'><input type='submit' name='build' class='button' id='action' value='build' /></td></tr></table>";
|
|
echo "</form>";
|
|
echo "</table>";
|
|
|
|
// search results //
|
|
if(isset($_GET['search'])){
|
|
$cs = isset($_GET['callsign']) ? str_replace("'", "&;", $_GET['callsign']) : '';
|
|
if($cs == ''){$cs = 'unknown';}
|
|
|
|
echo "<center><div class='queuedivreg'><table align='center'>";
|
|
echo "<tr><td colspan='5' class='queuedisplayhead'><font size='6'>Mission(s) : $cs</font></td></tr>";
|
|
echo "<tr><td class='queuedisplayhead' width='20%'>CallSign</td><td class='queuedisplayhead' width='20%'>Mission</td><td class='queuedisplayhead' width='20%'>ETD</td><td class='queuedisplayhead' width='20%'>Mech</td><td class='queuedisplayhead' width='20%'>Edit/Delete</td></tr>";
|
|
|
|
// get last commit time and mission id
|
|
$rs2 = pqs_row("SELECT max(MissionID) AS m, max(UNIX_TIMESTAMP(ctime)) AS t FROM pqs_pastmissions");
|
|
$lastmission = (int)($rs2['m'] ?? 0);
|
|
$lastCommitTime = $rs2['t'] ?? null;
|
|
if(is_null($lastCommitTime)){$lastCommitTime = time();}
|
|
|
|
// get time per game //
|
|
$cfg = pqs_row("SELECT timepergame, timetoreset FROM pqs_gameconfig");
|
|
$tpg = (int)$cfg['timepergame'] + (int)$cfg['timetoreset'];
|
|
|
|
foreach (pqs_rows("SELECT * FROM pqs_queue WHERE CallSign LIKE ? ORDER BY MissionID", 's', array($cs)) as $line) {
|
|
$mtd = ($line['MissionID'] - $lastmission) * $tpg;
|
|
$d=strtotime("+$mtd Minutes",$lastCommitTime);
|
|
$etd = date("h:i", $d);
|
|
$c = $line['CallSign']; $mid = $line['MissionID']; $pid = $line['ID']; $mch = $line['Mech'];
|
|
|
|
echo "<tr><td class='queuedisplay'>$c</td><td class='queuedisplay'>$mid</td><td class='queuedisplay'>$etd</td><td class='queuedisplay'>$mch</td><td class='queuedisplay'>";
|
|
echo "<a href='registration.php?action=edit&playerid=$pid&missionid=$mid' title='Edit $c's information'><img src='images/edit.png' border='0' height='22'></a> ";
|
|
echo "<a href='registration.php?action=delete&playerid=$pid&missionid=$mid' title='Delete $c from queue'><img src='images/delete.png' border='0' height='22'></a> ";
|
|
|
|
echo "</td></tr>";
|
|
}
|
|
echo "<tr><td align='center' colspan='4' class='queuedisplay'> </td>";
|
|
echo "</table></div>";
|
|
}
|
|
|
|
echo "</body></html>";
|
|
?>
|
|
<script type="text/javascript">
|
|
|
|
function changeIt(objval) {
|
|
oForm = document.forms["editgame"];
|
|
fAction = oForm.elements["editgame"].value;
|
|
fOldmap = oForm.elements["newmap"].value;
|
|
fOldtype = oForm.elements["newtype"].value;
|
|
fMissionid = oForm.elements["missionid"].value;
|
|
|
|
window.location.replace('http://<?php echo "$server"; ?>/pqs/registration.php?action=' + fAction + '&oldmap=' + fOldmap + '&oldtype=' + fOldtype + '&missionid=' + fMissionid)
|
|
|
|
}
|
|
</script>
|
|
|