From e6d7e71175e388b7d5e356eebb9ff350c941026e Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Sat, 28 May 2011 01:47:59 +1000 Subject: renamed "homepage" directory to "themes" --- templates/themes/recent/theme.php | 147 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 templates/themes/recent/theme.php (limited to 'templates/themes/recent/theme.php') diff --git a/templates/themes/recent/theme.php b/templates/themes/recent/theme.php new file mode 100644 index 00000000..764c4170 --- /dev/null +++ b/templates/themes/recent/theme.php @@ -0,0 +1,147 @@ +build($action, $settings); + } + + // Wrap functions in a class so they don't interfere with normal Tinyboard operations + class RecentPosts { + public function build($action, $settings) { + global $config, $_theme; + + if($action == 'all') { + //copy($config['dir']['homepage'] . '/' . $_theme . '/recent.css', $config['dir']['home'] . 'recent.css'); + } + + $this->excluded = explode(' ', $settings['exclude']); + + if($action == 'all' || $action == 'post') + // file_put_contents($config['dir']['home'] . $config['file_index'], $this->homepage($settings)); + file_write($config['dir']['home'] . 'recent.html', $this->homepage($settings)); + } + + // Build news page + public function homepage($settings) { + global $config, $board; + + // HTML5 + $body = '' + . '' + . '' + . '' + . '' . $settings['title'] . '' + . ''; + + $boardlist = createBoardlist(); + $body .= '
' . $boardlist['top'] . '
'; + + $body .= '

' . $settings['title'] . '

'; + + + $boards = listBoards(); + + // Wrap + $body .= '
'; + + // Recent images + $body .= '

Recent Images

    '; + $query = ''; + foreach($boards as &$_board) { + if(in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` WHERE `file` IS NOT NULL UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 3', $query); + $query = query($query) or error(db_error()); + + while($post = $query->fetch()) { + openBoard($post['board']); + + $body .= '
  • '; + } + $body .= '
'; + + // Latest posts + $body .= '

Latest Posts

    '; + $query = ''; + foreach($boards as &$_board) { + if(in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT *, '%s' AS `board` FROM `posts_%s` UNION ALL ", $_board['uri'], $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', 'ORDER BY `time` DESC LIMIT 30', $query); + $query = query($query) or error(db_error()); + + while($post = $query->fetch()) { + openBoard($post['board']); + + $body .= '
  • ' . $board['name'] . ': ' . pm_snippet($post['body'], 30) . '
  • '; + } + + $body .= '
'; + + + // Stats + $body .= '

Stats

    '; + + // Total posts + $query = 'SELECT SUM(`top`) AS `count` FROM ('; + foreach($boards as &$_board) { + if(in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT MAX(`id`) AS `top` FROM `posts_%s` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + $res = $query->fetch(); + $body .= '
  • Total posts: ' . number_format($res['count']) . '
  • '; + + // Unique IPs + $query = 'SELECT COUNT(DISTINCT(`ip`)) AS `count` FROM ('; + foreach($boards as &$_board) { + if(in_array($_board['uri'], $this->excluded)) + continue; + $query .= sprintf("SELECT `ip` FROM `posts_%s` UNION ALL ", $_board['uri']); + } + $query = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + $res = $query->fetch(); + $body .= '
  • Unique posters: ' . number_format($res['count']) . '
  • '; + + // Active content + $query = 'SELECT SUM(`filesize`) AS `count` 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 = preg_replace('/UNION ALL $/', ') AS `posts_all`', $query); + $query = query($query) or error(db_error()); + $res = $query->fetch(); + $body .= '
  • Active content: ' . format_bytes($res['count']) . '
  • '; + + $body .= '
'; + + // End wrap + $body .= '
'; + + // Finish page + $body .= '

Powered by Tinyboard'; + + return $body; + } + }; + +?> \ No newline at end of file -- cgit v1.3