finished sub creation on navigation page

main
fuzzykitten 2025-06-04 04:35:07 -04:00
parent d260c58010
commit 734e323dd5
6 changed files with 49 additions and 21 deletions

View File

@ -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

View File

@ -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 = '<table><tr><td>Account name</td><td>Contact</td>'
. '<td>Status</td><td>Enable</td>'

View File

@ -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 "<div class=\"header id=\"topheader\"><h1>$text</h1></div>";
}

View File

@ -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 = '';

View File

@ -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 .= "<tr><td><input type='text' name='sub' value='$sub' "
. "placeholder='name of sub'>";
}
@ -446,8 +445,10 @@ function show_settings($settings){
. $settings['site_name'] . "</td></tr>";
echo "<tr><td>Default css</td><td>"
. $settings['default_css'] . "</td></tr>";
echo "<tr><td>Enable creation of subs</td><td>";
var_export($settings['enable_sub_creation']);
echo "<tr><td>Enable creation of subs on main</td><td>";
var_export($settings['enable_sub_main']);
echo "<tr><td>Enable creation of subs via navigation</td><td>";
var_export($settings['enable_sub_navigation']);
echo "</td></tr>";
echo "<tr><td>Enable sage</td><td>";
var_export($settings['enable_sage']);

View File

@ -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>$title</title>";
print_top_header("Multifeed ($description)");
print_top_header($db, "Multifeed ($description)");
echo '<p id="page">';
$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, "<h3>Sub '$sub' exists already.</h3>");
}
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 '<p id="page">';
@ -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 '<title>available subs</title>';
echo '<title>navigation</title>';
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>$title</title>";
@ -875,7 +878,7 @@ switch($mode) {
quit($db, "<h1>Not enough posts to display page = $page...!</h1>");
}
print_top_header("$sub");
print_top_header($db, "$sub");
echo '<p id="page">';
lay_trap($settings);