From 066613d55c7803b08dbef2bd6d6741df53feeece Mon Sep 17 00:00:00 2001 From: Trevor Slocum Date: Sun, 31 Jan 2021 00:09:51 -0800 Subject: [PATCH] Add default name (or names) setting for anonymous posters Resolves #171. --- imgboard.php | 8 +++++++- inc/defines.php | 3 +++ inc/functions.php | 5 ++++- inc/html.php | 2 +- settings.default.php | 1 + 5 files changed, 16 insertions(+), 3 deletions(-) diff --git a/imgboard.php b/imgboard.php index 3110541..39c236f 100644 --- a/imgboard.php +++ b/imgboard.php @@ -237,7 +237,7 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) } $post = newPost(setParent()); - + if (!$loggedin) { if ($post['parent'] == TINYIB_NEWTHREAD && TINYIB_DISALLOWTHREADS != '') { fancyDie(TINYIB_DISALLOWTHREADS); @@ -257,7 +257,13 @@ if (!isset($_GET['delete']) && !isset($_GET['manage']) && (isset($_POST['name']) } } + if ($post['name'] == '' && $post['tripcode'] == '') { + global $tinyib_anonymous; + $post['name'] = $tinyib_anonymous[array_rand($tinyib_anonymous)]; + } + $post['ip'] = $_SERVER['REMOTE_ADDR']; + if ($rawpost || !in_array('name', $hide_fields)) { list($post['name'], $post['tripcode']) = nameAndTripcode($_POST['name']); $post['name'] = cleanString(substr($post['name'], 0, 75)); diff --git a/inc/defines.php b/inc/defines.php index a177cff..4c74320 100644 --- a/inc/defines.php +++ b/inc/defines.php @@ -137,6 +137,9 @@ if (!isset($tinyib_embeds)) { $tinyib_embeds['YouTube'] = 'https://www.youtube.com/oembed?url=TINYIBEMBED&format=json'; } } +if (!isset($tinyib_anonymous)) { + $tinyib_anonymous = array('Anonymous'); +} if (!isset($tinyib_capcodes)) { $tinyib_capcodes = array(array('Admin', 'red'), array('Mod', 'purple')); } diff --git a/inc/functions.php b/inc/functions.php index 0bb911b..75aaf5a 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -131,8 +131,11 @@ function nameAndTripcode($name) { } function nameBlock($name, $tripcode, $email, $timestamp, $rawposttext) { + global $tinyib_anonymous; + $anonymous = $tinyib_anonymous[array_rand($tinyib_anonymous)]; + $output = ''; - $output .= ($name == '' && $tripcode == '') ? __('Anonymous') : $name; + $output .= ($name == '' && $tripcode == '') ? $anonymous : $name; if ($tripcode != '') { $output .= '!' . $tripcode; diff --git a/inc/html.php b/inc/html.php index b98ea85..ff9e484 100644 --- a/inc/html.php +++ b/inc/html.php @@ -1236,7 +1236,7 @@ function encodeJSON($array) { function buildSinglePostJSON($post) { $name = $post['name']; if ($name == '') { - $name = __('Anonymous'); + $name = 'Anonymous'; } $output = array('id' => $post['id'], 'parent' => $post['parent'], 'timestamp' => $post['timestamp'], 'bumped' => $post['bumped'], 'name' => $name, 'tripcode' => $post['tripcode'], 'subject' => $post['subject'], 'message' => $post['message'], 'file' => $post['file'], 'file_hex' => $post['file_hex'], 'file_original' => $post['file_original'], 'file_size' => $post['file_size'], 'file_size_formated' => $post['file_size_formatted'], 'image_width' => $post['image_width'], 'image_height' => $post['image_height'], 'thumb' => $post['thumb'], 'thumb_width' => $post['thumb_width'], 'thumb_height' => $post['thumb_height']); diff --git a/settings.default.php b/settings.default.php index ce9591e..ca57d2d 100644 --- a/settings.default.php +++ b/settings.default.php @@ -43,6 +43,7 @@ define('TINYIB_JSON', true); // Generate JSON files define('TINYIB_DATEFMT', '%g/%m/%d(%a)%H:%M:%S'); // Date and time format (see php.net/strftime) $tinyib_hidefieldsop = array(); // Fields to hide when creating a new thread - e.g. array('name', 'email', 'subject', 'message', 'file', 'embed', 'password') $tinyib_hidefields = array(); // Fields to hide when replying +$tinyib_anonymous = array('Anonymous'); // Default name (or names) $tinyib_capcodes = array(array('Admin', 'red'), array('Mod', 'purple')); // Administrator and moderator capcode label and color // Post control