Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions client/main.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php
// Float pinned posts to the top.
// If they share a pinned/unpinned status, later post comes to the top.
// Otherwise, force pinned post to the top.
// Sort the threads array so that pinned posts float to the top.
// If the threads share a pinned status (both pinned or both not),
// then the thread with the later creation time floats to the top.
// Otherwise, the pinned thread is forced to the top.
function pinned_sort($thread_a,$thread_b) {
if ($thread_a["pinned"] == $thread_b["pinned"]) {
return (($thread_a["last_mod"]>$thread_b["last_mod"])? -1 : 1);
Expand Down
12 changes: 11 additions & 1 deletion client/thread.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
<?php
function lookup($match) {
$data = $thread["data"];
$usermap = $thread["usermap"];
$postnum = $match[1];
if ($postnum==0) {
return ">>OP";
}
return ">>".$postnum.$usermap[$data["messages"][$postnum]["author"]]["user_name"];
}
foreach($thread["data"]["messages"] as $message) {
$username = $thread["usermap"][$message["author"]]["user_name"];
$time = round($message['created']);
Expand All @@ -7,7 +16,8 @@
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>";
echo str_replace(">>0",">>OP",$message["body"]).PHP_EOL;
// echo str_replace(">>0",">>OP",$message["body"]).PHP_EOL;
echo preg_replace_callback("/>>(\d+)/",'lookup',$message["body"]).PHP_EOL;
echo "</pre>".PHP_EOL;
echo "\t\t</div>".PHP_EOL;
}
Expand Down