Pending mods

prepare('SELECT COUNT(mods_pending.id) AS count FROM mods_pending JOIN users ON users.id = mods_pending.user WHERE users.id = ? AND users.is_suspended = 0 AND users.is_deleted = 0 AND users.is_verified = 1;'); if (!$countStatement) { echo "

An unexpected error occurred while fetching mods.

"; } else { $countStatement->bind_param('i', $_SESSION['user']); $countStatement->execute(); $countResult = $countStatement->get_result(); if (!$countResult) { echo "

An unexpected error occurred while fetching mods.

"; $countStatement->close(); } else { $countRow = $countResult->fetch_assoc(); $countStatement->close(); if (!$countRow) { echo "

An unexpected error occurred while fetching mods.

"; } else { $modCount = $countRow['count']; $totalPages = ceil($modCount / PAGE_MODS); $statement = $connection->prepare('SELECT mods_pending.id AS id, mods_pending.name AS name, mods_pending.slug AS slug, mods_pending.description AS description, mods_pending.image_ext AS image_ext, mods_pending.is_paid AS is_paid, mods_pending.is_rejected AS is_rejected, users.username AS user, users.id AS user_id FROM mods_pending JOIN users ON users.id = mods_pending.user WHERE users.id = ? AND users.is_suspended = 0 AND users.is_deleted = 0 AND users.is_verified = 1 ORDER BY mods_pending.id DESC LIMIT ?,?;'); if (!$statement) { echo "

An unexpected error occurred while fetching mods.

"; } else { $pageNumber = isset($_GET['page']) && filter_var($_GET['page'], FILTER_VALIDATE_INT) ? intval($_GET['page']) : 1; $firstNumber = PAGE_MODS * ($pageNumber - 1); $pageMods = PAGE_MODS; $statement->bind_param('iii', $_SESSION['user'], $firstNumber, $pageMods); $statement->execute(); $result = $statement->get_result(); if (!$result) { echo "

An unexpected error occurred while fetching mods.

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

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

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

' . (isset($_SESSION['user']) && $_SESSION['user'] == $mod['user_id'] ? 'Edit mod | Discard mod' : '') . '

' . ($mod['is_rejected'] ? 'Rejected' : 'Pending') . ' ' . ($mod['is_paid'] ? 'Paid' : 'Gratis') . '
'; } if ($modsPresent) { echo '
'; } else { echo '

No mods.

'; } $statement->close(); if ($totalPages > 1) { $begPage = $pageNumber - 2; $endPage = $pageNumber + 2; if ($endPage > $totalPages) { $begPage -= $endPage - $totalPages; $endPage = $totalPages; } if ($begPage < 1) { $endPage += 1 - $begPage; $begPage = 1; } echo ''; } } } } } } ?>