¨
|
EOF;
} elseif ($post["file"] != "") {
$return .= <<File: ${post["file"]}–(${post["file_size_formatted"]}, ${post["image_width"]}x${post["image_height"]}, ${post["file_original"]})
EOF;
}
$return .= <<
|
EOF;
}
return $return;
}
function buildPage($htmlposts, $parent, $pages=0, $thispage=0) {
global $tinyib;
$managelink = basename($_SERVER['PHP_SELF']) . "?manage";
$postingmode = "";
$pagenavigator = "";
if ($parent == 0) {
$pages = max($pages, 0);
$previous = ($thispage == 1) ? "index" : $thispage - 1;
$next = $thispage + 1;
$pagelinks = ($thispage == 0) ? "Previous | " : ' | ';
$pagelinks .= "";
for ($i = 0;$i <= $pages;$i++) {
if ($thispage == $i) {
$pagelinks .= '[' . $i . '] ';
} else {
$href = ($i == 0) ? "index" : $i;
$pagelinks .= '[' . $i . '] ';
}
}
$pagelinks .= " | ";
$pagelinks .= ($pages <= $thispage) ? "Next | " : ' | ';
$pagenavigator = <<
$pagelinks
EOF;
} else {
$postingmode = '[Return]Posting mode: Reply
';
}
$unique_posts_html = '';
$unique_posts = uniquePosts();
if ($unique_posts > 0) {
$unique_posts_html = "Currently $unique_posts unique user posts.";
}
return <<
${tinyib['boarddescription']}
${tinyib['logo']}
${tinyib['boarddescription']}
$postingmode
$pagenavigator
EOF;
}
function rebuildIndexes() {
global $mysql_posts_table;
$htmlposts = "";
$page = 0;
$i = 0;
$pages = ceil(countThreads() / 10) - 1;
$threads = allThreads();
foreach ($threads as $thread) {
$htmlreplies = array();
$replies = latestRepliesInThreadByID($thread['id']);
foreach ($replies as $reply) {
$htmlreplies[] = buildPost($reply, False);
}
if (count($htmlreplies) == 3) {
$thread["omitted"] = (count(postsInThreadByID($thread['id'])) - 4);
} else {
$thread["omitted"] = 0;
}
$htmlposts .= buildPost($thread, False);
$htmlposts .= implode("", array_reverse($htmlreplies));
$htmlposts .= "
\n" .
"
";
$i += 1;
if ($i == 10) {
$file = ($page == 0) ? "index.html" : $page . ".html";
writePage($file, buildPage($htmlposts, 0, $pages, $page));
$page += 1;
$i = 0;
$htmlposts = "";
}
}
if ($page == 0 || $htmlposts != "") {
$file = ($page == 0) ? "index.html" : $page . ".html";
writePage($file, buildPage($htmlposts, 0, $pages, $page));
}
}
function rebuildThread($id) {
global $mysql_posts_table;
$htmlposts = "";
$posts = postsInThreadByID($id);
foreach ($posts as $post) {
$htmlposts .= buildPost($post, True);
}
$htmlposts .= "
\n" .
"
";
writePage("res/" . $id . ".html", fixLinksInRes(buildPage($htmlposts, $id)));
}
function manageNavBar() {
global $loggedin, $isadmin;
if (!$loggedin) { return ''; }
$text = '';
$text .= ($isadmin) ? 'bans · ' : '';
$text .= 'moderate post · ';
$text .= ($isadmin) ? 'rebuild all · ' : '';
$text .= 'log out';
return $text;
}
function managePage($text, $onload='') {
global $tinyib, $returnlink;
$navbar = manageNavBar();
return <<
${tinyib['boarddescription']}
${tinyib['logo']}
${tinyib['boarddescription']}
Manage mode
$navbar
$text
EOF;
}
function manageOnLoad($page) {
switch ($page) {
case 'login':
return ' onload="document.tinyib.password.focus();"';
case 'moderate':
return ' onload="document.tinyib.moderate.focus();"';
case 'bans':
return ' onload="document.tinyib.ip.focus();"';
}
}
function manageLogInForm() {
return <<
EOF;
}
function manageBanForm() {
return <<
EOF;
}
function manageBansTable() {
$text = '';
$allbans = allBans();
if (count($allbans) > 0) {
$text .= 'IP Address | Set At | Expires | Reason Provided | |
';
foreach ($allbans as $ban) {
$expire = ($ban['expire'] > 0) ? date('y/m/d(D)H:i:s', $ban['expire']) : 'Never';
$reason = ($ban['reason'] == '') ? ' ' : htmlentities($ban['reason']);
$text .= '' . $ban['ip'] . ' | ' . date('y/m/d(D)H:i:s', $ban['timestamp']) . ' | ' . $expire . ' | ' . $reason . ' | lift |
';
}
$text .= '
';
}
return $text;
}
function manageModeratePostForm() {
return <<
EOF;
}
function manageModeratePost($post) {
global $isadmin;
$ban = banByIP($post['ip']);
$ban_disabled = (!$ban && $isadmin) ? '' : ' disabled';
$ban_disabled_info = (!$ban) ? '' : (' A ban record already exists for ' . $post['ip']);
$post_html = buildPost($post, true);
return <<
EOF;
}
?>