aboutsummaryrefslogtreecommitdiffhomepage
path: root/cron.php
diff options
context:
space:
mode:
authorNicolas LÅ“uillet <nicolas@loeuillet.org>2014-03-07 13:26:56 +0100
committerNicolas LÅ“uillet <nicolas@loeuillet.org>2014-03-07 13:26:56 +0100
commitded2c63312c32c85f386d6cd8cd7085d8a9407e9 (patch)
tree4de5518586a1f45a3947d780962f264deaa0482d /cron.php
parent25114854b3e6b42c7be5e21a62539d8f23d3a10e (diff)
parentbf79463070c0dc96eacc52a949c1e3ad356817c0 (diff)
downloadwallabag-ded2c63312c32c85f386d6cd8cd7085d8a9407e9.tar.gz
wallabag-ded2c63312c32c85f386d6cd8cd7085d8a9407e9.tar.zst
wallabag-ded2c63312c32c85f386d6cd8cd7085d8a9407e9.zip
Merge pull request #532 from wallabag/upload-file
New import system
Diffstat (limited to 'cron.php')
-rw-r--r--cron.php53
1 files changed, 53 insertions, 0 deletions
diff --git a/cron.php b/cron.php
new file mode 100644
index 00000000..cc137ca2
--- /dev/null
+++ b/cron.php
@@ -0,0 +1,53 @@
1<?php
2
3include_once 'inc/poche/global.inc.php';
4include_once 'inc/poche/config.inc.php';
5
6if (php_sapi_name() === 'cli') {
7 $options_cli = getopt('', array(
8 'limit::',
9 'user-id::',
10 'token::',
11 ));
12}
13else {
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
21if (is_null($user_id)) {
22 die('You must give a user id');
23}
24
25if (is_null($token)) {
26 die('You must give a token');
27}
28
29$store = new Database();
30$config = $store->getConfigUser($user_id);
31
32if ($token != $config['token']) {
33 die(_('Uh, there is a problem with the cron.'));
34}
35
36$items = $store->retrieveUnfetchedEntries($user_id, $limit);
37
38foreach ($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