parent
c8d4d2c4c1
commit
7446ac644d
|
@ -1,4 +1,4 @@
|
|||
# TinyIB [![Donate](http://img.shields.io/liberapay/receives/rocketnine.space.svg?logo=liberapay)](https://liberapay.com/rocketnine.space/donate)
|
||||
# TinyIB [![Donate](http://img.shields.io/liberapay/receives/rocketnine.space.svg?logo=liberapay)](https://liberapay.com/rocketnine.space)
|
||||
|
||||
A lightweight and efficient [image board](https://en.wikipedia.org/wiki/Imageboard). See [TinyIB Installations](https://gitlab.com/tslocum/tinyib/wikis/Home) for demos.
|
||||
|
||||
|
|
49
imgboard.php
49
imgboard.php
|
@ -78,6 +78,7 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||
|
||||
list($loggedin, $isadmin) = manageCheckLogIn();
|
||||
$rawpost = isRawPost();
|
||||
$rawposttext = '';
|
||||
if (!$loggedin) {
|
||||
checkCAPTCHA();
|
||||
checkBanned();
|
||||
|
@ -86,30 +87,40 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||
}
|
||||
|
||||
$post = newPost(setParent());
|
||||
$rawposttext = '';
|
||||
$hide_fields = $post['parent'] == TINYIB_NEWTHREAD ? TINYIB_HIDEFIELDSOP : TINYIB_HIDEFIELDS;
|
||||
|
||||
$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>';
|
||||
} else {
|
||||
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']);
|
||||
if ($rawpost || !in_array('name', $hide_fields)) {
|
||||
list($post['name'], $post['tripcode']) = nameAndTripcode($_POST['name']);
|
||||
$post['name'] = cleanString(substr($post['name'], 0, 75));
|
||||
}
|
||||
if ($rawpost || !in_array('email', $hide_fields)) {
|
||||
$post['email'] = cleanString(str_replace('"', '"', substr($_POST['email'], 0, 75)));
|
||||
}
|
||||
if ($rawpost || !in_array('subject', $hide_fields)) {
|
||||
$post['subject'] = cleanString(substr($_POST['subject'], 0, 75));
|
||||
}
|
||||
if ($rawpost || !in_array('message', $hide_fields)) {
|
||||
$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>';
|
||||
} else {
|
||||
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'])) : '';
|
||||
if ($rawpost || !in_array('password', $hide_fields)) {
|
||||
$post['password'] = ($_POST['password'] != '') ? md5(md5($_POST['password'])) : '';
|
||||
}
|
||||
$post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time(), $rawposttext);
|
||||
|
||||
if (isset($_POST['embed']) && trim($_POST['embed']) != '') {
|
||||
if (isset($_POST['embed']) && trim($_POST['embed']) != '' && ($rawpost || !in_array('embed', $hide_fields))) {
|
||||
list($service, $embed) = getEmbed(trim($_POST['embed']));
|
||||
if (empty($embed) || !isset($embed['html']) || !isset($embed['title']) || !isset($embed['thumbnail_url'])) {
|
||||
fancyDie("Invalid embed URL. Only " . (implode("/", array_keys($tinyib_embeds))) . " URLs are supported.");
|
||||
|
@ -150,7 +161,7 @@ if (isset($_POST['message']) || isset($_POST['file'])) {
|
|||
|
||||
$post['file_original'] = cleanString($embed['title']);
|
||||
$post['file'] = str_ireplace(array('src="https://', 'src="http://'), 'src="//', $embed['html']);
|
||||
} else if (isset($_FILES['file'])) {
|
||||
} else if (isset($_FILES['file']) && ($rawpost || !in_array('file', $hide_fields))) {
|
||||
if ($_FILES['file']['name'] != "") {
|
||||
validateFileUpload();
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ define('TINYIB_WORDBREAK_IDENTIFIER', '@!@TINYIB_WORDBREAK@!@');
|
|||
if (!defined('TINYIB_INDEX')) {
|
||||
define('TINYIB_INDEX', 'index.html');
|
||||
}
|
||||
if (!defined('TINYIB_HIDEFIELDSOP')) {
|
||||
define('TINYIB_HIDEFIELDSOP', array());
|
||||
}
|
||||
if (!defined('TINYIB_HIDEFIELDS')) {
|
||||
define('TINYIB_HIDEFIELDS', array());
|
||||
}
|
||||
if (!defined('TINYIB_MAXREPLIES')) {
|
||||
define('TINYIB_MAXREPLIES', 0);
|
||||
}
|
||||
|
|
36
inc/html.php
36
inc/html.php
|
@ -72,6 +72,7 @@ function makeLinksClickable($text) {
|
|||
|
||||
function buildPostForm($parent, $raw_post = false) {
|
||||
global $tinyib_uploads, $tinyib_embeds;
|
||||
$hide_fields = $parent == TINYIB_NEWTHREAD ? TINYIB_HIDEFIELDSOP : TINYIB_HIDEFIELDS;
|
||||
|
||||
$form_action = 'imgboard.php';
|
||||
$form_extra = '<input type="hidden" name="parent" value="' . $parent . '">';
|
||||
|
@ -90,7 +91,7 @@ function buildPostForm($parent, $raw_post = false) {
|
|||
</td>
|
||||
</tr>
|
||||
EOF;
|
||||
$rules_extra = <<<EOF
|
||||
$rules_extra = <<<EOF
|
||||
<ul>
|
||||
<li>Text entered in the Message field will be posted as is with no formatting applied.</li>
|
||||
<li>Line-breaks must be specified with "<br>".</li>
|
||||
|
@ -143,7 +144,7 @@ EOF;
|
|||
EOF;
|
||||
}
|
||||
|
||||
if (!empty($tinyib_uploads)) {
|
||||
if (!empty($tinyib_uploads) && ($raw_post || !in_array('file', $hide_fields))) {
|
||||
if (TINYIB_MAXKB > 0) {
|
||||
$max_file_size_input_html = '<input type="hidden" name="MAX_FILE_SIZE" value="' . strval(TINYIB_MAXKB * 1024) . '">';
|
||||
$max_file_size_rules_html = '<li>Maximum file size allowed is ' . TINYIB_MAXKBDESC . '.</li>';
|
||||
|
@ -163,7 +164,7 @@ EOF;
|
|||
EOF;
|
||||
}
|
||||
|
||||
if (!empty($tinyib_embeds)) {
|
||||
if (!empty($tinyib_embeds) && ($raw_post || !in_array('embed', $hide_fields))) {
|
||||
$embed_input_html = <<<EOF
|
||||
<tr>
|
||||
<td class="postblock">
|
||||
|
@ -195,7 +196,7 @@ EOF;
|
|||
$unique_posts_html = "<li>Currently $unique_posts unique user posts.</li>\n";
|
||||
}
|
||||
|
||||
return <<<EOF
|
||||
$output = <<<EOF
|
||||
<div class="postarea">
|
||||
<form name="postform" id="postform" action="$form_action" method="post" enctype="multipart/form-data">
|
||||
$max_file_size_input_html
|
||||
|
@ -203,6 +204,9 @@ EOF;
|
|||
<table class="postform">
|
||||
<tbody>
|
||||
$input_extra
|
||||
EOF;
|
||||
if ($raw_post || !in_array('name', $hide_fields)) {
|
||||
$output .= <<<EOF
|
||||
<tr>
|
||||
<td class="postblock">
|
||||
Name
|
||||
|
@ -211,6 +215,10 @@ EOF;
|
|||
<input type="text" name="name" size="28" maxlength="75" accesskey="n">
|
||||
</td>
|
||||
</tr>
|
||||
EOF;
|
||||
}
|
||||
if ($raw_post || !in_array('email', $hide_fields)) {
|
||||
$output .= <<<EOF
|
||||
<tr>
|
||||
<td class="postblock">
|
||||
E-mail
|
||||
|
@ -219,6 +227,10 @@ EOF;
|
|||
<input type="text" name="email" size="28" maxlength="75" accesskey="e">
|
||||
</td>
|
||||
</tr>
|
||||
EOF;
|
||||
}
|
||||
if ($raw_post || !in_array('subject', $hide_fields)) {
|
||||
$output .= <<<EOF
|
||||
<tr>
|
||||
<td class="postblock">
|
||||
Subject
|
||||
|
@ -228,6 +240,10 @@ EOF;
|
|||
<input type="submit" value="Submit" accesskey="z">
|
||||
</td>
|
||||
</tr>
|
||||
EOF;
|
||||
}
|
||||
if ($raw_post || !in_array('message', $hide_fields)) {
|
||||
$output .= <<<EOF
|
||||
<tr>
|
||||
<td class="postblock">
|
||||
Message
|
||||
|
@ -236,9 +252,16 @@ EOF;
|
|||
<textarea id="message" name="message" cols="48" rows="4" accesskey="m"></textarea>
|
||||
</td>
|
||||
</tr>
|
||||
EOF;
|
||||
}
|
||||
|
||||
$output .= <<<EOF
|
||||
$captcha_html
|
||||
$file_input_html
|
||||
$embed_input_html
|
||||
EOF;
|
||||
if ($raw_post || !in_array('password', $hide_fields)) {
|
||||
$output .= <<<EOF
|
||||
<tr>
|
||||
<td class="postblock">
|
||||
Password
|
||||
|
@ -247,6 +270,9 @@ EOF;
|
|||
<input type="password" name="password" id="newpostpassword" size="8" accesskey="p"> (for post and file deletion)
|
||||
</td>
|
||||
</tr>
|
||||
EOF;
|
||||
}
|
||||
$output .= <<<EOF
|
||||
<tr>
|
||||
<td colspan="2" class="rules">
|
||||
$rules_extra
|
||||
|
@ -264,6 +290,8 @@ EOF;
|
|||
</form>
|
||||
</div>
|
||||
EOF;
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function buildPost($post, $res) {
|
||||
|
|
|
@ -22,6 +22,8 @@ define('TINYIB_REQMOD', ''); // Require moderation before displaying po
|
|||
// Board appearance
|
||||
define('TINYIB_INDEX', 'index.html'); // Index file
|
||||
define('TINYIB_LOGO', ''); // Logo HTML
|
||||
define('TINYIB_HIDEFIELDSOP',array());// Fields to hide when creating a new thread - e.g. array('name', 'email', 'subject', 'message', 'file', 'embed', 'password')
|
||||
define('TINYIB_HIDEFIELDS', array()); // Fields to hide when replying
|
||||
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]
|
||||
|
|
Loading…
Reference in New Issue