The task is to develop a PHP script which will read in a table of RSS/XML feeds from a MySQL database, check for new items in each feed and then load new items into a table in the same MySQL database.
I will provide you with MySQL table structure and the data for the table which contains all of the feeds to be processed.
The task is to develop a PHP script which will read in a table of RSS/XML feeds from a MySQL database, check for new items in each feed and then load new items into a table in MySQL.
1. As input for the script, read in a list of RSS/XML feeds from a table named feed.
a. The attached file [url removed, login to view] contains the code to create this table.
b. The script should only process a feed if the active field is set equal to 1.
2. For each feed, the script should
a. Read the contents of the feed. If it speeds up development, you can use a component such as MagpieRSS (<[url removed, login to view]>) or SimplePie ([[url removed, login to view]]) to read the feed contents
b. For each feed item, the script should check if the item is already stored in the database. To identify duplicates, the script should generate a hash of the title of the feed item (example: md5(item_title)) and then attempt to join this to the feed_content table on the md5 hash and the ID of the feed. Feel free to use another method to detect duplicates if you feel that there is a better technique.
c. If the item is not a duplicate item, insert the elements in the feed_content table. See the table layout in the attached [url removed, login to view] file. The fields in the table are:
i. Feed_content_id: auto generated ID for the feed item
ii. Feed_id: ID number of the feed, which is from the feed table
iii. Url: The URL associated with the feed item
iv. Title: The title of the feed item
v. Content: The content of the feed item
vi. Item_time: The item time from the feed, if it is provided. Otherwise, the feed will be null
vii. Item_md5: The MD5 value of the title (e.g. md5(title)).
3. Once the script has processed all of the feeds, it will generate the following output:
a. The following data for each feed in the feeds table
i. The Feed name, which will be hyperlinked to the URL of the feed (from the feeds table)
ii. The number of items read for each feed
iii. The number of items loaded to the database for each feed. This count excludes duplicate items which are not loaded into the database.
b. The total time that the PHP script took to execute. (example: Page generated in [url removed, login to view] seconds)