Add TINYIB_WORDBREAK - resolves #60
This commit is contained in:
parent
e4488c9189
commit
c8d4d2c4c1
5 changed files with 29 additions and 10 deletions
16
imgboard.php
16
imgboard.php
|
@ -86,19 +86,25 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||
}
|
||||
|
||||
$post = newPost(setParent());
|
||||
$rawposttext = '';
|
||||
|
||||
$post['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
|
||||
list($post['name'], $post['tripcode']) = nameAndTripcode($_POST['name']);
|
||||
|
||||
$post['name'] = cleanString(substr($post['name'], 0, 75));
|
||||
$post['email'] = cleanString(str_replace('"', '"', substr($_POST['email'], 0, 75)));
|
||||
$post['subject'] = cleanString(substr($_POST['subject'], 0, 75));
|
||||
$post['message'] = $_POST['message'];
|
||||
if ($rawpost) {
|
||||
// Treat message as raw HTML
|
||||
$rawposttext = ($isadmin) ? ' <span style="color: red;">## Admin</span>' : ' <span style="color: purple;">## Mod</span>';
|
||||
$post['message'] = $_POST['message']; // Treat message as raw HTML
|
||||
} else {
|
||||
$rawposttext = '';
|
||||
$post['message'] = str_replace("\n", '<br>', makeLinksClickable(colorQuote(postLink(cleanString(rtrim($_POST['message']))))));
|
||||
if (TINYIB_WORDBREAK > 0) {
|
||||
$post['message'] = preg_replace('/([^\s]{' . TINYIB_WORDBREAK . '})(?=[^\s])/', '$1'.TINYIB_WORDBREAK_IDENTIFIER, $post['message']);
|
||||
}
|
||||
$post['message'] = str_replace("\n", '<br>', makeLinksClickable(colorQuote(postLink(cleanString(rtrim($post['message']))))));
|
||||
if (TINYIB_WORDBREAK > 0) {
|
||||
$post['message'] = finishWordBreak($post['message']);
|
||||
}
|
||||
}
|
||||
$post['password'] = ($_POST['password'] != '') ? md5(md5($_POST['password'])) : '';
|
||||
$post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time(), $rawposttext);
|
||||
|
|
|
@ -6,6 +6,7 @@ if (!defined('TINYIB_BOARD')) {
|
|||
define('TINYIB_NEWTHREAD', '0');
|
||||
define('TINYIB_INDEXPAGE', false);
|
||||
define('TINYIB_RESPAGE', true);
|
||||
define('TINYIB_WORDBREAK_IDENTIFIER', '@!@TINYIB_WORDBREAK@!@');
|
||||
|
||||
// The following are provided for backward compatibility and should not be relied upon
|
||||
// Copy new settings from settings.default.php to settings.php
|
||||
|
@ -36,6 +37,9 @@ if (!defined('TINYIB_REQMOD')) {
|
|||
if (!defined('TINYIB_ALWAYSNOKO')) {
|
||||
define('TINYIB_ALWAYSNOKO', false);
|
||||
}
|
||||
if (!defined('TINYIB_WORDBREAK')) {
|
||||
define('TINYIB_WORDBREAK', 0);
|
||||
}
|
||||
if (!defined('TINYIB_TIMEZONE')) {
|
||||
define('TINYIB_TIMEZONE', '');
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ if (TINYIB_DBMODE == 'pdo' && TINYIB_DBDRIVER == 'pgsql') {
|
|||
CREATE INDEX ON "' . TINYIB_DBPOSTS . '"("bumped");
|
||||
CREATE INDEX ON "' . TINYIB_DBPOSTS . '"("stickied");
|
||||
CREATE INDEX ON "' . TINYIB_DBPOSTS . '"("moderated");';
|
||||
|
||||
|
||||
$bans_sql = 'CREATE TABLE "' . TINYIB_DBBANS . '" (
|
||||
"id" bigserial NOT NULL,
|
||||
"ip" varchar(39) NOT NULL,
|
||||
|
@ -77,7 +77,7 @@ if (TINYIB_DBMODE == 'pdo' && TINYIB_DBDRIVER == 'pgsql') {
|
|||
KEY `stickied` (`stickied`),
|
||||
KEY `moderated` (`moderated`)
|
||||
)";
|
||||
|
||||
|
||||
$bans_sql = "CREATE TABLE `" . TINYIB_DBBANS . "` (
|
||||
`id` mediumint(7) unsigned NOT NULL auto_increment,
|
||||
`ip` varchar(39) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,
|
||||
|
@ -90,8 +90,8 @@ if (TINYIB_DBMODE == 'pdo' && TINYIB_DBDRIVER == 'pgsql') {
|
|||
}
|
||||
|
||||
function cleanString($string) {
|
||||
$search = array("<", ">");
|
||||
$replace = array("<", ">");
|
||||
$search = array("&", "<", ">");
|
||||
$replace = array("&", "<", ">");
|
||||
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
@ -249,6 +249,14 @@ function postLink($message) {
|
|||
return preg_replace_callback('/>>([0-9]+)/', '_postLink', $message);
|
||||
}
|
||||
|
||||
function _finishWordBreak($matches) {
|
||||
return '<a' . $matches[1] . 'href="' . str_replace(TINYIB_WORDBREAK_IDENTIFIER, '', $matches[2]) . '"' . $matches[3] . '>' . str_replace(TINYIB_WORDBREAK_IDENTIFIER, '<br>', $matches[4]) . '</a>';
|
||||
}
|
||||
|
||||
function finishWordBreak($message) {
|
||||
return str_replace(TINYIB_WORDBREAK_IDENTIFIER, '<br>', preg_replace_callback('/<a(.*?)href="([^"]*?)"(.*?)>(.*?)<\/a>/', '_finishWordBreak', $message));
|
||||
}
|
||||
|
||||
function colorQuote($message) {
|
||||
if (substr($message, -1, 1) != "\n") {
|
||||
$message .= "\n";
|
||||
|
|
|
@ -74,7 +74,7 @@ function buildPostForm($parent, $raw_post = false) {
|
|||
global $tinyib_uploads, $tinyib_embeds;
|
||||
|
||||
$form_action = 'imgboard.php';
|
||||
$form_extra = '<input type="hidden" name="parent" value="' . $parent . '"">';
|
||||
$form_extra = '<input type="hidden" name="parent" value="' . $parent . '">';
|
||||
$input_extra = '';
|
||||
$rules_extra = '';
|
||||
if ($raw_post) {
|
||||
|
|
|
@ -25,6 +25,7 @@ define('TINYIB_LOGO', ''); // Logo HTML
|
|||
define('TINYIB_THREADSPERPAGE', 10); // Amount of threads shown per index page
|
||||
define('TINYIB_PREVIEWREPLIES', 3); // Amount of replies previewed on index pages
|
||||
define('TINYIB_TRUNCATE', 15); // Messages are truncated to this many lines on board index pages [0 to disable]
|
||||
define('TINYIB_WORDBREAK', 80); // Words longer than this many characters will be broken apart [0 to disable]
|
||||
define('TINYIB_TIMEZONE', 'UTC'); // See https://secure.php.net/manual/en/timezones.php - e.g. America/Los_Angeles
|
||||
|
||||
// Post control
|
||||
|
|
Loading…
Reference in a new issue