PHP Classes

File: feed/index.php

Recommend this page to a friend!
  Classes of Victor Andeloci   PHP RSS Feed Gallery Generator for Audio   feed/index.php   Download  
File: feed/index.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP RSS Feed Gallery Generator for Audio
Generate a RSS feed and gallery for audio files
Author: By
Last change:
Date: 9 months ago
Size: 1,046 bytes
 

Contents

Class file image Download
<?php

 
/*
      Runs from a directory containing files to provide an
      RSS 2.0 feed that contains the list and modification times for all the
      files.
  */

 
require_once('Rss.php');
 
$rss = new Rss();

  function
get_m_time_dir($path){
   
$directory = new RecursiveDirectoryIterator(
     
$path,
     
FilesystemIterator::KEY_AS_PATHNAME |
     
FilesystemIterator::CURRENT_AS_FILEINFO |
     
FilesystemIterator::SKIP_DOTS
   
);
   
$iterator = new RecursiveIteratorIterator(
     
$directory,
     
RecursiveIteratorIterator::SELF_FIRST
   
);
   
$resultFile = $iterator->current();
    foreach(
$iterator as $file) {
      if (
$file->getMtime() > $resultFile->getMtime()) {
       
$resultFile = $file;
      }
    }
    return
$resultFile->getMtime();
  }

 
$lastFile = get_m_time_dir('./content/');

 
header('Content-type: text/xml');

  if(
file_exists('rss_feed.xml') && (filemtime('rss_feed.xml') >= $lastFile)){

   
$xmlRss = file_get_contents('rss_feed.xml');
    echo
$xmlRss;

  } else {

    echo
$rss->generateFeed();

  }