diff --git a/README.md b/README.md index 4a9d3d6..cc0fc9e 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ git checkout -b my-pr-branch-name + [ ] Content filters * [x] Other + + [x] Sitemap + [x] RSS + [x] Moderation + [ ] Federative API diff --git a/example/environment/crontab b/example/environment/crontab index f392715..378d952 100644 --- a/example/environment/crontab +++ b/example/environment/crontab @@ -3,4 +3,5 @@ * * * * * indexer magnet --rotate -* * * * * /usr/bin/php /YGGtracker/src/crontab/scrape.php \ No newline at end of file +* * * * * /usr/bin/php /YGGtracker/src/crontab/scrape.php +0 0 * * * /usr/bin/php /YGGtracker/src/crontab/sitemap.php \ No newline at end of file diff --git a/src/crontab/sitemap.php b/src/crontab/sitemap.php new file mode 100644 index 0000000..5d5e297 --- /dev/null +++ b/src/crontab/sitemap.php @@ -0,0 +1,78 @@ + [ + 'ISO8601' => date('c'), + 'total' => microtime(true), + ], +]; + +// Connect DB +try { + + $db = new Database(DB_HOST, DB_PORT, DB_NAME, DB_USERNAME, DB_PASSWORD); + +} catch(Exception $e) { + + var_dump($e); + + exit; +} + +// Begin +try { + + // Delete cache + @unlink(__DIR__ . '/../public/sitemap.xml'); + + if ($handle = fopen(__DIR__ . '/../public/sitemap.xml', 'w+')) + { + + fwrite($handle, ''); + fwrite($handle, ''); + + foreach ($db->getMagnets() as $magnet) + { + if ($magnet->public && $magnet->approved) + { + fwrite($handle, sprintf('%s/magnet.php?magnetId=%s', WEBSITE_URL, $magnet->magnetId)); + } + } + + fwrite($handle, ''); + fclose($handle); + } + +} catch (EXception $e) { + + var_dump($e); +} + +// Debug output +$debug['time']['total'] = microtime(true) - $debug['time']['total']; + +print_r( + array_merge($debug, [ + 'db' => [ + 'total' => [ + 'select' => $db->getDebug()->query->select->total, + 'insert' => $db->getDebug()->query->insert->total, + 'update' => $db->getDebug()->query->update->total, + 'delete' => $db->getDebug()->query->delete->total, + ] + ] + ]) +); \ No newline at end of file