reworked comments code to match htmly coding style, themes integration, system messages

This commit is contained in:
Emidio Reggiani 2026-03-23 16:23:56 +01:00
commit a9638294a5
33 changed files with 1478 additions and 173 deletions

View file

@ -68,7 +68,10 @@ DirectoryIndex index.php
<IfModule mod_rewrite.c>
RewriteEngine on
# rule needed for sysmessages
RewriteRule ^(.*/)?system/resources/js/sysmessages-set\.js$ $1system/resources/php/sysmessages.php [L]
# Uncomment the following to redirect all visitors to the https version
# RewriteCond %{HTTPS} off
# RewriteRUle (.*) https://www.example.com/$1 [R=301,L]

View file

@ -42,6 +42,7 @@ e.g. `www.yoursite.com/login`
- Homepage: [HTMLy Homepage](https://www.htmly.com/)
- Documentation: [HTMLy Docs](https://docs.htmly.com/)
- Comment system: [HTMLy Comment System Docs](https://github.com/danpros/htmly/blob/master/system/includes/comments_readme.md)
- Themes: [HTMLy Themes](https://www.htmly.com/theme/)
- Demo: [HTMLy Demo](http://demo.htmly.com/)
- Repository: [Github](https://github.com/danpros/htmly/)

View file

@ -407,3 +407,33 @@ backtotop = "Back to top"
subpages = "Sub pages"
getstarted = "Get started"
onthispage = "On this page"
enable_jstime="Enable Javascript and timestamp anti-spam protection"
jstime_desc="Usually bots dont't use Javascript. Form also checks if submitted between 3 and 600 seconds (preventing bots fast submission)"
comment_email_admin_awaiting="New comment awaiting moderation"
comment_email_admin_new="New comment"
comment_email_subscription_subject = "Subscription confirmation to"
comment_email_new = "New comment on"
comment_email_from = "From"
comment_email_moderate = "Moderate comments"
comment_email_new_subscribed = "New reply on a subscribed thread"
comment_email_new_replied = "Someone replied to your comment on"
comment_email_view_comment = "View comment"
comment_subscribe_confirmation = "Subscription confirmation to"
comment_subscribe_thread = "Thread subscription at"
comment_subscribe_request = "We received a subscription request to a thread at"
comment_subscribe_never_requested = "If you never visited the site or requested to be notified on thread messages, please ignore this email."
comment_subscribe_click = "Click"
comment_subscribe_here = "HERE"
comment_subscribe_confirm_message = "to confirm your subscription and start receiving notification emails on replies on the thread."
comment_subscribe_unsubscribe_message = "You can unsubscribe all notifications from"
comment_subscribe_unsubscribe_anytime = "at any time using this link"
comment_unsubscribe = "unsubscribe"
sysmsg_subscribe_success = "Your will receive now new comment notifications on the subscribed threads."
sysmsg_subscribe_fail = "Something went wrong during subscription verification process."
sysmsg_unsubscribe_success = "You have successfully unsubscribed from notification emails."
sysmsg_unsubscribe_fail = "Something wrong during unsubscription process"
posts_not_found = "Posts not found!"
page_not_found = "Page not found!"

View file

@ -127,17 +127,9 @@
<?php elseif ($tab === 'settings'): ?>
<!-- Settings Form -->
<form method="POST" action="<?php echo site_url(); ?>admin/comments/settings">
<form method="POST">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<!-- // removed by Emidio 20251105
<div class="alert alert-info">
<strong><?php echo i18n('Note'); ?>:</strong> <?php echo i18n('Enable_comments_in_main_config'); ?>
<br>
<code>config/config.ini</code> <code>comment.system = "local"</code>
</div>
-->
<h4><?php echo i18n('General_Settings');?></h4>
<hr>
@ -145,8 +137,8 @@
<label class="col-sm-3 col-form-label"><?php echo i18n('Comment_Moderation');?></label>
<div class="col-sm-9">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="comments.moderation" value="true"
<?php echo comments_config('comments.moderation') === 'true' ? 'checked' : ''; ?>>
<input type="checkbox" class="form-check-input" name="-config-comments.moderation" value="true"
<?php echo config('comments.moderation') === 'true' ? 'checked' : ''; ?>>
<label class="form-check-label"><?php echo i18n('Require_admin_approval');?></label>
</div>
<small class="form-text text-muted"><?php echo i18n('Comments_moderation_desc');?></small>
@ -157,15 +149,15 @@
<label class="col-sm-3 col-form-label"><?php echo i18n('Anti_Spam_Protection');?></label>
<div class="col-sm-9">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="comments.honeypot" value="true"
<?php echo comments_config('comments.honeypot') === 'true' ? 'checked' : ''; ?>>
<input type="checkbox" class="form-check-input" name="-config-comments.honeypot" value="true"
<?php echo config('comments.honeypot') === 'true' ? 'checked' : ''; ?>>
<label class="form-check-label"><?php echo i18n('Enable_honeypot');?></label>
</div>
<small class="form-text text-muted"><?php echo i18n('Honeypot_desc');?></small>
<div class="form-check">
<input type="checkbox" class="form-check-input" name="comments.jstime" value="true"
<?php echo comments_config('comments.jstime') === 'true' ? 'checked' : ''; ?>>
<input type="checkbox" class="form-check-input" name="-config-comments.jstime" value="true"
<?php echo config('comments.jstime') === 'true' ? 'checked' : ''; ?>>
<label class="form-check-label"><?php echo i18n('Enable_jstime');?></label>
</div>
<small class="form-text text-muted"><?php echo i18n('Jstime_desc');?></small>
@ -179,8 +171,8 @@
<label class="col-sm-3 col-form-label"><?php echo i18n('Enable_Notifications');?></label>
<div class="col-sm-9">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="comments.notify" value="true"
<?php echo comments_config('comments.notify') === 'true' ? 'checked' : ''; ?>>
<input type="checkbox" class="form-check-input" name="-config-comments.notify" value="true"
<?php echo config('comments.notify') === 'true' ? 'checked' : ''; ?>>
<label class="form-check-label"><?php echo i18n('Send_email_notifications');?></label>
</div>
</div>
@ -189,8 +181,8 @@
<div class="form-group row">
<label for="admin-email" class="col-sm-3 col-form-label"><?php echo i18n('Admin_Email');?></label>
<div class="col-sm-9">
<input type="email" class="form-control" id="admin-email" name="comments.admin.email"
value="<?php echo _h(comments_config('comments.admin.email')); ?>"
<input type="email" class="form-control" id="admin-email" name="-config-comments.admin.email"
value="<?php echo _h(config('comments.admin.email')); ?>"
placeholder="admin@example.com">
<small class="form-text text-muted"><?php echo i18n('Admin_email_desc');?></small>
</div>
@ -203,8 +195,8 @@
<label class="col-sm-3 col-form-label"><?php echo i18n('Enable_SMTP');?></label>
<div class="col-sm-9">
<div class="form-check">
<input type="checkbox" class="form-check-input" name="comments.mail.enabled" value="true"
<?php echo comments_config('comments.mail.enabled') === 'true' ? 'checked' : ''; ?>>
<input type="checkbox" class="form-check-input" name="-config-comments.mail.enabled" value="true"
<?php echo config('comments.mail.enabled') === 'true' ? 'checked' : ''; ?>>
<label class="form-check-label"><?php echo i18n('Enable_SMTP_for_emails');?></label>
</div>
</div>
@ -213,8 +205,8 @@
<div class="form-group row">
<label for="mail-host" class="col-sm-3 col-form-label"><?php echo i18n('SMTP_Host');?></label>
<div class="col-sm-9">
<input type="text" class="form-control" id="mail-host" name="comments.mail.host"
value="<?php echo _h(comments_config('comments.mail.host')); ?>"
<input type="text" class="form-control" id="mail-host" name="-config-comments.mail.host"
value="<?php echo _h(config('comments.mail.host')); ?>"
placeholder="smtp.gmail.com">
</div>
</div>
@ -222,8 +214,8 @@
<div class="form-group row">
<label for="mail-port" class="col-sm-3 col-form-label"><?php echo i18n('SMTP_Port');?></label>
<div class="col-sm-9">
<input type="number" class="form-control" id="mail-port" name="comments.mail.port"
value="<?php echo _h(comments_config('comments.mail.port')); ?>"
<input type="number" class="form-control" id="mail-port" name="-config-comments.mail.port"
value="<?php echo _h(config('comments.mail.port')); ?>"
placeholder="587">
<small class="form-text text-muted">587 (TLS) or 465 (SSL)</small>
</div>
@ -232,9 +224,9 @@
<div class="form-group row">
<label for="mail-encryption" class="col-sm-3 col-form-label"><?php echo i18n('Encryption');?></label>
<div class="col-sm-9">
<select class="form-control" id="mail-encryption" name="comments.mail.encryption">
<option value="tls" <?php echo comments_config('comments.mail.encryption') === 'tls' ? 'selected' : ''; ?>>TLS</option>
<option value="ssl" <?php echo comments_config('comments.mail.encryption') === 'ssl' ? 'selected' : ''; ?>>SSL</option>
<select class="form-control" id="mail-encryption" name="-config-comments.mail.encryption">
<option value="tls" <?php echo config('comments.mail.encryption') === 'tls' ? 'selected' : ''; ?>>TLS</option>
<option value="ssl" <?php echo config('comments.mail.encryption') === 'ssl' ? 'selected' : ''; ?>>SSL</option>
</select>
</div>
</div>
@ -242,8 +234,8 @@
<div class="form-group row">
<label for="mail-username" class="col-sm-3 col-form-label"><?php echo i18n('SMTP_Username');?></label>
<div class="col-sm-9">
<input type="text" class="form-control" id="mail-username" name="comments.mail.username"
value="<?php echo _h(comments_config('comments.mail.username')); ?>"
<input type="text" class="form-control" id="mail-username" name="-config-comments.mail.username"
value="<?php echo _h(config('comments.mail.username')); ?>"
placeholder="your-email@gmail.com">
</div>
</div>
@ -251,8 +243,8 @@
<div class="form-group row">
<label for="mail-password" class="col-sm-3 col-form-label"><?php echo i18n('SMTP_Password');?></label>
<div class="col-sm-9">
<input type="password" class="form-control" id="mail-password" name="comments.mail.password"
value="<?php echo _h(comments_config('comments.mail.password')); ?>"
<input type="password" class="form-control" id="mail-password" name="-config-comments.mail.password"
value="<?php echo _h(config('comments.mail.password')); ?>"
placeholder="<?php echo i18n('Enter_password');?>">
</div>
</div>
@ -260,8 +252,8 @@
<div class="form-group row">
<label for="mail-from-email" class="col-sm-3 col-form-label"><?php echo i18n('From_Email');?></label>
<div class="col-sm-9">
<input type="email" class="form-control" id="mail-from-email" name="comments.mail.from.email"
value="<?php echo _h(comments_config('comments.mail.from.email')); ?>"
<input type="email" class="form-control" id="mail-from-email" name="-config-comments.mail.from.email"
value="<?php echo _h(config('comments.mail.from.email')); ?>"
placeholder="noreply@example.com">
</div>
</div>
@ -269,8 +261,8 @@
<div class="form-group row">
<label for="mail-from-name" class="col-sm-3 col-form-label"><?php echo i18n('From_Name');?></label>
<div class="col-sm-9">
<input type="text" class="form-control" id="mail-from-name" name="comments.mail.from.name"
value="<?php echo _h(comments_config('comments.mail.from.name')); ?>"
<input type="text" class="form-control" id="mail-from-name" name="-config-comments.mail.from.name"
value="<?php echo _h(config('comments.mail.from.name')); ?>"
placeholder="<?php echo config('blog.title'); ?>">
</div>
</div>
@ -291,7 +283,6 @@
<form method="POST" action="<?php echo site_url(); ?>admin/comments/update/<?php echo $editComment['file_encoded']; ?>/<?php echo $editComment['id']; ?>">
<input type="hidden" name="csrf_token" value="<?php echo get_csrf(); ?>">
<input type="hidden" name="url" value="<?php echo $editComment['url']; ?>">
<input type="hidden" name="file" value="<?php echo $editComment['file_encoded']; ?>">
<div class="form-group">

View file

@ -150,7 +150,7 @@ if (isset($author[0])) {
</ul>
</li>
<?php if ($role === 'editor' || $role === 'admin'):?>
<?php if (local()): ?>
<?php if (comments()): ?>
<li class="nav-item has-treeview menu-open">
<a href="#" class="nav-link">
<i class="nav-icon fa fa-comments"></i>

View file

@ -23,6 +23,20 @@
"social.tiktok",
"breadcrumb.home",
"comment.system",
"comments.moderation",
"comments.honeypot",
"comments.jstime",
"comments.notify",
"comments.admin.email",
"comments.mail.enabled",
"comments.mail.host",
"comments.mail.port",
"comments.mail.encryption",
"comments.mail.encryption",
"comments.mail.username",
"comments.mail.password",
"comments.mail.from.email",
"comments.mail.from.name",
"fb.appid",
"fb.num",
"fb.color",

View file

@ -25,6 +25,11 @@ publish_scheduled();
// Load theme settings
theme_settings();
// Handle comments subscribe/unsubscribe
handle_comments_subscription();
// The front page of the blog
get('/index', function () {
@ -3243,23 +3248,8 @@ post('/admin/comments/settings', function () {
$config['comments.mail.password'] = $password;
}
// Debug: log to file (remove after debugging)
file_put_contents('content/comments-debug.log',
date('Y-m-d H:i:s') . "\n" .
"POST data: " . print_r($_POST, true) . "\n" .
"Config array: " . print_r($config, true) . "\n\n",
FILE_APPEND
);
$result = save_comments_config($config);
// Log result
file_put_contents('content/comments-debug.log',
"Save result: " . ($result ? "SUCCESS ($result bytes)" : "FAILED") . "\n" .
"File content after save:\n" . file_get_contents('config/comments.ini') . "\n\n",
FILE_APPEND
);
$redir = site_url() . 'admin/comments/settings';
header("location: $redir");
} else {
@ -6072,7 +6062,7 @@ post('/:year/:month/:name/delete', function () {
// Submit comment from public form
post('/comments/submit', function () {
if (!local()) {
if (!comments()) {
$redir = site_url();
header("location: $redir");
return;

View file

@ -1,6 +1,4 @@
<?php
if (!defined('HTMLY')) die('HTMLy');
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
@ -9,93 +7,68 @@ use PHPMailer\PHPMailer\Exception;
*
* @return bool
*/
function local()
function comments($a = null)
{
return config('comment.system') === 'local';
if ($a === null) {
return config('comment.system') === 'local';
}
else {
displayCommentsSection($a);
}
}
/**
* Get comments configuration value
*
* @param string $key Configuration key (use 'reload' to force cache reload)
* @return mixed Configuration value or null
*/
function comments_config($key)
{
static $_config = array();
$config_file = 'config/comments.ini';
// Allow cache reload
if ($key === 'reload') {
$_config = array();
return null;
function last_comments($num = 5) {
if (!filter_var($num, FILTER_VALIDATE_INT) !== false || (int)$num <= 0) {
$num = 5;
}
if (empty($_config) && file_exists($config_file)) {
$_config = parse_ini_file($config_file, false);
$comments = getPublishedComments($num);
$recent_comments = '<ul>';
foreach ($comments as $comment) {
$recent_comments .= "<li><a href=\"" . site_url() . $comment['url'] . "#comment-" . $comment['id'] . "\">" . $comment['name'] . "</a>";
$recent_comments .= "<span><br>" . date(config('date.format'), $comment['timestamp']) . "</span>";
$recent_comments .= "<br>" . $comment['comment'] . "</li>";
}
return isset($_config[$key]) ? $_config[$key] : null;
$recent_comments .= '</ul>';
return $recent_comments;
}
/**
* Save comments configuration
*
* @param array $data Configuration data to save
* @return bool Success status
*/
function save_comments_config($data = array())
{
$config_file = 'config/comments.ini';
if (!file_exists($config_file)) {
return false;
}
$string = file_get_contents($config_file);
foreach ($data as $word => $value) {
// Ensure null and empty values are saved as empty strings
if ($value === null || $value === '') {
$value = '""';
} else {
// Encode value
$value = json_encode($value, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
function handle_comments_subscription() {
$subscription = null;
if (isset($_GET['unsubscribe'])) {
$subscription = getSubscription($_GET['unsubscribe']);
if ($subscription['status'] == 'no') {
$response['message'] = i18n('sysmsg_unsubscribe_success');
$response['class'] = 'success';
}
$map = array('\r\n' => ' \n ', '\r' => ' \n ');
$value = trim(strtr($value, $map));
// Escape dots in the key for regex
$escapedWord = str_replace('.', '\.', $word);
// Try to replace existing line
$pattern = "/^" . $escapedWord . " = .*/m";
if (preg_match($pattern, $string)) {
$string = preg_replace($pattern, $word . ' = ' . $value, $string);
} else {
// If line doesn't exist, add it at the end
$string = rtrim($string) . "\n" . $word . ' = ' . $value . "\n";
else {
$response['message'] = i18n('sysmsg_unsubscribe_fail');
$response['class'] = 'error';
}
$_SESSION['sysmessages'][] = $response;
// stash('subscription', $subscription);
} elseif (isset($_GET['subscribe'])) {
$subscription = setSubscription($_GET['subscribe'], 'confirm');
if ($subscription['status'] == 'subscribed') {
$response['message'] = i18n('sysmsg_subscribe_success');
$response['class'] = 'success';
}
else {
$response['message'] = i18n('sysmsg_subscribe_fail');
$response['class'] = 'error';
}
$_SESSION['sysmessages'][] = $response;
}
$string = rtrim($string) . "\n";
$result = file_put_contents($config_file, $string, LOCK_EX);
// Clear PHP opcache for this file
if (function_exists('opcache_invalidate')) {
opcache_invalidate($config_file, true);
}
// Clear cache after saving
if ($result !== false) {
comments_config('reload');
}
return $result;
}
/**
* Get comments file path for a post/page
* Replicates content file path inside comments folder
@ -403,14 +376,14 @@ function validateComment($data)
}
// Validate honeypot (if enabled)
if (comments_config('comments.honeypot') === 'true') {
if (config('comments.honeypot') === 'true') {
if (!empty($data['website'])) {
$errors[] = 'comment_submission_error_spam';
}
}
// Validate js and time (if enabled) - minimum 2 seconds, maximum 600 seconds
if (comments_config('comments.jstime') === 'true') {
if (config('comments.jstime') === 'true') {
if (!$data['company'] || secondsGenerationSubmit($data['company']) < 3 || secondsGenerationSubmit($data['company']) > 3600) {
$errors[] = 'comment_submission_error_spam';
}
@ -464,7 +437,7 @@ function commentInsert($data, $url, $mdfile = null)
'date' => date('Y-m-d H:i:s', $timestamp),
'parent_id' => isset($data['parent_id']) && !empty($data['parent_id']) ? $data['parent_id'] : null,
'notify' => isset($data['notify']) && $data['notify'] === '1',
'published' => comments_config('comments.moderation') !== 'true', // Auto-publish if moderation disabled
'published' => config('comments.moderation') !== 'true', // Auto-publish if moderation disabled
'ip' => $_SERVER['REMOTE_ADDR'] ?? 'unknown'
);
@ -506,21 +479,29 @@ function commentInsert($data, $url, $mdfile = null)
);
}
// action can be subscribe, confirm, unsubscribe
function setSubscription($email, $action) {
$subscriptions_dir = 'content/comments/.subscriptions';
if (!is_dir($subscriptions_dir)) {
mkdir($subscriptions_dir);
}
$subscription_file = $subscriptions_dir . '/' . encryptEmailForFilename($email, comments_config('comments.salt'));
// Ensure config is loaded - if not loads it
$config_loaded = config('permalink.type');
if (!$config_loaded) {
if (file_exists('config/config.ini')) {
config('source', 'config/config.ini');
}
}
$subscription_file = $subscriptions_dir . '/' . encryptEmailForFilename($email, config('comments.salt'));
$subscription = getSubscription($email);
if ($action == 'subscribe') {
if ($subscription['status'] == 'subscribed') {
return true;
return $subscription;
}
elseif ($subscription['status'] == 'waiting') {
sendSubscriptionEmail($email);
@ -530,7 +511,7 @@ function setSubscription($email, $action) {
$json = json_encode($subscription, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
file_put_contents($subscription_file, $json);
sendSubscriptionEmail($email);
return true;
return $subscription;
}
}
@ -538,15 +519,16 @@ function setSubscription($email, $action) {
$subscription['status'] = 'subscribed';
$json = json_encode($subscription, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
file_put_contents($subscription_file, $json);
return true;
return $subscription;
}
elseif ($action == 'unsubscribe') {
@unlink($subscription_file);
return true;
$subscription['status'] = 'no';
return $subscription;
}
else {
// nothing here
return false;
return $subscription;
}
}
@ -554,7 +536,7 @@ function setSubscription($email, $action) {
// returns array
function getSubscription($email) {
$subscriptions_dir = 'content/comments/.subscriptions';
$subscription_file = $subscriptions_dir . '/' . encryptEmailForFilename($email, comments_config('comments.salt'));
$subscription_file = $subscriptions_dir . '/' . encryptEmailForFilename($email, config('comments.salt'));
if (!file_exists($subscription_file)) {
$subscription['status'] = 'no';
$subscription['date'] = date('Y-m-d H:i:s');
@ -643,13 +625,13 @@ function sendSubscriptionEmail($email) {
// Server settings
$mail->isSMTP();
$mail->Host = comments_config('comments.mail.host');
$mail->Host = config('comments.mail.host');
$mail->SMTPAuth = true;
$mail->Username = comments_config('comments.mail.username');
$mail->Password = comments_config('comments.mail.password');
$mail->Port = comments_config('comments.mail.port');
$mail->Username = config('comments.mail.username');
$mail->Password = config('comments.mail.password');
$mail->Port = config('comments.mail.port');
$encryption = comments_config('comments.mail.encryption');
$encryption = config('comments.mail.encryption');
if ($encryption === 'tls') {
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
} elseif ($encryption === 'ssl') {
@ -658,8 +640,8 @@ function sendSubscriptionEmail($email) {
// Recipients
$mail->setFrom(
comments_config('comments.mail.from.email'),
comments_config('comments.mail.from.name')
config('comments.mail.from.email'),
config('comments.mail.from.name')
);
$mail->addAddress($email);
@ -672,9 +654,9 @@ function sendSubscriptionEmail($email) {
<h3>" . i18n('comment_subscribe_thread') . ": ".config('site.url')."</h3>
<p>" . i18n('comment_subscribe_request') . " ".config('blog.title')."</p>
<p>" . i18n('comment_subscribe_never_requested') . "</p>
<p>" . i18n('comment_subscribe_click') . " <a href=\"".config('site.url')."?subscribe=".encryptEmailForFilename($email, comments_config('comments.salt'))."\"><b>" . i18n('comment_subscribe_here') . "</b></a> " . i18n('comment_subscribe_confirm_message') . "</p>
<p>" . i18n('comment_subscribe_click') . " <a href=\"".config('site.url')."?subscribe=".encryptEmailForFilename($email, config('comments.salt'))."\"><b>" . i18n('comment_subscribe_here') . "</b></a> " . i18n('comment_subscribe_confirm_message') . "</p>
<p>&nbsp;</p>
<p>" . i18n('comment_subscribe_unsubscribe_message') . " ".config('blog.title')." " . i18n('comment_subscribe_unsubscribe_anytime') . ": <a href=\"".config('site.url')."?unsubscribe=".encryptEmailForFilename($email, comments_config('comments.salt'))."\"><b>" . i18n('comment_unsubscribe') . "</b></a>.</p>
<p>" . i18n('comment_subscribe_unsubscribe_message') . " ".config('blog.title')." " . i18n('comment_subscribe_unsubscribe_anytime') . ": <a href=\"".config('site.url')."?unsubscribe=".encryptEmailForFilename($email, config('comments.salt'))."\"><b>" . i18n('comment_unsubscribe') . "</b></a>.</p>
<p>&nbsp;</p>
";
@ -840,7 +822,7 @@ function commentModify($file, $commentId, $data)
function sendCommentNotifications($url, $newComment, $allComments, $notifyAdmin = true, $notifySubscribers = true)
{
// Check if mail is enabled
if (comments_config('comments.mail.enabled') !== 'true') {
if (config('comments.mail.enabled') !== 'true') {
return;
}
@ -848,11 +830,11 @@ function sendCommentNotifications($url, $newComment, $allComments, $notifyAdmin
// Add admin email - notify if comments.notifyadmin = "true" OR comments.moderation = "true"
if ($notifyAdmin) {
$shouldNotifyAdmin = (comments_config('comments.notifyadmin') === 'true') ||
(comments_config('comments.moderation') === 'true');
$shouldNotifyAdmin = (config('comments.notifyadmin') === 'true') ||
(config('comments.moderation') === 'true');
if ($shouldNotifyAdmin) {
$adminEmail = comments_config('comments.admin.email');
$adminEmail = config('comments.admin.email');
if (!empty($adminEmail) && filter_var($adminEmail, FILTER_VALIDATE_EMAIL)) {
$recipients[$adminEmail] = array(
'name' => 'Administrator',
@ -863,7 +845,7 @@ function sendCommentNotifications($url, $newComment, $allComments, $notifyAdmin
}
// Add subscribers only if notifySubscribers is true AND comments.notify is enabled
if ($notifySubscribers && comments_config('comments.notify') === 'true') {
if ($notifySubscribers && config('comments.notify') === 'true') {
// Add parent comment author (if replying)
if (!empty($newComment['parent_id'])) {
foreach ($allComments as $comment) {
@ -920,13 +902,13 @@ function sendCommentEmail($to, $toName, $url, $comment, $type = 'admin')
// Server settings
$mail->isSMTP();
$mail->Host = comments_config('comments.mail.host');
$mail->Host = config('comments.mail.host');
$mail->SMTPAuth = true;
$mail->Username = comments_config('comments.mail.username');
$mail->Password = comments_config('comments.mail.password');
$mail->Port = comments_config('comments.mail.port');
$mail->Username = config('comments.mail.username');
$mail->Password = config('comments.mail.password');
$mail->Port = config('comments.mail.port');
$encryption = comments_config('comments.mail.encryption');
$encryption = config('comments.mail.encryption');
if ($encryption === 'tls') {
$mail->SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS;
} elseif ($encryption === 'ssl') {
@ -935,8 +917,8 @@ function sendCommentEmail($to, $toName, $url, $comment, $type = 'admin')
// Recipients
$mail->setFrom(
comments_config('comments.mail.from.email'),
comments_config('comments.mail.from.name')
config('comments.mail.from.email'),
config('comments.mail.from.name')
);
$mail->addAddress($to, $toName);
@ -945,7 +927,7 @@ function sendCommentEmail($to, $toName, $url, $comment, $type = 'admin')
$mail->CharSet = 'UTF-8';
if ($type === 'admin') {
if (comments_config('comments.moderation') === 'true') {
if (config('comments.moderation') === 'true') {
$mail->Subject = i18n('comment_email_admin_awaiting') . " - " . config('blog.title');
}
else {
@ -967,7 +949,7 @@ function sendCommentEmail($to, $toName, $url, $comment, $type = 'admin')
<p>" . nl2br(htmlspecialchars($comment['comment'])) . "</p>
<p><a href='" . site_url() . "{$url}#comment-{$comment['id']}'>" . i18n('comment_email_view_comment') . "</a></p>
<p>&nbsp;</p>
<p>" . i18n('comment_subscribe_unsubscribe_message') . " ".config('blog.title')." " . i18n('comment_subscribe_unsubscribe_anytime') . ": <a href=\"".config('site.url')."?unsubscribe=".encryptEmailForFilename($to, comments_config('comments.salt'))."\"><b>" . i18n('comment_unsubscribe') . "</b></a>.</p>
<p>" . i18n('comment_subscribe_unsubscribe_message') . " ".config('blog.title')." " . i18n('comment_subscribe_unsubscribe_anytime') . ": <a href=\"".config('site.url')."?unsubscribe=".encryptEmailForFilename($to, config('comments.salt'))."\"><b>" . i18n('comment_unsubscribe') . "</b></a>.</p>
<p>&nbsp;</p>
";
}
@ -1028,6 +1010,364 @@ function formatCommentText($text)
/**
* Display comments form
*
* @param string $postId Post or page ID
* @param string $parentId Parent comment ID for replies (optional)
* @return void
*/
function displayCommentsForm($url, $mdfile = null, $parentId = null)
{
if (!comments()) {
return;
}
$formId = $parentId ? 'reply-form-' . $parentId : 'comment-form';
$submitUrl = site_url() . 'comments/submit';
?>
<form id="<?php echo $formId; ?>" method="POST" action="<?php echo $submitUrl; ?>" class="comment-form">
<input type="hidden" name="url" value="<?php echo _h($url); ?>">
<?php if ($parentId): ?>
<input type="hidden" name="parent_id" value="<?php echo _h($parentId); ?>">
<?php endif; ?>
<!-- Honeypot field (hidden from users) -->
<div style="position:absolute;left:-5000px;" aria-hidden="true">
<input type="text" name="website" tabindex="-1" value="" autocomplete="off">
</div>
<!-- JS check & time check field (hidden from users) -->
<div style="position:absolute;left:-6000px;" aria-hidden="true">
<input type="text" name="company" tabindex="-2" value="" autocomplete="off">
</div>
<div class="form-group" style="width: 100%">
<label for="name-<?php echo $formId; ?>"><?php echo i18n('Name'); ?> <span class="required">*</span></label>
<input type="text" class="form-control" id="name-<?php echo $formId; ?>" name="name" required>
<label for="email-<?php echo $formId; ?>"><?php echo i18n('Email'); ?> <span class="required">*</span></label>
<input type="email" class="form-control" id="email-<?php echo $formId; ?>" name="email" required>
<br><small class="form-text text-muted"><?php echo i18n('Email_not_published'); ?></small>
</div>
<br clear="all">
<div class="form-group">
<label for="comment-<?php echo $formId; ?>"><?php echo i18n('Comment'); ?> <span class="required">*</span></label>
<textarea class="form-control" id="comment-<?php echo $formId; ?>" name="comment" rows="5" required></textarea>
<small class="form-text text-muted"><?php echo i18n('Comment_formatting_help'); ?></small>
</div>
<div class="form-group form-check">
<input type="checkbox" class="form-check-input" id="notify-<?php echo $formId; ?>" name="notify" value="1">
<label class="form-check-label" for="notify-<?php echo $formId; ?>">
<?php echo i18n('Notify_new_comments'); ?>
</label>
</div>
<br>
<div class="form-group">
<button type="submit" class="btn btn-primary submit-comment"><?php echo $parentId ? i18n('Post_Reply') : i18n('Post_Comment'); ?></button>
<?php if ($parentId): ?>
<button type="button" class="btn btn-secondary cancel-reply" onclick="cancelReply('<?php echo $parentId; ?>')"><?php echo i18n('Cancel'); ?></button>
<?php endif; ?>
</div>
</form>
<?php
}
/**
* Display single comment
*
* @param array $comment Comment data
* @param string $postId Post ID
* @return void
*/
function displayComment($comment, $postId)
{
$indent = isset($comment['level']) ? $comment['level'] : 0;
$marginLeft = $indent * 0; // 40px per level - changed to 0 Emidio 20251106
// Add visual depth indicator
$depthClass = 'comment-level-' . min($indent, 5); // Max 5 for styling
$borderColor = $indent > 0 ? '#ddd' : '#007bff';
?>
<div id="comment-<?php echo $comment['id']; ?>" class="comment-item <?php echo $depthClass; ?>"
style="margin-left: <?php echo $marginLeft; ?>px; border-left: 3px solid <?php echo $borderColor; ?>;"
data-level="<?php echo $indent; ?>">
<div class="comment-header">
<strong class="comment-author"><?php echo _h($comment['name']); ?></strong>
<span class="comment-date"><?php echo format_date($comment['timestamp']); ?></span>
<!---
<?php if ($indent > 0): ?>
<span class="comment-level-badge"><?php echo i18n('Level'); ?> <?php echo $indent; ?></span>
<?php endif; ?>
--->
</div>
<div class="comment-body">
<?php echo formatCommentText($comment['comment']); ?>
</div>
<div class="comment-footer">
<button class="btn btn-sm btn-link reply-button" onclick="showReplyForm('<?php echo $comment['id']; ?>', '<?php echo ltrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/'); ?>')">
<i class="fa fa-reply"></i> <?php echo i18n('Reply'); ?>
</button>
</div>
<div id="reply-container-<?php echo $comment['id']; ?>" class="reply-container" style="display:none; margin-top:15px;">
<!-- Reply form will be inserted here via JavaScript -->
</div>
<?php
// Display child comments (recursive - unlimited depth)
if (!empty($comment['children'])) {
echo '<div class="comment-children">';
foreach ($comment['children'] as $child) {
displayComment($child, $postId);
}
echo '</div>';
}
?>
</div>
<?php
}
/**
* Display all comments for a post
*
* @param string $postId Post or page ID
* @return void
*/
function displayComments($url, $file = null)
{
if (!comments()) {
return;
}
$comments = getComments($url, $file = null);
if (empty($comments)) {
return;
}
// Build comment tree
$commentTree = buildCommentTree($comments);
?>
<div class="comments-list">
<!--- <h4><?php echo i18n('Comments'); ?> (<?php echo count($comments); ?>)</h4> --->
<?php
foreach ($commentTree as $comment) {
displayComment($comment, $url, $file = null);
}
?>
</div>
<?php
}
/**
* Display complete comments section (list + form)
*
* @param string $postId Post or page ID
* @return void
* type can be post, author, page, subpage (same a view variable)
*/
function displayCommentsSection($a)
{
if (!comments()) {
return;
}
$url = $a->url;
$file = $a->file;
$urlpath = ltrim(parse_url($url, PHP_URL_PATH), '/');
?>
<section class="comments comment-box" id="comments">
<!---
<div class="comments-number">
<h3><?php echo i18n("Comments"); ?></h3>
</div>
--->
<div class="comment-alert-status" id="comment-alert-status" style="display:none;">
</div>
<?php displayComments($urlpath, $file = null); ?>
<div class="comment-form-section">
<h4><?php echo i18n('Leave_a_comment'); ?></h4>
<?php displayCommentsForm($urlpath, $file = null); ?>
</div>
</section>
<script type="text/javascript">
function showReplyForm(commentId, commentUrl) {
// Hide all other reply forms
document.querySelectorAll('.reply-container').forEach(function(el) {
el.style.display = 'none';
el.innerHTML = '';
});
// Show this reply form
var container = document.getElementById('reply-container-' + commentId);
if (container) {
container.style.display = 'block';
// Build form HTML
var submitUrl = '<?php echo site_url(); ?>comments/submit';
var formId = 'reply-form-' + commentId;
var formHtml = '<form id="' + formId + '" method="POST" action="' + submitUrl + '" class="comment-form">' +
'<input type="hidden" name="url" value="' + commentUrl + '">' +
'<input type="hidden" name="parent_id" value="' + commentId + '">' +
'<div style="position:absolute;left:-5000px;" aria-hidden="true">' +
'<input type="text" name="website" tabindex="-1" value="" autocomplete="off">' +
'</div>' +
'<div style="position:absolute;left:-6000px;" aria-hidden="true">' +
'<input type="text" name="company" tabindex="-2" value="" autocomplete="off">' +
'</div>' +
'<div class="form-group">' +
'<label for="name-' + formId + '"><?php echo i18n("Name"); ?> <span class="required">*</span></label>' +
'<input type="text" class="form-control" id="name-' + formId + '" name="name" required>' +
'</div>' +
'<div class="form-group">' +
'<label for="email-' + formId + '"><?php echo i18n("Email"); ?> <span class="required">*</span></label>' +
'<input type="email" class="form-control" id="email-' + formId + '" name="email" required>' +
'<small class="form-text text-muted"><?php echo i18n("Email_not_published"); ?></small>' +
'</div>' +
'<div class="form-group">' +
'<label for="comment-' + formId + '"><?php echo i18n("Comment"); ?> <span class="required">*</span></label>' +
'<textarea class="form-control" id="comment-' + formId + '" name="comment" rows="5" required></textarea>' +
'<small class="form-text text-muted"><?php echo i18n("Comment_formatting_help"); ?></small>' +
'</div>' +
'<div class="form-group form-check">' +
'<input type="checkbox" class="form-check-input" id="notify-' + formId + '" name="notify" value="1">' +
'<label class="form-check-label" for="notify-' + formId + '"><?php echo i18n("Notify_new_comments"); ?></label>' +
'</div>' +
'<br><div class="form-group">' +
'<button type="submit" class="btn btn-primary submit-reply"><?php echo i18n("Post_Reply"); ?></button> ' +
'<button type="button" class="btn btn-secondary cancel-reply" onclick="cancelReply(\'' + commentId + '\')"><?php echo i18n("Cancel"); ?></button>' +
'</div>' +
'</form>';
container.innerHTML = formHtml;
// Populate antispam company field with current timestamp
const timestampSeconds = Math.floor(Date.now() / 1000);
const companyField = container.querySelector('[name="company"]');
if (companyField) {
companyField.value = timestampSeconds;
}
}
}
function cancelReply(commentId) {
var container = document.getElementById('reply-container-' + commentId);
if (container) {
container.style.display = 'none';
container.innerHTML = '';
}
}
function handleCommentStatus() {
// Setting messages
const messages = {
comment_submission_success: "<?php echo i18n('comment_submission_success'); ?>",
comment_submission_moderation: "<?php echo i18n('comment_submission_moderation'); ?>",
comment_submission_error: "<?php echo i18n('comment_submission_error'); ?>",
comment_submission_error_shortname: "<?php echo i18n('comment_submission_error_shortname'); ?>",
comment_submission_error_email: "<?php echo i18n('comment_submission_error_email'); ?>",
comment_submission_error_short: "<?php echo i18n('comment_submission_error_short'); ?>",
comment_submission_error_spam: "<?php echo i18n('comment_submission_error_spam'); ?>"
};
// Get the hash in the URL
const hash = window.location.hash;
// Check if there's #comment-status
if (hash.startsWith('#comment-status')) {
// Get the part after +
const parts = hash.split('+');
if (parts.length > 1) {
const statusKey = parts[1];
const alertDiv = document.querySelector('.comment-alert-status');
if (alertDiv && messages[statusKey]) {
// Set message to display
alertDiv.textContent = messages[statusKey];
// Set div colors (classes) based on message type
if (statusKey.includes('error')) {
alertDiv.className = 'comment-alert-status comment-alert-status-error'
} else if (statusKey.includes('success')) {
alertDiv.className = 'comment-alert-status comment-alert-status-success'
} else if (statusKey.includes('moderation')) {
alertDiv.className = 'comment-alert-status comment-alert-status-warning'
}
// Reset opacity and show status message div
alertDiv.style.opacity = '1';
alertDiv.style.transition = 'none';
alertDiv.style.display = 'block';
// Scroll to status message
document.getElementById('comments').scrollIntoView({
behavior: 'smooth',
block: 'start'
});
// Hide div after 3 seconds with fade-out effect
setTimeout(() => {
alertDiv.style.transition = 'opacity 0.8s ease';
alertDiv.style.opacity = '0';
// After the fade completes, hide the element completely
alertDiv.addEventListener('transitionend', () => {
alertDiv.style.display = 'none';
}, { once: true });
}, 3000);
}
}
}
}
// Antispam protection, executed when page is loaded
document.addEventListener('DOMContentLoaded', function () {
const timestampSeconds = Math.floor(Date.now() / 1000);
// Select all forms in page
document.querySelectorAll('form').forEach(function (form) {
// Finds all fields named "company"
form.querySelectorAll('[name="company"]').forEach(function (field) {
field.value = timestampSeconds;
});
});
});
// Executed when page is loaded
document.addEventListener('DOMContentLoaded', handleCommentStatus);
// Executed also when page hash changes (navigating in same page)
window.addEventListener('hashchange', handleCommentStatus);
</script>
<?php
}
if (isset($_GET['subscribe'])) {
confirmSubscription($_GET['subscribe']);
}

View file

@ -10,6 +10,11 @@ Some major fixes to comment system:
* improved antispam system
* added subscription verification system
## 2026-03-22
Reworked functions to match HTMLy coding style, changed local() to comments. Comment system has been integrated in existing themes (some css to adapt to the theme layout added), and added a system messages function (to give messages during subsciption/unsubscription process) - it can be used for other integrations.
Also, comments configuration is now in config.ini.
### Antispam
Antispam work using a honeyspot and js/token verification
@ -25,4 +30,3 @@ Notification email are sent on comment publish (if validation is enabled) or com
**TODO**: limit comment insert by time from same IP address
**TODO**: reworking backend functions to use HTMLy basic functions and avoid code duplication

View file

@ -0,0 +1,63 @@
// Javascript to handle system messages calls - actually used for subscribe/unsubscribe
document.addEventListener('DOMContentLoaded', function() {
const params = new URLSearchParams(window.location.search);
if (params.toString()) {
const scriptEl = document.currentScript || document.querySelector('script[data-base]');
const base = scriptEl?.dataset.base || '/';
fetch(base + 'system/resources/js/sysmessages-set.js?' + params.toString())
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(data => {
// Parse the JSON string if needed
const messages = typeof data === 'string' ? JSON.parse(data) : data;
if (!Array.isArray(messages) || messages.length === 0) return;
const messagesDiv = document.getElementById('messages-div');
const messagesTextDiv = document.getElementById('messages-text');
// const innerDiv = messagesDiv.querySelector('.message-alert');
const innerDiv = messagesDiv.querySelector('.message-alert') || messagesDiv;
// Show messages one at a time, sequentially
let index = 0;
function showMessage(msg) {
if (!msg.message || msg.message.trim() === '') return showNext();
messagesTextDiv.textContent = msg.message;
innerDiv.className = innerDiv.className + ' message-alert-' + msg.class;
// Reset display and opacity
messagesDiv.style.transition = 'none';
messagesDiv.style.opacity = '1';
messagesDiv.style.display = 'block';
// Fade out after 5 seconds, then show next
setTimeout(() => {
messagesDiv.style.transition = 'opacity 0.8s ease';
messagesDiv.style.opacity = '0';
messagesDiv.addEventListener('transitionend', () => {
showNext();
}, { once: true });
}, 5000);
}
function showNext() {
if (index < messages.length) {
showMessage(messages[index++]);
} else {
messagesDiv.style.display = 'none';
}
}
showNext();
});
}
});

View file

@ -0,0 +1,34 @@
<?php
session_start();
include_once('../../includes/dispatch.php');
include_once('../../includes/comments.php');
// Set JSON header
header('Content-Type: application/json');
// Initialize response array
$response = array();
try {
// check if any message to be displayed
if (isset($_SESSION['sysmessages']) && is_array($_SESSION['sysmessages'])) {
$response = json_encode($_SESSION['sysmessages']);
$_SESSION['sysmessages'] = array();
}
} catch (Exception $e) {
// Handle any exceptions
$msg['message'] = 'An unexpected error occurred.';
$msg['class'] = 'error';
$response[] = $msg;
// Log the error (in production, don't expose error details to client)
error_log('Backend error: ' . $e->getMessage());
}
// Return JSON response
echo json_encode($response);
exit;
?>

View file

@ -641,3 +641,73 @@ ul.month {
.social-logo a:before {
padding-top:6px;
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comments.aside.section li {
list-style: none;
margin-bottom: 10px;
}
.comments.aside.section ul {
padding-left: 0px;
}
.comments.aside.section a {
color: #5f6b77;
font-size: 16px;
line-height: 1.3;
font-family: 'Montserrat', sans-serif;
font-weight: 700;
margin-bottom: 10px;
}
.comments.aside.section span {
font-style: italic;
font-size: small;
}
.comment-item {
padding-left: 10px;
}
#messages-div {
display: none;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -68,6 +68,16 @@
<div class="container sections-wrapper">
<div class="row">
<div class="primary col-md-8 col-sm-12 col-xs-12">
<!--//sysmessages div-->
<div class="post section" id="messages-div">
<div class="section-inner message-alert">
<div class="content">
<div id="messages-text">&nbsp;</div>
</div>
</div>
</div>
<?php echo content();?>
</div><!--//primary-->
<div class="secondary col-md-4 col-sm-12 col-xs-12">
@ -131,6 +141,7 @@
</aside><!--//section-->
<?php endif;?>
<?php if (disqus() || comments()): ?>
<?php if (disqus()): ?>
<aside class="comments aside section">
<div class="section-inner">
@ -142,6 +153,17 @@
</div><!--//section-inner-->
</aside><!--//section-->
<?php endif; ?>
<?php if (comments()): ?>
<aside class="comments aside section">
<div class="section-inner">
<h2 class="heading"><?php echo i18n("Comments");?></h2>
<div class="content">
<?php echo last_comments() ?>
</div><!--//content-->
</div><!--//section-inner-->
</aside><!--//section-->
<?php endif; ?>
<?php endif;?>
<?php if (theme_config('archive')):?>
<aside class="archive aside section">
@ -189,6 +211,7 @@
</footer><!--//footer-->
<!-- Javascript -->
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/jquery.min.js"></script>
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/sysmessages.js" data-base="<?= base_url() ?>"></script>
<script type="text/javascript" src="<?php echo theme_path();?>js/bootstrap.min.js"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>

View file

@ -92,7 +92,7 @@
</div><!--//content-->
</div><!--//section-inner-->
</section><!--//section-->
<?php if (facebook() || disqus()): ?>
<?php if (facebook() || disqus() || comments()): ?>
<section class="comment-wrapper post section">
<div class="section-inner">
<div class="content">
@ -104,6 +104,9 @@
<?php if (disqus()): ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
</div><!--//content-->
</div><!--//section-inner-->

View file

@ -954,4 +954,86 @@ ul.archivegroup {
margin-top:-1rem;
box-shadow: none;
border: none;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comment-item {
padding-left: 10px;
font-size: small;
}
.comments .btn {
background-color: white;
border: none;
font-family: Times New Roman;
color: #389dc1;
font-weight: bold;
cursor: pointer;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comments .form-check-input {
margin-right: 5px;
}
.comments textarea {
width: 100%;
}
#messages-div {
display: none;
position: absolute;
margin-top: 10px;
width: 100%;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -54,8 +54,19 @@
<div class="copyright"><?php echo copyright() ?></div>
</aside>
<section id="content">
<!--//sysmessages div-->
<div class="main" id="messages-div">
<div class="section-inner message-alert">
<div class="content">
<div id="messages-text">&nbsp;</div>
</div>
</div>
</div>
<?php echo content() ?>
</section>
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/sysmessages.js" data-base="<?php echo site_url(); ?>"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>
</html>

View file

@ -67,6 +67,9 @@
<?php if (disqus()): ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
<div class="postnav">
<?php if (!empty($next)): ?>

View file

@ -3580,4 +3580,63 @@ body.dark .social-logo a:hover, .dark .toc-wrapper a:hover {
.list-unstyled li {
margin: 0;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comment-item {
padding-left: 10px;
border-left: 3px solid #49256a !important;
}
.comments .form-check-input {
margin-right: 5px;
}
#messages-div {
display: none;
margin-top: 10px;
width: 100%;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -65,6 +65,14 @@ $front = get_frontpage(); ?>
<section class="section container-fluid mt-n3 pb-3">
<div class="row justify-content-center">
<div class="col-lg-12 text-center">
<!--//sysmessages div-->
<div id="messages-div">
<div class="message-alert">
<div id="messages-text">&nbsp;</div>
</div>
</div>
<h1 class="mt-0"><?php echo $front->title;?></h1>
<?php if(login()):?><small><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentcolor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-edit-2"><path d="M17 3a2.828 2.828.0 114 4L7.5 20.5 2 22l1.5-5.5L17 3z"></path></svg> <a href="<?php echo $front->url;?>/edit?destination=front"><?php echo i18n('edit');?></a></small><?php endif;?>
</div>
@ -97,6 +105,14 @@ $front = get_frontpage(); ?>
<div id="content" class="content">
<div class="row justify-content-center">
<div class="col-md-12 col-lg-10 col-xl-9">
<!--//sysmessages div-->
<div id="messages-div">
<div class="message-alert">
<div id="messages-text">&nbsp;</div>
</div>
</div>
<?php echo content();?>
</div>
</div>
@ -123,6 +139,7 @@ $front = get_frontpage(); ?>
</div>
</footer>
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/sysmessages.js" data-base="<?php echo site_url(); ?>"></script>
<script src="<?php echo theme_path();?>js/main.js"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>

View file

@ -73,7 +73,7 @@
<?php echo disqus($post->title, $post->url) ?>
<?php endif; ?>
<?php if (facebook() || disqus()): ?>
<?php if (facebook() || disqus() || comments()): ?>
<div class="comments-area" id="comments">
<?php if (facebook()): ?>
<div class="fb-comments" data-href="<?php echo $post->url ?>" data-numposts="<?php echo config('fb.num') ?>" data-colorscheme="<?php echo config('fb.color') ?>"></div>
@ -81,6 +81,9 @@
<?php if (disqus()): ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
<?php endif; ?>

View file

@ -983,4 +983,88 @@ ul.archivegroup {
margin-top:-1rem;
box-shadow: none;
border: none;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
#comments {
width: 90%;
}
.comments .btn {
background-color: white;
border: none;
font-family: Georgia, sans-serif;
font-size: 15px;
color: #21759B;
font-weight: bold;
cursor: pointer;
}
.comments .btn:hover {
text-decoration: underline;
color: #D54E21;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comment-item {
padding-left: 10px;
border-left: 3px solid #21759B !important;
}
.comments .form-check-input {
margin-right: 5px;
}
.comments textarea {
width: 100%;
}
#messages-div {
display: none;
margin-top: 10px;
width: 100%;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2);
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2);
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2);
}

View file

@ -36,6 +36,14 @@
<div id="main-wrapper">
<div id="main" class="responsive">
<section id="content">
<!--//sysmessages div-->
<div id="messages-div">
<div class="message-alert">
<div id="messages-text">&nbsp;</div>
</div>
</div>
<?php echo content() ?>
</section>
<aside id="sidebar">
@ -69,6 +77,7 @@
</div>
<?php endif;?>
<?php if (disqus() || comments()): ?>
<?php if (disqus()): ?>
<div class="comments">
<h3><?php echo i18n('Comments');?></h3>
@ -77,6 +86,15 @@
</div>
<?php endif; ?>
<?php if (comments()): ?>
<div class="comments">
<h3><?php echo i18n('Comments');?></h3>
<?php echo recent_comments() ?>
<?php echo last_comments(); ?>
</div>
<?php endif; ?>
<?php endif; ?>
<?php if (theme_config('category_list')):?>
<div class="category-list">
<h3><?php echo i18n('Category');?></h3>
@ -102,6 +120,7 @@
</footer>
</div>
</div>
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/sysmessages.js" data-base="<?php echo site_url(); ?>"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>
</html>

View file

@ -67,6 +67,9 @@
<?php if (disqus()): ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
<div class="postnav">
<?php if (!empty($next)): ?>

View file

@ -1038,4 +1038,97 @@ ul.archivegroup {
margin-top:-1rem;
box-shadow: none;
border: none;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comment-item {
padding-left: 10px;
font-size: small;
border-left: 3px solid #555 !important;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comments .form-check-input {
margin-right: 5px;
}
.comments textarea {
width: 100%;
}
.comments input[type="email"] {
padding: 4px 6px;
font-size: 14px;
background-color: #F6F7F9;
border: 1px solid #CFDAE5;
}
.comments .btn {
border-radius: 3px;
color: #555;
font-family: 'Source Sans', sans-serif;
font-size: 12px;
font-weight: bold;
color: #555;
padding: 5px 10px 5px 10px;
background: none repeat scroll 0 0 #E4E7EE;
border: none;
cursor: pointer;
}
#messages-div {
display: none;
width: 100%;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -40,6 +40,16 @@
<div id="content-wrapper">
<div class="container">
<section id="content">
<!--//sysmessages div-->
<div class="main" id="messages-div">
<div class="section-inner message-alert">
<div class="content">
<div id="messages-text">&nbsp;</div>
</div>
</div>
</div>
<?php echo content() ?>
</section>
</div>
@ -52,6 +62,8 @@
</div>
</div>
</div>
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/sysmessages.js" data-base="<?php echo site_url(); ?>"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>
</html>

View file

@ -65,6 +65,9 @@
<?php if (disqus()): ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
<div class="postnav">
<?php if (!empty($next)): ?>

View file

@ -147,4 +147,96 @@
.recent-posts > ul {
padding-left: 15px;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comment-form-section {
text-align: left;
}
.comment-form-section > h4 {
font-weight: bold;
margin-top: 10px;
}
.comment-body {
font-style: italic;
}
.comment-item {
padding-left: 10px;
font-size: small;
border-left: 3px solid #555 !important;
text-align: left;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comments .form-check-input {
margin-right: 5px;
}
.comments textarea {
width: 100%;
}
.comments .btn {
color: #ec4899;
text-decoration: underline;
font-weight: 500;
border: none;
}
#messages-div {
display: none;
width: 100%;
}
#messages-text {
padding: 5px 10px 5px 10px;
text-align: center;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -79,9 +79,29 @@
<main class="mb-auto">
<?php if (is_index() || isset($is_profile)) {?>
<div class="divide-y divide-gray-200 dark:divide-gray-700">
<!--//sysmessages div-->
<div class="main" id="messages-div">
<div class="section-inner message-alert">
<div class="content">
<div id="messages-text">&nbsp;</div>
</div>
</div>
</div>
<?php echo content();?>
</div>
<?php } else {?>
<!--//sysmessages div-->
<div class="main" id="messages-div">
<div class="section-inner message-alert">
<div class="content">
<div id="messages-text">&nbsp;</div>
</div>
</div>
</div>
<?php echo content();?>
<?php } ?>
</main>
@ -156,6 +176,8 @@
</script>
<script src="<?php echo theme_path();?>js/functions.js"></script>
<script type="text/javascript" src="<?php echo site_url();?>system/resources/js/sysmessages.js" data-base="<?php echo site_url(); ?>"></script>
<?php if (analytics()): ?><?php echo analytics() ?><?php endif; ?>
</body>
</html>

View file

@ -68,7 +68,7 @@
<h2 class="text-xl text-gray-700 dark:text-gray-300"><?php echo i18n('related_posts');?></h2>
<?php echo get_related($p->related);?>
</div>
<?php if (facebook() || disqus()): ?>
<?php if (facebook() || disqus() || comments()): ?>
<div class="pb-6 pt-6 text-center text-gray-700 dark:text-gray-300" id="comment">
<?php if (facebook()): ?>
<div class="fb-comments" data-href="<?php echo $p->url ?>" data-numposts="<?php echo config('fb.num') ?>" data-colorscheme="<?php echo config('fb.color') ?>"></div>
@ -77,6 +77,9 @@
<?php echo disqus($p->title, $p->url) ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
<?php endif;?>
</div>

View file

@ -6159,4 +6159,69 @@ ul.month {
.social-logo a {
height:35px;
width:35px;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.widget.widget_meta span {
font-style: italic;
font-size: small;
}
.comment-item {
padding-left: 10px;
font-size: small;
border-left: 3px solid #555 !important;
margin-top: 5px;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comments .form-check-input {
margin-right: 5px;
width: 5%;
}
.comments textarea {
width: 100%;
}
.comments .btn {
font-size: small;
}
.comment-form label {
display: inline;
}
#messages-div {
display: none;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -6166,4 +6166,88 @@ ul.month {
.social-logo a {
height:35px;
width:35px;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.widget.widget_meta span {
font-style: italic;
font-size: small;
}
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comment-item {
padding-left: 10px;
font-size: small;
border-left: 3px solid #555 !important;
margin-top: 5px;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comments .form-check-input {
margin-right: 5px;
width: 5%;
}
.comments textarea {
width: 100%;
}
.comments .btn {
font-size: small;
}
.comment-form label {
display: inline;
}
#messages-div {
display: none;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}

View file

@ -75,7 +75,7 @@
<?php if (disqus_count()): ?>
<?php echo disqus_count() ?>
<?php endif; ?>
<?php if (facebook() || disqus()): ?>
<?php if (facebook() || disqus() || comments()): ?>
<div class="comments-area" id="comments">
<?php if (facebook()): ?>
<div class="fb-comments" data-href="<?php echo $p->url ?>" data-numposts="<?php echo config('fb.num') ?>" data-colorscheme="<?php echo config('fb.color') ?>"></div>
@ -83,6 +83,9 @@
<?php if (disqus()): ?>
<div id="disqus_thread"></div>
<?php endif; ?>
<?php if (comments()): ?>
<?php comments($p); ?>
<?php endif; ?>
</div>
<?php endif; ?>
<nav role="navigation" class="navigation post-navigation">

View file

@ -4092,4 +4092,85 @@ ul.month {
.social-logo a:before {
line-height: 33px!important;
}
}
/*--------------------------------------------------------------
## - CSS comments
--------------------------------------------------------------*/
.comment-alert-status {
padding: 5px;
margin-bottom: 20px;
border-radius: 5px;
}
.comment-alert-status-success {
background-color: rgba(0, 128, 0, 0.2);
border-left: 3px solid rgba(0, 128, 0);
}
.comment-alert-status-warning {
background-color: rgba(255, 204, 0, 0.2);
border-left: 3px solid rgba(255, 204, 0);
}
.comment-alert-status-error {
background-color: rgba(191, 0, 0, 0.2);
border-left: 3px solid rgba(191, 0, 0);
}
.comment-item {
padding-left: 10px;
font-size: small;
border-left: 3px solid #555 !important;
margin-top: 5px;
}
.comments input:not([type="checkbox"]) {
width: 100%;
}
.comments .form-check-input {
margin-right: 5px;
width: 5%;
}
.comments textarea {
width: 100%;
}
.comments .btn {
font-size: small;
}
.comment-form label {
display: inline;
}
#messages-div {
display: none;
margin-bottom: 10px;
}
#messages-text {
padding: 5px 10px 5px 10px;
}
.message-alert-success {
background-color: rgba(0, 128, 0, 0.2) !important;
}
.message-alert-warning {
background-color: rgba(255, 204, 0, 0.2) !important;
}
.message-alert-error {
background-color: rgba(191, 0, 0, 0.2) !important;
}