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 %} {% endfor %}
{% endif %} {% endif %}
</div> </div>
{% if stats %}
<div class="ban"> <div class="ban post">
<h2 id="post-statistics"> <h2 id="post-statistics">
{% trans "Post Statistics" %} {% trans "Post Statistics" %}
</h2> </h2>
<p> <table class="modlog" style="width: 50%; text-align: left;">
{{ stats.pph }} {% trans "posts in the last hour." %} <thead>
{{ stats.unique_ip_count }} {% trans "unique posters in the last hour." %} <tr>
</p> <th>Board</th>
</div> <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> <footer>
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard + <p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard +
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} - <a href="https://engine.vichan.net/">vichan</a> {{ config.version }} -
<br>Tinyboard Copyright &copy; 2010-2014 Tinyboard Development Group <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><a href="https://engine.vichan.net/">vichan</a> Copyright &copy; 2012-2016 vichan-devel
<br><br> <br><br>
<br><b>Leftypol.org is not currently under investigation by any Federal, State, or Local Authorities.</b></p> <br><b>Leftypol.org is not currently under investigation by any Federal, State, or Local Authorities.</b></p>
</footer> </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_main'], Categories::homepage($settings));
file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings)); file_write($config['dir']['home'] . $settings['file_news'], Categories::news($settings));
} }
if ($action == 'all'){ if ($action == 'all'){
file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings)); file_write($config['dir']['home'] . $settings['file_sidebar'], Categories::sidebar($settings));
} }
@ -94,33 +94,49 @@
} }
private static function getPostStatistics($settings) { private static function getPostStatistics($settings) {
$boards = query("SELECT uri FROM ``boards``"); if (!isset($config['boards'])) {
$unique = Array(); return null;
$pph = 0; }
$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( $pph_query = query(
sprintf("SELECT COUNT(*) AS count FROM ``posts_%s`` WHERE time > %d", sprintf("SELECT COUNT(*) AS count FROM ``posts_%s`` WHERE time > %d",
$_board['uri'], $_board['uri'],
time()-3600) time()-3600)
) or error(db_error()); ) or error(db_error());
$pph += $pph_query->fetch()['count']; $boardStat['pph'] = $pph_query->fetch()['count'];
$unique_query = query( $unique_query = query(
sprintf("SELECT ip FROM ``posts_%s`` WHERE time > %d", sprintf("SELECT DISTINCT ip FROM ``posts_%s`` WHERE time > %d",
$_board['uri'], $_board['uri'],
time()-3600) time()-3600)
) or error(db_error()); ) 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; $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