Files
PQS/callsign.php
CydandClaude Opus 4.8 689c6a4dd2 Item #4: centralize timezone, collapse the 16 pod branches to loops
- 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>
2026-07-01 14:30:57 -05:00

311 lines
14 KiB
PHP

<html>
<head>
<title>PQS - CallSign v2</title>
<link href="css/main.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/jquery.alphanumeric.js"></script>
</head>
<body style='background: #000;'>
<?php
//var_dump($_GET);
require_once("includes/config.php");
require_once("includes/db.php");
$tdate = date('Ymd');
$ttime = date('Hi');
$isLight = false;
$isMedium = false;
$isHeavy = false;
$isAssault = false;
$isRandom = false;
$isLeader = false;
$isMember = false;
$groupAvalible = $_SESSION['groupAvalible'];
//var_dump($_SESSION);
if (isset($GET_['who'])){
$who = $GET_['who'];
} else {
$who = "";
}
if (isset($_GET['howmany'])){
$hm = intval($_GET['howmany']);
} else {
$hm = 0;
$howmany = 0;
}
if (isset($_GET['callsign'])){
$cs = $_GET['callsign'];
} else {
$cs = "";
}
if (isset($_GET['wclass'])){
$wclass = $_GET['wclass'];
$wcmech = $_GET['wclass'];
$wclass = "'" . $wclass . "'";
switch ($wcmech) {
case 'Light':
$isLight = true;
break;
case 'Medium':
$isMedium = true;
break;
case 'Heavy':
$isHeavy = true;
break;
case 'Assault':
$isAssault = true;
break;
case 'Random':
$isRandom = true;
break;
}
} else {
$wclass = "''";
$wcmech = "no mech";
}
if (isset($_GET['group'])){
$group = $_GET['group'];
switch($group){
case 'Leader':
$isLeader = true;
$isMember = false;
break;
case 'Member':
$isMember = true;
$isLeader = false;
break;
}
} else {
$group = "";
$isLeader = false;
$isMember = false;
}
if (isset($_GET['submit'])) {
$callsign = str_replace("'", "&;", $_GET['callsign']);
$mechid = $_GET['mech'];
$link = mysqli_connect('localhost', 'pqs', 'pqs') or die('Could not connect: ' . mysqli_error($link));
mysqli_select_db($link, 'pqs') or die('Could not select database');
$sql = "SELECT MechName FROM pqs_mechinfo WHERE MechID = $mechid";
$result = mysqli_query($link, $sql) or die('Query failed: ' . mysqli_error($link));
$line = mysqli_fetch_array($result);
$mechname = $line[0];
$query = "SELECT timepergame, timetoreset FROM pqs_gameconfig";
$gettpg = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
$rs1 = mysqli_fetch_array($gettpg);
$timePerGame = $rs1[0]+$rs1[1];
$query = "SELECT max(MissionID), max(UNIX_TIMESTAMP(ctime)) FROM pqs_pastmissions";
$getLCMID = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
$rs2 = mysqli_fetch_array($getLCMID);
$lastCommitedMissionID = $rs2[0];
$lastCommitTime = $rs2[1];
if($isMember){
// Atomically claim an unclaimed slot reserved by the group leader.
require_once("includes/queue.php");
$missionid = pqs_claim_group_slot($_GET['who'], $callsign, $mechname);
if ($missionid === null) {
echo "<table width='1024' height='768' align='center' style='background: url(images/bsb.jpg);' border=1>";
echo "<tr><td><br><br><table width='820' height='614' align='center' style='background: url(images/mr-block.gif);'>";
echo "<tr><td height='500' align='center' valign='middle'><div class='queued'><br>Sorry $_GET[callsign], there are no open slots left in that group.<br><br>Please register on your own or ask the group leader to reserve more slots.<br><br></div></td></tr>";
echo "</table></td></tr></table>";
echo "<meta http-equiv='refresh' content='4;url=callsign.php'>";
exit;
}
$minToDeparture = $timePerGame*($missionid-$lastCommitedMissionID);
$d=strtotime("+$minToDeparture Minutes",$lastCommitTime);
$etd = date("h:i", $d);
echo "<table width='1024' height='768' align='center' style='background: url(images/bsb.jpg);' border=1>";
echo "<tr><td><br><br><table width='820' height='614' align='center' style='background: url(images/mr-block.gif);'>";
echo "<tr><td height='500' align='center' valign='middle'><div class='queued'><br>Thank you $_GET[callsign]. You have been entered into the queue piloting a $mechname.<br><br>You are currently set for mission:<br><br><font size='7'>#$missionid</font><br><br>Please continue to check the queue displays for your position in the queue.<br><br></div></td></tr>";
echo "</table></td></tr></table>";
echo "<meta http-equiv='refresh' content='4;url=callsign.php'>";
exit;
}
if($isLeader){
// Atomically reserve $hm seats (leader + placeholders) in one mission.
require_once("includes/queue.php");
$missionid = pqs_enqueue_group($callsign, $mechname, $hm);
$minToDeparture = $timePerGame*($missionid-$lastCommitedMissionID);
$d=strtotime("+$minToDeparture Minutes",$lastCommitTime);
$etd = date("h:i", $d);
echo "<table width='1024' height='768' align='center' style='background: url(images/bsb.jpg);' border=1>";
echo "<tr><td><br><br><table width='820' height='614' align='center' style='background: url(images/mr-block.gif);'>";
echo "<tr><td height='500' align='center' valign='middle'><div class='queued'><br>Thank you $_GET[callsign]. You have been entered into the queue piloting a $mechname.<br><br>You are currently set for mission:<br><font size='7'>#$missionid</font><br>Your Estimated Departure time is: $etd <br><br>Please continue to check the queue displays for your position in the queue.<br><br></div></td></tr>";
echo "</table></td></tr></table>";
echo "<meta http-equiv='refresh' content='4;url=callsign.php'>";
exit;
}
// Atomically seat the player in the next open mission (creates one if
// needed). Serialized + transactional to prevent the overfill race that
// concurrent kiosk/staff registrations used to cause. See includes/queue.php.
require_once("includes/queue.php");
$missionid = pqs_enqueue_player($callsign, $mechname);
$minToDeparture = $timePerGame*($missionid-$lastCommitedMissionID);
$d=strtotime("+$minToDeparture Minutes",$lastCommitTime);
$etd = date("h:i", $d);
echo "<table width='1024' height='768' align='center' style='background: url(images/bsb.jpg);' border=1>";
echo "<tr><td><br><br><table width='820' height='614' align='center' style='background: url(images/mr-block.gif);'>";
// echo "<tr><td height='500' align='center' valign='middle'><div class='queued'><br>Thank you $_GET[callsign]. You have been entered into the queue piloting a $mechname.<br><br>You are currently set for mission:<br><br><font size='7'>#$missionid</font><br>Your Estimated Departure time is: $etd <br>Please continue to check the queue displays for your position in the queue.<br><br></div></td></tr>";
echo "<tr><td height='500' align='center' valign='middle'><div class='queued'><br>Thank you $_GET[callsign]. You have been entered into the queue piloting a $mechname.<br><br>You are currently set for mission:<br><br><font size='7'>#$missionid</font><br>Your Estimated Departure time is: $etd <br>Please continue to check the queue displays for your position in the queue.<br><br><FORM><INPUT TYPE='button' style='font-size:20px;color:green;height:50px;width:250px' VALUE='ACKNOWLEDGED! o7' onClick='parent.location=`callsign.php`'></FORM><br></div></td></tr>";
echo "</table></td></tr></table>";
// echo "<meta http-equiv='refresh' content='4;url=callsign.php'>";
exit;
}
?>
<div id='mainpage'>
<form name='submit-callsign' method='get'>
<table width='1024' height='768' align='center' style='background: url(images/bsb.jpg);' border=1>
<tr><td><br><br>
<table width='820' height='614' align='center' style='background: url(images/mr-block.gif);'>
<tr><td colspan='2' height='100' align='center' valign='bottom'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/mr.gif' align='absmiddle'></td></tr>
<tr><td width='380' height='75' align='center' valign='middle'><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/callsign.gif' align='absmiddle'></td>
<td align='left' valign='middle'><br>
<input class='callsign' type='text' name='callsign' size='25' maxlength='16' value='<?php echo "$cs"; ?>'/>
</td></tr>
<tr><td width='380' height='75' align='center' valign='middle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/group.gif' align='absmiddle' alt='group'></td>
<td align='left' valign='middle'>
<select class='main' name='group' onchange='changeIt(this.options[this.selectedIndex].value)'>
<option value="None"><?php if ($groupAvalible) { Echo "Not in Group"; } else { echo "Do Not Use";} ?></option>
<?php
if ($groupAvalible){
echo '<option value="Leader"';if($isLeader)echo ' selected ';echo">Group Leader</option>";
echo '<option value="Member"';if($isMember)echo ' selected ';echo">Group Member</option>";
} else {
}
?>
</td></tr>
<?php
if ($isLeader){
echo "<tr><td width='380' height='75' align='center' valign='middle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='hidden' class='main' name='who'><img src='images/howmany.gif' align='absmiddle' alt='howmany'></td>
<td align='left' valign='middle'><select class='main' name='howmany'>
";
$link = mysqli_connect('localhost', 'pqs', 'pqs') or die('Could not connect: ' . mysqli_error($link));
mysqli_select_db($link, 'pqs') or die('Could not select database');
$query = "SELECT `numpods` FROM `pqs_gameconfig` WHERE 1";
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
$line = mysqli_fetch_array($result);
$i = 2;
$max = intval($line[0]);
while ($i <= $max){
echo "<option value=$i";if($hm == $i){echo" selected ";}echo">$i</option>
";
$i ++;
}
echo "</td></tr>";
} else if ($isMember){
echo "<tr><td width='380' height='75' align='center' valign='middle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='hidden' class='main' name='howmany'><img src='images/who.gif' align='absmiddle' alt='who'></td>
<td align='left' valign='middle'><select class='main' name='who'>
";
$link = mysqli_connect('localhost', 'pqs', 'pqs') or die('Could not connect: ' . mysqli_error($link));
mysqli_select_db($link, 'pqs') or die('Could not select database');
$query = "SELECT DISTINCT left(`CallSign`,LOCATE('-',`CallSign`)-1) FROM `pqs_queue` WHERE `CallSign` like '%-%'";
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
while ($line = mysqli_fetch_array($result)) {
echo "<option value=$line[0]";if(strcmp($_GET['who'], $line[0])==0){echo " selected ";} echo ">$line[0]</option>
";}
} else {
echo "<tr><td width='380' height='75' align='center' valign='middle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td><td align='left' valign='middle'><input type='hidden' class='main' name='howmany'><input type='hidden' class='main' name='who'>";
}
?>
<tr><td width='380' height='75' align='center' valign='middle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/weight.gif' align='absmiddle'></td>
<td align='left' valign='middle'>
<select class='main' name='wclass' onchange='changeIt(this.options[this.selectedIndex].value)'>
<option value="no mech">Choose a Class</option>
<option value="Light"<?php if($isLight)echo ' selected ';?>>Light</option>
<option value="Medium"<?php if($isMedium){echo ' selected ';}?>>Medium</option>
<option value="Heavy"<?php if($isHeavy){echo ' selected ';}?>>Heavy</option>
<option value="Assault"<?php if($isAssault){echo ' selected ';}?>>Assault</option>
<option value="Random"<?php if($isRandom){echo ' selected ';}?>>Random</option>
</td></tr>
<tr><td width='380' height='75' align='center' valign='middle'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<img src='images/mech.gif' align='absmiddle'></td>
<td align='left' valign='middle'>
<select class='main' name='mech' >
<option value=0><?php echo "$wcmech" . "s"; ?></option>
<?php
$link = mysqli_connect('localhost', 'pqs', 'pqs') or die('Could not connect: ' . mysqli_error($link));
mysqli_select_db($link, 'pqs') or die('Could not select database');
$query = "SELECT * FROM pqs_mechinfo WHERE `Class` IN ($wclass) ORDER BY mechname";
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
while ($line = mysqli_fetch_array($result)) {
echo "<option value=$line[0]>$line[1]</option>
";
}
mysqli_free_result($result);
mysqli_close($link);
?></td></tr>
<tr><td>&nbsp;</td><td align='center' valign='top'><div class='submit'><input type='image' src='images/submit.gif' border='0' alt='SUBMIT!'></div></td></tr>
<input type='hidden' name='submit' value='yes' />
</form>
</table>
</td></tr>
</table>
</div>
</body>
</html>
<script type="text/javascript">
$('.callsign').alphanumeric({ichars:'-%&*/\\<>?",:;[]'});
$("form").submit(function() {
oForm = document.forms["submit-callsign"];
fName = oForm.elements["callsign"].value;
fMech = oForm.elements["mech"].value;
if (fName == "") {
fMessage = "Callsign required. Please enter a callsign and resubmit.";
}
if (fMech == 0) {
fMessage = "Mech required. Please choose a mech and resubmit.";
}
if ((fName != "") && (fMech != 0)) {
return true;
} else {
alert(fMessage);
return false;
}
});
<?php $server = $_SERVER['SERVER_ADDR'];
?>
function changeIt(objval) {
oForm = document.forms["submit-callsign"];
fClass = oForm.elements["wclass"].value;
fName = oForm.elements["callsign"].value;
fGroup = oForm.elements["group"].value;
fHowmany = oForm.elements["howmany"].value;
fWho = oForm.elements["who"].value;
window.location.replace('http://<?php echo "$server"; ?>/pqs/callsign.php?wclass=' + fClass + '&callsign=' + fName + '&group=' + fGroup + '&howmany=' + fHowmany + '&who=' + fWho)
}
</script>