Adding work for tonight

This commit is contained in:
Robert Miles 2018-07-07 02:09:31 -04:00
parent 6224c67a39
commit 27c7594f9d
6 changed files with 87 additions and 0 deletions

8
client/config.php Normal file
View File

@ -0,0 +1,8 @@
<?php
// Location of CSS
define("CSS_LOCATION","/css/hacker.css");
// Host and Port of BBJ instance
define("BBJ_HOST","127.0.0.1");
define("BBJ_PORT",7099);
?>

3
client/footer.php Normal file
View File

@ -0,0 +1,3 @@
</div>
</body>
</html>

15
client/header.php Normal file
View File

@ -0,0 +1,15 @@
<html>
<head>
<title><?=$title?></title>
<link rel="stylesheet" href="<?=CSS_LOCATION?>">
<style>
pre {
white-space: pre-wrap;
word-wrap: break-word;
word-break: normal;
}
</style>
</head>
<body>
<div class="container">
<h1><?=$title?></h1>

31
index.php Normal file
View File

@ -0,0 +1,31 @@
<?php
include 'client/config.php';
include 'bbj.php';
$bbj = new BBJ(BBJ_HOST,BBJ_PORT);
if (isset($_GET["thread_id"])) {
$thread = $bbj->thread_load($_GET["thread_id"]);
if ($thread["error"]!=null) {
$title = "Unknown Thread | ~team BBJ";
include 'client/header.php';
echo "\t\t<p>No such thread exists. <a href='/index.php'>Go home.</a></p>";
include 'client/footer.php';
die();
} else {
$title = $thread["data"]["title"]." by ".$thread["usermap"][$thread["data"]["author"]]["user_name"]." | ~team BBJ";
}
} else {
$title = "~team BBJ";
}
include 'client/header.php';
if (isset($thread)) {
include 'thread.php';
} else {
include 'main.php';
}
include 'client/footer.php';
?>

16
main.php Normal file
View File

@ -0,0 +1,16 @@
<?php
$threads = $bbj->thread_index();
foreach($threads["data"] as $thread) {
$username = $threads["usermap"][$thread["author"]]["user_name"];
$time = new DateTime("@{$thread['created']}");
$time = date_format($time, "c");
$tt = $thread["title"];
$plural = $thread['reply_count']==1 ? "y" : "ies";
$tid = $thread["thread_id"];
echo "\t\t<div class='well'>".PHP_EOL;
echo "\t\t\t<p><a href='index.php?thread_id={$tid}'>{$tt}</a> by {$username} @ {$time}</p>".PHP_EOL;
echo "\t\t\t<p>{$thread['reply_count']} repl{$plural}, last post by {$last_author}";
echo "\t\t</div>".PHP_EOL;
}
?>
<p>RIP</p>

14
thread.php Normal file
View File

@ -0,0 +1,14 @@
<?php
foreach($thread["data"]["messages"] as $message) {
$username = $thread["usermap"][$message["author"]]["user_name"];
$time = new DateTime("@{$message['created']}");
$time = date_format($time, "c");
echo "\t\t<div class='well' id='post{$message["post_id"]}'>".PHP_EOL;
echo "\t\t\t<p>&gt;{$message['post_id']} {$username} @ {$time}</p>".PHP_EOL;
echo "\t\t\t<pre>".PHP_EOL;
echo $message["body"].PHP_EOL;
echo "\t\t\t</pre>".PHP_EOL;
echo "\t\t</div>".PHP_EOL;
}
?>
<p>RIP</p>