From 1bd79b27d660ae8afc4f3c703ab9e17606171c88 Mon Sep 17 00:00:00 2001 From: Neck Date: Tue, 21 May 2013 19:18:19 +0100 Subject: [PATCH] Allow cronjob.php to be called from web. --- cronjob.php | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cronjob.php b/cronjob.php index 4e048fe..f7346ee 100644 --- a/cronjob.php +++ b/cronjob.php @@ -13,12 +13,17 @@ if (is_console()) { $limit = empty($options['limit']) ? LIMIT_ALL : (int)$options['limit']; $update_interval = empty($options['update-interval']) ? null : (int)$options['update-interval']; $call_interval = empty($options['call-interval']) ? null : (int)$options['call-interval']; +} else { - if ($update_interval !== null && $call_interval !== null && $limit === LIMIT_ALL && $update_interval >= $call_interval) { - - $feeds_count = \PicoTools\singleton('db')->table('feeds')->count(); - $limit = ceil($feeds_count / ($update_interval / $call_interval)); // compute new limit - } - - Model\update_feeds($limit); + $limit = empty($_GET['limit']) ? LIMIT_ALL : (int)$_GET['limit']; + $update_interval = empty($_GET['update-interval']) ? null : (int)$_GET['update-interval']; + $call_interval = empty($_GET['call-interval']) ? null : (int)$_GET['call-interval']; } + +if ($update_interval !== null && $call_interval !== null && $limit === LIMIT_ALL && $update_interval >= $call_interval) { + + $feeds_count = \PicoTools\singleton('db')->table('feeds')->count(); + $limit = ceil($feeds_count / ($update_interval / $call_interval)); // compute new limit +} + +Model\update_feeds($limit);