diff options
| author | czaks <marcin@6irc.net> | 2013-07-17 22:17:37 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-07-17 22:17:37 -0400 |
| commit | 8c72c8a43232f137256fa170c889ba330ebba7af (patch) | |
| tree | 3e91b94489627a774971dbb09f84bfaaa1465a75 /templates/themes/sitemap/theme.php | |
| parent | dd4aea54312b288dbfe885be87148f8df116047a (diff) | |
| parent | 7e95e80c25e2f35b8a49ebd73f95671b0233be6f (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Diffstat (limited to 'templates/themes/sitemap/theme.php')
| -rw-r--r-- | templates/themes/sitemap/theme.php | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/templates/themes/sitemap/theme.php b/templates/themes/sitemap/theme.php new file mode 100644 index 00000000..372d292d --- /dev/null +++ b/templates/themes/sitemap/theme.php @@ -0,0 +1,28 @@ +<?php + require 'info.php'; + + function sitemap_build($action, $settings) { + global $config; + + // Possible values for $action: + // - all (rebuild everything, initialization) + // - news (news has been updated) + // - boards (board list changed) + // - post (a post has been made) + + $boards = explode(' ', $settings['boards']); + + $threads = array(); + + foreach ($boards as $board) { + $query = query(sprintf("SELECT `id` AS `thread_id`, (SELECT `time` FROM `posts_%s` WHERE `thread` = `thread_id` OR `id` = `thread_id` ORDER BY `time` DESC LIMIT 1) AS `lastmod` FROM `posts_%s` WHERE `thread` IS NULL", $board, $board)) or error(db_error()); + $threads[$board] = $query->fetchAll(PDO::FETCH_ASSOC); + } + + file_write($settings['path'], Element('themes/sitemap/sitemap.xml', Array( + 'settings' => $settings, + 'config' => $config, + 'threads' => $threads, + 'boards' => $boards, + ))); + } |
