Skip to content

Commit

Permalink
remove query() from sections/logchecker
Browse files Browse the repository at this point in the history
  • Loading branch information
Spine committed May 6, 2021
1 parent 972d4e4 commit d613024
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 30 deletions.
28 changes: 12 additions & 16 deletions sections/logchecker/update.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
<div class="thin">
<h2 class="center">Update Log</h2>
<div class="box pad">
<p>
This form allows you to update the logs for any torrent that you've uploaded.
<p>This form allows you to update the logs for any torrent that you've uploaded.
Select a torrent and upload the log files in the form <u>below</u>, making sure to add
all logs that you wish to upload. This will overwrite any previously uploaded logs for
this torrent. If you wish to just have a torrent manually rescored, please report it
to staff.
</p>
to staff.</p>
<br />
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="take_upload" />
Expand All @@ -29,20 +27,21 @@
</tr>
HTML;

$DB->query("
SELECT
ID, GroupID, `Format`, Encoding, HasCue, HasLog, HasLogDB, LogScore,
LogChecksum
$DB->prepared_query("
SELECT ID, GroupID, `Format`, Encoding, HasCue, HasLog, HasLogDB, LogScore, LogChecksum
FROM torrents
WHERE HasLog='1' AND HasLogDB='1' AND UserID = " . $LoggedUser['ID']);

if ($DB->has_results()) {
WHERE HasLog = '1' AND HasLogDB = '1' AND UserID = ?
", $LoggedUser['ID']
);
if (!$DB->has_results()) {
echo "\t\t\t<tr><td colspan='2'>No uploads found.</td></tr>";
} else {
$GroupIDs = $DB->collect('GroupID');
$TorrentsInfo = $DB->to_array('ID');
$Groups = Torrents::get_groups($GroupIDs);
foreach ($TorrentsInfo as $TorrentID => $Torrent) {
list($ID, $GroupID, $Format, $Encoding, $HasCue, $HasLog, $HasLogDB, $LogScore, $LogChecksum) = $Torrent;
$Group = $Groups[(int) $GroupID];
[$ID, $GroupID, $Format, $Encoding, $HasCue, $HasLog, $HasLogDB, $LogScore, $LogChecksum] = $Torrent;
$Group = $Groups[$GroupID];
$GroupName = $Group['Name'];
$GroupYear = $Group['Year'];
$ExtendedArtists = $Group['ExtendedArtists'];
Expand Down Expand Up @@ -99,9 +98,6 @@
</tr>
HTML;

}
else {
echo "\t\t\t<tr><td colspan='2'>No uploads found.</td></tr>";
}
print <<<HTML
</table>
Expand Down
26 changes: 12 additions & 14 deletions sections/logchecker/upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
<div class="thin">
<h2 class="center">Upload Missing Logs</h2>
<div class="box pad">
<p>
These torrents are your uploads that state that there are logs within the torrent, but none were
<p>These torrents are your uploads that state that there are logs within the torrent, but none were
uploaded to the site. To fix this, please select a torrent and then some torrents to upload below.
<br /><br />
If you'd like to upload new logs for your uploaded torrents that have been scored, please go <a href="logchecker.php?action=update">here</a>.
Additionally, you can report any torrent to staff for them to be manually rescored by staff.
</p>
Additionally, you can report any torrent to staff for them to be manually rescored by staff.</p>
<br />
<form action="" method="post" enctype="multipart/form-data">
<input type="hidden" name="action" value="take_upload" />
Expand All @@ -28,20 +26,23 @@
<td colspan="2">Select a Torrent</td>
</tr>
HTML;
$DB->query("
SELECT
ID, GroupID, `Format`, Encoding, HasCue, HasLog, HasLogDB, LogScore, LogChecksum
FROM torrents
WHERE HasLog='1' AND HasLogDB='0' AND UserID = ".$LoggedUser['ID']);

$DB->prepared_query("
SELECT ID, GroupID, `Format`, Encoding, HasCue, HasLog, HasLogDB, LogScore, LogChecksum
FROM torrents
WHERE HasLog = '1' AND HasLogDB = '0' AND UserID = ?
", $LoggedUser['ID']
);
if ($DB->has_results()) {
echo "\t\t\t\t<tr><td colspan='2'>No uploads found.</td></tr>";
} else {
$GroupIDs = $DB->collect('GroupID');
$TorrentsInfo = $DB->to_array('ID');
$Groups = Torrents::get_groups($GroupIDs);

foreach ($TorrentsInfo as $TorrentID => $Torrent) {
list($ID, $GroupID, $Format, $Encoding, $HasCue, $HasLog, $HasLogDB, $LogScore, $LogChecksum) = $Torrent;
$Group = $Groups[(int) $GroupID];
[$ID, $GroupID, $Format, $Encoding, $HasCue, $HasLog, $HasLogDB, $LogScore, $LogChecksum] = $Torrent;
$Group = $Groups[$GroupID];
$GroupName = $Group['Name'];
$GroupYear = $Group['Year'];
$ExtendedArtists = $Group['ExtendedArtists'];
Expand Down Expand Up @@ -98,9 +99,6 @@
</tr>
HTML;

}
else {
echo "\t\t\t\t<tr><td colspan='2'>No uploads found.</td></tr>";
}
echo <<<HTML
</table>
Expand Down

0 comments on commit d613024

Please sign in to comment.