WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Mobile Dev World

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : AutoRSS
Categories : PHP, Rich Site Summary (RSS), PHP Classes
ROBERTO ALEMAN
Date : Dec 06th 2009
Grade : Be the 1st to grade this Code Example
Viewed : 1380
File : 5009.zip
Images : Image 1
Search : More code by ROBERTO ALEMAN
Action : Grade This Code Example
Tools : My Examples List

 
Like this code?
Show the author your appreciation.
Submit your own code examples 
 

This class can be used to generate a RSS feed from files pf a directory.

It can read the list of files available in a given server directory and generates an RSS 2.0 feed with the list of files.

The base URL for the files and other details are configurable options.

index.php
<?php
/* Class AutoRSS v 1.0
Autor : Roberto Aleman
Email : ventics@gmail.com
General Public Licence , GPL */

// call to auto rss class
require_once("autorss.php");

//create new object
$newrss = new autorss();

/* example of use and orden of vars :
$document_type : document type, default : Content-type:text/xml
$path: absolute path of your folder, example path : http://ventics.com/autorss/
$xmlversion : XML file version , default : 1.0
$encoding : encondig : default :utf-8
$rssversion : RSS version, default : 2.0
$atomversion : ATOM version , default : http://www.w3.org/2005/Atom
$title: Title of your RSS autoengine channel : example: CLASS AUTORSS
$homelink: Link os your RSS autoengine channerl: example: http://www.ventics.com/autorss/
$description: description about your autoengine channel : example : CLASS AUTORSS TEST by ROBERTO ALEMAN
$language: language of xml file definition , ISO format is require, example: en-us
$lastupdate: Date of last update xml file autoengine, example : Sun, 31 May 2009 09:41:01 GMT
$callfile: file to calle autorss class, example : index.php
$generator: channel generator
$permalink: if permalink? true or false
$category: category of each file

change log :

22/06/09: Add tags : generator in channel definition and pubDate, isPermalink, category domain in item definition
and add lstat option to get info about file, where:
$info[7],  size in bytes
$info[9], 9 mtime last modified (Unix time)

*/
//send parameters and engine rss
$newrss->show("Content-type:text/xml","http://localhost/autorss/", "1.0","utf-8","2.0","http://www.w3.org/2005/Atom","CLASS AUTORSS","http://localhost/autorss/","CLASS AUTORSS TEST by ROBERTO ALEMAN","en-us","Sun, 31 May 2009 09:41:01 GMT","index.php","CLASS AUTORSS","true","My Pics");
?>



autorss.php
<?php
/* CLASS AUTORSS V 1.0 Autor : Roberto Aleman Email : ventics@gmail.com
This class is to automatic read and show  the files in a directory as rss 2.0 version,
only configure the config.php file with de globals vars and xml and rss versions,
the directory path and put config, callfile and autorss in directory to show at rss channel.
i apply to read a folder of images and show images gallery to rss channel with feedreader. Enjoy!!
GENERAL PUBLIC LICENCE , GPL */
class autorss
{
    public function
show($document_type,$path,$xmlversion,$encoding,$rssversion,$atomversion,$title,$homelink,$description,$language,$lastupdate,$callfile,$generator,$permalink,$category)
    {
       
header($document_type); // define document type header
       
$dir=getcwd(); // get directory where is script
       
$dr=@opendir($dir); //asign path to $dr var
       
if(!$dr){
            echo
"<error/>"; //if error, stop! and exit!
           
exit;
        return;
        }
        else
        {
//begin write xml file whith vars
echo "<?xml version='".$xmlversion."' encoding='".$encoding."'?>
<rss version='"
.$rssversion."' xmlns:atom='".$atomversion."'>
<channel>
<atom:link href='"
.$path."' rel='self' type='application/rss+xml'/>
<title>"
.$title."</title>
<link>"
.$homelink."</link>
<description>"
.$description."</description>
<language>"
.$language."</language>
<lastBuildDate>"
.$lastupdate."</lastBuildDate>
<generator>"
.$generator."</generator>";
while ((
$archivo = readdir($dr)) !== false){
    if(
$archivo!="autorss.php" AND $archivo!="." AND $archivo!=".." AND $archivo!="error_log" AND $archivo!=$callfile )    {
       
clearstatcache() ;
       
$info = lstat($archivo);
        echo
"
        <item>
        <title>"
.$path.$archivo."</title>
        <link>"
.$path.$archivo."</link>
        <pubDate>"
.date('r' ,$info[9])."</pubDate>
        <description><![CDATA[<img src="
.$path.$archivo."></img><br/>File Size :".$info[7]." Bytes, Modified:".date('r',$info[9])."]]></description>
        <guid isPermaLink='"
.$permalink."'>".$path.$archivo."</guid>
        <category domain='"
.$path."'>".$category."</category>
        </item>"
;
    }
}
echo
"</channel></rss>";
           
closedir($dr);
            return;
        }
    }
}
?>



RSS parser. Parses RSS into an array. Quick and nasty but does the job. No checking is done for correct Tags, only correct XML. PHP4 needed to display result (uses print_r).
Categories : PHP, XML, PHP Classes, Rich Site Summary (RSS)
XML Menu
Categories : PHP, PHP Classes, Navigation, XML, XSL
Browser Detecor Class
Categories : PHP Classes, PHP, HTML
Building a basic error handler with custom error types
Categories : PHP, PHP Classes, Errors and Logging
Blueshoes PHP Application Framework
Categories : PHP, Frameworks, PHP Classes
PostGreSQL and MySQL 2 in 1 db Manager
Categories : PHP, PHP Classes, Databases, PostgreSQL, MySQL
An updated OOP - Inheritance
Categories : PHP, PHP Classes, Object Oriented
Class for sending mail with MIME attachments in multipart format using external sendmail, mimencode and zip
Categories : Email, Network, PHP, PHP Classes
ECHO-PHP Class Real Time Transaction Processor v1.4.4 for Credit Cards and Checks / ACH
Categories : PHP Classes, Cybercash, Classes and Objects, Ecommerce, PHP
Password Creator: This PHP code exmaple shows how to use bitwise operations on a single variable and using it as a flagged variable. The class generates passwords of a given length using specified characters and the flags.
Categories : PHP, PHP Classes, Algorithms, Security
A very basic and fast XML parser
Categories : PHP, PHP Classes, XML
php for odbc /* connect to access from odbc */
Categories : PHP Classes, ODBC, MS Access, PHP
credit card security code
Categories : PHP, Credit Cards, PHP Classes, Credit Cards
Greatest Common Denominator - A simple class that finds the greatest common denominator for two integers.
Categories : PHP, PHP Classes, Math.
ClassFuncDoc - This script is a classes and functions documentation tool.
Categories : PHP, Classes and Objects, Documentation, PHP Classes, Complete Programs