diff --git a/src/lib/Feed.php b/src/lib/Feed.php index 459fc83..c5900c7 100644 --- a/src/lib/Feed.php +++ b/src/lib/Feed.php @@ -26,6 +26,10 @@ class Feed { /** @var string The XML namespace for XHTML */ public const string XHTML_NS = 'http://www.w3.org/1999/xhtml'; + /** @var string The user agent for Feed Reader Central's refresh requests */ + private const string USER_AGENT = + 'FeedReaderCentral/' . FRC_VERSION . ' +https://bitbadger.solutions/open-source/feed-reader-central'; + /** * When parsing XML into a DOMDocument, errors are presented as warnings; this creates an exception for them * @@ -170,6 +174,7 @@ class Feed { curl_setopt($docReq, CURLOPT_RETURNTRANSFER, true); curl_setopt($docReq, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($docReq, CURLOPT_TIMEOUT, 15); + curl_setopt($docReq, CURLOPT_USERAGENT, self::USER_AGENT); $result = [ 'content' => curl_exec($docReq), diff --git a/src/public/docs/index.php b/src/public/docs/index.php index 13ad8c9..37278bf 100644 --- a/src/public/docs/index.php +++ b/src/public/docs/index.php @@ -10,6 +10,7 @@ page_head('Documentation'); ?>

About the CLI provides orientation on Feed Reader Central’s command line interface

Configuring Security Modes describes the three security modes and how to manage each of them +

Refresh Feeds has instructions on how feeds can be refreshed on a schedule close(); diff --git a/src/public/docs/refresh-feeds.php b/src/public/docs/refresh-feeds.php new file mode 100644 index 0000000..1407e83 --- /dev/null +++ b/src/public/docs/refresh-feeds.php @@ -0,0 +1,52 @@ + +

Refresh Feeds

+
+

Manual Feed Refresh

+

Next to the “Your Unread Items” heading on the main page, there is a link labeled “Refresh All + Feeds”. Clicking this link will reload the main page once the feeds have been refreshed. Depending on the + number and size of feeds, this may take a bit of time; each feed is refreshed individually. +

Automatic Refreshing

+

The refresh utility script will perform this refresh from the CLI. As it runs, it will list the + feeds as it processes them, and if it encounters any errors, that is noted as well. This process can be + automated via cron on Linux or Mac systems. This is most easily implemented by writing a small + shell script to provide some environment settings, then telling cron to run that script. +

+#!/bin/bash
+exec 1> >(logger -t feed-reader-central) 2>&1
+cd /path/to/frc
+php-cli util/refresh.php all
+

Save this (frc-refresh.sh might be a good name) and be sure it is executable + (chmod +x ./frc-refresh.sh). Before we put it in crontab, though, let’s understand what each + line does: +

+

Finally, we are ready to add this to our crontab. Enter crontab -e to edit the file, then add a row + at the bottom that looks like this: +

+0 */6 * * *  /path/to/job/frc-refresh.sh
+

The items before the path specify when it should run. This example will run at the top of the hour every six + hours. Crontab schedules can be tricky to create; a full treatment is outside the scope of this documentation. + However, this site + lets you put values in each position and it translates that to words; this lets you see if what you put is what + you meant. +

This should not require many resources; the majority of its time will be spent waiting for the websites to return + their feeds so it can process them. However, if you want it to yield to everything else happening on the server, + add nice -n 1 (with a trailing space) before the path to the script. +

close();