Add files via upload

This commit is contained in:
get52 2020-07-26 21:57:58 -04:00 committed by GitHub
parent 002391ffc2
commit 11bd3d0bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 863 additions and 0 deletions

122
createthread.php Normal file
View File

@ -0,0 +1,122 @@
<style>
body{
color:#f00;
background:#000;
}
</style>
<body>
<?php
$bbspass = "changeme";
$postAllowed = true;
$postName = $_POST["name"];
$postText = $_POST["post"];
$postReply = $_POST["reply"];
$postBoard = $_POST["board"];
$postAdmin = $_POST["admin"]; // admin post?
function indianName(){
$indianfirstnames = ["Xi", "Wang", "Yang", "Li", "Bao", "Chun", "Jìngyi", "Mao", "Dong", "Harry", "Get"];
$indianlastnames = ["Chang", "Jinping", "Zedong", "Zhū", "Zhèng", "Sòng", "Tián", "Chiang", "Dong", "Gle"];
return $indianfirstnames[array_rand($indianfirstnames)] . " " . $indianlastnames[array_rand($indianlastnames)];
}
$fortunes = ["It is certain.", "Reply hazy, try again.", "Don't count on it.", "Without a doubt.", "Better not tell you now", "My reply is no.", "Yes, definitely.", "Very doubtful.", "My sources say no."];
$db = json_decode(file_get_contents("db.json"));
//all the error crap
if(isset($postAdmin)){
if($postAdmin != $bbspass){
$postAllowed = false;
echo "ERROR: INCORRECT ADMIN PASSWORD.";
}
}
if(!isset($postName) or $postName == ""){
if($postReply == 0){
$postAllowed = false;
echo "ERROR: Please enter a title for your thread.";
} else {
$postName = indianName();
}
}
if(!(isset($postText)) or $postText == ""){
$postAllowed = false;
echo "ERROR: You didn't enter a post.";
}
if(!(isset($postReply)) or $postReply == ""){
$postAllowed = false;
echo "You know what you did, idiot.";
}
if(!(isset($postBoard)) or $postBoard == ""){
$postAllowed = false;
echo "Board not specified";
}
if(strlen($postText) > 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);
}
}
?>
</body>

1
db.json Normal file

File diff suppressed because one or more lines are too long

90
functions.php Normal file
View File

@ -0,0 +1,90 @@
<?php
function json_search($database, $value, $key){
$results = [];
for($i=0; $i < count($database); $i++){
if($database->$value == $key){
array_push($results, $database[$i]);
}
}
return $results;
}
// get replies to thread
function get_replies($database, $id){
$replies = array();
for($i=0; $i < count($database); $i++){
if($database[$i]->reply == $database[$id]->id){
array_unshift($replies, $database[$i]);
}
}
return $replies;
}
// render the threads for the "list" page
function render_threadlist($database, $postNum, $board){
$replies = get_replies($database, $postNum);
//var_dump($replies);
echo "<tr>";
echo "<td><a href='index.php?board=" . $board . "&thread=" . $database[$postNum]->id . "'>" . $database[$postNum]->name . "</a></td>"; //post headline
echo "<td>" . count($replies) . "</td>"; // number of replies
if($replies[0] == NULL){
echo "<td>" . $database[$postNum]->date . "</td>"; //post headline
} else{
echo "<td>" . $replies[0]->date . "</td>"; // date of last reply
}
echo "</tr>";
}
// Render an OP post.
function render_op($database, $postNum){
echo '<div class="op">';
echo '<span class="postHeadline">' . $database[$postNum]->name . '</span>';
if(isset($database[$postNum]->admin)){
echo '<span class="postAdmin"> ' . "## Getgle Golden God" . '</span>';
}
echo '<span class="postDate"> ' . $database[$postNum]->date . '</span>';
echo '<span class="postName"> No. ' . $database[$postNum]->id . '</span>';
echo '<a href="?board=' . $_GET["board"] . '&thread=' . $database[$postNum]->id . '"> [reply]</a>';
if($database[$postNum]->style == "monospace"){
echo '<pre>' . str_replace(["nigger", "NIGGER", "Nigger"], ["kulak", "KULAK", "Kulak"], $database[$postNum]->post) . '</pre>';
}
if($database[$postNum]->style == "homosexual"){
echo '<p id="homosexual">' . str_replace(["nigger", "NIGGER", "Nigger"], ["kulak", "KULAK", "Kulak"], $database[$postNum]->post) . '</p>';
}
if($database[$postNum]->style == "normal" or !isset($database[$postNum]->style)){
echo '<p>' . str_replace(["\r\n", "nigger", "NIGGER", "Nigger", "Zchan", "zchan"], ["<br>", "kulak", "KULAK", "Kulak", "Cuckchan", "cuckchan"], $database[$postNum]->post) . '</p>';
}
if(isset($database[$postNum]->fortune)){
echo "<span id='fortune'>Fortune: " . $database[$postNum]->fortune . "</span>";
}
if(isset($database[$postNum]->roll)){
echo "<span id='roll'>You rolled: " . $database[$postNum]->roll . "</span>";
}
echo "<span class='disclaimer'><i>Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the Getgle administration.</i></span>";
}
// Render a Reply post.
function render_replies($database, $postNum){
echo '<div class="reply">';
echo '<span class="postName">' . $database[$postNum]->name . '</span>';
echo '<span class="postDate"> ' . $database[$postNum]->date . '</span>';
echo '<span class="postNum">' . "<a href='#" . $database[$postNum]->id . "'> No. " . $database[$postNum]->id . '</a></span>';
if($database[$postNum]->style == "monospace"){
echo '<pre>' . str_replace(["nigger", "NIGGER", "Nigger"], ["kulak", "KULAK", "Kulak"], $database[$postNum]->post) . '</pre>';
}
if($database[$postNum]->style == "homosexual"){
echo '<p id="homosexual">' . str_replace(["nigger", "NIGGER", "Nigger"], ["kulak", "KULAK", "Kulak"], $database[$postNum]->post) . '</p>';
}
if($database[$postNum]->style == "normal" or !isset($database[$postNum]->style)){
echo '<p>' . str_replace(["\r\n", "nigger", "NIGGER", "Nigger"], ["<br>", "kulak", "KULAK", "Kulak"], $database[$postNum]->post) . '</p>';
}
if(isset($database[$postNum]->fortune)){
echo "<span id='fortune'>Fortune: " . $database[$postNum]->fortune . "</span>";
}
if(isset($database[$postNum]->roll)){
echo "<span id='roll'>You rolled: " . $database[$postNum]->roll . "</span>";
}
echo "<span class='disclaimer'><i>Disclaimer: this post and the subject matter and contents thereof - text, media, or otherwise - do not necessarily reflect the views of the Getgle administration.</i></span>";
echo '</div>';
}
?>

35
index.php Normal file
View File

@ -0,0 +1,35 @@
<?php
$dbfile = file_get_contents("db.json");
if($dbfile == null or $dbfile == ""){
file_put_contents("db.json", file_get_contents("backups/db.json"));
}
$db = json_decode(file_get_contents("db.json"));
$settings = json_decode(file_get_contents("settings.json"));
$thread = $_GET["thread"];
$page = $_GET["page"];
$board = $_GET["board"];
if($page == "create"){
include_once("templates/threadMaker.php");
}
if($page == "list"){
include_once("templates/threadlist.php");
} else{
if($board == ""){
include_once("templates/index.php");
} else{
if(in_array($board, $settings->boards) && $thread == ""){
include_once("templates/threads.php");
}
if(in_array($board, $settings->boards) && isset($thread)){
include_once("templates/thread.php");
}
if(!in_array($board, $settings->boards) or $board == ""){
echo "this board does not exist";
}
}
}
?>

40
index2.php Normal file
View File

@ -0,0 +1,40 @@
<?php
$db = json_decode(file_get_contents("db.json"));
$settings = json_decode(file_get_contents("settings.json"));
$thread = $_GET["thread"];
$board = $_GET["board"];
//$boards = ["lounge", "music", "all"];
function render_post($database, $postNum){
echo '<div class="reply">';
echo '<span class="postName">' . $database[$postNum]->name . '</span>';
echo '<span class="postName"> ' . $db[$postNum]->date . '</span>';
echo '<span class="postName"> No. ' . $database[$postNum]->id . '</span>';
echo '<p>' . $database[$postNum]->post . '</p>';
echo '</div>';
}
if($board == ""){
echo include_once("templates/index.php");
}
if(in_array($board, $settings->boards)){
echo include_once("templates/threads.php");
}
if(!in_array($board, $settings->boards) or $board == ""){
echo "this board does not exist";
}
for($i=0; $i < count($db); $i++){
if($db[$i]->reply == $thread and $db[$i]->board == $board){
render_post($db, $i);
}
if($db[$i]->reply == $thread and $board == "all"){
render_post($db, $i);
}
}
?>

4
settings.json Normal file
View File

@ -0,0 +1,4 @@
{
"name":"Getgle",
"boards":["lounge", "monkey", "all"]
}

3
static/index.html Normal file
View File

@ -0,0 +1,3 @@
<h1>Index Page</h1>
boards: <a href="index.php?thread=0&board=lounge">/lounge/, </a>
<a href="index.php?thread=0&board=music">/music/</a>

58
static/style.css Normal file
View File

@ -0,0 +1,58 @@
.infoBox{
background:#ea8;
border:1px solid #800;
padding:0 5px;
}
body{
color: maroon;
font-family: arial,helvetica,sans-serif;
font-size: 10pt;
padding:5px;
margin:5px;
background: #ffe url("fade.png") top center repeat-x;
}
.postName{
color: #117743;
font-weight: 700;
}
.reply{
margin:8px;
padding:5px;
background:#f0e0d6;
border: 1px solid #d9bfb7;
}
#postBox{
margin:8px;
background:#f0e0d6;
border: 1px solid #d9bfb7
}
td:first-child{
background-color: #ea8;
color: #800;
font-weight: 700;
border: 1px solid #800;
padding: 0 5px;
font-size: 10pt;
}
textarea{
width:320px;
height:100;
}
#powered{
margin:8px;
padding:5px;
font-size:8px;
font-weight:800;
}
.logo{
font-size:24px;
}
#header{
text-align:center;
}
#boards{
}

102
style.css Normal file
View File

@ -0,0 +1,102 @@
.infoBox{
background:#ea8;
border:1px solid #800;
padding:0 5px;
}
.disclaimer{
font-size:10px;
}
body{
padding:0px;
margin:0px;
color:#000;
font-family: arial,helvetica,sans-serif;
font-size: 10pt;
text-align:center;
background: #fff;
}
#page{
background:#fff;
width:100%;
padding:5px;
display:inline-block;
text-align:left;
padding-bottom:500px;
}
.postHeadline{
color:#000;
font-weight: 700;
font-size:24px;
}
.postName{
color: #117743;
font-weight: 700;
}
.postAdmin{
color:#ffc837;
text-shadow:2px 2px #685217;
font-size:20px;
font-weight:1000;
}
#catalogTable{
text-align:center;
}
.reply{
margin:8px;
padding:5px;
background: #fff;
color:000;
border: 1px solid #096;
overflow-wrap: break-word;
}
#postBox{
margin:8px;
background:#f0e0d6;
border: 1px solid #d9bfb7
}
#postTable{
background-color: #0fa;
color: #031;
font-weight: 700;
border: 1px solid #800;
padding: 0 5px;
font-size: 10pt;
}
textarea{
width:320px;
height:100;
}
#powered{
margin:8px;
padding:5px;
font-size:8px;
font-weight:800;
}
.logo{
font-size:24px;
}
#header{
text-align:center;
}
#boards{
}
#homosexual{
background-image: linear-gradient(to left, violet, indigo, blue, green, orange, red) ; -webkit-background-clip: text;
background-size:150px 10px;
color: transparent;
}
#roll{
display:block;
color:#f00;
font-size:16px;
}
#fortune{
display:block;
color:#f0f;
font-size:16px;
}

79
style_old.css Normal file
View File

@ -0,0 +1,79 @@
.infoBox{
background:#ea8;
border:1px solid #800;
padding:0 5px;
}
.disclaimer{
font-size:10px;
}
body{
padding:0px;
margin:0px;
color:#fff;
font-family: arial,helvetica,sans-serif;
font-size: 10pt;
text-align:center;
background: #000;
}
#page{
background:#000;
width:100%;
padding:5px;
display:inline-block;
text-align:left;
padding-bottom:500px;
}
.postHeadline{
color:#096;
font-weight: 700;
font-size:24px;
}
.postName{
color: #117743;
font-weight: 700;
}
#catalogTable{
text-align:center;
}
.reply{
margin:8px;
padding:5px;
background: #000;
border: 1px solid #096;
overflow-wrap: break-word;
}
#postBox{
margin:8px;
background:#f0e0d6;
border: 1px solid #d9bfb7
}
#postTable{
background-color: #0fa;
color: #031;
font-weight: 700;
border: 1px solid #800;
padding: 0 5px;
font-size: 10pt;
}
textarea{
width:320px;
height:100;
}
#powered{
margin:8px;
padding:5px;
font-size:8px;
font-weight:800;
}
.logo{
font-size:24px;
}
#header{
text-align:center;
}
#boards{
}
a{
color:#096;
}

BIN
teen.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 21 KiB

View File

@ -0,0 +1,21 @@
<?php
$pass = "bidenpxy";
$db = json_decode(file_get_contents("db.json"));
$settings = json_decode(file_get_contents("settings.json"));
if($_POST["pass"] == $pass){
echo "password correct";
// delete post
if($_POST["function"] == "delete"){
for($i=0; $i < count($db); $i++){
if($db[$i]->id == $_POST["postid"]){
unset($db[$i]);
echo "post deleted";
}
}
}
}else{
echo "password wrong";
}
?>

9
templates/header.php Normal file
View File

@ -0,0 +1,9 @@
<div id="boards">
boards: [<a href="index.php">/home/</a>,<a href="index.php?board=all">/all/</a>, <a href="index.php?board=lounge">/lounge/</a>, <a href="index.php?board=monkey">/monkey/</a>]
</div>
<div id="header">
<span class="logo"><?php echo $settings->name ?> - /<?php echo $board ?>/</span><br>
<a href=<?php echo '"?board=' . $board ?>">frontpage,</a>
<a href=<?php echo '"?board=' . $board . '&page=list"' ?>>catalog,</a>
<a href=<?php echo '"?board=' . $board . '&page=create"' ?>>create thread</a>
</div>

23
templates/index.php Normal file
View File

@ -0,0 +1,23 @@
<html>
<head>
<title>Getgle BBS</title>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="boards">
boards: [<a href="index.php">[home]</a>, <a href="index.php?board=lounge">/all/</a>, <a href="index.php?board=lounge">/lounge/</a>, <a href="index.php?board=monkey">/monkey/</a>]
</div>
<center>
<h1>Getgle BBS</h1>
Boards:<br>
<a href="?board=all">/all/ - View all posts at once (overboard).</a><br>
<a href="?board=lounge">/lounge/ - Talk about anything.</a><br>
<a href="?board=monkey">/monkey/ - Spammy Shoutbox.</a><br><br>
Rules:
<li>Don't get me arrested by posting illegal shit.</li>
<li>Spam in lounge will be moved to /monkey/ or deleted.</li>
</center>
</body>
</html>

75
templates/style.css Normal file
View File

@ -0,0 +1,75 @@
.infoBox{
background:#ea8;
border:1px solid #800;
padding:0 5px;
}
body{
padding:0px;
margin:0px;
color:#031;
font-family: arial,helvetica,sans-serif;
font-size: 10pt;
text-align:center;
background: #efe url("fade.png") top center repeat-x;
}
#page{
background:#fff;
width:900;
padding:5px;
display:inline-block;
text-align:left;
}
.postHeadline{
color:#096;
font-weight: 700;
font-size:24px;
}
.postName{
color: #117743;
font-weight: 700;
}
#catalogTable{
text-align:center;
}
.reply{
margin:8px;
padding:5px;
background: #e6fff2;
border: 1px solid #d9bfb7;
overflow-wrap: break-word;
}
#postBox{
margin:8px;
background:#f0e0d6;
border: 1px solid #d9bfb7
}
#postTable{
background-color: #0fa;
color: #800;
font-weight: 700;
border: 1px solid #800;
padding: 0 5px;
font-size: 10pt;
}
textarea{
width:320px;
height:100;
}
#powered{
margin:8px;
padding:5px;
font-size:8px;
font-weight:800;
}
.logo{
font-size:24px;
}
#header{
text-align:center;
}
#boards{
}
a{
color:#096;
}

57
templates/thread.php Normal file
View File

@ -0,0 +1,57 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css?v=1.1">
</head>
<body>
<div id="page">
<?php
include "header.php";
?>
<?php
include "functions.php";
$db = json_decode(file_get_contents("db.json"));
$thread = $_GET["thread"];
$board = $_GET["board"];
for($i=0; $i < count($db); $i++){
if($db[$i]->id == $thread){
render_op($db, $i);
}
}
for($i=0; $i < count($db); $i++){
if($db[$i]->reply == $thread){
render_replies($db, $i);
}
}
?>
<div id="createthread">
<span class="createThreadHeader">New Reply</span>
<form action="createthread.php" method="post">
<table>
<tr>
<td id="postTable">Name:</td><td > <input type="text" name="name" value=""><input type="submit" value="Post"></td>
<input type="text" name="reply" value="<?php echo $thread ?>" style="display:none;">
<input type="text" name="board" value="<?php echo $board; ?>" style="display:none;">
</tr>
<tr>
<td id="postTable">Post:</td><td><textarea name="post"></textarea></td>
</tr>
</table>
<input type="checkbox" name="mono" id="mono">
<label for="mono">monospace</label>
<input type="checkbox" name="homo" id="homo">
<label for="homo">homosexual</label>
<input type="checkbox" name="roll" id="homo">
<label for="roll">roll</label>
<input type="checkbox" name="fortune" id="homo">
<label for="fortune">fortune</label>
</form>
</div>
</div>
</body>
</html>

51
templates/threadMaker.php Normal file
View File

@ -0,0 +1,51 @@
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<?php
include "functions.php";
$db = json_decode(file_get_contents("db.json"));
$settings = json_decode(file_get_contents("settings.json"));
$thread = $_GET["thread"];
$board = $_GET["board"];
$admin = $_GET["admin"];
?>
<div id="page">
<?php
include "header.php";
?>
<div id="createthread">
<span class="createThreadHeader">New Thread</span>
<form action="createthread.php" method="post">
<table>
<tr>
<td id="postTable">Headline:</td><td> <input type="text" name="name" value=""><input type="submit" value="Post"></td>
<input type="text" name="reply" value="0" style="display:none;">
<input type="text" name="board" value="<?php echo $board; ?>" style="display:none;">
</tr>
<tr>
<td id="postTable">Post:</td><td><textarea name="post"></textarea></td>
</tr>
<?php
if(isset($admin)){
echo '<tr><td id="postTable">Admin:</td><td> <input type="text" name="admin" value=""></td></tr>';
}
?>
</table>
<input type="checkbox" name="mono" id="mono">
<label for="mono">monospace</label>
<input type="checkbox" name="homo" id="homo">
<label for="homo">homosexual</label>
<input type="checkbox" name="roll" id="homo">
<label for="roll">roll</label>
<input type="checkbox" name="fortune" id="homo">
<label for="fortune">fortune</label>
<?php
if(isset($admin)){
echo '<input type="checkbox" name="html" id="html">
<label for="html">html</label>';
}
?>
</form>
</div>
</div>
</body>

30
templates/threadlist.php Normal file
View File

@ -0,0 +1,30 @@
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="page">
<?php
include "header.php";
?>
<br>
<center>
<table id="catalogTable">
<tr>
<th id="postTable">Headline</th>
<th id="postTable">Replies</th>
<th id="postTable">Last Updated</th>
</tr>
<?php
include_once "functions.php";
for($i=0; $i < count($db); $i++){
if($db[$i]->reply == $thread and $db[$i]->board == $board or $board == "all" and $db[$i]->reply == $thread){
render_threadlist($db, $i, $_GET["board"]);
}
}
?>
</table>
</center>
</div>
</body>
</html>

32
templates/threads.php Normal file
View File

@ -0,0 +1,32 @@
<html>
<head>
<?php
include "functions.php";
$db = json_decode(file_get_contents("db.json"));
$settings = json_decode(file_get_contents("settings.json"));
$thread = $_GET["thread"];
$board = $_GET["board"];
?>
<link rel="stylesheet" type="text/css" href="style.css?v=1.1">
</head>
<body>
<div id="page">
<?php
include "header.php";
for($i=0; $i < count($db); $i++){
if($db[$i]->reply == $thread and $db[$i]->board == $board or $db[$i]->reply == $thread and $board == "all"){
render_op($db, $i);
for($z=0; $z < count($db); $z++){
if($db[$z]->reply == $db[$i]->id){
render_replies($db, $z);
}
}
echo "</div>";
}
}
?>
</div>
</body>
</html>

31
threadMaker.php Normal file
View File

@ -0,0 +1,31 @@
<link rel="stylesheet" type="text/css" href="style.css">
<body>
<?php
include "functions.php";
$db = json_decode(file_get_contents("db.json"));
$settings = json_decode(file_get_contents("settings.json"));
$thread = $_GET["thread"];
$board = $_GET["board"];
?>
<div id="page">
<?php
include "header.php";
?>
<div id="createthread">
<span class="createThreadHeader">New Thread</span>
<form action="createthread.php" method="post">
<table>
<tr>
<td id="postTable">Headline:</td><td> <input type="text" name="name" value=""><input type="submit" value="Post"></td>
<input type="text" name="reply" value="0" style="display:none;">
<input type="text" name="board" value="<?php echo $board; ?>" style="display:none;">
</tr>
<tr>
<td id="postTable">Post:</td><td><textarea name="post"></textarea></td>
</tr>
</table>
</form>
</div>
</div>
</body>