diff --git a/imgboard.php b/imgboard.php
index b7123ba..875402a 100644
--- a/imgboard.php
+++ b/imgboard.php
@@ -48,7 +48,7 @@ if (TINYIB_TRIPSEED == '' || TINYIB_ADMINPASS == '') {
$redirect = true;
// Check if the request is to make a post
-if (isset($_POST["message"]) || isset($_POST["file"])) {
+if (isset($_POST['message']) || isset($_POST['file'])) {
list($loggedin, $isadmin) = manageCheckLogIn();
$rawpost = isRawPost();
if (!$loggedin) {
@@ -60,25 +60,19 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
$post = newPost(setParent());
$post['ip'] = $_SERVER['REMOTE_ADDR'];
- list($post['name'], $post['tripcode']) = nameAndTripcode($_POST["name"]);
+ 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['email'] = cleanString(str_replace('"', '"', substr($_POST['email'], 0, 75)));
+ $post['subject'] = cleanString(substr($_POST['subject'], 0, 75));
if ($rawpost) {
$rawposttext = ($isadmin) ? ' ## Admin' : ' ## Mod';
- $post['message'] = $_POST["message"]; // Treat message as raw HTML
+ $post['message'] = $_POST['message']; // Treat message as raw HTML
} else {
$rawposttext = '';
- $post['message'] = str_replace("\n", "
", colorQuote(postLink(cleanString(rtrim($_POST["message"])))));
+ $post['message'] = str_replace("\n", '
', colorQuote(postLink(cleanString(rtrim($_POST['message'])))));
}
$post['password'] = ($_POST['password'] != '') ? md5(md5($_POST['password'])) : '';
- if (strtolower($post['email']) == "noko") {
- $post['email'] = '';
- $noko = true;
- } else {
- $noko = false;
- }
$post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time(), $rawposttext);
if (isset($_FILES['file'])) {
@@ -153,7 +147,7 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
}
$post['id'] = insertPost($post);
- if ($noko) {
+ if (strtolower($post['email']) == 'noko') {
$redirect = 'res/' . ($post['parent'] == TINYIB_NEWTHREAD ? $post['id'] : $post['parent']) . '.html#' . $post['id'];
}
trimThreads();
@@ -161,7 +155,7 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
if ($post['parent'] != TINYIB_NEWTHREAD) {
rebuildThread($post['parent']);
- if (strtolower($post['email']) != "sage") {
+ if (strtolower($post['email']) != 'sage') {
bumpThreadByID($post['parent']);
}
} else {
@@ -172,31 +166,30 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
rebuildIndexes();
// Check if the request is to delete a post and/or its associated image
} elseif (isset($_GET['delete']) && !isset($_GET['manage'])) {
- if (isset($_POST['delete'])) {
- $post = postByID($_POST['delete']);
- if ($post) {
- list($loggedin, $isadmin) = manageCheckLogIn();
-
- if ($loggedin && $_POST['password'] == '') {
- // Redirect to post moderation page
- echo '--> --> -->';
- } elseif ($post['password'] != '' && md5(md5($_POST['password'])) == $post['password']) {
- deletePostByID($post['id']);
- if ($post['parent'] == TINYIB_NEWTHREAD) { threadUpdated($post['id']); } else { threadUpdated($post['parent']); }
- fancyDie('Post deleted.');
- } else {
- fancyDie('Invalid password.');
- }
+ if (!isset($_POST['delete'])) { fancyDie('Tick the box next to a post and click "Delete" to delete it.'); }
+
+ $post = postByID($_POST['delete']);
+ if ($post) {
+ list($loggedin, $isadmin) = manageCheckLogIn();
+
+ if ($loggedin && $_POST['password'] == '') {
+ // Redirect to post moderation page
+ echo '--> --> -->';
+ } elseif ($post['password'] != '' && md5(md5($_POST['password'])) == $post['password']) {
+ deletePostByID($post['id']);
+ if ($post['parent'] == TINYIB_NEWTHREAD) { threadUpdated($post['id']); } else { threadUpdated($post['parent']); }
+ fancyDie('Post deleted.');
} else {
- fancyDie('Sorry, an invalid post identifier was sent. Please go back, refresh the page, and try again.');
+ fancyDie('Invalid password.');
}
} else {
- fancyDie('Tick the box next to a post and click "Delete" to delete it.');
+ fancyDie('Sorry, an invalid post identifier was sent. Please go back, refresh the page, and try again.');
}
+
$redirect = false;
// Check if the request is to access the management area
-} elseif (isset($_GET["manage"])) {
- $text = ""; $onload = ""; $navbar = " ";
+} elseif (isset($_GET['manage'])) {
+ $text = ''; $onload = ''; $navbar = ' ';
$redirect = false; $loggedin = false; $isadmin = false;
$returnlink = basename($_SERVER['PHP_SELF']);
@@ -204,14 +197,14 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
if ($loggedin) {
if ($isadmin) {
- if (isset($_GET["rebuildall"])) {
+ if (isset($_GET['rebuildall'])) {
$allthreads = allThreads();
foreach ($allthreads as $thread) {
- rebuildThread($thread["id"]);
+ rebuildThread($thread['id']);
}
rebuildIndexes();
$text .= manageInfo('Rebuilt board.');
- } elseif (isset($_GET["bans"])) {
+ } elseif (isset($_GET['bans'])) {
clearExpiredBans();
if (isset($_POST['ip'])) {
@@ -243,7 +236,7 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
}
}
- if (isset($_GET["delete"])) {
+ if (isset($_GET['delete'])) {
$post = postByID($_GET['delete']);
if ($post) {
deletePostByID($post['id']);
@@ -255,7 +248,7 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
} else {
fancyDie("Sorry, there doesn't appear to be a post with that ID.");
}
- } elseif (isset($_GET["moderate"])) {
+ } elseif (isset($_GET['moderate'])) {
if ($_GET['moderate'] > 0) {
$post = postByID($_GET['moderate']);
if ($post) {
@@ -284,7 +277,7 @@ if (isset($_POST["message"]) || isset($_POST["file"])) {
}
echo managePage($text, $onload);
-} elseif (!file_exists('index.html') || count(allThreads()) == 0) {
+} elseif (!file_exists('index.html') || countThreads() == 0) {
rebuildIndexes();
}
@@ -292,4 +285,4 @@ if ($redirect) {
echo '--> --> -->';
}
-?>
\ No newline at end of file
+?>
diff --git a/inc/database_flatfile.php b/inc/database_flatfile.php
index e5a6570..1d494bd 100644
--- a/inc/database_flatfile.php
+++ b/inc/database_flatfile.php
@@ -40,7 +40,7 @@ $db->datadir = 'inc/flatfile/';
# Post Functions
function uniquePosts() {
- return 0;
+ return 0; // Unsupported by this database option
}
function postByID($id) {
@@ -258,4 +258,4 @@ function deleteBanByID($id) {
$GLOBALS['db']->deleteWhere(BANS_FILE, new SimpleWhereClause(BAN_ID, '=', $id, INTEGER_COMPARISON));
}
-?>
\ No newline at end of file
+?>
diff --git a/inc/functions.php b/inc/functions.php
index 6d16ea7..02b0c1d 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -111,15 +111,15 @@ function nameAndTripcode($name) {
function nameBlock($name, $tripcode, $email, $timestamp, $rawposttext) {
$output = '';
- $output .= ($name == "" && $tripcode == "") ? "Anonymous" : $name;
+ $output .= ($name == '' && $tripcode == '') ? 'Anonymous' : $name;
- if ($tripcode != "") {
+ if ($tripcode != '') {
$output .= '!' . $tripcode;
}
$output .= '';
- if ($email != "") {
+ if ($email != '' && strtolower($email) != 'noko') {
$output = '' . $output . '';
}
@@ -371,4 +371,4 @@ function strallpos($haystack, $needle, $offset = 0) {
return $result;
}
-?>
\ No newline at end of file
+?>
diff --git a/inc/html.php b/inc/html.php
index 23c7a5f..3c73951 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -64,8 +64,8 @@ EOF;
EOF;
- if ($post["subject"] != "") {
- $return .= " ${post["subject"]} ";
+ if ($post['subject'] != '') {
+ $return .= ' ' . ${post['subject']} . ' ';
}
$return .= <<Reply]";
}
- if (TINYIB_TRUNCATE > 0 && !$res && substr_count($post['message'], "
") > TINYIB_TRUNCATE) { // Truncate messages on board index pages for readability
- $br_offsets = strallpos($post['message'], "
");
+ if (TINYIB_TRUNCATE > 0 && !$res && substr_count($post['message'], '
') > TINYIB_TRUNCATE) { // Truncate messages on board index pages for readability
+ $br_offsets = strallpos($post['message'], '
');
$post['message'] = substr($post['message'], 0, $br_offsets[TINYIB_TRUNCATE - 1]);
$post['message'] .= '
Post truncated. Click Reply to view.
';
}
@@ -103,8 +103,8 @@ ${post["message"]}
EOF;
if ($post['parent'] == TINYIB_NEWTHREAD) {
- if ($res == TINYIB_INDEXPAGE && $post["omitted"] > 0) {
- $return .= '' . $post['omitted'] . ' ' . plural("post", $post["omitted"]) . ' omitted. Click Reply to view.';
+ if ($res == TINYIB_INDEXPAGE && $post['omitted'] > 0) {
+ $return .= '' . $post['omitted'] . ' ' . plural('post', $post['omitted']) . ' omitted. Click Reply to view.';
}
} else {
$return .= <<\n
";
+ $htmlposts .= buildPost($thread, TINYIB_INDEXPAGE) . implode('', array_reverse($htmlreplies)) . "
\n
";
$i += 1;
if ($i == 10) {
- $file = ($page == 0) ? "index.html" : $page . ".html";
+ $file = ($page == 0) ? 'index.html' : $page . '.html';
writePage($file, buildPage($htmlposts, 0, $pages, $page));
- $page += 1; $i = 0; $htmlposts = "";
+ $page += 1; $i = 0; $htmlposts = '';
}
}
- if ($page == 0 || $htmlposts != "") {
- $file = ($page == 0) ? "index.html" : $page . ".html";
+ if ($page == 0 || $htmlposts != '') {
+ $file = ($page == 0) ? 'index.html' : $page . '.html';
writePage($file, buildPage($htmlposts, 0, $pages, $page));
}
}
@@ -312,19 +312,14 @@ function rebuildThread($id) {
$htmlposts .= "
\n
\n";
- writePage("res/" . $id . ".html", fixLinksInRes(buildPage($htmlposts, $id)));
+ writePage('res/' . $id . '.html', fixLinksInRes(buildPage($htmlposts, $id)));
}
function adminBar() {
global $loggedin, $isadmin, $returnlink;
$return = '[Return]';
if (!$loggedin) { return $return; }
- $text = '[Status] [';
- $text .= ($isadmin) ? 'Bans] [' : '';
- $text .= 'Moderate Post] [Raw Post] [';
- $text .= ($isadmin) ? 'Rebuild All] [' : '';
- $text .= 'Log Out] · ' . $return;
- return $text;
+ return '[Status] [' . (($isadmin) ? 'Bans] [' : '') . 'Moderate Post] [Raw Post] [' . (($isadmin) ? 'Rebuild All] [' : '') . 'Log Out] · ' . $return;
}
function managePage($text, $onload='') {
@@ -593,4 +588,4 @@ EOF;
function manageInfo($text) {
return '' . $text . '
';
}
-?>
\ No newline at end of file
+?>