miniflux-legacy/cronjob.php
Mathias Kresin cfd03efc01 Fix database hijacking
Check if a requested database can be selected. Error out if not.
This prevents automatic fallbacks to the default database.

Remove the authorized information from the session if a new database
gets selected.

Factor out logout function to reuse existing code.
2015-01-17 21:14:44 +01:00

39 lines
1.2 KiB
PHP

<?php
require __DIR__.'/common.php';
if (php_sapi_name() === 'cli') {
$options = getopt('', array(
'limit::',
'call-interval::',
'update-interval::',
'database::',
));
}
else {
$options = $_GET;
}
if (! empty($options['database'])) {
if (! Model\Database\select($options['database'])) {
die("Database ".$options['database']." not found\r\n");
}
}
$limit = ! empty($options['limit']) && ctype_digit($options['limit']) ? (int) $options['limit'] : Model\Feed\LIMIT_ALL;
$update_interval = ! empty($options['update-interval']) && ctype_digit($options['update-interval']) ? (int) $options['update-interval'] : null;
$call_interval = ! empty($options['call-interval']) && ctype_digit($options['call-interval']) ? (int) $options['call-interval'] : null;
if ($update_interval !== null && $call_interval !== null && $limit === Model\Feed\LIMIT_ALL && $update_interval >= $call_interval) {
$feeds_count = PicoDb\Database::get('db')->table('feeds')->count();
$limit = ceil($feeds_count / ($update_interval / $call_interval));
}
Model\Feed\refresh_all($limit);
Model\Item\autoflush_read();
Model\Item\autoflush_unread();
Model\Config\write_debug();