Browse Source
Add PPH and unique posters stats to home page
pull/40/head
Dedushka
3 years ago
No known key found for this signature in database
GPG Key ID: DC969A6BA7657A70
2 changed files with
60 additions and
16 deletions
-
templates/themes/categories/news.html
-
templates/themes/categories/theme.php
|
|
@ -25,6 +25,16 @@ |
|
|
|
{% 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> |
|
|
|
|
|
|
|
<footer> |
|
|
|
<p class="unimportant" style="margin-top:20px;text-align:center;">- Tinyboard + |
|
|
|
<a href="https://engine.vichan.net/">vichan</a> {{ config.version }} - |
|
|
|
|
|
@ -30,6 +30,7 @@ |
|
|
|
global $config; |
|
|
|
$query = query("SELECT * FROM ``news`` ORDER BY `time` DESC") or error(db_error()); |
|
|
|
$news = $query->fetchAll(PDO::FETCH_ASSOC); |
|
|
|
$stats = Categories::getPostStatistics($settings); |
|
|
|
return Element( |
|
|
|
'themes/categories/frames.html', |
|
|
|
Array( |
|
|
@ -37,6 +38,7 @@ |
|
|
|
'settings' => $settings, |
|
|
|
'categories' => Categories::getCategories($config), |
|
|
|
'news' => $news, |
|
|
|
'stats' => $stats, |
|
|
|
'boardlist' => createBoardlist(false) |
|
|
|
|
|
|
|
) |
|
|
@ -83,6 +85,38 @@ |
|
|
|
|
|
|
|
return $categories; |
|
|
|
} |
|
|
|
|
|
|
|
private static function getPostStatistics($settings) { |
|
|
|
$boards = query("SELECT uri FROM ``boards``"); |
|
|
|
$unique = Array(); |
|
|
|
$pph = 0; |
|
|
|
|
|
|
|
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']; |
|
|
|
|
|
|
|
$unique_query = query( |
|
|
|
sprintf("SELECT ip FROM ``posts_%s`` WHERE time > %d", |
|
|
|
$_board['uri'], |
|
|
|
time()-3600) |
|
|
|
) or error(db_error()); |
|
|
|
|
|
|
|
foreach ($unique_query->fetchAll() as $_k => $row) { |
|
|
|
$unique[$row['ip']] = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
$unique_ip_count = count($unique); |
|
|
|
|
|
|
|
return Array('pph' => $pph, 'unique_ip_count' => $unique_ip_count); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
?> |
|
|
|