в админку добавлено количество комментариев в ответах

This commit is contained in:
2025-12-31 23:17:37 +05:00
parent 596ff2db2b
commit 53d4e51114
3 changed files with 126 additions and 115 deletions

View File

@@ -4,8 +4,8 @@
$module = array(
'ModuleSysName' => 'comment',
'ModuleVersion' => '1.26.2a',
'ModuleAutor' => 'AVE.cms Team',
'ModuleVersion' => '3.30',
'ModuleAutor' => 'Repellent',
'ModuleCopyright' => '© 2007-' . date('Y') . ' AVE.cms',
'ModuleStatus' => 1,
'ModuleIsFunction' => 1,

211
sql.php
View File

@@ -1,118 +1,113 @@
<?php
if (!defined('BASE_DIR')) exit;
/**
* AVE.cms - Модуль Комментарии
*
* Обновленная структура с поддержкой выбора типа рейтинга,
* идентификации анонимов, загрузки файлов и защиты по IP.
* ДОБАВЛЕНО: Управление расширениями, размером и КОЛИЧЕСТВОМ файлов.
* СИНХРОНИЗАЦИЯ: Добавлен формат webp по умолчанию.
*/
/**
* AVE.cms - Модуль Комментарии
* (Структура по аналогии с модулем Forms)
*/
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
$module_sql_install = array();
$module_sql_deinstall = array();
$module_sql_update = array();
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comments`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comment_info`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comment_votes`;";
// 1. УДАЛЕНИЕ (Чистим всё перед установкой)
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comments`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comment_info`;";
$module_sql_deinstall[] = "DROP TABLE IF EXISTS `%%PRFX%%_module_comment_votes`;";
// =================================================================================
// 1. УСТАНОВКА МОДУЛЯ (CREATE TABLE)
// =================================================================================
$module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_comments` (
`Id` tinyint(1) unsigned NOT NULL auto_increment,
`comment_max_chars` smallint(3) unsigned NOT NULL default '1000',
`comment_user_groups` text NOT NULL,
`comment_user_groups_read` text NOT NULL,
`comment_need_approve` enum('0','1') NOT NULL default '0',
`comment_active` enum('1','0') NOT NULL default '1',
`comment_use_antispam` enum('1','0') NOT NULL default '1',
`comment_use_page_nav` enum('1','0') NOT NULL default '1',
`comment_page_nav_count` varchar(5) NOT NULL,
`comment_show_f1` tinyint(1) NOT NULL default '1',
`comment_req_f1` tinyint(1) NOT NULL default '0',
`comment_name_f1` varchar(255) NOT NULL default '',
`comment_show_f2` tinyint(1) NOT NULL default '1',
`comment_req_f2` tinyint(1) NOT NULL default '0',
`comment_name_f2` varchar(255) NOT NULL default '',
`comment_allow_files` tinyint(1) NOT NULL default '0',
`comment_allowed_extensions` varchar(255) NOT NULL default 'jpg,jpeg,png,gif,webp',
`comment_max_file_size` int(10) NOT NULL default '2048',
`comment_max_files` tinyint(2) NOT NULL default '5',
`comment_rating_type` tinyint(1) NOT NULL default '0',
`comment_show_user_rating` tinyint(1) NOT NULL default '0',
`comment_show_user_rating_replies` tinyint(1) NOT NULL default '0',
`comment_rating_anon_vote` tinyint(1) NOT NULL default '0',
`comment_rating_anon_set` tinyint(1) NOT NULL default '0',
`comment_allow_files_anon` tinyint(1) NOT NULL default '0',
`comment_edit_time` int(11) NOT NULL default '60',
`comment_cookie_life` int(11) NOT NULL default '30',
PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
// 2. УСТАНОВКА (Создаем таблицы сразу со всеми нужными полями)
$module_sql_install[] = "
CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_comments` (
`Id` tinyint(1) unsigned NOT NULL AUTO_INCREMENT,
`comment_max_chars` smallint(3) unsigned NOT NULL DEFAULT '1000',
`comment_user_groups` text NOT NULL,
`comment_user_groups_read` text NOT NULL,
`comment_need_approve` enum('0','1') NOT NULL DEFAULT '0',
`comment_active` enum('1','0') NOT NULL DEFAULT '1',
`comment_use_antispam` enum('1','0') NOT NULL DEFAULT '1',
`comment_use_page_nav` enum('1','0') NOT NULL DEFAULT '1',
`comment_page_nav_count` varchar(5) NOT NULL,
`comment_show_f1` tinyint(1) NOT NULL DEFAULT '1',
`comment_req_f1` tinyint(1) NOT NULL DEFAULT '0',
`comment_name_f1` varchar(255) NOT NULL DEFAULT '',
`comment_show_f2` tinyint(1) NOT NULL DEFAULT '1',
`comment_req_f2` tinyint(1) NOT NULL DEFAULT '0',
`comment_name_f2` varchar(255) NOT NULL DEFAULT '',
`comment_allow_files` tinyint(1) NOT NULL DEFAULT '0',
`comment_allowed_extensions` varchar(255) NOT NULL DEFAULT 'jpg,jpeg,png,gif,webp',
`comment_max_file_size` int(10) NOT NULL DEFAULT '2048',
`comment_max_files` tinyint(2) NOT NULL DEFAULT '5',
`comment_rating_type` tinyint(1) NOT NULL DEFAULT '0',
`comment_show_user_rating` tinyint(1) NOT NULL DEFAULT '0',
`comment_show_user_rating_replies` tinyint(1) NOT NULL DEFAULT '0',
`comment_rating_anon_vote` tinyint(1) NOT NULL DEFAULT '0',
`comment_rating_anon_set` tinyint(1) NOT NULL DEFAULT '0',
`comment_allow_files_anon` tinyint(1) NOT NULL DEFAULT '0',
`comment_edit_time` int(11) NOT NULL DEFAULT '60',
`comment_cookie_life` int(11) NOT NULL DEFAULT '30',
`comment_ajax_replies_limit` tinyint(3) NOT NULL DEFAULT '5',
PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 AUTO_INCREMENT=1;
";
// Таблица info
$module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_comment_info` (
`Id` int(10) unsigned NOT NULL auto_increment,
`parent_id` int(10) unsigned NOT NULL default '0',
`document_id` int(10) unsigned NOT NULL default '0',
`comment_author_name` varchar(255) NOT NULL,
`comment_author_id` int(10) unsigned NOT NULL default '0',
`comment_author_email` varchar(255) NOT NULL,
`comment_author_city` varchar(255) NOT NULL,
`comment_author_website` varchar(255) NOT NULL,
`comment_author_ip` varchar(45) NOT NULL,
`anon_key` varchar(32) DEFAULT NULL,
`comment_published` int(10) unsigned NOT NULL default '0',
`comment_changed` int(10) unsigned NOT NULL default '0',
`comment_text` text NOT NULL,
`comment_status` tinyint(1) unsigned NOT NULL default '1',
`comments_close` tinyint(1) unsigned NOT NULL default '0',
`comment_file` varchar(255) NOT NULL default '',
`user_rating` tinyint(1) NOT NULL default '0',
`rating_sum` int(10) NOT NULL default '0',
`rating_count` int(10) NOT NULL default '0',
PRIMARY KEY (`Id`),
KEY `document_id` (`document_id`),
KEY `parent_id` (`parent_id`),
KEY `comment_status` (`comment_status`),
KEY `anon_key` (`anon_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0;";
$module_sql_install[] = "
CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_comment_info` (
`Id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`parent_id` int(10) unsigned NOT NULL DEFAULT '0',
`document_id` int(10) unsigned NOT NULL DEFAULT '0',
`comment_author_name` varchar(255) NOT NULL,
`comment_author_id` int(10) unsigned NOT NULL DEFAULT '0',
`comment_author_email` varchar(255) NOT NULL,
`comment_author_city` varchar(255) NOT NULL,
`comment_author_website` varchar(255) NOT NULL,
`comment_author_ip` varchar(45) NOT NULL,
`anon_key` varchar(32) DEFAULT NULL,
`comment_published` int(10) unsigned NOT NULL DEFAULT '0',
`comment_changed` int(10) unsigned NOT NULL DEFAULT '0',
`comment_text` text NOT NULL,
`comment_status` tinyint(1) unsigned NOT NULL DEFAULT '1',
`comments_close` tinyint(1) unsigned NOT NULL DEFAULT '0',
`comment_file` varchar(255) NOT NULL DEFAULT '',
`user_rating` tinyint(1) NOT NULL DEFAULT '0',
`rating_sum` int(10) NOT NULL DEFAULT '0',
`rating_count` int(10) NOT NULL DEFAULT '0',
PRIMARY KEY (`Id`),
KEY `document_id` (`document_id`),
KEY `parent_id` (`parent_id`),
KEY `comment_status` (`comment_status`),
KEY `anon_key` (`anon_key`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 AUTO_INCREMENT=1;
";
$module_sql_install[] = "CREATE TABLE `%%PRFX%%_module_comment_votes` (
`id` int(10) unsigned NOT NULL auto_increment,
`comment_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned DEFAULT '0',
`anon_key` varchar(32) DEFAULT '',
`remote_addr` varchar(45) DEFAULT '',
`vote_value` tinyint(1) NOT NULL,
`date_voted` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `comment_id` (`comment_id`),
KEY `anon_key` (`anon_key`),
KEY `user_id` (`user_id`),
KEY `remote_addr` (`remote_addr`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8;";
$module_sql_install[] = "
CREATE TABLE IF NOT EXISTS `%%PRFX%%_module_comment_votes` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`comment_id` int(10) unsigned NOT NULL,
`user_id` int(10) unsigned DEFAULT '0',
`anon_key` varchar(32) DEFAULT '',
`remote_addr` varchar(45) DEFAULT '',
`vote_value` tinyint(1) NOT NULL,
`date_voted` int(10) unsigned NOT NULL,
PRIMARY KEY (`id`),
KEY `comment_id` (`comment_id`),
KEY `anon_key` (`anon_key`),
KEY `user_id` (`user_id`),
KEY `remote_addr` (`remote_addr`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 PACK_KEYS=0 AUTO_INCREMENT=1;
";
/* Настройки по умолчанию (добавлено значение 5 для comment_max_files) */
$module_sql_install[] = "INSERT INTO `%%PRFX%%_module_comments` VALUES (1, 1000, '1,3', '1,2,3,4', '0', '1', '1' , '0', '', 1, 0, '', 1, 0, '', 0, 'jpg,jpeg,png,gif,webp', 2048, 5, 0, 1, 0, 0, 0, 0, 60, 30);";
// =================================================================================
// 2. ОБНОВЛЕНИЕ МОДУЛЯ (ALTER TABLE)
// =================================================================================
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_edit_time` INT(11) NOT NULL DEFAULT '60';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_cookie_life` INT(11) NOT NULL DEFAULT '30';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_rating_type` TINYINT(1) NOT NULL DEFAULT '0';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_show_user_rating` TINYINT(1) NOT NULL DEFAULT '0';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_show_user_rating_replies` TINYINT(1) NOT NULL DEFAULT '0';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_rating_anon_vote` TINYINT(1) NOT NULL DEFAULT '0';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_rating_anon_set` TINYINT(1) NOT NULL DEFAULT '0';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_allow_files_anon` TINYINT(1) NOT NULL DEFAULT '0';";
/* Новые поля для файлов при обновлении */
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_allowed_extensions` VARCHAR(255) NOT NULL DEFAULT 'jpg,jpeg,png,gif,webp';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_max_file_size` INT(10) NOT NULL DEFAULT '2048';";
$module_sql_update[] = "ALTER TABLE `%%PRFX%%_module_comments` ADD COLUMN IF NOT EXISTS `comment_max_files` TINYINT(2) NOT NULL DEFAULT '5';";
// Начальные настройки
$module_sql_install[] = "INSERT INTO `%%PRFX%%_module_comments` VALUES (1, 1000, '1,3', '1,2,3,4', '0', '1', '1' , '0', '', 1, 0, '', 1, 0, '', 0, 'jpg,jpeg,png,gif,webp', 2048, 5, 0, 1, 0, 0, 0, 0, 60, 30, 5);";
// 3. ОБНОВЛЕНИЕ (Только системная информация)
$module_sql_update[] = "
UPDATE `%%PRFX%%_module`
SET
ModuleAveTag = '" . $module['ModuleAveTag'] . "',
ModulePHPTag = '" . $module['ModulePHPTag'] . "',
ModuleVersion = '" . $module['ModuleVersion'] . "'
WHERE
ModuleSysName = '" . $module['ModuleSysName'] . "'
LIMIT 1;
";
?>

View File

@@ -43,15 +43,30 @@
</tr>
<tr>
<td>{#COMMENT_SPAMPROTECT#}</td>
<td><input name="comment_use_antispam" type="checkbox" value="1" {if $comment_use_antispam=='1'}checked{/if} /></td>
<td colspan="4" style="background: #f9f9f9; font-weight: bold; text-align: center;">Настройка постраничной навигации</td>
</tr>
<tr>
<td>{#COMMENT_USE_PAGE_NAV#}</td>
<td><input name="comment_use_page_nav" type="checkbox" value="1" {if $comment_use_page_nav=='1'}checked{/if} /></td>
<td style="border-right: 1px solid #ddd;"><input name="comment_use_page_nav" type="checkbox" value="1" {if $comment_use_page_nav=='1'}checked{/if} /></td>
<td>{#COMMENT_PAGE_NAV_COUNT#} (родителей)</td>
<td><input name="comment_page_nav_count" type="text" value="{$comment_page_nav_count}" size="4" style="width: 50px;" /></td>
</tr>
<tr>
<td>Лимит AJAX-ответов в ветке:</td>
<td style="border-right: 1px solid #ddd;">
<input name="comment_ajax_replies_limit" type="text" value="{$comment_ajax_replies_limit|default:'5'}" size="4" style="width: 50px;" />
<span style="color: #888; font-size: 11px; margin-left: 5px;">(0 - без лимита)</span>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td>{#COMMENT_PAGE_NAV_COUNT#}</td>
<td><input name="comment_page_nav_count" type="text" value="{$comment_page_nav_count}" size="4" style="width: 50px;" /></td>
<td colspan="4" style="background: #f9f9f9; font-weight: bold; text-align: center;">Защита и ограничения</td>
</tr>
<tr>
<td>{#COMMENT_SPAMPROTECT#}</td>
<td style="border-right: 1px solid #ddd;"><input name="comment_use_antispam" type="checkbox" value="1" {if $comment_use_antispam=='1'}checked{/if} /></td>
<td>{#COMMENT_MAX_CHARS#}</td>
<td><input name="comment_max_chars" type="text" id="comment_max_chars" value="{$comment_max_chars}" size="5" maxlength="5" style="width: 50px;" /></td>
</tr>
@@ -238,6 +253,7 @@
</form>
</div>
<script type="text/javascript">
$(document).ready(function() {
function saveCommentSettings() {