diff --git a/composer.json b/composer.json index 6394dcb..a55b803 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,9 @@ "system/includes/functions.php", "system/admin/admin.php", "system/includes/session.php", - "system/includes/opml.php" + "system/includes/opml.php", + "system/includes/comments.php", + "system/includes/comments-frontend.php" ] } } diff --git a/lang/en_US.ini b/lang/en_US.ini index ff6076e..d2e0e55 100644 --- a/lang/en_US.ini +++ b/lang/en_US.ini @@ -336,3 +336,66 @@ custom_fields = "Custom fields" views_counter = "Views counter" themes = "Themes" version = "Version" +comments_management = "Comments Management" +all_comments = "All Comments" +pending_moderation = "Pending Moderation" +comment = "Comment" +post_page = "Post/Page" +date = "Date" +status = "Status" +actions = "Actions" +published = "Published" +pending = "Pending" +reply_to_comment = "Reply to comment" +notifications_enabled = "Notifications enabled" +modified = "Modified" +publish = "Publish" +edit = "Edit" +delete = "Delete" +confirm_publish_comment = "Are you sure you want to publish this comment?" +confirm_delete_comment = "Are you sure you want to delete this comment? This will also delete all replies to this comment." +no_comments_found = "No comments found" +edit_comment = "Edit Comment" +name = "Name" +email = "Email" +update_comment = "Update Comment" +cancel = "Cancel" +comments_settings = "Comments Settings" +general_settings = "General Settings" +note = "Note" +enable_comments_in_main_config = "To enable local comments, set comment.system = \"local\" in config/config.ini" +comment_moderation = "Comment Moderation" +require_admin_approval = "Comments must be approved by an administrator before being published" +comments_moderation_desc = "When enabled, new comments will be held for moderation and won't be visible until approved" +anti_spam_protection = "Anti-Spam Protection" +enable_honeypot = "Enable honeypot anti-spam protection" +honeypot_desc = "Honeypot is an invisible field that only bots fill out, helping prevent spam without user interaction" +email_notifications = "Email Notifications" +enable_notifications = "Enable Notifications" +send_email_notifications = "Send email notifications for new comments" +admin_email = "Administrator Email" +admin_email_desc = "Email address to receive notifications about new comments" +smtp_settings = "SMTP Settings" +enable_smtp = "Enable SMTP" +enable_smtp_for_emails = "Enable SMTP for sending email notifications" +smtp_host = "SMTP Host" +smtp_port = "SMTP Port" +encryption = "Encryption" +smtp_username = "SMTP Username" +smtp_password = "SMTP Password" +enter_password = "Enter password" +from_email = "From Email" +from_name = "From Name" +save_settings = "Save Settings" +leave_a_comment = "Leave a Comment" +email_not_published = "Your email will not be published" +comment_formatting_help = "You can use **bold text** for formatting. Line breaks are preserved." +notify_new_comments = "Notify me of new comments in this thread" +post_reply = "Post Reply" +post_comment = "Post Comment" +reply = "Reply" +comment_submitted_success = "Your comment has been posted successfully!" +comment_submitted_moderation = "Your comment has been submitted and is awaiting moderation." +comment_submission_error = "There was an error submitting your comment. Please try again." +pending_comments = "Pending Comments" +level = "Level" \ No newline at end of file diff --git a/system/admin/views/comments.html.php b/system/admin/views/comments.html.php new file mode 100644 index 0000000..9f5ed4a --- /dev/null +++ b/system/admin/views/comments.html.php @@ -0,0 +1,297 @@ + +
+| + | + | + | + | + | + |
|---|---|---|---|---|---|
|
+ + + IP: + |
+
+ 100) echo '...';
+ ?>
+
+ + + + + + |
+ + + + + | +
+
+
+ : + + |
+ + + + + + + | ++ + + + + + + + + + + + | +
.
+ + + + + + + + + + ++ + 0): ?> + + + +
+ + +From: {$comment['name']} ({$comment['email']})
+Comment:
+" . nl2br(htmlspecialchars($comment['comment'])) . "
+ + "; + } else { + $mail->Subject = 'New reply to your comment'; + $mail->Body = " +From: {$comment['name']}
+Comment:
+" . nl2br(htmlspecialchars($comment['comment'])) . "
+ + "; + } + + $mail->send(); + return true; + } catch (Exception $e) { + error_log("Comment notification email failed: {$mail->ErrorInfo}"); + return false; + } +} + +/** + * Get comment count for a post + * + * @param string $postId Post or page ID + * @param bool $includeUnpublished Include unpublished comments + * @return int Comment count + */ +function getCommentCount($postId, $includeUnpublished = false) +{ + $comments = getComments($postId, $includeUnpublished); + return count($comments); +} + +/** + * Get pending comments count (for admin) + * + * @return int Pending comments count + */ +function getPendingCommentsCount() +{ + $allComments = getAllComments(); + $pending = array_filter($allComments, function($comment) { + return !$comment['published']; + }); + return count($pending); +} + +/** + * Format comment text (allow basic formatting) + * + * @param string $text Comment text + * @return string Formatted text + */ +function formatCommentText($text) +{ + // Convert line breaks + $text = nl2br(htmlspecialchars($text, ENT_QUOTES, 'UTF-8')); + + // Allow simple bold with **text** or __text__ + $text = preg_replace('/\*\*(.+?)\*\*/', '$1', $text); + $text = preg_replace('/__(.+?)__/', '$1', $text); + + return $text; +} + +?> \ No newline at end of file diff --git a/system/includes/functions.php b/system/includes/functions.php index 2ed505f..599c456 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -3535,7 +3535,7 @@ function is_index() } } else { $req = strtok($_SERVER["REQUEST_URI"], '?'); - if (stripos($req, '/category/') !== false || stripos($req, '/archive/') !== false || stripos($req, '/tag/') !== false || stripos($req, '/search/') !== false || stripos($req, '/type/') !== false || stripos($req, '/' . blog_path()) !== false || $req == site_path() . '/') { + if (stripos($req, '/category/') !== false || stripos($req, '/archive/') !== false || stripos($req, '/tag/') !== false || stripos($req, '/search/') !== false || stripos($req, '/type/') !== false || stripos($req, '/' . blog_path()) !== false || $req == site_path() . '/' || $req == '/') { return true; } else { return false; diff --git a/system/vendor/composer/autoload_files.php b/system/vendor/composer/autoload_files.php index 46cd6f2..90aaf54 100644 --- a/system/vendor/composer/autoload_files.php +++ b/system/vendor/composer/autoload_files.php @@ -12,4 +12,6 @@ return array( '8432047aca7938f88a2098a2f7770228' => $baseDir . '/system/admin/admin.php', '1b9bf2d9d029f1364c3d7262b5375c41' => $baseDir . '/system/includes/session.php', '62f038defb1b29aab3998eb437e01df9' => $baseDir . '/system/includes/opml.php', + '7d7ae14f7bb933ac50b7f6e42f6a7d60' => $baseDir . '/system/includes/comments.php', + '2591226a04118e81824e40ae6712427b' => $baseDir . '/system/includes/comments-frontend.php', ); diff --git a/system/vendor/composer/autoload_static.php b/system/vendor/composer/autoload_static.php index 6baf180..1f56f55 100644 --- a/system/vendor/composer/autoload_static.php +++ b/system/vendor/composer/autoload_static.php @@ -13,6 +13,8 @@ class ComposerStaticInitd88c6c25320034df85dd42f1462fbda7 '8432047aca7938f88a2098a2f7770228' => __DIR__ . '/../../..' . '/system/admin/admin.php', '1b9bf2d9d029f1364c3d7262b5375c41' => __DIR__ . '/../../..' . '/system/includes/session.php', '62f038defb1b29aab3998eb437e01df9' => __DIR__ . '/../../..' . '/system/includes/opml.php', + '7d7ae14f7bb933ac50b7f6e42f6a7d60' => __DIR__ . '/../../..' . '/system/includes/comments.php', + '2591226a04118e81824e40ae6712427b' => __DIR__ . '/../../..' . '/system/includes/comments-frontend.php', ); public static $prefixLengthsPsr4 = array (