/*
HR-Converter: Convert The Church of the Heavenly Rest's Media and Communications
Page into an RSS feed with enclosures.
Copyright (C) 2008 Sean P. Reiser
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 3 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.
The GNU Public LIcense is available here: http://www.gnu.org/licenses/.
*/
');
fwriteln ($output,'');
fwriteln($output,'');
fwriteln($output,'');
fwriteln($output,'Church of Heavenly Rest, Media and Communications');
fwriteln($output,'http://heavenlyrest.org/');
fwriteln($output,'Church of Heavenly Rest, Media and Communications');
fwriteln($output,'en-us');
fwriteln($output,'');
fwriteln($output,'clean');
fwriteln($output,'kflannery@heavenlyrest.org');
fwriteln($output,'Church of Heavenly Rest, Media and Communications');
fwriteln($output,'');
fwriteln($output,'');
fwriteln($output,'');
foreach ($items as $item){
if (!(empty($item['mp3']))){
fwriteln($output,"");
fwriteln($output,"".$item['title']."");
fwriteln($output,"".$item['link']."");
fwriteln($output,"".strip_tags($item['description'])."");
//fwriteln($output,"".$item['title']."");
fwriteln($output,'');
fwriteln($output,'clean');
fwriteln($output,'');
fwriteln($output,''.$item['title'].' Sermon for '.$item['date'].'');
fwriteln($output,"");
}
if (!(empty($item['pdf']))){
fwriteln($output,"");
fwriteln($output,"".$item['title']."");
fwriteln($output,"".$item['link']."");
fwriteln($output,"".strip_tags($item['description'])."");
fwriteln($output,'');
fwriteln($output,"");
}
}
fwriteln($output,'');
fwriteln($output,'');
fclose($output);
function builditems($File){
$buffer = file_get_contents($File);
$items = array();
$temp = strpos($buffer,"Sermon / Homily");
$start = strrpos(substr($buffer,1,$temp),'TABLE');
$end = strpos(substr($buffer,$start+20),'/TABLE');
$buffer=substr($buffer,$start,$end+4);
$start = strpos($buffer,"TR");
$end = strpos($buffer,"/TR");
$buffer=substr($buffer,$end+4); // skip title record
$start = strpos($buffer,"TR");
$end = strpos($buffer,"/TR");
// walk html file
while ($start > 0){
//$item = array("date" =>$date, "title"=>$title, "description"=>$description, "mp3" => $mp3, "pdf" => $pdf, "link" => $link);
$date = '';
$title = '';
$description = '';
$mp3 = '';
$pdf = '';
$link = '';
$itembuffer = substr($buffer,$start,$end);
if (strpos($itembuffer,"Messenger") > 0){
$title = "Messenger";
$description = "Holy Messenger";
// Get date
$istart = strpos($itembuffer,"TD");
$iend = strpos($itembuffer,"TD",$istart+5);
$ibuffer = strip_tags(substr($itembuffer,$istart+3,$iend - $istart));
$foo = strpos($ibuffer," ");
$date = substr($ibuffer,0,$foo).' 01, 20'.substr($ibuffer,$foo+1);
//Skip
$itembuffer=substr($itembuffer,$iend+3);
$istart = strpos($itembuffer,"TD");
$iend = strpos($itembuffer,"TD",$istart+5);
$ibuffer = strip_tags(substr($itembuffer,$istart+3,$iend - $istart));
// Get File URL
$itembuffer=substr($itembuffer,$iend+3);
$istart = strpos($itembuffer,"TD");
$iend = strpos($itembuffer,"TD",$istart+5);
$ibuffer = substr($itembuffer,$istart+3,$iend - $istart);
$pstart = strpos($ibuffer,"href");
$ibuffer = substr($ibuffer,$pstart+6);
$pend = strpos($ibuffer,'"');
$pdf = 'http://heavenlyrest.org/'.substr($ibuffer,1,$pend-1);
$link = $pdf;
$pdftitle = $title.' for '.$date;
$pdfdescription = $description.' for '.$date;
//echo $ibuffer;
}
else{
// Get date
$istart = strpos($itembuffer,"