2013-02-18 03:48:21 +01:00
|
|
|
<?php
|
2013-05-21 12:25:13 +02:00
|
|
|
|
2016-08-19 03:06:46 +02:00
|
|
|
require __DIR__.'/app/common.php';
|
2013-02-18 03:48:21 +01:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
use Miniflux\Handler;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Model;
|
2017-01-16 00:03:53 +01:00
|
|
|
use Miniflux\Session\SessionStorage;
|
2016-08-25 03:17:58 +02:00
|
|
|
|
2013-05-22 13:13:56 +02:00
|
|
|
if (php_sapi_name() === 'cli') {
|
2013-05-18 20:35:16 +02:00
|
|
|
$options = getopt('', array(
|
|
|
|
'limit::',
|
|
|
|
'call-interval::',
|
2014-04-06 02:24:13 +02:00
|
|
|
'update-interval::',
|
2013-05-18 20:35:16 +02:00
|
|
|
));
|
2016-12-26 15:44:53 +01:00
|
|
|
} else {
|
|
|
|
$token = isset($_GET['token']) ? $_GET['token'] : '';
|
|
|
|
$user = Model\User\get_user_by_token('cronjob_token', $token);
|
2013-05-18 20:35:16 +02:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
if (empty($user) || !ENABLE_CRONJOB_HTTP_ACCESS) {
|
|
|
|
die('Access Denied');
|
2015-01-17 19:35:59 +01:00
|
|
|
}
|
2016-12-26 15:44:53 +01:00
|
|
|
|
|
|
|
$options = $_GET;
|
2014-04-06 02:24:13 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
$limit = get_cli_option('limit', $options);
|
|
|
|
$update_interval = get_cli_option('update-interval', $options);
|
|
|
|
$call_interval = get_cli_option('call-interval', $options);
|
2017-01-16 00:03:53 +01:00
|
|
|
$session = SessionStorage::getInstance();
|
|
|
|
|
|
|
|
foreach (Model\User\get_all_user_ids() as $user_id) {
|
|
|
|
$session->flush();
|
|
|
|
$session->setUser(Model\User\get_user_by_id($user_id));
|
2013-05-22 13:13:56 +02:00
|
|
|
|
2016-12-26 15:44:53 +01:00
|
|
|
if ($update_interval !== null && $call_interval !== null && $limit === null && $update_interval >= $call_interval) {
|
2017-01-16 00:03:53 +01:00
|
|
|
$feeds_count = Model\Feed\count_feeds($user_id);
|
2017-01-09 14:08:34 +01:00
|
|
|
$current_limit = ceil($feeds_count / ($update_interval / $call_interval));
|
|
|
|
} else {
|
|
|
|
$current_limit = $limit;
|
2016-12-26 15:44:53 +01:00
|
|
|
}
|
2013-05-21 20:18:19 +02:00
|
|
|
|
2017-01-16 00:03:53 +01:00
|
|
|
echo 'Update feeds for user_id='.$user_id.', limit='.$current_limit.PHP_EOL;
|
|
|
|
|
|
|
|
Handler\Feed\update_feeds($user_id, $current_limit);
|
|
|
|
Model\Item\autoflush_read($user_id);
|
|
|
|
Model\Item\autoflush_unread($user_id);
|
2016-12-26 15:44:53 +01:00
|
|
|
Miniflux\Helper\write_debug_file();
|
|
|
|
}
|