Parameterize history.php and search.php
Both now use db.php helpers with bound params: history's mission index (was injectable via $_GET[index]) and the callsign LIKE search. Loops switched to associative fetches. Verified: history shows the committed mission + players + merc count; search finds a queued callsign. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+21
-36
@@ -6,39 +6,26 @@
|
||||
<body style='background: #000;'>
|
||||
<?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');
|
||||
require_once("includes/db.php");
|
||||
|
||||
$query = "SELECT MIN(missionid) FROM pqs_pastmissions";
|
||||
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
|
||||
$rs = mysqli_fetch_array($result);
|
||||
$minmission = $rs[0];
|
||||
|
||||
$query = "SELECT MAX(missionid) FROM pqs_pastmissions";
|
||||
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
|
||||
$rs = mysqli_fetch_array($result);
|
||||
$maxmission = $rs[0];
|
||||
$minmission = (int) pqs_val("SELECT MIN(missionid) FROM pqs_pastmissions");
|
||||
$maxmission = (int) pqs_val("SELECT MAX(missionid) FROM pqs_pastmissions");
|
||||
$index = $maxmission;
|
||||
$fl = "";
|
||||
|
||||
if (isset($_GET['prev'])) {
|
||||
if (isset($_GET['index'])) {
|
||||
$index = $_GET['index'] - 1;
|
||||
if ($index < $minmission) { $index = $maxmission; }
|
||||
}
|
||||
if (isset($_GET['prev']) && isset($_GET['index'])) {
|
||||
$index = (int)$_GET['index'] - 1;
|
||||
if ($index < $minmission) { $index = $maxmission; }
|
||||
}
|
||||
if (isset($_GET['next'])) {
|
||||
if (isset($_GET['index'])) {
|
||||
$index = $_GET['index'] + 1;
|
||||
if ($index > $maxmission) { $index = $minmission; }
|
||||
}
|
||||
if (isset($_GET['next']) && isset($_GET['index'])) {
|
||||
$index = (int)$_GET['index'] + 1;
|
||||
if ($index > $maxmission) { $index = $minmission; }
|
||||
}
|
||||
|
||||
if ($index == $maxmission) { $fl = "(Last Mission)"; }
|
||||
if ($index == $minmission) { $fl = "(First Mission)"; }
|
||||
|
||||
$query = "SELECT callsign, mech, pqs_pastmissions.missionid, missiondate, nummercs, missionsize, numplayers, missiontime FROM pqs_pastmissions inner join pqs_mission where pqs_pastmissions.missionid = pqs_mission.missionid HAVING pqs_pastmissions.missionid = $index";
|
||||
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
|
||||
$rows = pqs_rows("SELECT callsign, mech, pqs_pastmissions.missionid, missiondate, nummercs, missionsize, numplayers, missiontime FROM pqs_pastmissions inner join pqs_mission where pqs_pastmissions.missionid = pqs_mission.missionid HAVING pqs_pastmissions.missionid = ?", 'i', array($index));
|
||||
|
||||
if (isset($_GET['launch'])) {
|
||||
if ($_GET['launch'] == 'console') {
|
||||
@@ -50,24 +37,24 @@ if (isset($_GET['launch'])) {
|
||||
echo "<tr><td colspan='2' class='queuedisplayhead'><font size='6'>Mission #$index</font> <font size='4'>$fl</font></td></tr>";
|
||||
echo "<tr><td class='queuedisplayhead' width='34%'>Callsign</td><td class='queuedisplayhead' width='34%'>Mech</td></tr>";
|
||||
|
||||
while ($line = mysqli_fetch_array($result)) {
|
||||
echo "<tr><td class='queuedisplay'>$line[0]</td><td class='queuedisplay'>$line[1]</td></tr>";
|
||||
$cfull = $line[3];
|
||||
foreach ($rows as $line) {
|
||||
echo "<tr><td class='queuedisplay'>$line[callsign]</td><td class='queuedisplay'>$line[mech]</td></tr>";
|
||||
$cfull = $line['missiondate'];
|
||||
$cyear = substr($cfull,0,4);
|
||||
$cmonth = substr($cfull,4,2);
|
||||
$cday = substr($cfull,6);
|
||||
$mdate = date("l, F jS, o", mktime(0,0,0, $cmonth,$cday,$cyear));
|
||||
$mercs = $line[4];
|
||||
$pods = $line[5];
|
||||
$numplayers = $line[6];
|
||||
if (strlen($line[7]) == 3) {
|
||||
$mtime = substr($line[7], 0, 1);
|
||||
$mercs = $line['nummercs'];
|
||||
$pods = $line['missionsize'];
|
||||
$numplayers = $line['numplayers'];
|
||||
if (strlen($line['missiontime']) == 3) {
|
||||
$mtime = substr($line['missiontime'], 0, 1);
|
||||
$mtime = $mtime . ":";
|
||||
$mtime = $mtime . (substr($line[7], 1,2));
|
||||
$mtime = $mtime . (substr($line['missiontime'], 1,2));
|
||||
} else {
|
||||
$mtime = substr($line[7], 0, 2);
|
||||
$mtime = substr($line['missiontime'], 0, 2);
|
||||
$mtime = $mtime . ":";
|
||||
$mtime = $mtime . (substr($line[7], 2,2));
|
||||
$mtime = $mtime . (substr($line['missiontime'], 2,2));
|
||||
}
|
||||
}
|
||||
echo "<tr><td align='center' colspan='2' class='queuedisplay'> </td>";
|
||||
@@ -83,8 +70,6 @@ if (isset($_GET['launch'])) {
|
||||
}
|
||||
echo "<tr><td align='center'><a class='queuedisplayhead' href='history.php?prev=1&index=$index'>Prev</a></td>";
|
||||
echo "<td align='center'><a class='queuedisplayhead' href='#' onclick='window.close()'>Close</a></td><td align='center'><a class='queuedisplayhead' href='history.php?next=1&index=$index'>Next</a></td></tr></table>";
|
||||
mysqli_free_result($result);
|
||||
mysqli_close($link);
|
||||
echo "</body></html>";
|
||||
?>
|
||||
|
||||
|
||||
+11
-29
@@ -35,48 +35,30 @@ echo "<tr><td colspan='4' class='queuedisplayhead'><font size='6'>Mission(s) : $
|
||||
//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>";
|
||||
echo "<tr><td class='queuedisplayhead' width='25%'>CallSign</td><td class='queuedisplayhead' width='25%'>Mission</td><td class='queuedisplayhead' width='25%'>ETD</td><td class='queuedisplayhead' width='25%'>Mech</td></tr>";
|
||||
|
||||
$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');
|
||||
require_once("includes/db.php");
|
||||
|
||||
// get last commit time and mission id
|
||||
$query = "SELECT max(MissionID), max(UNIX_TIMESTAMP(ctime)) FROM pqs_pastmissions";
|
||||
$getlct = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
|
||||
$rs2 = mysqli_fetch_array($getlct);
|
||||
$lastmission = $rs2[0];
|
||||
if(is_null($lastmission)){$lastmission = 0;}
|
||||
$lastCommitTime = $rs2[1];//-(6*60*60);
|
||||
if(is_null($lastCommitTime)){$lastCommitTime = time();}//-(6*60*60);}
|
||||
//echo"$lastCommitTime";
|
||||
//$d=strtotime("+$mtd Minutes",$lastCommitTime);
|
||||
//$etd = date("h:i", $d);
|
||||
$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 //
|
||||
$query = "SELECT timepergame, timetoreset FROM pqs_gameconfig";
|
||||
$gettpg = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
|
||||
$rs1 = mysqli_fetch_array($gettpg);
|
||||
$tpg = $rs1[0]+$rs1[1];
|
||||
$cfg = pqs_row("SELECT timepergame, timetoreset FROM pqs_gameconfig");
|
||||
$tpg = (int)$cfg['timepergame'] + (int)$cfg['timetoreset'];
|
||||
|
||||
// fetch data //
|
||||
$query = "SELECT * FROM pqs_queue WHERE CallSign LIKE '$cs'";
|
||||
$result = mysqli_query($link, $query) or die('Query failed: ' . mysqli_error($link));
|
||||
|
||||
while ($line = mysqli_fetch_array($result)) {
|
||||
|
||||
$mtd = ($line[3] - $lastmission) * $tpg;
|
||||
foreach (pqs_rows("SELECT * FROM pqs_queue WHERE CallSign LIKE ?", 's', array($cs)) as $line) {
|
||||
$mtd = ($line['MissionID'] - $lastmission) * $tpg;
|
||||
$d=strtotime("+$mtd Minutes",$lastCommitTime);
|
||||
$etd = date("h:i", $d);
|
||||
|
||||
echo "<tr><td class='queuedisplay'>$line[0]</td><td class='queuedisplay'>$line[3]</td><td class='queuedisplay'>$etd</td><td class='queuedisplay'>$line[1]</td><td class='queuedisplay'>";
|
||||
// echo "<a href='registration.php?action=edit&playerid=$line[2]&missionid=$line[3]' title='Edit $line[0]'s information'><img src='images/edit.png' border='0' height='22'></a> ";
|
||||
// echo "<a href='registration.php?action=delete&playerid=$line[2]&missionid=$line[3]' title='Delete $line[0] from queue'><img src='images/delete.png' border='0' height='22'></a> ";
|
||||
|
||||
|
||||
echo "<tr><td class='queuedisplay'>$line[CallSign]</td><td class='queuedisplay'>$line[MissionID]</td><td class='queuedisplay'>$etd</td><td class='queuedisplay'>$line[Mech]</td><td class='queuedisplay'>";
|
||||
echo "</td></tr>";
|
||||
}
|
||||
echo "<tr><td align='center' colspan='4' class='queuedisplay'> </td>";
|
||||
echo "</table></div>";
|
||||
|
||||
mysqli_free_result($result);
|
||||
mysqli_close($link);
|
||||
echo "</body></html>";
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
|
||||
Reference in New Issue
Block a user