Merge pull request #129 from JasonPuglisi/active-content-fix

Fixed and re-enabled active content stat for recent theme
This commit is contained in:
Marcin Łabanowski 2015-03-28 05:22:02 +01:00
commit 8eb3d709f7

View File

@ -125,15 +125,20 @@
$stats['unique_posters'] = number_format($query->fetchColumn());
// Active content
/*$query = 'SELECT SUM(`filesize`) FROM (';
$query = 'SELECT DISTINCT(`files`) FROM (';
foreach ($boards as &$_board) {
if (in_array($_board['uri'], $this->excluded))
continue;
$query .= sprintf("SELECT `filesize` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
$query .= sprintf("SELECT `files` FROM ``posts_%s`` UNION ALL ", $_board['uri']);
}
$query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query);
$query = preg_replace('/UNION ALL $/', ' WHERE `num_files` > 0) AS `posts_all`', $query);
$query = query($query) or error(db_error());
$stats['active_content'] = $query->fetchColumn();*/
$files = $query->fetchAll();
$stats['active_content'] = 0;
foreach ($files as &$file) {
preg_match_all('/"size":([0-9]*)/', $file[0], $matches);
$stats['active_content'] += array_sum($matches[1]);
}
return Element('themes/recent/recent.html', Array(
'settings' => $settings,