CaRP: Caching RSS Parser - Documentation
is a plugin bundled with CaRP Evolution.
It stores parsed RSS newsfeed items in a mySQL database for use by other programs.
Note that the data is not processed before being stored (HTML tags are not removed, it is not truncated to any specific length, etc.)
The application using the data must handle such functions as required.
- Put mysql.php into the "plugins" folder inside the folder containing carp.php.
(If no plugins folder exists, create one.)
- Follow the instructions at the top of the file mysql_setup.php, which is included in the CaRP Evolution archive, to set up your database tables.
To use this plugin, do the following:
- Enter the following command into your webpage after "require_once '/path/to/carp.php';":
- If necessary, use the functions listed below to change the plugin's configuration.
- MysqlCarpConf($field, $value);
Sets a configuration setting to the specified value (see below for more details).
- MysqlCarpRegisterField($internal_name, $database_field);
Use the function to indicate which RSS fields to store in the database, and the name of database field in which to store them.
The plugin already lists a default set of fields to store, so you may not need to use this function.
$internal_name is the same CaRP internal name for the field that you would specify in CarpConf('iorder','[field names]');
Use the CarpMapField function to set up new internal names for fields if you wish to store fields not automatically processed by CaRP.
Use this function to tell the plugin not to store a field which it is either configured to store by default, or which you told it to store using MysqlCarpRegisterField.
Resets the plugin's settings.
- MysqlCarpDeleteItem(); [Carp >=4.0.7 only]
This function marks a feed item as "deleted" by setting the "8" bit of the "new" field.
It also deletes most of the data in the item.
However, to prevent the item from reappearing the next time the feed is refreshed,
the item is not actually removed from the database.
Items marked "deleted" may be purged from the database
using the "mark_seen" and "purge_deleted_unseen" configuration settings described below.
Important: See the following function.
- MysqlCarpPrepareToDelete(); [Carp >=4.0.7 only]
This function needs to be called once before calling MysqlCarpDeleteItem().
MysqlCarpDeleteItem() may then be called multiple times to mark multiple items deleted at once.
- connect: 1 to have the plugin open a connection to mySQL, 0 to have it use an existing connection (which you must set up).
- username: The username to use in connecting to mySQL (if 'connect' is 0, leave this blank).
- password: The password to use in connecting to mySQL (if 'connect' is 0, leave this blank).
- host: The hostname, possibly incuding a port number, to use in connecting to mySQL.
If the mySQL is running on your webserver, the appropriate value is likely to be 'localhost'.
Ask your server administrator if you are unsure.
(If 'connect' is 0, leave this blank).
- dbname: The name of the database in which to store the newsfeed data.
If you will set up a mySQL connection and select the appropriate database before executing CaRP, you may leave this blank.
- closeconnection: 1 to have the plugin close the mySQL connection when it's done, 0 to leave the connection open.
- connection: A mySQL connection identifier, or FALSE if no connection is open.
You only need to specify this if you will open the connection in advance and you want to tell the plugin to use a specific connection.
If it may use the last connection opened, you don't need to set this.
- feedtable: The name of the database table where the plugin will store newsfeed id numbers and an MD5 hash of the URL to the feed.
- mark_seen: [Carp >=4.0.7 only]
If this setting is set to a non-zero value, an item in the feed is already in the database when it is refreshed,
the "new" field in the "rssitems" table will have it's "8" bit set.
Otherwise, the "8" bit will be cleared.
If this setting is set to 0 (the default), the "new" field will not be modified.
- purge_deleted_unseen: [Carp >=4.0.7 only]
If both mark_seen and this setting are set to non-zero values,
any items in a feed which have been marked "deleted" (by having their "new" field set to "2")
and which no longer appear in the feed will be deleted from the database.
The following configuration settings will only need to be changed if you wish to customize how the plugin stores the newsfeed data.
- itemtable: The name of the database field where the plugin will store the newsfeed items.
- savefields: A list of fields to store in the database.
The key is CaRP's internal field name, and the value is the name of the database field.
- datefields: The names of any database fields which will contain UNIX timestamps.
Any fields listed here are converted from text dates to UNIX timestamp numbers before being stored.
- numberfields: A list of fields which should only contain digits.
Any fields listed here are ensured to be numbers (and are set to zero if blank) before they are stored.
- checksumfields: A list of fields to create an MD5 hash of to determine whether an item has been modified since it was first stored.
- duplicatefields: A list of lists of fields to use in determining whether two newsfeed items are duplicates of each other.
Only one of the lists is used, as follows:
The first list for which the newsfeed contains an item for all of the fields listed is used, if any.
Otherwise, the last list is used.
- auxfields: This is a list similar to 'savefields', but used for internal operation rather than determining which fields to store.
The key should not be changed, but if you use non-standard database field names, you will need to change the values to match.