From 8bda8c887d5263932a27ce1ee76b50fbad7ef603 Mon Sep 17 00:00:00 2001 From: Getindor Date: Thu, 10 Sep 2020 00:34:24 -0400 Subject: [PATCH] Add files via upload --- board.php | 139 ++++++++++++++++++++++++++++++++++++++++++++ catalog.php | 9 +++ config.php | 9 +++ createthread.html | 39 +++++++++++++ createthread.php | 80 ++++++++++++++++++++++++++ html/catalog.html | 21 +++++++ html/form.html | 13 +++++ html/thread.html | 21 +++++++ html/threads.html | 23 ++++++++ index.php | 10 ++++ thread.css | 143 ++++++++++++++++++++++++++++++++++++++++++++++ thread.php | 10 ++++ threads.css | 133 ++++++++++++++++++++++++++++++++++++++++++ 13 files changed, 650 insertions(+) create mode 100644 board.php create mode 100644 catalog.php create mode 100644 config.php create mode 100644 createthread.html create mode 100644 createthread.php create mode 100644 html/catalog.html create mode 100644 html/form.html create mode 100644 html/thread.html create mode 100644 html/threads.html create mode 100644 index.php create mode 100644 thread.css create mode 100644 thread.php create mode 100644 threads.css diff --git a/board.php b/board.php new file mode 100644 index 0000000..d9e1219 --- /dev/null +++ b/board.php @@ -0,0 +1,139 @@ +config = $db; + } + function connect(){ + $this->db = new mysqli($this->config["server"], $this->config["user"], $this->config["pass"], $this->config["database"]); + } + function addPost($post){ + return $this->db->query("INSERT INTO posts + (id, name, date, reply, board, post, info, style, fortune, roll, admin) + VALUES (" . $post["id"] . ", '" . $post["name"] . "', '" . $post["date"] + . "', " . $post["reply"] . ", '" . $post["board"] . "', '" . $post["post"] + . " ', '" . $post["info"] . "', '" . $post["style"] . "', '" . $post["fortune"] + . "', '" . $post["roll"] . "', '" . $post["admin"] . "');") or die($this->db->error); + } + // get a single post + function getPost($id){ + $query = $this->db->query("SELECT * from posts WHERE id = " . $id) or die($this->db->error); + return $query->fetch_assoc(); + } + // get a single post + function getPosts(){ + $query = $this->db->query("SELECT * from posts") or die($this->db->error); + return $query; + } + function getThreads(){ + $query = $this->db->query("SELECT * from posts WHERE reply = 0 ORDER BY id DESC") or die($this->db->error); + return $query; + } + function getReplies($id){ + $query = $this->db->query("SELECT * from posts WHERE reply = " . $id) or die($this->db->error); + return $query; + } + function getReplyCount($id){ + $query = $this->db->query("SELECT COUNT(*) FROM posts WHERE reply = " . $id) or die($this->db->error); + return $query; + } + function getLatestReplies($id){ + $query = $this->db->query("SELECT * from posts WHERE reply = " . $id . " ORDER BY id DESC LIMIT 5") or die($this->db->error); + return $query; + } +} + +class render{ + // Render a thread for catalog. + function catalog($db, $post){ + return '
+ ' . strval($db->getReplies($post["id"])->num_rows) . 'replies + ' . $post["name"] . ' + ' . $post["date"] . ' +
'; + } + + // Render an OP post. + function op($post){ + return '' . + '' . $post["name"] . '' . + ' ' . $post["date"] . '' . + ' No. ' . $post["id"] . '' . + '

' . str_replace("\r\n", "
" , $post["post"]) . '

'; + + } + // Render a Reply post. + function reply($post){ + return '
' . + '' . $post["name"] . '' . + '' . + '' . " No. " . $post["id"] . '' . + '

' . str_replace("\r\n", "
" , $post["post"]) . '

' . + '
'; + + } + // render a new thread form + function newThreadForm(){ + return '

New Thread

Headline:
Post:
'; + } + // render a new reply form + function newReplyForm($id){ + return '

Reply

Name:
Post:
'; + } + +} +class buildHTML{ + public $db; + public $posts; + function __construct($db){ + $this->db = $db; //give it the class, not the config + } + function insertHTML($file, $content){ + return str_replace("", $content,file_get_contents($file)); + } + function threads(){ + $result = ""; + for($i=0; $i < count($this->threads);$i++){ + $result = $result . render::op($this->threads, $i); + $repliesArray = $this->db->getLatestReplies($this->posts[$i]["id"]); + for($x=0; $x < count($repliesArray);$x++){ + $result = $result . render::reply($repliesArray, $x); + } + } + return buildHTML::insertHTML("html/threads.html", $result); + } + function thread($id){ + $result = ""; + $result = $result . render::op($this->db->getPost($id)); + $replies = $this->db->getReplies($id); + while($reply = $replies->fetch_assoc()){ + $result = $result . render::reply($reply); + } + $result = $result . render::newReplyForm($id); + return buildHTML::insertHTML("html/threads.html", $result); + } + function frontpage(){ + $result = ""; + $threads = $this->db->getThreads(); + while($thread = $threads->fetch_assoc()){ + $result = $result . render::op($thread); + $replies = $this->db->getLatestReplies($thread["id"]); + $result = $result . "
See " . strval($this->db->getReplies($thread["id"])->num_rows) . " replies.
"; + while($reply = $replies->fetch_assoc()){ + $result = $result . render::reply($reply); + } + $result = $result . render::newReplyForm($thread["id"]); + } + return buildHTML::insertHTML("html/threads.html", $result); + } + function catalog(){ + $threads = $this->db->getThreads(); + $result = ""; + while($thread = $threads->fetch_assoc()){ + $result = $result . render::catalog($this->db, $thread); + } + return buildHTML::insertHTML("html/threads.html", $result); + } +} +?> diff --git a/catalog.php b/catalog.php new file mode 100644 index 0000000..27f0789 --- /dev/null +++ b/catalog.php @@ -0,0 +1,9 @@ +connect(); +$html = new buildHTML($db); +echo $html->catalog(); + +?> diff --git a/config.php b/config.php new file mode 100644 index 0000000..447afe9 --- /dev/null +++ b/config.php @@ -0,0 +1,9 @@ + "changeme", + "database" => "changeme", + "table" => "changeme", + "user" => "changeme", + "pass" => "changeme" +]; +?> diff --git a/createthread.html b/createthread.html new file mode 100644 index 0000000..975c5d5 --- /dev/null +++ b/createthread.html @@ -0,0 +1,39 @@ + + + GetgleBBS + + + +
+ +
+
+
+ + +

New Thread

+ + + + + + + + + +
Headline:
Post:
+
+
+
+
+ + + + diff --git a/createthread.php b/createthread.php new file mode 100644 index 0000000..deca4ca --- /dev/null +++ b/createthread.php @@ -0,0 +1,80 @@ + + + 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){ + $bbspass = "changeme"; + $db = new db($config); + $db->connect(); + $newPost = array( + "id" => $db->getPosts()->num_rows+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'], $bbspass), // used for IP banning people without storing their ip as plaintext + "style" => "normal", + "fortune" => "none", + "roll" => "none", + "admin" => "none" + ); + $new = $newPost; + echo $db->addPost($new); + header("Location: index.php"); +} else { + echo "not allowed"; +} +?> + diff --git a/html/catalog.html b/html/catalog.html new file mode 100644 index 0000000..50ff7db --- /dev/null +++ b/html/catalog.html @@ -0,0 +1,21 @@ + + +GetgleBBS 2.0 + + + + + +
+ +
+ + + diff --git a/html/form.html b/html/form.html new file mode 100644 index 0000000..220a189 --- /dev/null +++ b/html/form.html @@ -0,0 +1,13 @@ +
+ + + + + + + + + + +
Name:
Post:
+
diff --git a/html/thread.html b/html/thread.html new file mode 100644 index 0000000..ac5ead8 --- /dev/null +++ b/html/thread.html @@ -0,0 +1,21 @@ + + +GetgleBBS + + + +
+ + +return to frontpage +
+ + + diff --git a/html/threads.html b/html/threads.html new file mode 100644 index 0000000..745fab1 --- /dev/null +++ b/html/threads.html @@ -0,0 +1,23 @@ + + +GetgleBBS + + + + +
+ +
+ +
+
+ + + diff --git a/index.php b/index.php new file mode 100644 index 0000000..b63fe0a --- /dev/null +++ b/index.php @@ -0,0 +1,10 @@ +connect(); +$html = new buildHTML($db); +echo $html->frontpage(); + +//print_r($db->getPost(11)); +?> diff --git a/thread.css b/thread.css new file mode 100644 index 0000000..9a2405e --- /dev/null +++ b/thread.css @@ -0,0 +1,143 @@ +.infoBox{ +background:#ea8; +border:1px solid #800; +padding:0 5px; +} +body{ +padding:10px; +color:#031; +font-family: "Lucida Console", Monaco, monospace; +font-size: 10pt; +text-align:center; +background: #fff url("fade.png") top center repeat-x; +margin:auto; +} +#page{ +background:#fff; +width:95%; +padding:10px; +display:inline-block; +text-align:left; +padding-bottom:500px; + +} +#header{ +text-align:center; + +} +#more{ + text-align:center; + width:100%; +} +#threads{ + margin:20px; +} +#thread{ + width:100%; + display:inner-block; + padding:10px; + border:1px solid #000; + text-align:left; + margin:20px; +} +header{ + padding:10px; + border:1px solid #000; +} +.postHeadline{ + color:#096; + font-weight: 700; + font-size:24px; +} +.postName{ +color: #117743; +font-weight: 700; +} +#catalogTable{ + text-align:center; +} +.reply{ +margin:8px; +padding:15px; +border-top: 1px solid #ccc; +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; +} + +#boards{ + +} +a{ +color:#096; +} +.pageLinkActive{ + color:#f00; +} +#pageList{ + overflow-wrap:break-word; + margin:auto; + text-align:center; + margin:5px; +} +#catalog{ +width:90%; +} +.catalogContent{ +display:inline-block; +padding:25px; +height:100%; +} +.catalogThread{ + display:inline-block; +text-align:left; +padding:10px; +margin:10px; +width:100%; +height:24px; +height: 60px; +border: 1px solid #000; +} +.catalogReplies{ + display:inline-block; + text-align:center; + float:left; + padding:10px; + +} +.catalogRepliesCount{ + font-size:24px; +} +.catalogRepliesText{ + display:block; +} +.catalogThreadTitle{ + +} +.catalogThreadDate{ + text-align:right; +} diff --git a/thread.php b/thread.php new file mode 100644 index 0000000..2a96385 --- /dev/null +++ b/thread.php @@ -0,0 +1,10 @@ +connect(); +$html = new buildHTML($db); +echo $html->thread($_GET["q"]); + +//print_r($db->getPost(11)); +?> diff --git a/threads.css b/threads.css new file mode 100644 index 0000000..2513f8b --- /dev/null +++ b/threads.css @@ -0,0 +1,133 @@ +.infoBox{ +background:#ea8; +border:1px solid #800; +padding:0 5px; +} +body{ +color:#031; +font-family: "Lucida Console", Monaco, monospace; +font-size: 10pt; +background: #fff url("fade.png") top center repeat-x; +} +#page{ +background:#fff; +width:100%; +margin:0; +padding:0; +} +#more{ + text-align:center; + width:100%; +} +#threads{ + +} +#thread{ + display:inner-block; + padding:10px; + border:1px solid #000; + text-align:left; + margin:20px; +} +header{ + padding:10px; + border:1px solid #000; +} +.postHeadline{ + color:#096; + font-weight: 700; + font-size:24px; +} +.postName{ +color: #117743; +font-weight: 700; +} +#catalogTable{ + text-align:center; +} +.reply{ +margin:8px; +padding:15px; +border-top: 1px solid #ccc; +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:0 auto; +padding:5px; +font-size:8px; +font-weight:800; +text-align:center; +} +.logo{ +font-size:24px; +} + +#boards{ + +} +a{ +color:#096; +} +.pageLinkActive{ + color:#f00; +} +#pageList{ + overflow-wrap:break-word; + margin:auto; + text-align:center; + margin:5px; +} +#catalog{ +width:90%; +} +.catalogContent{ +display:inline-block; +padding:25px; +height:100%; +} +.catalogThread{ + display:inline-block; +text-align:left; +padding:10px; +margin:10px; +width:100%; +height:24px; +height: 60px; +border: 1px solid #ccc; +} +.catalogReplies{ + display:inline-block; + text-align:center; + float:left; + padding:10px; + +} +.catalogRepliesCount{ + font-size:24px; +} +.catalogRepliesText{ + display:block; +} +.catalogThreadTitle{ + +} +.catalogThreadDate{ + text-align:right; +}