diff options
Diffstat (limited to 'templates/themes/recent/theme.php')
| -rw-r--r-- | templates/themes/recent/theme.php | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php index ad6f99e4..f44e2529 100644 --- a/templates/themes/recent/theme.php +++ b/templates/themes/recent/theme.php @@ -24,8 +24,14 @@ $this->excluded = explode(' ', $settings['exclude']); - if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') - file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + if ($action == 'all' || $action == 'post' || $action == 'post-thread' || $action == 'post-delete') { + if ($config['smart_build']) { + file_unlink($config['dir']['home'] . $settings['html']); + } + else { + file_write($config['dir']['home'] . $settings['html'], $this->homepage($settings)); + } + } } // Build news page @@ -62,7 +68,7 @@ // board settings won't be available in the template file, so generate links now $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] - . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + . link_for($post) . '#' . $post['id']; if ($files) { if ($files[0]->thumb == 'spoiler') { @@ -92,7 +98,7 @@ while ($post = $query->fetch(PDO::FETCH_ASSOC)) { openBoard($post['board']); - $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . sprintf($config['file_page'], ($post['thread'] ? $post['thread'] : $post['id'])) . '#' . $post['id']; + $post['link'] = $config['root'] . $board['dir'] . $config['dir']['res'] . link_for($post) . '#' . $post['id']; if ($post['body'] != "") $post['snippet'] = pm_snippet($post['body'], 30); else @@ -124,15 +130,21 @@ $query = query($query) or error(db_error()); $stats['unique_posters'] = number_format($query->fetchColumn()); - /*$query = 'SELECT SUM(`filesize`) FROM ('; + // Active content + $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, |
