about summary refs log tree commit diff stats
path: root/wiki/inc/FeedParser.php
diff options
context:
space:
mode:
authorahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
committerahriman <ahriman@falte.red>2018-12-03 19:22:25 -0500
commit0ae8cbf5c0b1a198b963490985b7738392ebcb97 (patch)
treeb2c77ae72c6b717e2b97492065196ac5ffb2d9e2 /wiki/inc/FeedParser.php
parentf57f6cc5a2d159f90168d292437dc4bd8cd7f934 (diff)
downloadsite-0ae8cbf5c0b1a198b963490985b7738392ebcb97.tar.gz
installed dokuwiki, added to navbar, updated news
Diffstat (limited to 'wiki/inc/FeedParser.php')
-rw-r--r--wiki/inc/FeedParser.php84
1 files changed, 84 insertions, 0 deletions
diff --git a/wiki/inc/FeedParser.php b/wiki/inc/FeedParser.php
new file mode 100644
index 0000000..39434dc
--- /dev/null
+++ b/wiki/inc/FeedParser.php
@@ -0,0 +1,84 @@
+<?php
+/**
+ * Class used to parse RSS and ATOM feeds
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+
+if(!defined('DOKU_INC')) die('meh.');
+
+/**
+ * We override some methods of the original SimplePie class here
+ */
+class FeedParser extends SimplePie {
+
+    /**
+     * Constructor. Set some defaults
+     */
+    function __construct(){
+        parent::__construct();
+        $this->enable_cache(false);
+        $this->set_file_class('FeedParser_File');
+    }
+
+    /**
+     * Backward compatibility for older plugins
+     *
+     * @param string $url
+     */
+    function feed_url($url){
+        $this->set_feed_url($url);
+    }
+}
+
+/**
+ * Fetch an URL using our own HTTPClient
+ *
+ * Replaces SimplePie's own class
+ */
+class FeedParser_File extends SimplePie_File {
+    var $http;
+    var $useragent;
+    var $success = true;
+    var $headers = array();
+    var $body;
+    var $error;
+    /** @noinspection PhpMissingParentConstructorInspection */
+
+    /**
+     * Inititializes the HTTPClient
+     *
+     * We ignore all given parameters - they are set in DokuHTTPClient
+     *
+     * @inheritdoc
+     */
+    function __construct($url, $timeout=10, $redirects=5,
+                         $headers=null, $useragent=null, $force_fsockopen=false, $curl_options = array()) {
+        $this->http    = new DokuHTTPClient();
+        $this->success = $this->http->sendRequest($url);
+
+        $this->headers = $this->http->resp_headers;
+        $this->body    = $this->http->resp_body;
+        $this->error   = $this->http->error;
+
+        $this->method  = SIMPLEPIE_FILE_SOURCE_REMOTE | SIMPLEPIE_FILE_SOURCE_FSOCKOPEN;
+
+        return $this->success;
+    }
+
+    /** @inheritdoc */
+    function headers(){
+        return $this->headers;
+    }
+
+    /** @inheritdoc */
+    function body(){
+        return $this->body;
+    }
+
+    /** @inheritdoc */
+    function close(){
+        return true;
+    }
+
+}