4096){ $postAllowed = false; echo "Your post is too long. Maximum post size is 4,096 chars."; } if(strlen($postName) > 256){ $postAllowed = false; echo "Your post name is too long. Maximum name size is 256 chars."; } // Finally, lets get to the posting. if($postAllowed == true){ file_put_contents("backups/" . "db.json_backup" . uniqid(), json_encode($db)); //backup all posts file_put_contents("backups/" . "db.json", json_encode($db)); $newPost = array( "id" => count($db)+1, "name" => htmlspecialchars($postName), "date" => date("Y/m/d g:i:s"), "reply" => intval($postReply), "board" => $postBoard, "post" => htmlspecialchars($postText), "info" => crypt($_SERVER['REMOTE_ADDR'], "wewlad"), "style" => "normal" ); // >"hurrr durrr use a switch statement!!" // No, they perform basically the same as ifs in PHP and if statements look better. if(isset($_POST["homo"])){ $newPost["style"] = "homosexual"; } if(isset($_POST["mono"])){ $newPost["style"] = "monospace"; } if(isset($_POST["roll"])){ $newPost["roll"] = rand(100000, 999999); } if(isset($_POST["fortune"])){ $newPost["fortune"] = $fortunes[array_rand($fortunes)]; } if(isset($_POST["admin"])){ $newPost["admin"] = true; $newPost["post"] = htmlspecialchars_decode($newPost["post"]); } if($postReply == 0){ array_unshift($db, $newPost); } else { array_push($db, $newPost); if($postName != "sage"){ for($i=0; $i < count($db); $i++){ if($db[$i]->id == intval($postReply)){ $bumpPost = $db[$i]; unset($db[$i]); array_unshift($db, $bumpPost); } } } //var_dump($bumpPost); } file_put_contents("db.json", json_encode($db)); if($postReply == 0){ // it's an OP Header("Location: index.php?board=" . $postBoard); } else { // it's a reply Header("Location: index.php?board=" . $postBoard . "&thread=" . $postReply); } } ?>