Skip to content

Commit

Permalink
Commit after running composer exec "phpcbf -p ." .
Browse files Browse the repository at this point in the history
  • Loading branch information
deepend-tildeclub authored and RedDragonWebDesign committed Jan 26, 2024
1 parent 8e13be8 commit a90425e
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 183 deletions.
2 changes: 1 addition & 1 deletion src/classes/basic.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function addNew($arrColumns, $arrValues) {

if (is_array($arrValues)) {
foreach ($arrValues as $key => $value) {
$value = $value ?? '';
$value = $value ?? '';
$temp = str_replace(">", ">", $value);
$value = str_replace("&lt;", "<", $temp);
$temp = str_replace('&quot;', '"', $value);
Expand Down
2 changes: 1 addition & 1 deletion src/members/include/admin/adddownloadcategory.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
}


$countErrors = 0;
$countErrors = 0;

if ($countErrors == 0) {
$accessKey = ($_POST['accesskey'] ?? 0) != 1 ? 0 : 1;
Expand Down
43 changes: 12 additions & 31 deletions src/members/include/admin/managedownloadcat/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,18 @@
$consoleObj->select($cID);
$_GET['cID'] = $cID;

if($member->authorizeLogin($_SESSION['btPassword'])) {


if ($member->authorizeLogin($_SESSION['btPassword'])) {
$memberInfo = $member->get_info_filtered();

if($member->hasAccess($consoleObj) && $downloadCatObj->select($_POST['catID'])) {

if ($member->hasAccess($consoleObj) && $downloadCatObj->select($_POST['catID'])) {
define('MEMBERRANK_ID', $memberInfo['rank_id']);
$downloadCatInfo = $downloadCatObj->get_info_filtered();

$arrCats = $downloadCatObj->getAssociateIDs();

if(count($arrCats) > 0) {


if (count($arrCats) > 0) {
echo "<div id='newDeleteMessage' style='display: none'><p align='center'>There are currently downloads with the download category <b>".$downloadCatInfo['name']."</b>. Please move all downloads out of this category before deleting it.</p></div>";

echo "
<script type='text/javascript'>
$(document).ready(function() {
Expand All @@ -67,28 +63,13 @@
});
</script>
";


} elseif (isset($_POST['confirm']) && $_POST['confirm'] == "1") {
$downloadCatObj->delete();
include("main.php");
} else {
echo "<p align='center'>Are you sure you want to delete the download category <b>".$downloadCatInfo['name']."</b>?</p>";
}
elseif(isset($_POST['confirm']) && $_POST['confirm'] == "1") {
$downloadCatObj->delete();
include("main.php");
}
else {
echo "<p align='center'>Are you sure you want to delete the download category <b>".$downloadCatInfo['name']."</b>?</p>";
}

}
elseif(!$downloadCatObj->select($_POST['catID'])) {

} elseif (!$downloadCatObj->select($_POST['catID'])) {
echo "<p align='center'>Unable find the selected download category. Please try again or contact the website administrator.</p>";

}




}


?>
185 changes: 80 additions & 105 deletions src/members/include/admin/managedownloadcat/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
*
*/

if(!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") {
if (!isset($member) || substr($_SERVER['PHP_SELF'], -11) != "console.php") {
exit();
}
else {
} else {
$memberInfo = $member->get_info_filtered();
$consoleObj->select($_GET['cID']);
if(!$member->hasAccess($consoleObj)) {
if (!$member->hasAccess($consoleObj)) {
exit();
}
}
Expand All @@ -29,8 +28,8 @@
$downloadCatObj = new DownloadCategory($mysqli);
$downloadExtensionObj = new Basic($mysqli, "download_extensions", "extension_id");

if(!$downloadCatObj->select($_GET['catID'])) {
die("<script type='text/javascript'>window.location = '".$MAIN_ROOT."members';</script>");
if (!$downloadCatObj->select($_GET['catID'])) {
die("<script type='text/javascript'>window.location = '".$MAIN_ROOT."members';</script>");
}


Expand All @@ -48,96 +47,81 @@
$countErrors = 0;
$dispError = "";

if(isset($_POST['submit'])) { // Corrected this line

if (isset($_POST['submit'])) { // Corrected this line
$resortOrder = false;
// Check Category Name
if(trim($_POST['catname']) == "") {

if (trim($_POST['catname']) == "") {
$countErrors++;
$dispError .= "&nbsp;&nbsp;&nbsp;<b>&middot;</b> You must enter a Category Name.<br>";
}

// Check Extensions
$arrExtensions = explode(",", trim($_POST['catexts']));
if(count($arrExtensions) <= 0) {

if (count($arrExtensions) <= 0) {
$countErrors++;
$dispError .= "&nbsp;&nbsp;&nbsp;<b>&middot;</b> You must enter at least one download extension.<br>";
}

// Check Cat Order


$intNewOrderSpot = "";
if(!$downloadCatObj->select($_POST['catorder']) AND $_POST['catorder'] != "first") {
if (!$downloadCatObj->select($_POST['catorder']) and $_POST['catorder'] != "first") {
$countErrors++;
$dispError .= "&nbsp;&nbsp;&nbsp;<b>&middot;</b> You selected an invalid category order. (category)<br>";
}
elseif($_POST['catorder'] == "first") {
} elseif ($_POST['catorder'] == "first") {
// "(no other categories)" selected, check to see if there are actually no other categories

$result = $mysqli->query("SELECT * FROM ".$dbprefix."downloadcategory");
$num_rows = $result->num_rows;
if($num_rows > 1) {

if ($num_rows > 1) {
$countErrors++;
$dispError .= "&nbsp;&nbsp;&nbsp;<b>&middot;</b> You selected an invalid category order. (category)<br>";
}
else {
} else {
$intNewOrderSpot = 1;
}

}
else {

if($_POST['beforeafter'] != "before" AND $_POST['beforeafter'] != "after") {
} else {
if ($_POST['beforeafter'] != "before" and $_POST['beforeafter'] != "after") {
$countErrors++;
$dispError .= "&nbsp;&nbsp;&nbsp;<b>&middot;</b> You selected an invalid category order. (before/after)<br>";
}
else {

} else {
$catOrderOrderNum = $downloadCatObj->get_info("ordernum");

$addTo = -1;
if($_POST['beforeafter'] == "before") {
$addTo = 1;
if ($_POST['beforeafter'] == "before") {
$addTo = 1;
}

$checkOrderNum = $catOrderOrderNum+$addTo;
if($checkOrderNum != $downloadCatInfo['ordernum']) {
if ($checkOrderNum != $downloadCatInfo['ordernum']) {
$intNewOrderSpot = $downloadCatObj->makeRoom($_POST['beforeafter']);
}

}


}


if($countErrors == 0) {



if ($countErrors == 0) {
$updateColumns = array("name", "accesstype");
$updateValues = array($_POST['catname'], $_POST['accesstype']);
if($intNewOrderSpot != "") {

if ($intNewOrderSpot != "") {
$resortOrder = true;

$updateColumns[] = "ordernum";
$updateValues[] = $intNewOrderSpot;

}

$downloadCatObj->select($downloadCatInfo['downloadcategory_id']);
if($downloadCatObj->update($updateColumns, $updateValues)) {

if ($downloadCatObj->update($updateColumns, $updateValues)) {
$result = $mysqli->query("DELETE FROM ".$mysqli->get_tablePrefix()."download_extensions WHERE downloadcategory_id = '".$downloadCatInfo['downloadcategory_id']."'");
foreach($arrExtensions as $strExtension) {

foreach ($arrExtensions as $strExtension) {
$downloadExtensionObj->addNew(array("downloadcategory_id", "extension"), array($downloadCatInfo['downloadcategory_id'], trim($strExtension)));
}

echo "
<div style='display: none' id='successBox'>
<p align='center'>
Expand All @@ -149,80 +133,74 @@
popupDialog('Edit Download Category', '".$MAIN_ROOT."members/console.php?cID=".$cID."', 'successBox');
</script>
";
if($resortOrder) {
$downloadCatObj->resortOrder();

if ($resortOrder) {
$downloadCatObj->resortOrder();
}

}

}
else {
} else {
$_POST = filterArray($_POST);
$_POST['submit'] = false;
}

}

if(!isset($_POST['submit'])) {

$countCategories = 0;
$catOrderOptions = ""; // Initialize $catOrderOptions here

$intHighestOrderNum = $downloadCatObj->getHighestOrderNum();
$afterSelected = "";

if($downloadCatInfo['ordernum'] == 1) {
$selectCat = $downloadCatInfo['ordernum'] + 1;
$afterSelected = "selected";
} else {
$selectCat = $downloadCatInfo['ordernum'] - 1;
}

$result = $mysqli->query("SELECT * FROM ".$dbprefix."downloadcategory WHERE downloadcategory_id != '".$downloadCatInfo['downloadcategory_id']."' ORDER BY ordernum DESC");
while($row = $result->fetch_assoc()) {

$strSelected = "";
if($selectCat == $row['ordernum']) {
$strSelected = "selected";
}

$catOrderOptions .= "<option value='".$row['downloadcategory_id']."' ".$strSelected.">".filterText($row['name'])."</option>";
$countCategories++;
}

if($countCategories == 0) {
$catOrderOptions = "<option value='first'>(no other categories)</option>";
}

if (!isset($_POST['submit'])) {
$countCategories = 0;
$catOrderOptions = ""; // Initialize $catOrderOptions here

$intHighestOrderNum = $downloadCatObj->getHighestOrderNum();
$afterSelected = "";

if ($downloadCatInfo['ordernum'] == 1) {
$selectCat = $downloadCatInfo['ordernum'] + 1;
$afterSelected = "selected";
} else {
$selectCat = $downloadCatInfo['ordernum'] - 1;
}

$result = $mysqli->query("SELECT * FROM ".$dbprefix."downloadcategory WHERE downloadcategory_id != '".$downloadCatInfo['downloadcategory_id']."' ORDER BY ordernum DESC");
while ($row = $result->fetch_assoc()) {
$strSelected = "";
if ($selectCat == $row['ordernum']) {
$strSelected = "selected";
}

$catOrderOptions .= "<option value='".$row['downloadcategory_id']."' ".$strSelected.">".filterText($row['name'])."</option>";
$countCategories++;
}

if ($countCategories == 0) {
$catOrderOptions = "<option value='first'>(no other categories)</option>";
}

$arrDownloadExts = $downloadCatObj->getExtensions();

$arrDispDLExts = array();
foreach($arrDownloadExts as $extID) {

foreach ($arrDownloadExts as $extID) {
$downloadExtensionObj->select($extID);
$arrDispDLExts[] = $downloadExtensionObj->get_info_filtered("extension");
}

$dispDownloadExts = implode(", ", $arrDispDLExts);


echo "
<form action='console.php?cID=".$cID."&catID=".$_GET['catID']."&action=edit' method='post' enctype='multipart/form-data'>
<div class='formDiv'>
";
if($dispError != "") {


if ($dispError != "") {
echo "
<div class='errorDiv'>
<strong>Unable to edit download category because the following errors occurred:</strong><br><br>
$dispError
</div>
";
}

$selectAccessType = ($downloadCatInfo['accesstype'] == 1) ? " selected" : "";
echo "
Use the form below to edit the selected download category.<br><br>
Expand Down Expand Up @@ -258,7 +236,4 @@
</form>
";

}

?>
4 changes: 1 addition & 3 deletions src/members/include/admin/managedownloadcat/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php

/*
* Bluethrust Clan Scripts v4
* Copyright 2014
Expand All @@ -15,5 +15,3 @@
// YOU SHOULD NOT BE VIEWING THIS!

header("HTTP/1.0 404 Not Found");

?>
Loading

0 comments on commit a90425e

Please sign in to comment.