Browse Source

Per board pph

pull/40/head
nonmakina 3 years ago
parent
commit
c438ff9ab0
  1. 59
      templates/themes/categories/news.html
  2. 36
      templates/themes/categories/theme.php

59
templates/themes/categories/news.html

@ -24,22 +24,51 @@
{% endfor %}
{% endif %}
</div>
<div class="ban">
<h2 id="post-statistics">
{% trans "Post Statistics" %}
</h2>
<p>
{{ stats.pph }} {% trans "posts in the last hour." %}
{{ stats.unique_ip_count }} {% trans "unique posters in the last hour." %}
</p>
</div>
{% if stats %}
<div class="ban post">
<h2 id="post-statistics">
{% trans "Post Statistics" %}
</h2>
<table class="modlog" style="width: 50%; text-align: left;">
<thead>
<tr>
<th>Board</th>
<th>PPH</th>
<th>Recent IPs</th>
</tr>
</thead>
<tbody>
<tr>
<td class="minimal">
<span>{% trans Total %}</span>
</td>
<td class="minimal">
<span>{{ stats.pph }}</span>
</td>
<td class="minimal">
<span>{{ stats.recent_ips }}</span>
</td>
</tr>
{% for boardStat in stats.boards %}
<tr>
<td class="minimal">
<span>{{ boardStat.title }}</span>
</td>
<td class="minimal">
<span>{{ boardStat.pph }}</span>
</td class="minimal">
<span>{{ boardStat.recent_ips }}</span>
</td>
</tr>
</tbody>
</table>
</div>
{% endif %}
<footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard +
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} -
<br>Tinyboard Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard +
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} -
<br>Tinyboard Copyright &copy; 2010-2014 Tinyboard Development Group
<br><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel
<br><br>
<br><b>Leftypol.org is not currently under investigation by any Federal, State, or Local Authorities.</b></p>
</footer>

36
templates/themes/categories/theme.php

@ -24,7 +24,7 @@
file_write($config['dir']['home'] . $settings['file_main'], Categories::homepage($settings));
file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings));
}
if ($action == 'all'){
file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings));
}
@ -94,33 +94,49 @@
}
private static function getPostStatistics($settings) {
$boards = query("SELECT uri FROM ``boards``");
$unique = Array();
$pph = 0;
if (!isset($config['boards'])) {
return null;
}
$stats = [];
foreach (array_merge(... $config['boards']) as $_board) {
$title = boardTitle($board);
if (!$title) {
// board doesn't exist.
continue;
}
$boardStat['title'] = $title;
foreach ($boards->fetchAll() as $_board) {
$pph_query = query(
sprintf("SELECT COUNT(*) AS count FROM ``posts_%s`` WHERE time > %d",
$_board['uri'],
time()-3600)
) or error(db_error());
$pph += $pph_query->fetch()['count'];
$boardStat['pph'] = $pph_query->fetch()['count'];
$unique_query = query(
sprintf("SELECT ip FROM ``posts_%s`` WHERE time > %d",
sprintf("SELECT DISTINCT ip FROM ``posts_%s`` WHERE time > %d",
$_board['uri'],
time()-3600)
) or error(db_error());
foreach ($unique_query->fetchAll() as $_k => $row) {
$unique_ips = $unique_query->fetchAll();
$boardStat['recent_ips'] = count($unique_ips);
foreach ( as $_k => $row) {
$unique[$row['ip']] = true;
}
$stats['boards'][] = $boardStat;
}
$unique_ip_count = count($unique);
$stats['recent_ips'] = count($unique);
$stats['pph'] = count(array_column($stats['board'], 'pph'));
return Array('pph' => $pph, 'unique_ip_count' => $unique_ip_count);
return $stats;
}

Loading…
Cancel
Save