diff --git a/CHANGELOG.md b/CHANGELOG.md index 5de334df7..20696a520 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - [CLI] TorrentPier installer ☕️ [\#1576](https://github.com/torrentpier/torrentpier/pull/1576), [\#1582](https://github.com/torrentpier/torrentpier/pull/1582), [\#1585](https://github.com/torrentpier/torrentpier/pull/1585), [\#1591](https://github.com/torrentpier/torrentpier/pull/1591) ([belomaxorka](https://github.com/belomaxorka)) - Added some new HTML meta-tags [\#1562](https://github.com/torrentpier/torrentpier/pull/1562) ([belomaxorka](https://github.com/belomaxorka)) - Added robots meta-tag support 🤖 [\#1587](https://github.com/torrentpier/torrentpier/pull/1587) ([belomaxorka](https://github.com/belomaxorka)) +- Newtopic: Added configuring robots indexing [\#1599](https://github.com/torrentpier/torrentpier/pull/1599) ([belomaxorka](https://github.com/belomaxorka)) - Added showing releaser stats in profile [\#1568](https://github.com/torrentpier/torrentpier/pull/1568) ([belomaxorka](https://github.com/belomaxorka)) - Improved `filelist.php` [\#1586](https://github.com/torrentpier/torrentpier/pull/1586) ([belomaxorka](https://github.com/belomaxorka)) - Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql index 1ddd0bb1b..d072fb9f0 100644 --- a/install/sql/mysql.sql +++ b/install/sql/mysql.sql @@ -1254,6 +1254,7 @@ CREATE TABLE IF NOT EXISTS `bb_topics` `topic_dl_type` TINYINT(1) NOT NULL DEFAULT '0', `topic_last_post_time` INT(11) NOT NULL DEFAULT '0', `topic_show_first_post` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', + `topic_allow_robots` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0', PRIMARY KEY (`topic_id`), KEY `forum_id` (`forum_id`), KEY `topic_last_post_id` (`topic_last_post_id`), @@ -1270,7 +1271,7 @@ INSERT INTO `bb_topics` VALUES ('1', '1', 'Welcome to TorrentPier Cattle', '2', UNIX_TIMESTAMP(), '0', '0', '0', '0', '0', '1', '1', '0', '0', - '0', UNIX_TIMESTAMP(), '0'); + '0', UNIX_TIMESTAMP(), '0', '1'); -- ---------------------------- -- Table structure for `bb_topics_watch` diff --git a/library/language/source/main.php b/library/language/source/main.php index 81733a4ce..9db83e78a 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -376,6 +376,7 @@ $lang['MAX_SMILIES_PER_POST'] = 'Emoticons limit of %s emoticons exceeded.'; $lang['ATTACH_SIGNATURE'] = 'Attach signature (signatures can be changed in profile)'; $lang['NOTIFY'] = 'Notify me when on replies'; +$lang['ALLOW_ROBOTS_INDEXING'] = 'Allow robots indexing this topic'; $lang['STORED'] = 'Your message has been entered successfully.'; $lang['EDITED'] = 'The message has been changed'; diff --git a/posting.php b/posting.php index bf7324bf3..e2aa84feb 100644 --- a/posting.php +++ b/posting.php @@ -249,8 +249,12 @@ if (!empty($bb_cfg['tor_cannot_edit']) && $post_info['allow_reg_tracker'] && $po } } -// Notify +// Notify & Allow robots indexing +$robots_indexing = $post_info['topic_allow_robots'] ?? true; if ($submit || $refresh) { + if (IS_AM) { + $robots_indexing = !empty($_POST['robots']); + } $notify_user = (int)!empty($_POST['notify']); } else { $notify_user = bf($userdata['user_opt'], 'user_opt', 'user_notify'); @@ -334,7 +338,7 @@ if (($delete || $mode == 'delete') && !$confirm) { if (!$error_msg) { $topic_type = (isset($post_data['topic_type']) && $topic_type != $post_data['topic_type'] && !$is_auth['auth_sticky'] && !$is_auth['auth_announce']) ? $post_data['topic_type'] : $topic_type; - \TorrentPier\Legacy\Post::submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $topic_type, DB()->escape($username), DB()->escape($subject), DB()->escape($message), $update_post_time, $poster_rg_id, $attach_rg_sig); + \TorrentPier\Legacy\Post::submit_post($mode, $post_data, $return_message, $return_meta, $forum_id, $topic_id, $post_id, $topic_type, DB()->escape($username), DB()->escape($subject), DB()->escape($message), $update_post_time, $poster_rg_id, $attach_rg_sig, (int)$robots_indexing); $post_url = POST_URL . "$post_id#$post_id"; $post_msg = ($mode == 'editpost') ? $lang['EDITED'] : $lang['STORED']; @@ -496,9 +500,14 @@ if (!IS_GUEST) { } } -// Topic type selection $topic_type_toggle = ''; if ($mode == 'newtopic' || ($mode == 'editpost' && $post_data['first_post'])) { + // Allow robots indexing + if (IS_AM) { + $template->assign_var('SHOW_ROBOTS_CHECKBOX'); + } + + // Topic type selection $template->assign_block_vars('switch_type_toggle', []); if ($is_auth['auth_sticky']) { @@ -613,11 +622,12 @@ $template->assign_vars([ 'MESSAGE' => $message, 'POSTER_RGROUPS' => !empty($poster_rgroups) ? $poster_rgroups : '', - 'ATTACH_RG_SIG' => ($switch_rg_sig) ?: false, + 'ATTACH_RG_SIG' => $switch_rg_sig ?: false, 'U_VIEWTOPIC' => ($mode == 'reply') ? TOPIC_URL . "$topic_id&postorder=desc" : '', - 'S_NOTIFY_CHECKED' => ($notify_user) ? 'checked' : '', + 'S_NOTIFY_CHECKED' => $notify_user ? 'checked' : '', + 'S_ROBOTS_CHECKED' => $robots_indexing ? 'checked' : '', 'S_TYPE_TOGGLE' => $topic_type_toggle, 'S_TOPIC_ID' => $topic_id, 'S_POST_ACTION' => POSTING_URL, diff --git a/src/Legacy/Post.php b/src/Legacy/Post.php index 8910738d5..f90724c39 100644 --- a/src/Legacy/Post.php +++ b/src/Legacy/Post.php @@ -90,10 +90,11 @@ class Post * @param bool $update_post_time * @param int $poster_rg_id * @param int $attach_rg_sig + * @param int $robots_indexing * * @return string */ - public static function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig) + public static function submit_post($mode, &$post_data, &$message, &$meta, &$forum_id, &$topic_id, &$post_id, &$topic_type, $post_username, $post_subject, $post_message, $update_post_time, $poster_rg_id, $attach_rg_sig, $robots_indexing) { global $userdata, $post_info, $is_auth, $bb_cfg, $lang, $datastore; @@ -140,9 +141,9 @@ class Post $sql_insert = " INSERT INTO - " . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type) + " . BB_TOPICS . " (topic_title, topic_poster, topic_time, forum_id, topic_status, topic_type, topic_dl_type, topic_allow_robots) VALUES - ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type) + ('$post_subject', " . $userdata['user_id'] . ", $current_time, $forum_id, " . TOPIC_UNLOCKED . ", $topic_type, $topic_dl_type, $robots_indexing) "; $sql_update = " @@ -151,7 +152,8 @@ class Post SET topic_title = '$post_subject', topic_type = $topic_type, - topic_dl_type = $topic_dl_type + topic_dl_type = $topic_dl_type, + topic_allow_robots = $robots_indexing WHERE topic_id = $topic_id "; diff --git a/styles/templates/default/posting.tpl b/styles/templates/default/posting.tpl index 303b785d9..be82acbf0 100644 --- a/styles/templates/default/posting.tpl +++ b/styles/templates/default/posting.tpl @@ -132,6 +132,12 @@ + + + + + + diff --git a/viewtopic.php b/viewtopic.php index 8e5a7cd8d..a9d674905 100644 --- a/viewtopic.php +++ b/viewtopic.php @@ -113,6 +113,9 @@ $topic_id = $t_data['topic_id']; $forum_id = $t_data['forum_id']; $topic_attachment = isset($t_data['topic_attachment']) ? (int)$t_data['topic_attachment'] : null; +// Allow robots indexing +$page_cfg['allow_robots'] = (bool)$t_data['topic_allow_robots']; + if ($t_data['allow_porno_topic'] && bf($userdata['user_opt'], 'user_opt', 'user_porn_forums')) { bb_die($lang['ERROR_PORNO_FORUM']); }