2013-07-17 16:17:28 +02:00
< ? php
require 'info.php' ;
2013-07-18 18:06:26 +02:00
function sitemap_build ( $action , $settings , $board ) {
2013-07-17 16:17:28 +02:00
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)
2013-07-18 18:06:26 +02:00
// - thread (a thread has been made)
if ( $action != 'post' && $action != 'post-thread' )
return ;
2013-07-17 16:17:28 +02:00
$boards = explode ( ' ' , $settings [ 'boards' ]);
$threads = array ();
foreach ( $boards as $board ) {
2013-08-01 04:14:26 +02:00
$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 ());
2013-07-17 16:17:28 +02:00
$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 ,
)));
}