Review submitted
Your review has been submitted.
Review deleted
Your review has been deleted.
5) {
$errorMessage = "Invalid rating.";
} else {
$statement = $connection->prepare("REPLACE INTO reviews (
`mod`,
user,
rating,
review
) VALUES (
?,
?,
?,
?
);");
if (!$statement) {
$errorMessage = "An unexpected error occurred while submitting the review.";
} else {
$statement->bind_param('iiis', $modData['id'], $_SESSION['user'], $rating, $_POST['review']);
if (!$statement->execute()) {
$errorMessage = "An unexpected error occurred while submitting the review.";
} else {
$reviewSubmitted = true;
}
}
}
}
} elseif ($_POST['action'] == "delete") {
$statement = $connection->prepare("DELETE FROM reviews WHERE `mod` = ? AND user = ?");
if (!$statement) {
$errorMessage = "An unexpected error occurred while deleting the review.";
} else {
$statement->bind_param('ii', $modData['id'], $_SESSION['user']);
if (!$statement->execute()) {
$errorMessage = "An unexpected error occurred while deleting the review.";
} else {
$reviewDeleted = true;
}
}
} else {
$errorMessage = "Unknown action specified.";
}
}
if ($reviewSubmitted) {
$pageTitle = "Review submitted";
$pageDescription = "Your review has been submitted.";
} elseif ($reviewDeleted) {
$pageTitle = "Review deleted";
$pageDescription = "Your review has been deleted.";
} else {
$pageTitle = 'Reviews for "' . $modData['name'] . '" mod';
$pageDescription = 'See reviews for the "' . $modData['name'] . '" mod on SVR.JS Mods directory.';
$pageImage = (isset($modData['image_ext']) && $modData['image_ext'] ? 'mods/' . urlencode(str_replace(['/', '\\'], '', $modData['slug'])) . '.' . urlencode(str_replace(['/', '\\'], '', $modData['image_ext'])) : 'mod-missing.png');
}
include 'header.php';
?>
Your review has been submitted. Your review has been deleted.Review submitted
Review deleted
Reviews for “” mod
' . htmlspecialchars($errorMessage) . '
Reviews:
You need to be logged in to submit a review on this mod.
As a mod publisher, you cannot submit a review on this mod.
prepare('SELECT rating, review FROM reviews WHERE `mod` = ? AND user = ?;'); if ($statement) { $statement->bind_param('ii', $modData['id'], $_SESSION['user']); $statement->execute(); $result = $statement->get_result(); if ($result) { $userReview = $result->fetch_assoc(); } $statement->close(); } ?>An unexpected error occurred while fetching reviews.
"; } else { $countStatement->bind_param('i', $modData['id']); $countStatement->execute(); $countResult = $countStatement->get_result(); if (!$countResult) { echo "An unexpected error occurred while fetching reviews.
"; $countStatement->close(); } else { $countRow = $countResult->fetch_assoc(); $countStatement->close(); if (!$countRow) { echo "An unexpected error occurred while fetching reviews.
"; } else { $modCount = $countRow['count']; $totalPages = ceil($modCount / PAGE_MODS); $statement = $connection->prepare('SELECT reviews.id AS id, reviews.rating AS rating, reviews.review AS review, mods.name AS mod_name, mods.slug AS mod_slug, users.username AS user, users.id AS user_id FROM reviews JOIN ( SELECT mods.id AS id, mods.is_removed AS is_removed, mods.name AS name, mods.slug AS slug FROM mods JOIN users ON users.id = mods.user AND users.is_verified = 1 AND users.is_deleted = 0 AND users.is_suspended = 0 ) AS mods ON mods.id = reviews.mod JOIN users ON users.id = reviews.user WHERE mods.id = ? AND mods.is_removed = 0 AND users.is_suspended = 0 AND users.is_deleted = 0 AND users.is_verified = 1 ORDER BY reviews.id DESC LIMIT ?,?;'); if (!$statement) { echo "An unexpected error occurred while fetching reviews.
"; } else { $pageNumber = isset($_GET['page']) && filter_var($_GET['page'], FILTER_VALIDATE_INT) ? intval($_GET['page']) : 1; $firstNumber = PAGE_REVIEWS * ($pageNumber - 1); $pageReviews = PAGE_REVIEWS; $statement->bind_param('iii', $modData['id'], $firstNumber, $pageReviews); $statement->execute(); $result = $statement->get_result(); if (!$result) { echo "An unexpected error occurred while fetching reviews.
"; $statement->close(); } else { $reviewsPresent = false; while ($review = $result->fetch_assoc()) { $reviewsPresent = true; echo '' . str_replace(["\r\n", "\n", "\r"], '
', htmlspecialchars($review['review'])) . '
No reviews.
'; } $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 '