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 : 1 of 5 (graded 3 times)
Viewed : 3419
File : 5009.zip
Images : Image 1
Search : More code by ROBERTO ALEMAN
Action : Grade This Code Example
Tools : My Examples List

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

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)
Database and Recordset classes fo SyBASE Usage is obvious.
Categories : Sybase, Databases, PHP Classes, PHP
The Ajax Tree view class fetches data from a db for the requested parent category id. The data is then stored in an array and converted into JSON (Javascript Object Notation) format. This format is then used by JavaScript for populating tree view.
Categories : PHP, PHP Classes, Java Script, AJAX, Databases
Advanced Image WaterMarker
Categories : PHP, PHP Classes, GD image library, Graphics, Object Oriented
Gonx URLs - This class is meant to generate URLs for accessing application dynamically generated pages based on parameters passed in the URL.
Categories : PHP, PHP Classes, Navigation, URLs
SPL and ITERATOR : examples
Categories : PHP, Object Oriented, PHP Classes, Sessions
TAB_STRUCT Class: Is supporting Class for the DBXML Class
Categories : PHP, PHP Classes, MySQL, XML, Databases
Menu in sliding bar or tree style. Handles frames by using small amount of javascript. Handles external and internal pages. Allows custom code to replace a menu item.
Categories : PHP Classes, PHP, Java Script, DHTML
pcCalendar class - Allows for the creation of calendars in HTML pages. All output functions can be easily overridden, refer to article 1471 for an example.
Categories : PHP, Date Time, Calendar, PHP Classes
XPertMailer - Sends TRUE Mails
Categories : PHP, Mail, SMTP, PHP Classes
PHP VXML Class : How to use PHP in VoiceXML applications
Categories : PHP, PHP Classes, VXML
Objects to XML Serializer/Unserializer
Categories : PHP, PHP Classes, DOM XML, Serialize
DbObject - A PHP wrapper for working with various databases
Categories : Databases, PHP, PHP Classes
Url To Pdf Report By Remote Application
Categories : PHP, PHP Classes, PDF, CURL
A Custom Error Handling And Debugging Class
Categories : PHP, PHP Classes, Debugging, Errors and Logging