diff options
author | Maryana Rozhankivska <mariroz@mr.lviv.ua> | 2014-04-03 12:18:49 +0300 |
---|---|---|
committer | Maryana Rozhankivska <mariroz@mr.lviv.ua> | 2014-04-03 12:18:49 +0300 |
commit | a297fb1e38ce70a2c25f5dd9096fcfbf988ddf05 (patch) | |
tree | 91bcece7c7d959c2350335f8cc96e8e73b84868a /cron.php | |
parent | a4585f7eaa74d5f705c1622ac2419ea1198a7aba (diff) | |
download | wallabag-a297fb1e38ce70a2c25f5dd9096fcfbf988ddf05.tar.gz wallabag-a297fb1e38ce70a2c25f5dd9096fcfbf988ddf05.tar.zst wallabag-a297fb1e38ce70a2c25f5dd9096fcfbf988ddf05.zip |
import w/o cron
Diffstat (limited to 'cron.php')
-rw-r--r-- | cron.php | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/cron.php b/cron.php deleted file mode 100644 index 8fbf421a..00000000 --- a/cron.php +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | <?php | ||
2 | error_reporting(E_ALL); | ||
3 | include_once 'inc/poche/global.inc.php'; | ||
4 | include_once 'inc/poche/config.inc.php'; | ||
5 | |||
6 | if (php_sapi_name() === 'cli') { | ||
7 | $options_cli = getopt('', array( | ||
8 | 'limit::', | ||
9 | 'user-id::', | ||
10 | 'token::', | ||
11 | )); | ||
12 | } | ||
13 | else { | ||
14 | $options_cli = $_GET; | ||
15 | } | ||
16 | |||
17 | $limit = ! empty($options_cli['limit']) && ctype_digit($options_cli['limit']) ? (int) $options_cli['limit'] : 10; | ||
18 | $user_id = ! empty($options_cli['user-id']) && ctype_digit($options_cli['user-id']) ? (int) $options_cli['user-id'] : null; | ||
19 | $token = ! empty($options_cli['token']) ? $options_cli['token'] : null; | ||
20 | |||
21 | if (is_null($user_id)) { | ||
22 | die('You must give a user id'); | ||
23 | } | ||
24 | |||
25 | if (is_null($token)) { | ||
26 | die('You must give a token'); | ||
27 | } | ||
28 | |||
29 | $store = new Database(); | ||
30 | $config = $store->getConfigUser($user_id); | ||
31 | |||
32 | if ($token != $config['token']) { | ||
33 | die(_('Uh, there is a problem with the cron.')); | ||
34 | } | ||
35 | |||
36 | $items = $store->retrieveUnfetchedEntries($user_id, $limit); | ||
37 | |||
38 | foreach ($items as $item) { | ||
39 | $url = new Url(base64_encode($item['url'])); | ||
40 | $content = Tools::getPageContent($url); | ||
41 | |||
42 | $title = ($content['rss']['channel']['item']['title'] != '') ? $content['rss']['channel']['item']['title'] : _('Untitled'); | ||
43 | $body = $content['rss']['channel']['item']['description']; | ||
44 | |||
45 | // // clean content from prevent xss attack | ||
46 | $config = HTMLPurifier_Config::createDefault(); | ||
47 | $purifier = new HTMLPurifier($config); | ||
48 | $title = $purifier->purify($title); | ||
49 | $body = $purifier->purify($body); | ||
50 | |||
51 | |||
52 | $store->updateContentAndTitle($item['id'], $title, $body, $user_id); | ||
53 | } \ No newline at end of file | ||