GithubHelp home page GithubHelp logo

feed2js's Introduction

Feed2JS Code

by Alan Levine https://cogdogblog.com/

This directory contains likely the last of Feed2JS source code. It's still running as a free public service at http://feed2js.org but it barely works and is not maintained.

Most feeds will report error messages about it being invalid, this is the result of the ancient RSS parser not returning results. As of April 22, 2023 I am declaring it dead.

I am sorry but making this code work is beyond my abilities.

ABOUT

This PHP script will take an RSS feed as a value of src="...." and return a JavaScript file that can be linked remotely from any other web page. Output includes site title, link, and description as well as item site, link, and description with these outouts contolled by extra parameters.

It will not run inder PHP 8.

CODE

https://github.com/cogdog/feed2js

Feed2JS makes use of the Magpie RSS parser from http://magpierss.sourceforge.net/

License

GNU General Public License Copyright (C) 2004-2013 Alan Levine This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details http://www.gnu.org/licenses/gpl.html

INSTALLATION

Get the Latest Source Code now available at https://github.com/cogdog/feed2js

The files provided include:

  • build.php - build page which will allow your web site users to easily generate their proper JavaScript that works from your installation of Feed2JS.
  • feed2js_config.php - local configuration, set the file paths for Magpie, etc.
  • feed2js.php - the main workhorse script; see below for configuration details.
  • feed2js.inc - another version that you can access from the same server using a PHP include method rather than JavaScript.
  • footer - text for footer on Feed2JS web pages
  • magpie (directory) - latest version of MagpieRSS (http://magpierss.sourceforge.net/)
  • magpie_debug.php - test script if you have trouble setting up Magpie (best to remove from server if it works OK)
  • magpie_simple.php - demo page for magpie
  • nosource.php - a simple error file if the script is not provided an URL for the RSS feed.
  • popup.js - external Javascript library to enable links to appear in JavaScript generated window.
  • preview.php - used to generate previews from the build form.
  • styles (directory) - sample style sheets used for the preview feature of the build script.
  • style_preview.php - generates the styled previews
  • style.php - a version of our style tool which will allow your web site users to select and modify CSS styles for their feeds.

Directory structure

(main server directory)

/feed2js
  feed2js.php
     :
     :

  /magpie
	/extlib  
	  Snoopy.class.inc
	rss_cache.inc
	rss_fetch.inc
	rss_parse.inc
	rss_utils.inc
	/cache
	/cache-utf8

The "extlib" directory contains the a library file required by magpie "Snoopy.class.inc".

Inside the magpie directory are 2 directories named cache and cache_utf8 to store the cache files used by Magpie (the second are for RSS feeds that use UTF8 encoding). Make sure you change the permissions on both of these directories to be world writable with unix commands

chmod 0777 cache  
chmod 0777 cache_utf8

Before going further, you may want to run the magpie test file, magpie_debug.php. If you keep this file in /feed2js and keep the magpie files in its own subdirectory as provided in the download, there should be no edits required to make this work. Loading this in a web browser, e.g. http://www.mydomain.org/feed/magpie_debug.php will test your magpie installation.

Check if there are PHP errors-- PHP warnings are not a problem and are ignored by the main script.

If Magpie works okay, you are ready to configure the feed2js_config.php file. Look for the section labeled "INCLUDES" where you must define the correct paths for the Magpie files, the cache directory, and the time setting for having cache files expire, in seconds. the default is 60*60 or one hour. The default settings will work if you store the magpie directory inside the same directory as feed2js.php. This means that you do not have to make any changes to it.

// MAGPIE SETUP ----------------------------------------------------
// Define path to Magpie files and load library
// The easiest setup is to put the 4 Magpie include
// files in the same directory:
// define('MAGPIE_DIR', './magpie/')

// Otherwise, provide a full valid file path to the directory
// where magpie sites
define('MAGPIE_DIR', './magpie/');

// access magpie libraries
require_once(MAGPIE_DIR.'rss_fetch.inc');
require_once(MAGPIE_DIR.'rss_utils.inc');

// value of 2 optionally show lots of debugging info, 0 for production
define('MAGPIE_DEBUG', 0);

// Define cache age in seconds.
define('MAGPIE_CACHE_AGE', 60*60);

Some Windows servers do not handle the gmmktime function in line 45- this dynamically determines the server time's offset from GMT. If you see errors on this line, you can edit this line to manually set the time zone offset, e.g.:

$tz_offset = -7;

Run a known RSS Feed through your installed version of the build.php page and then test the style editor page.

If you are unable to see a feed previewed from the build page, there is likely a syntax error in feed2js.php. To isolate the problem, generate the JavaScript string, copy the URL that appears in the src="......" portion, and load it in your web browser. Any PHP errors should appear.

LIMITING USE OF YOUR INSTALL

You probably do not want to run a public service of Feed2JS; you can modify the feed2js_config.php file to include a domain to limit use of feeds (e.g. only sites within that domain can use your install). At this time, it is limited to either a single domain or a wildcard for subdomains (this needs to be updated in the code to allow a list of domains)

The default configuration file does not limit the usage to a domain

// Restrict RSS url to domain
// Example: www.example.org => allows www.example.org and mywww.example.org
// Example: .example.org => allows www.example.org and other.example.org

// remove the comment here to activate url restriction
//$restrict_url = ".example.org";

// comment out this line to activate url restriction
unset($restrict_url);

Modify it to use the domain you want to limit it:

// Restrict RSS url to domain
// Example: www.example.org => allows www.example.org and mywww.example.org
// Example: .example.org => allows www.example.org and other.example.org

// remove the comment here to activate url restriction
$restrict_url = ".example.org";

// comment out this line to activate url restriction
//unset($restrict_url);

See also a different approach for limiting via htaccess http://darcynorman.net/2009/03/18/blocking-script-leechers-by-http-referrer/

feed2js's People

Contributors

bateller avatar cogdog avatar hopets avatar mstrokin avatar myersg86 avatar steven1350 avatar timmmmyboy avatar woodwardtw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

feed2js's Issues

Magpie cache directories missing

The instructors say the user needs to chmod 2 cache directories in the magpie folder but currently those cache directories don't exist in the repository. Is the user supposed to create them?

Adding index.html?

I'm curious to know if there was any reasoning behind naming the main page where the action happens build.php and not either having an index.html page with some basic information or (even better in my eyes) just renaming build.php to index.php so users would only have to navigate to the root of the domain they put it on? Occurred to me when setting up the Amazon AMI that if users didn't read the documentation carefully they'd fire it up, get an Apache test page, and be confused. I'm happy to work on this if it's something you're interested in changing but figured I'd check here first in case there was a reason not to do it.

Wordpress.com Feeds Displays "Array" Instead of the Description

Hi there,

Apologies if this is not the right place to put this comment.

I was using your excellent service to embed a feed from wordpress.com. It was working great, however, recently it stopped working and instead of showing the description for an item it displays the word "array". It is doing this for all wordpress.com feeds. I have validated the feed as well.

Ben

Links or not for rss-item ?

Hello
Thanks for your "Feed2JS" generator.
I have a flux with no links (provide by : https://rss.aelf.org). So .rss-item have links with a blank href.
It will be nice if you could choose in the generator to have links or not for rss-item ?
Thanks

Warning: date(): It is not safe to rely on the system's timezone settings.

Hello, about 3 days ago, the news feeds on http://RocPic.Com/news stopped showing.
I viewed the source code

which is 15 instances of the first paragraph below, followed by the 2nd paragraph, then the missing news stories are below that.

Warning: date(): It is not safe to rely on the system's timezone settings. You are required to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/New_York' for 'EDT/-4.0/DST' instead in /home/feed2js/domains/feed2js.org/public_html/feed2js.php on line 306

Warning: Cannot modify header information - headers already sent by (output started at /home/feed2js/domains/feed2js.org/public_html/feed2js.php:306) in /home/feed2js/domains/feed2js.org/public_html/feed2js.php on line 387
feed2js_ck = true;

....
document.write('

');
document.write('

Minor XSS issue

The test for malicious use of script tags, feed2js.php lines 50 to 54 are insufficient.

Happy to share proof of concept as DM.

Can be mitigated at the server level. Can also be mitigated at the script level with new code from PHP7+ and/or a larger XSS library.

A PHP-level mitigation might impact project requirements and dependencies, so I wanted to file the issue before offering a PR.

Failing to Fetch HTTP Redirect Feeds

I'm failing to get a fetched feed for WordPress sites. Testing with magpie_debug.php -- e.g.

https://lab.cogdogblog.com/feed2js/magpie_debug.php?url=http%3A%2F%2Fcogdogblog.com%2Ffeed

I get

Warning: MagpieRSS: Failed to fetch http://cogdogblog.com/feed (HTTP Response: HTTP/1.1 301 Moved Permanently ) in /home/cogdog/subdomains/lab/feed2js/magpie/rss_fetch.inc on line 238 Error: MagpieRSS: Failed to fetch http://cogdogblog.com/feed (HTTP Response: HTTP/1.1 301 Moved Permanently )

PHP 8 incompatibility

Anyone else struggling to run feed2js on PHP 8? Works fine on PHP 7.4 for me, but after tupdating new RSS items aren't pulling through.

Feed Validator issue is breaking service

Hello,

It looks like http://feedvalidator.org/ is dead, and that services provided at http://feedvalidator.org/check.cgi can now be found https://validator.w3.org/feed/check.cgi. Can you please update?

Thank You

Error: Feed failed! Causes may be (1) No data found for RSS feed https://retirementresearcher.com/feed/; (2) There are no items are available for this feed; (3) The RSS feed does not validate.

Please verify that the URL https://retirementresearcher.com/feed/ works first in your browser and that the feed passes a validator test.

Not working anymore?

Hello, my feed used to work perfectly fine until maybe a month ago, but now all feeds seem to fail. Even the example http://cogdogblog.com/feed/ doesn't work. If I use the validator test that the error links to, they all still validate.
What could it be? Is the project still being worked on?

Feed won't validate WordPress feeds containing images with srcset

I have a site where the script outputs errors stating the feed url is invalid or the feed content is not valid:

Error: Feed failed! Causes may be (1) No data found for RSS feed https://www.mywebsite.com/blog/feed; (2) There are no items are available for this feed; (3) The RSS feed does not validate.

However when I execute the script src directly in my browser it works just fine.

feed2js_ck = true;

document.write('<div class="rss-box">');
document.write('<ul class="rss-items">');
document.write('<li class="rss-item"><a class="rss-item" href="https://www.mywebsite.com/blog/families-of-criminals-reach-their-breaking-point-a-new-investigation-discovery-series-premiering-january-15" target="_self">FAMILIES OF CRIMINALS REACH THEIR BREAKING POINT - A NEW INVESTIGATION DISCOVERY SERIES PREMIERING JANUARY 15</a><br />');
document.write('</li>');
document.write('<li class="rss-item"><a class="rss-item" href="https://www.mywebsite.com/blog/lifestyle-leader-and-mindfulness-expert-is-keynote-speaker-at-long-island-womens-wellness-conference" target="_self">LIFESTYLE LEADER AND MINDFULNESS EXPERT IS KEYNOTE SPEAKER AT LONG ISLAND WOMENS WELLNESS CONFERENCE</a><br />');
document.write('</li>');
document.write('<li class="rss-item"><a class="rss-item" href="https://www.mywebsite.com/blog/lifestyle-leader-joan-moran-receives-nomination-la-business-journal-for-women-making-a-difference-award" target="_self">Lifestyle Leader Joan Moran Receives Nomination - LA Business Journal for Women Making a Difference Award</a><br />');
document.write('</li>');
document.write('<li class="rss-item"><a class="rss-item" href="https://www.mywebsite.com/blog/the-annual-socal-csp-event" target="_self">the Annual SoCal CSP Event</a><br />');
document.write('</li>');
document.write('<li class="rss-item"><a class="rss-item" href="https://www.mywebsite.com/blog/slam-dunk-delivery-with-two-nsa-members" target="_self">SLAM Dunk Delivery with Two NSA Members</a><br />');
document.write('</li>');
document.write('</ul></div>');

Any ideas?

Access to close Issues

Alan,
Can you give me access to close issues and push commits to this repository so I can update Magpie?

Thanks,
Brian

Websites validate, but are not working

Hello, I can get the website to validate. However, once it throws in the code for backslashes and what not, the sites immediately invalidate on feed2js. I can go to them in a browser and view all the data, but it appears something in the coding that it is generated for the feed is invalidating the website url.

Valid RSS throws error

I try to add https://www.exploit-db.com/rss.xml which is according to Feed Validator a valid RSS Feed, but when i try do load it with feed2js i get this error:

HTTPS case
Feed URL missing, incomplete, or not valid. Must start with http:// and be a valid URL

HTTP case

Error: Feed failed! Causes may be (1) No data found for RSS feed http://www.exploit-db.com/rss.xml; (2) There are no items are available for this feed; (3) The RSS feed does not validate.

Please verify that the URL http://www.exploit-db.com/rss.xml works first in your browser and that the feed passes a validator test.

https://www.space.com/feeds/all does not validate but is valid per other RSS Feed validators

Error: Feed failed! Causes may be (1) No data found for RSS feed https://www.space.com/feeds/all; (2) There are no items are available for this feed; (3) The RSS feed does not validate.

https://www.space.com/feeds/all is valid per the link below.

https://validator.w3.org/feed/check.cgi?url=https%3A%2F%2Fwww.space.com%2Ffeeds%2Fall

feed2js used to work with https://www.space.com/feeds/all, but it stopped about a year ago but not sure why.

Speed issues

While I am very thankful that this project is still up and running, I couldn't help but notice that the speed with which the feed is pulled down has decreased drastically. I'm sure this is because of the switch to different hosting, but it's taking upwards of 5-10 seconds for the page to load, which is really hurting my sites performance.

Assuming this is something that isn't fixable, can you recommend an alternate option to your great design that I might be able to use to perform the same task?

Thanks very much for all your hard work, it was a great little piece of code!

Feed disappears when site changes to SSL

Hello,

Wonderful script! However I noticed today the RSS feed was gone from my site and at first I thought it was because of a server connection at the .org site but then I installed the script on my server and got the same thing. I accessed the site on a different computer and the RSS feed was in place. But on the machine I was working on I noticed my ecommerce site had switched to SSL because I was navigating around the cart (the RSS is in the footer on all pages). When on the SSL pages, the RSS feed was gone. When I switched to the site URL without SSL the feed returned.

Any way to get this to work on both?

I have the script hosted on one of my other accounts.

New RSS Parser

Hello,
Would there be interest in me implementing a new RSS parser? magpie is pretty dated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.