/***************************************************************************
* RSS 2.0 generation class
* ————————
*
* copyright : (C) 2006 Marijo Galesic
* email : mgalesic@gmail.com
*
* Id: class.rss.php, v 1.1 2006/08/25
*
* www.starmont.net
*
* Redistribution and use in source and binary forms,
* with or without modification must retain the above copyright notice
*
***************************************************************************/
class rss {
var $rss;
var $encoding;
var $title;
var $link;
var $description;
var $language;
var $copyright;
var $managingEditor;
var $webMaster;
var $pubDate;
var $lastBuildDate;
var $category;
var $generator;
var $docs;
var $cloud;
var $ttl;
var $image;
var $textinput;
var $skipHours = array();
var $skipDays = array();
var $itemTitle;
var $itemLink;
var $itemDescription;
var $itemAuthor;
var $itemCategory;
var $itemComments;
var $itemEnclosure;
var $itemGuid;
var $itemPubDate;
var $itemSource;
var $path;
var $filename;
function rss($encoding = ”){
$this-?>
generator = ‘RSS 2.0 generation class’; $this->docs = ‘http://blogs.law.harvard.edu/tech/rss’; if(!empty($encoding)){ $this->encoding = $encoding; } } function channel($title, $link, $description){ $this->title = $title; $this->link = $link; $this->description = $description; } function language($language){ $this->language = $language; } function copyright($copyright){ $this->copyright = $copyright; } function managingEditor($managingEditor){ $this->managingEditor = $managingEditor; } function webMaster($webMaster){ $this->webMaster = $webMaster; } function pubDate($pubDate){ $this->pubDate = $pubDate; } function lastBuildDate($lastBuildDate){ $this->lastBuildDate = $lastBuildDate; } function category($category, $domain = ”){ $this->category .= $this->s(2) . ‘category .= ‘ domain=”‘ . $domain . ‘”‘; } $this->category .= ‘>’ . $category . ” . “n”; } function cloud($domain, $port, $path, $registerProcedure, $protocol){ $this->cloud .= $this->s(2) . ”; } function ttl($ttl){ $this->ttl = $ttl; } function image($url, $title, $link, $width = ”, $height = ”, $description = ”){ $this->image = $this->s(2) . ” . “n”; $this->image .= $this->s(3) . ” . $url . ” . “n”; $this->image .= $this->s(3) . ” . “n”; $this->image .= $this->s(3) . ” . $link . ” . “n”; if($width != ”){ $this->s(3) . ” . $width . ” . “n”; } if($height != ”){ $this->s(3) . ” . $height . ” . “n”; } if($description != ”){ $this->s(3) . ” . $description . ” . “n”; } $this->image .= $this->s(2) . ” . “n”; } function textInput($title, $description, $name, $link){ $this->textInput = $this->s(2) . ” . “n”; $this->textInput .= $this->s(3) . ” . “n”; $this->textInput .= $this->s(3) . ” . $description . ” . “n”; $this->textInput .= $this->s(3) . ” . $name . ” . “n”; $this->textInput .= $this->s(3) . ” . $link . ” . “n”; $this->textInput .= $this->s(2) . ” . “n”; } function skipHours(){ $this->skipHours = array(); $args = func_get_args(); $this->skipHours = array_values($args); } function skipDays(){ $this->skipDays = array(); $args = func_get_args(); $this->skipDays = array_values($args); } function startRSS($path = ‘.’, $filename = ‘rss’){ $this->path = $path; $this->filename = $filename; $this->rss = ‘encoding)){ $this->rss .= ‘ encoding=”‘ . $this->encoding . ‘”‘; } $this->rss .= ‘?>’ . “n”; $this->rss .= ” . “n”; $this->rss .= $this->s(1) . ” . “n”; $this->rss .= $this->s(2) . ” . “n”; $this->rss .= $this->s(2) . ” . $this->link . ” . “n”; $this->rss .= $this->s(2) . ” . $this->description . ” . “n”; if(!empty($this->language)){ $this->rss .= $this->s(2) . ” . $this->language . ” . “n”; } if(!empty($this->copyright)){ $this->rss .= $this->s(2) . ” . $this->copyright . ” . “n”; } if(!empty($this->managingEditor)){ $this->rss .= $this->s(2) . ” . $this->managingEditor . ” . “n”; } if(!empty($this->webMaster)){ $this->rss .= $this->s(2) . ” . $this->webMaster . ” . “n”; } if(!empty($this->pubDate)){ $this->rss .= $this->s(2) . ” . $this->pubDate . ” . “n”; } if(!empty($this->lastBuildDate)){ $this->rss .= $this->s(2) . ” . $this->lastBuildDate . ” . “n”; } if(!empty($this->category)){ $this->rss .= $this->category; } $this->rss .= $this->s(2) . ” . $this->generator . ” . “n”; $this->rss .= $this->s(2) . ” . $this->docs . ” . “n”; if(!empty($this->cloud)){ $this->rss .= $this->cloud; } if(!empty($this->ttl)){ $this->rss .= $this->s(2) . ” . $this->ttl . ” . “n”; } if(!empty($this->image)){ $this->rss .= $this->image; } if(!empty($this->textInput)){ $this->rss .= $this->textInput; } if(count($this->skipHours) > 0){ $this->rss .= $this->s(2) . ” . “n”; for($i = 0; $i < count($this->skipHours); $i++){ $this->rss .= $this->s(3) . ” . $this->skipHours[$i] . ” . “n”; } $this->rss .= $this->s(2) . ” . “n”; } if(count($this->skipDays) > 0){ $this->rss .= $this->s(2) . ” . “n”; for($i = 0; $i < count($this->skipDays); $i++){ $this->rss .= $this->s(3) . ” . $this->skipHours[$i] . ” . “n”; } $this->rss .= $this->s(2) . ” . “n”; } } function itemTitle($title){ $this->itemTitle = $title; } function itemLink($link){ $this->itemLink = $link; } function itemDescription($description){ $this->itemDescription = $description; } function itemAuthor($author){ $this->itemAuthor = $author; } function itemCategory($category, $domain = ”){ $this->itemCategory .= $this->s(3) . ‘itemCategory .= ‘ domain=”‘ . $domain . ‘”‘; } $this->itemCategory .= ‘>’ . $category . ” . “n”; } function itemComments($comments){ $this->itemComments = $comments; } function itemEnclosure($enclosure){ $this->itemEnclosure = $enclosure; } function itemGuid($guid, $isPermaLink = ”){ $this->itemGuid = $this->s(3) . ‘itemGuid .= ‘ isPermaLink=”‘ . $isPermaLink . ‘”‘; } $this->itemGuid .= ‘>’ . $guid . ” . “n”; } function itemPubDate($pubDate){ $this->itemPubDate = $pubDate; } function itemSource($source, $url){ $this->itemSource = $this->s(3) . ” . $source . ” . “n”; } function addItem(){ $this->rss .= $this->s(2) . ” . “n”; if(!empty($this->itemTitle)){ $this->rss .= $this->s(3) . ” . “n”; } if(!empty($this->itemLink)){ $this->rss .= $this->s(3) . ” . $this->itemLink . ” . “n”; } if(!empty($this->itemDescription)){ $this->rss .= $this->s(3) . ” . $this->itemDescription . ” . “n”; } if(!empty($this->itemAuthor)){ $this->rss .= $this->s(3) . ” . $this->itemAuthor . ” . “n”; } if(!empty($this->itemCategory)){ $this->rss .= $this->itemCategory; } if(!empty($this->itemComments)){ $this->rss .= $this->s(3) . ” . $this->itemComments . ” . “n”; } if(!empty($this->itemEnclosure)){ $this->rss .= $this->s(3) . ” . $this->itemEnclosure . ” . “n”; } if(!empty($this->itemGuid)){ $this->rss .= $this->itemGuid; } if(!empty($this->itemPubDate)){ $this->rss .= $this->s(3) . ” . $this->itemPubDate . ” . “n”; } if(!empty($this->itemSource)){ $this->rss .= $this->itemSource; } $this->rss .= $this->s(2) . ” . “n”; $this->itemTitle = ”; $this->itemLink = ”; $this->itemDescription = ”; $this->itemAuthor = ”; $this->itemCategory = ”; $this->itemComments = ”; $this->itemEnclosure = ”; $this->itemGuid = ”; $this->itemPubDate = ”; $this->itemSource = ”; } function RSSdone(){ $this->rss .= $this->s(1) . ” . “n”; $this->rss .= ”; /* $handle = fopen($this->path . ‘/’. $this->filename . ‘.xml’, “w”); fwrite($handle, $this->rss); fclose($handle);*/ print($this->rss); } function clearRSS(){ $this->title = ”; $this->link = ”; $this->description = ”; $this->language = ”; $this->copyright = ”; $this->managingEditor = ”; $this->webMaster = ”; $this->pubDate = ”; $this->lastBuildDate = ”; $this->category = ”; $this->cloud = ”; $this->ttl = ”; $this->skipHours = array(); $this->skipDays = array(); } function s($space){ $s = ”; for($i = 0; $i < $space; $i++){ $s .= ‘ ‘; } return $s; } } ?>
$rss = new rss(‘utf-8’);
$rss-?>
channel(‘Feed RSS di ‘.$config_name_site, $path_assoluta, ‘ le news di ‘.$config_name_site); $rss->language(‘it-it’); $rss->copyright(‘Copyright by ‘.$config_name_site.’ ‘.date(“Y”)); $rss->managingEditor($from); $rss->category(‘Onlus’); $rss->startRSS(); while($rs_news=mysql_fetch_array($sql_news)){ $firstcategoria=explode(“;”,$sub[‘categoria’]); $rss->itemTitle(salva($rs_news[‘title’])); $image=getelement(“SELECT t.image FROM files AS t,l_files AS l,news AS a WHERE t.id=l.refered AND l.language=’”.$language.”‘ AND a.id=t.refered AND t.refered=’”.$rs_news[‘id’].”‘ AND t.type=’news’ and t.format=1 ORDER BY t.ordine”); if($image==””)$image=”no_image.gif”; $rss->itemLink($path_assoluta.$lg[$language][‘menu’][10].”/”. $rs_news[‘titleseo’]); $immagine=$path_assoluta.”includes/resize.php?q=20&url=”.$path_assoluta.”uploads/home/”.$image.”&size=300x170c50″; $rss->itemDescription(”
“.cut(strip_tags($rs_news[‘text’]),45).”]]>
“); $rss->itemAuthor($from); $rss->itemGuid($path_assoluta.$lg[$language][‘menu’][10].”/”. $rs_news[‘titleseo’]); $rss->itemSource($config_name_site, $path_assoluta_href); $rss->addItem(); //echo $rs_news[‘title’]; } echo $rss->RSSdone(); ?>
Lascia un commento
Devi essere connesso per inviare un commento.