From eb88cfc9de5577c388aacec83bb6169a6f2938f0 Mon Sep 17 00:00:00 2001 From: 8chan Date: Tue, 23 Sep 2014 23:26:27 +0000 Subject: [PATCH] Fix #10 --- boards.php | 152 +++++++++++++++++++++++++++++++++++++++++++++ static/logo_33.svg | 38 ++++++++++++ 2 files changed, 190 insertions(+) create mode 100644 boards.php create mode 100644 static/logo_33.svg diff --git a/boards.php b/boards.php new file mode 100644 index 00000000..93ba7fe2 --- /dev/null +++ b/boards.php @@ -0,0 +1,152 @@ + +th.header { + background-image: url(/static/bg.gif); + cursor: pointer; + background-repeat: no-repeat; + background-position: center right; + padding-left: 20px; + margin-left: -1px; +} +th.headerSortUp { + background-image: url(/static/asc.gif); +} +th.headerSortDown { + background-image: url(/static/desc.gif); +} +.flag-eo { + background-image: url(/static/eo.png); +} +.flag-en { + background-image: url(/static/en.png); +} + +CSS; +$body .= ''; +$total_posts_hour = 0; +$total_posts = 0; + +foreach ($boards as $i => $board) { + + //$query = prepare(sprintf("SELECT (SELECT MAX(id) from ``posts_%s``) AS max, (SELECT MAX(id) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) < DATE_SUB(NOW(), INTERVAL 1 HOUR)) AS oldmax, (SELECT MAX(id) from ``posts_%s``) AS max_d, (SELECT MAX(id) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) < DATE_SUB(NOW(), INTERVAL 1 DAY)) AS oldmax_d, (SELECT count(id) FROM ``posts_%s``) AS count;", $board['uri'], $board['uri'], $board['uri'], $board['uri'], $board['uri'])); + + $query = prepare(sprintf(" +SELECT MAX(id) max, (SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 DAY)) ppd, +(SELECT COUNT(*) FROM ``posts_%s`` WHERE FROM_UNIXTIME(time) > DATE_SUB(NOW(), INTERVAL 1 HOUR)) pph, +(SELECT count(id) FROM ``posts_%s``) count FROM ``posts_%s`` +", $board['uri'], $board['uri'], $board['uri'], $board['uri'])); + $query->execute() or error(db_error($query)); + $r = $query->fetch(PDO::FETCH_ASSOC); + + $pph = $r['pph']; + $ppd = $r['ppd']; + + $total_posts_hour += $pph; + $total_posts += $r['max']; + + $boards[$i]['pph'] = $pph; + $boards[$i]['ppd'] = $ppd; + $boards[$i]['max'] = $r['max']; +} + +usort($boards, +function ($a, $b) { + $x = $b['ppd'] - $a['ppd']; + if ($x) { return $x; + //} else { return strcmp($a['uri'], $b['uri']); } + } else { return $b['max'] - $a['max']; } +}); + +$hidden_boards_total = 0; +foreach ($boards as $i => &$board) { + $board_config = @file_get_contents($board['uri'].'/config.php'); + $boardCONFIG = array(); + if ($board_config && $board['uri'] !== 'int') { + $board_config = str_replace('$config', '$boardCONFIG', $board_config); + $board_config = str_replace('"; + + if ($showboard || $admin) { + if (!$showboard) { + $lock = ' '; + } else { + $lock = ''; + } + $board['ago'] = human_time_diff(strtotime($board['time'])); + $body .= ""; + } else { + unset($boards[$i]); + $hidden_boards_total += 1; + } +} + +$body .= <<
LBoardPosts in last hourTotal postsCreated
$img/{$board['uri']}/$lock{$board['pph']}{$board['max']}{$board['time']} ({$board['ago']} ago)
+FOOTER; + +$n_boards = sizeof($boards); +$t_boards = $hidden_boards_total + $n_boards; + +$body = "

There are currently {$n_boards} boards + $hidden_boards_total unindexed boards = $t_boards total boards. Site-wide, {$total_posts_hour} posts have been made in the last hour, with {$total_posts} being made on all active boards since October 23, 2013.

" . $body; + +//date_default_timezone_set('UTC'); +$body .= "

Page last updated: ".date('r')."

"; +$body .= "

".shell_exec('uptime -p')." without interruption

"; + +$config['additional_javascript'] = array('js/jquery.min.js', 'js/jquery.tablesorter.min.js'); +$html = Element("page.html", array("config" => $config, "body" => $body, "title" => "Boards on ∞chan")); +if ($admin) { + echo $html; +} else { + file_write("boards.json", json_encode($boards)); + file_write("boards.html", $html); + echo 'Done'; +} + diff --git a/static/logo_33.svg b/static/logo_33.svg new file mode 100644 index 00000000..74cca00b --- /dev/null +++ b/static/logo_33.svg @@ -0,0 +1,38 @@ + + + + + + + + + + + + +