diff --git a/inc/functions.php b/inc/functions.php index fec3521..0bcbe17 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -111,12 +111,7 @@ function nameAndTripcode($name) { function nameBlock($name, $tripcode, $email, $timestamp, $modposttext) { $output = ''; - - if ($name == "" && $tripcode == "") { - $output .= "Anonymous"; - } else { - $output .= $name; - } + $output .= ($name == "" && $tripcode == "") ? "Anonymous" : $name; if ($tripcode != "") { $output .= '!' . $tripcode; @@ -280,33 +275,24 @@ function checkDuplicateImage($hex) { $hexmatches = postsByHex($hex); if (count($hexmatches) > 0) { foreach ($hexmatches as $hexmatch) { - if ($hexmatch["parent"] == "0") { - $goto = $hexmatch["id"]; - } else { - $goto = $hexmatch["parent"]; - } - fancyDie("Duplicate file uploaded. That file has already been posted here."); + fancyDie("Duplicate file uploaded. That file has already been posted here."); } } } function thumbnailDimensions($width, $height) { - if ($width > 250 || $height > 250) { - return array(250, 250); - } else { - return array($width, $height); - } + return ($width > 250 || $height > 250) ? array(250, 250) : array($width, $height); } function createThumbnail($name, $filename, $new_w, $new_h) { $system = explode(".", $filename); $system = array_reverse($system); if (preg_match("/jpg|jpeg/", $system[0])) { - $src_img=imagecreatefromjpeg($name); + $src_img = imagecreatefromjpeg($name); } else if (preg_match("/png/", $system[0])) { - $src_img=imagecreatefrompng($name); + $src_img = imagecreatefrompng($name); } else if (preg_match("/gif/", $system[0])) { - $src_img=imagecreatefromgif($name); + $src_img = imagecreatefromgif($name); } else { return false; } @@ -316,11 +302,7 @@ function createThumbnail($name, $filename, $new_w, $new_h) { } $old_x = imageSX($src_img); $old_y = imageSY($src_img); - if ($old_x > $old_y) { - $percent = $new_w / $old_x; - } else { - $percent = $new_h / $old_y; - } + $percent = ($old_x > $old_y) ? ($new_w / $old_x) : ($new_h / $old_y); $thumb_w = round($old_x * $percent); $thumb_h = round($old_y * $percent); diff --git a/inc/html.php b/inc/html.php index 8f53a97..a3c147a 100644 --- a/inc/html.php +++ b/inc/html.php @@ -259,37 +259,28 @@ EOF; } function rebuildIndexes() { - $htmlposts = ""; - $page = 0; - $i = 0; + $page = 0; $i = 0; $htmlposts = ""; $pages = ceil(countThreads() / 10) - 1; $threads = allThreads(); + foreach ($threads as $thread) { - $htmlreplies = array(); $replies = latestRepliesInThreadByID($thread['id']); - foreach ($replies as $reply) { + + $htmlreplies = array(); + foreach ($replies as $reply) { $htmlreplies[] = buildPost($reply, False); } - if (count($htmlreplies) == 3) { - $thread["omitted"] = (count(postsInThreadByID($thread['id'])) - 4); - } else { - $thread["omitted"] = 0; - } - $htmlposts .= buildPost($thread, False); - - $htmlposts .= implode("", array_reverse($htmlreplies)); + $thread["omitted"] = (count($htmlreplies) == 3) ? (count(postsInThreadByID($thread['id'])) - 4) : 0; + + $htmlposts .= buildPost($thread, False) . implode("", array_reverse($htmlreplies)) . "
\n
"; - $htmlposts .= "
\n" . - "
"; $i += 1; if ($i == 10) { $file = ($page == 0) ? "index.html" : $page . ".html"; writePage($file, buildPage($htmlposts, 0, $pages, $page)); - $page += 1; - $i = 0; - $htmlposts = ""; + $page += 1; $i = 0; $htmlposts = ""; } }