RSS Feeds for FTP Servers

RSS Feeds for FTP Servers
by Mark Woodman |

Put It to Work

After placing ftp_monitor.php on your PHP-enabled web server, you can reference it from any other PHP script. Here is an example of how that might look:

<?php

  

   // Import the FTP Monitor

   require_once('ftp_monitor.php');

    

   // Connection params to monitor FreeBSD snapshots

   $host = "ftp.freebsd.org";

   $user = "anonymous";

   $pass = "guest@anon.com";

   $path = "/pub/FreeBSD/snapshots";

   

   // Generate RSS 2.0 feed showing newest FreeBSD snapshots

   generateRssFeed($host, $user, $pass, $path, 10);

?>

Here is a sample output file from the above connection parameters: freebsd.xml. When viewed in SharpReader, the items look like this:

PHP Info with FTP Enabled
Figure 2. FTP Monitor items for ftp.freebsd.org

Many RSS aggregators will automatically follow an item's link if it does not have a description element. SharpReader is one of these aggregators, and it also supports the ftp:// protocol. Thus, clicking on one of the items from our FTP monitor will start to download it automatically. This usually works just fine if the FTP server allows anonymous connections. If you had to provide a real username and password in ftp_monitor.php, however, your ability to "click and download" will depend on whether your RSS reader can prompt you for FTP credentials.

Enhance Your Performance

There are a few caveats to keep in mind when using this script. First, many FTP servers aren't exactly speedy, so the performance of this script will be bound by the response times of the FTP commands themselves. Simply put, the more directories it has to recurse, the longer it will take. Try to limit the scope of what you need to monitor.

Second, this script is not intended to be hit by a lot of concurrent users. The speed issue is one factor, but the other is FTP connections. For every concurrent hit to this script, a connection is made to the FTP server. It won't take much for the available connections to max out. So, if you want to provide an RSS feed to a lot of users, you should hide this script behind a cache which calls it on a periodic basis. Let the real load be handled by your cache, not the ftp_monitor script.

If you keep these constraints in mind, you can provide a nice service to your users which provides the information they need without frustrating response times.

Give It Back

If you find this script useful, or if you come up with a cool modification to it, I'd love to hear from you. Post a comment and share what you have learned with the xml.com community.

Prev  [1] [2] [3] [4] 

Close    To Top
  • Prev Article-XML:
  • Next Article-XML: None
  • Now: Tutorial for Web and Software Design > XML > Metadata > XML Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction