prepare("SELECT mods.id AS id, mods.is_removed AS is_removed, mods.name AS name, mods.slug AS slug, mods.description AS description, mods.image_ext AS image_ext, mods.is_paid AS is_paid, mods.category AS category, mods.link AS link, mods.docs_link AS docs_link, mods.is_paid AS is_paid, users.username AS username, users.email AS user_email, users.id AS user FROM mods JOIN users ON users.id = mods.user AND users.is_suspended = 0 AND users.is_deleted = 0 AND users.is_verified = 1 WHERE mods.id = ?"); if (!$statement) { $errorMessage = "An unexcepted error occurred when checking the mod."; } else { $statement->bind_param('i', $modID); $statement->execute(); $result = $statement->get_result(); if (!$result) { $errorMessage = "An unexcepted error occurred when checking the mod."; $statement->close(); } else { $modData = $result->fetch_assoc(); $statement->close(); if (!$modData) { $errorMessage = "The mod doesn't exist."; } else { if (!isset($_POST['action'])) { $errorMessage = "No action specified."; } elseif ($_POST['action'] == "remove") { if (!isset($_POST['reason']) || !$_POST['reason']) { $errorMessage = "You need to specify the reason for removal."; } elseif ($modData['is_removed']) { $errorMessage = "The mod is already removed."; } else { $statement = $connection->prepare('UPDATE mods SET is_removed = 1 WHERE id = ?'); if (!$statement) { $errorMessage = "An unexpected error occurred while removing the mod."; } else { $statement->bind_param('i', $modData['id']); if (!$statement->execute()) { $errorMessage = "An unexpected error occurred while removing the mod."; $statement->close(); } else { $modRemoved = true; $statement->close(); } } } } elseif ($_POST['action'] == "restore") { if (!$modData['is_removed']) { $errorMessage = "The mod is already restored."; } else { $statement = $connection->prepare('UPDATE mods SET is_removed = 0 WHERE id = ?'); if (!$statement) { $errorMessage = "An unexpected error occurred while restoring the mod."; } else { $statement->bind_param('i', $modData['id']); if (!$statement->execute()) { $errorMessage = "An unexpected error occurred while restoring the mod."; $statement->close(); } else { $modRestored = true; $statement->close(); } } } } else { $errorMessage = "Unknown action specified."; } } } } } } $pageTitle = "Mods"; include '../includes/moderation_header.php'; ?>

Mods

' . htmlspecialchars($errorMessage) . '

'; ?> Mod has been removed.

'; } elseif ($modRestored) { echo '

Mod has been restored.

'; } ?> query('SELECT mods.id AS id, mods.name AS name, mods.slug AS slug, mods.description AS description, mods.image_ext AS image_ext, mods.is_paid AS is_paid, mods.link AS link, mods.docs_link AS docs_link, mods.is_removed AS is_removed, categories.name AS category, users.username AS user, users.id AS user_id FROM mods LEFT JOIN categories ON categories.id = mods.category JOIN users ON users.id = mods.user AND users.is_suspended = 0 AND users.is_deleted = 0 AND users.is_verified = 1 ORDER BY mods.id DESC;'); if (!$result) { echo "

An unexpected error occurred while fetching mods.

"; } else { $modsPresent = false; while ($mod = $result->fetch_assoc()) { $modsPresent = true; echo '
' . htmlspecialchars($mod['name']) . ' cover image

' . htmlspecialchars($mod['name']) . '

' . ($mod['is_paid'] ? 'Paid' : 'Gratis') . '' . ($mod['is_removed'] ? 'Removed' : '') . '

' . (isset($mod['description']) && $mod['description'] ? str_replace(["\r\n", "\n", "\r"], '
', htmlspecialchars(shortenDescription($mod['description']))) : "No description") . '

Publisher: ' . htmlspecialchars($mod['user']) . ' | Category: ' . htmlspecialchars($mod['category']) . '

Download URL: ' . htmlspecialchars($mod['link']) . '

' . ($mod['docs_link'] ? '

Documentation URL: ' . htmlspecialchars($mod['docs_link']) . '

' : '') . ' ' . ($mod['is_removed'] ? '
' : '
') . '
'; } if (!$modsPresent) { echo '

No mods.

'; } } ?> $modData['username'], "address" => $modData['user_email'] ]], 'Your mod has been removed.', 'Unfortunately, your "' . str_replace(["\r\n", "\n", "\r"], '', $modData['name']) . "\" mod has been removed by the moderator. Below is the reason why the moderator removed this mod:\n\n" . $_POST['reason'] ); } elseif ($modRestored) { sendEmail( [[ "name" => $modData['username'], "address" => $modData['user_email'] ]], 'Your mod has been restored.', 'Your "' . str_replace(["\r\n", "\n", "\r"], '', $modData['name']) . '" mod has been restored by the moderator and is now listed again on SVR.JS Mods directory.' ); } include '../includes/moderation_final.php'; include '../includes/final.php'; ?>