From 9dad93b90e2a56b663e2a4db184a379769d05d0f Mon Sep 17 00:00:00 2001 From: Retro_Guy Date: Mon, 18 Nov 2024 05:20:15 -0700 Subject: [PATCH] Style notifications of posting limits in post.php and use new_account time remaining if exists. --- Rocksolid_Light/common/themes/style.css | 17 +++++++++++++++++ Rocksolid_Light/rocksolid/post.php | 19 ++++++++++++++++--- 2 files changed, 33 insertions(+), 3 deletions(-) diff --git a/Rocksolid_Light/common/themes/style.css b/Rocksolid_Light/common/themes/style.css index 31f70b7..50db005 100644 --- a/Rocksolid_Light/common/themes/style.css +++ b/Rocksolid_Light/common/themes/style.css @@ -781,6 +781,23 @@ textarea.configuration { font-size: 0.6em; } +/* POST */ +.post_rate_limit_notice { + text-align: left; + font-size: 1.0em; +} + +.post_rate_limit_notice_limit_reached { + text-align: center; + font-size: 1.0em; +} + +.post_new_user_notice { + font-size: 0.9em; + font-style: italic; + color: var(--color-highlight); +} + /* Grouplist */ /* grouplist.php */ diff --git a/Rocksolid_Light/rocksolid/post.php b/Rocksolid_Light/rocksolid/post.php index cdafcf1..f7ded28 100644 --- a/Rocksolid_Light/rocksolid/post.php +++ b/Rocksolid_Light/rocksolid/post.php @@ -308,15 +308,18 @@ if ($type == "post") { // Does user have their own rate limit? $new_user_notice = ''; + $is_new = false; $rate_limit = get_user_config($name, 'rate_limit'); if (($rate_limit !== FALSE) && ($rate_limit > 0)) { $is_new = get_user_config($name, 'new_account'); if ($is_new == true) { $create_date = get_user_config($name, 'created'); if (isset($OVERRIDES['new_account_life']) && $create_date > (time() - ($OVERRIDES['new_account_life'] * 3600))) { // Account is new + $is_new = ($create_date - (time() - ($OVERRIDES['new_account_life'] * 3600))) / 60; // Time left before is NOT new $CONFIG['rate_limit'] = $rate_limit; - $new_user_notice = '

(posting is limited for ' . $OVERRIDES['new_account_life'] . ' hour(s) after account creation)
'; + $new_user_notice = '

(posting is limited for ' . $OVERRIDES['new_account_life'] . ' hour(s) after account creation)
'; } else { + $is_new = false; set_user_config($name, 'new_account', false); set_user_config($name, 'rate_limit', false); } @@ -326,10 +329,17 @@ if ($type == "post") { if ($CONFIG['rate_limit'] == true) { $postsremaining = check_rate_limit($name); if ($postsremaining < 1) { + $postsremaining = 0; $wait = check_rate_limit($name, 0, 1); - echo 'You have reached the limit of ' . $CONFIG['rate_limit'] . ' posts per hour.
Please wait ' . round($wait) . ' minutes before posting again.'; + if ($is_new != false && ($is_new < $wait)) { + $wait = $is_new; + } + echo '
'; + echo 'You have reached the limit of ' . $CONFIG['rate_limit'] . ' posts per hour.
Please wait ' . round($wait, 1) . ' minutes before posting again.'; echo $new_user_notice; echo '

' . $text_post["button_back"] . ' ' . $text_post["button_back2"] . ' ' . group_display_name($returngroup) . '

'; + echo '
'; + file_put_contents($logfile, "\n" . logging_prefix() . " POST Limit REACHED for: " . $name . ': ' . $postsremaining . ' posts remaining of ' . $CONFIG['rate_limit'], FILE_APPEND); return; } } @@ -365,12 +375,15 @@ if ($type == "post") { } if ($CONFIG['rate_limit'] == true) { $postsremaining = check_rate_limit($name, 1); + echo '
'; echo 'You have ' . $postsremaining . ' posts remaining of ' . $CONFIG['rate_limit'] . ' posts per hour.
'; + file_put_contents($logfile, "\n" . logging_prefix() . " POST Limit Checked for: " . $name . ': ' . $postsremaining . ' posts remaining of ' . $CONFIG['rate_limit'], FILE_APPEND); if ($postsremaining < 1) { $wait = check_rate_limit($name, 0, 1); - echo 'Please wait ' . round($wait) . ' minutes before posting again.
'; + echo 'Please wait ' . round($wait, 1) . ' minutes before posting again.
'; echo $new_user_notice; } + echo '
'; } echo '

Back

'; } else {