1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2025-01-19 01:24:05 +01:00
This commit is contained in:
8chan 2014-09-23 23:26:27 +00:00
parent da9ee32c2b
commit eb88cfc9de
2 changed files with 190 additions and 0 deletions

152
boards.php Normal file
View File

@ -0,0 +1,152 @@
<?php
include "inc/functions.php";
include "inc/mod/auth.php";
$admin = isset($mod["type"]) && $mod["type"]<=30;
if (php_sapi_name() == 'fpm-fcgi' && !$admin) {
error('Cannot be run directly.');
}
$boards = listBoards();
$body = <<<CSS
<style>
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);
}
</style>
CSS;
$body .= '<table class="modlog" style="width:auto"><thead><tr><th>L</th><th>Board</th><th>Posts in last hour</th><th>Total posts</th><th>Created</th></thead></tr><tbody>';
$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('<?php', '', $board_config);
eval($board_config);
$showboard = (!isset($boardCONFIG['meta_noindex']) || !$boardCONFIG['meta_noindex']);
}
$locale = isset($boardCONFIG['locale'])?$boardCONFIG['locale']:'en';
$board['title'] = htmlentities(utf8tohtml($board['title']));
$locale_arr = explode('_', $locale);
$locale_short = isset($locale_arr[1]) ? strtolower($locale_arr[1]) : strtolower($locale_arr[0]);
$locale_short = str_replace('.utf-8', '', $locale_short);
if ($board['uri'] === 'int') {$locale_short = 'eo'; $locale = 'eo';}
$img = "<img class=\"flag flag-$locale_short\" src=\"/static/blank.gif\" style=\"width:16px;height:11px;\" alt=\"$locale\" title=\"$locale\">";
if ($showboard || $admin) {
if (!$showboard) {
$lock = ' <i class="fa fa-lock" title="No index"></i>';
} else {
$lock = '';
}
$board['ago'] = human_time_diff(strtotime($board['time']));
$body .= "<tr><td>$img</td><td><a href='/{$board['uri']}/' title=\"{$board['title']}\">/{$board['uri']}/</a>$lock</td><td style='text-align:right'>{$board['pph']}</td><td style='text-align:right'>{$board['max']}</td><td>{$board['time']} ({$board['ago']} ago)</td></tr>";
} else {
unset($boards[$i]);
$hidden_boards_total += 1;
}
}
$body .= <<<FOOTER
</tbody></table><script>
/*$.tablesorter.addParser({
id: 'flags',
is: function(s) {
return false;
},
format: function(s) {
return 0;
},
type: 'text'
}); */
$(function() {
$('table').tablesorter({sortList: [[2,1]],
textExtraction: function(node) {
childNode = node.childNodes[0];
if (!childNode) { return node.innerHTML; }
if (childNode.tagName == 'IMG') {
return childNode.getAttribute('class');
} else {
return (childNode.innerHTML ? childNode.innerHTML : childNode.textContent);
}
}
});
});
</script>
FOOTER;
$n_boards = sizeof($boards);
$t_boards = $hidden_boards_total + $n_boards;
$body = "<p style='text-align:center'>There are currently <strong>{$n_boards}</strong> boards + <strong>$hidden_boards_total</strong> unindexed boards = <strong>$t_boards</strong> 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.</p>" . $body;
//date_default_timezone_set('UTC');
$body .= "<p style='text-align:center'><em>Page last updated: ".date('r')."</em></p>";
$body .= "<p style='text-align:center'>".shell_exec('uptime -p')." without interruption</p>";
$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 &infin;chan"));
if ($admin) {
echo $html;
} else {
file_write("boards.json", json_encode($boards));
file_write("boards.html", $html);
echo 'Done';
}

38
static/logo_33.svg Normal file
View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 15.0.2, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_3" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="595.28px" height="453.543px" viewBox="0 0 595.28 453.543" enable-background="new 0 0 595.28 453.543"
xml:space="preserve">
<path fill="#009FE3" d="M137.225,267.417"/>
<path fill="#239623" d="M484.483,49.328c-18.029-8.871-38.313-13.861-59.764-13.861c-66.533,0.002-121.867,47.932-133.37,111.146
c0,0,11.868-2.606,31.965-16.396c22.902-15.712,31.834-36.442,67.834-43.442c-30.375,12.947-36.334,33.333-34.873,54.428
c11.338-24.875,36.418-42.165,65.539-42.165c39.766,0,72,32.235,72,72c0,39.205-31.339,72.692-70.334,71.96
c-13.403-0.252-43.044-13.399-74.213-30.578c-30.024-16.548-88.918-51.731-119.237-67.736
c-17.677-9.332-38.139-13.717-59.477-13.717c-74.873,0-135.572,60.697-135.572,135.572c0,53.422,30.905,99.619,75.808,121.708
c18.03,8.871,38.313,13.861,59.765,13.861c66.533-0.002,121.867-47.931,133.37-111.144c0,0-11.868,2.605-31.966,16.395
c-22.901,15.713-31.834,36.443-67.834,43.443c30.376-12.947,36.334-33.334,34.873-54.428
c-11.338,24.875-36.417,42.164-65.539,42.164c-39.765,0-72-32.234-72-72c0-39.205,31.339-72.691,70.334-71.959
c13.403,0.252,43.045,13.399,74.214,30.578c30.025,16.548,88.919,51.731,119.237,67.736c17.677,9.332,38.139,13.717,59.477,13.717
c74.873,0,135.572-60.697,135.572-135.572C560.292,117.615,529.386,71.417,484.483,49.328z"/>
<g>
<path d="M343.934,394.863l12.635,4.516c-3.093,4.273-5.331,7.102-6.714,8.484c-6.796,6.796-14.995,10.193-24.598,10.193
c-9.563,0-17.741-3.397-24.536-10.193c-6.795-6.795-10.192-14.994-10.192-24.598c0-9.603,3.397-17.801,10.192-24.597
c6.795-6.795,14.974-10.192,24.536-10.192c9.603,0,17.802,3.397,24.598,10.192c1.383,1.384,3.621,4.171,6.714,8.363l-12.635,4.639
c-1.628-1.994-2.727-3.275-3.296-3.846c-4.232-4.231-9.359-6.348-15.381-6.348c-5.981,0-11.099,2.127-15.35,6.378
c-4.253,4.253-6.379,9.39-6.379,15.411c0,5.982,2.126,11.1,6.379,15.351c4.251,4.253,9.368,6.378,15.35,6.378
c6.021,0,11.17-2.115,15.442-6.348C341.228,398.077,342.306,396.816,343.934,394.863z"/>
<path d="M364.241,318.751h12.696v41.626c3.539-6.795,8.666-10.193,15.381-10.193c6.713,0,12.074,2.41,16.082,7.232
c4.008,4.822,6.073,10.875,6.195,18.159v40.832h-12.635v-40.344c0-3.622-1.027-6.724-3.082-9.309
c-2.055-2.583-5.3-3.875-9.734-3.875c-5.25,0-9.318,2.807-12.207,8.422v45.105h-12.696V318.751z"/>
<path d="M479.475,357.998v-4.395h12.695v62.866h-12.695v-7.873c-6.104,6.308-13.184,9.461-21.24,9.461
c-9.604,0-17.792-3.388-24.566-10.163c-6.775-6.774-10.162-14.963-10.162-24.566c0-9.603,3.387-17.792,10.162-24.567
c6.774-6.775,14.963-10.163,24.566-10.163C466.291,348.597,473.371,351.731,479.475,357.998z M479.475,387.966v-9.277
c-0.732-3.946-2.686-7.527-5.859-10.742c-4.272-4.231-9.399-6.348-15.381-6.348c-6.022,0-11.16,2.116-15.411,6.348
c-4.253,4.232-6.378,9.359-6.378,15.381c0,5.981,2.125,11.099,6.378,15.351c4.251,4.252,9.389,6.378,15.411,6.378
c5.981,0,11.108-2.115,15.381-6.348C476.789,395.494,478.742,391.913,479.475,387.966z"/>
<path d="M517.249,370.449v45.959h-12.695v-62.805h12.695v7.325c2.645-7.163,7.955-10.743,15.931-10.743
c6.795,0,12.196,2.41,16.204,7.232c4.008,4.822,6.073,10.875,6.195,18.159v40.832h-12.634v-40.344c0-3.622-1.323-6.724-3.968-9.309
c-2.646-2.583-5.798-3.875-9.46-3.875c-3.622,0-6.755,1.261-9.4,3.783C518.652,368.17,517.696,369.432,517.249,370.449z"/>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.6 KiB