From 734e323dd56cdbd6615d406e22966f4d2bebeecd Mon Sep 17 00:00:00 2001 From: fuzzykitten Date: Wed, 4 Jun 2025 04:35:07 -0400 Subject: [PATCH] finished sub creation on navigation page --- etc/config.php | 3 ++- opt/admin.php | 4 ++-- opt/display.php | 23 ++++++++++++++++++++--- opt/post.php | 6 ++++++ opt/show.php | 11 ++++++----- srv/index.php | 23 +++++++++++++---------- 6 files changed, 49 insertions(+), 21 deletions(-) diff --git a/etc/config.php b/etc/config.php index dee8ffe..48aeb51 100644 --- a/etc/config.php +++ b/etc/config.php @@ -31,7 +31,8 @@ $settings = array( "unknown_words_bot_sub" => 'acme', // the sub to which the post should be made. "enable_blocklist_bot" => TRUE, // check if all words of a post are known, or not. Make a post if not. "blocklist_bot_sub" => 'acme', // the sub to which the post should be made. - "enable_sub_creation" => TRUE, // enable users to create subs by posting in main + "enable_sub_main" => TRUE, // enable users to create subs by posting in main + "enable_sub_navigation" => TRUE, // enable users to create subs by posting in main "enable_logging" => TRUE, // set to FALSE to disable all logs of endboard. This will provide stricter privacy, however, it will also // disable the features: max_post_*, bot_block, portal, max_requests_* and fail2ban. "enable_sage" => TRUE, // show the option to not bump a thread diff --git a/opt/admin.php b/opt/admin.php index 9fabc83..02e322c 100644 --- a/opt/admin.php +++ b/opt/admin.php @@ -1024,7 +1024,7 @@ function show_auth_form($db, $css, $settings, $type) function show_shadowed($db, $css, $settings, $token) { - print_top_header('Shadowed messages and subs'); + print_top_header($db, 'Shadowed messages and subs'); $statement = $db->prepare("SELECT post_id, org_id, sub, text FROM threads @@ -1335,7 +1335,7 @@ function view_mods($db, $css, $settings, $token) 'disabled')"); $result = $statement->execute(); - print_top_header('Moderators accounts'); + print_top_header($db, 'Moderators accounts'); $html_string = '' . '' diff --git a/opt/display.php b/opt/display.php index ab173c4..d192866 100644 --- a/opt/display.php +++ b/opt/display.php @@ -119,8 +119,7 @@ function blocklist_bot($text, $settings) $word_uppercase = strtoupper($word_filtered); if ( (in_array($word_uppercase, $blocked_words) ) && - (! empty($word_filtered) ) && - ($word == $word_filtered) ) { + (! empty($word_filtered) ) ) { array_push($blocked_found, $word); } } @@ -1176,8 +1175,26 @@ function print_sub($db, $sub, $css, $settings, $page) } // prints the fixed topheader with some text -function print_top_header($text) +function print_top_header($db, $text) { + $found_sub = FALSE; + $statement = $db->prepare("SELECT moderator, motto + FROM subs + WHERE name = ? + "); + $statement->bindParam(1, $text); + $result = $statement->execute(); + + while ($row = $result->fetchArray(SQLITE3_NUM)) { + $moderator = "{$row[0]}"; + $motto = "{$row[1]}"; + $found_sub = TRUE; + } + + if ( $found_sub == TRUE ){ + $text = $text . "-$motto-created by $moderator"; + } + echo "

$text

"; } diff --git a/opt/post.php b/opt/post.php index 32bc29f..63e852c 100644 --- a/opt/post.php +++ b/opt/post.php @@ -535,6 +535,12 @@ function make_post($db, $sub, $settings, $text, $org_id) $name = filter($parts[0], 'email', 20); $tripkey = filter($parts[1], 'alnum', 50); $tripcode = check_name($db, $name, $tripkey); + } elseif ( ( $settings['enable_tripcodes'] == TRUE ) && + (!empty($_POST['mod'])) && + (!empty($_POST['pass'])) ) { + $name = filter($_POST['mod'], 'email', 20); + $tripkey = filter($_POST['pass'], 'alnum', 50); + $tripcode = check_name($db, $name, $tripkey); } else { $name = ''; $tripcode = ''; diff --git a/opt/show.php b/opt/show.php index 3e07135..b6b03cc 100644 --- a/opt/show.php +++ b/opt/show.php @@ -141,8 +141,7 @@ function show_edit_form($db, $sub, $post_id, $ip, $css, $settings) // Show the form that allows create a new sub. function show_create_sub_form($db, $settings, $sub, $ip, $css) { -//REWRITE - if ( ($settings['enable_sub_creation'] != TRUE) ) { + if ( ($settings['enable_sub_navigation'] != TRUE) ) { return; } @@ -261,7 +260,7 @@ function show_post_form($db, $msg, $sub, $settings, $org_id, $css, $quote, $ip) if ( (!$org_id) && ($sub == 'main') && - ($settings['enable_sub_creation'] == TRUE) ) { + ($settings['enable_sub_main'] == TRUE) ) { $html_string .= ""; echo ""; - echo ""; echo "
Account nameContactStatusEnable
"; } @@ -446,8 +445,10 @@ function show_settings($settings){ . $settings['site_name'] . "
Default css" . $settings['default_css'] . "
Enable creation of subs"; - var_export($settings['enable_sub_creation']); + echo "
Enable creation of subs on main"; + var_export($settings['enable_sub_main']); + echo "
Enable creation of subs via navigation"; + var_export($settings['enable_sub_navigation']); echo "
Enable sage"; var_export($settings['enable_sage']); diff --git a/srv/index.php b/srv/index.php index b88855e..a6743a7 100644 --- a/srv/index.php +++ b/srv/index.php @@ -437,7 +437,7 @@ switch($mode) { $org_id = reset_org_id($db, $sub, $post_id); if (empty($_POST['edit_text'])) { - print_top_header("Edit post $sub/$post_id"); + print_top_header($db, "Edit post $sub/$post_id"); show_edit_form($db, $sub, $post_id, $visitor_ip, $css, $settings); show_post_history($db, $sub, $post_id, $settings); } else { @@ -524,7 +524,7 @@ switch($mode) { echo "$title"; - print_top_header("Multifeed ($description)"); + print_top_header($db, "Multifeed ($description)"); echo '

'; $total_posts = print_individual_feed($db, $css, $settings, @@ -599,7 +599,10 @@ switch($mode) { log_event($db, $settings, 'user', $post_block_message, $visitor_ip); header( 'HTTP/1.1 429 Too Many Requests' ); quit($db, '429'); - } + } elseif ( check_sub_exists($db, $sub) == TRUE ) { + quit($db, "

Sub '$sub' exists already.

"); + } + check_captcha($db, $settings); @@ -609,10 +612,10 @@ switch($mode) { $post_id = make_post($db, $sub, $settings, $text, $org_id); $appl_name = filter($_POST['mod'], 'alnum', 30); - $appl_pass = $_POST['pass']; + $appl_pass = password_hash($_POST['pass'], PASSWORD_DEFAULT); set_application($db, $appl_name, '', - $appl_password, $sub, $settings); + $appl_pass, $sub, $settings); $appl_motto = strip_tags($_POST['motto']); $appl_css = filter($_POST['sub_css'], 'alnum', 20); @@ -753,7 +756,7 @@ switch($mode) { $quote = set_quote(); $msg = ($sub . '/' . $org_id); - print_top_header("$msg"); + print_top_header($db, "$msg"); echo '

'; @@ -806,9 +809,9 @@ switch($mode) { print_footer_admin($css, $settings, $token); quit($db, ""); - // displays all subs, including their message counts + // displays all subs, and other navigational helps case 'subs': - echo 'available subs'; + echo 'navigation'; show_subs_count($db, $css, $settings); show_set_feeds_form($db, $settings, $css); show_create_sub_form($db, $settings, $sub, $ip, $css); @@ -862,7 +865,7 @@ switch($mode) { if ( $sub == 'overboard' ) { $title = $settings['title']; } else { - $title = "sub/$sub"; + $title = "s/$sub"; } echo "$title"; @@ -875,7 +878,7 @@ switch($mode) { quit($db, "

Not enough posts to display page = $page...!

"); } - print_top_header("$sub"); + print_top_header($db, "$sub"); echo '

'; lay_trap($settings);