'', 'title' => '', 'link' => '', 'description' => '', 'w' => 0, 'h' => 0); public function __construct($title, $link, $description, $optional = '') { $this->title = $title; $this->link = $link; $this->description = $description; if (is_array($optional) && count($optional)) { $this->optional = $optional; } } function AddOptional($key, $value) { $this->optional[$key] = $value; } function AddImage($title, $url, $link, $description = '') { $this->image['title'] = $title; $this->image['url'] = $url; $this->image['link'] = $link; $this->image['description'] = $description; if( $tmp = @getimagesize($url) ){ $this->image['w'] = ($tmp[0] > 144) ? 144 : $tmp[0]; $this->image['h'] = ($tmp[1] > 400) ? 400 : $tmp[1]; } } function AddArticle($title, $link, $description, $optional = '') { // inserisce un nuovo articolo $i = array_push($this->Articles, array('title' => $title, 'link' => $link, 'description' => $description)); // aggiunge le coppie chiave valore opzionali // all'articolo appena inserito if (is_array($optional) && count($optional)) { --$i; foreach($optional as $k=>$v) { $this->Articles[$i][$k] = $v; } } } function Output($save = false, $path = '') { $out = '' . "\n" . '' . "\n" . '' . "\n"; global $rss_ttl,$baseurl; $parameters=array(); foreach ($_GET as $key=>$value){ $parameters[$key]=$value; } $parameters=http_build_query($parameters,'','&'); global $baseurl; $out .= "$this->title\n" . "$this->link\n" . "$this->description\n". "".$rss_ttl."\n". ''; // Channel optionals if (is_array($this->optional) && count($this->optional)) { foreach($this->optional as $k => $v) { $out .= "<$k>$v\n"; } } // Image if ($this->image['title'] && $this->image['url'] && $this->image['link']) { $out .= "\n" . "" . $this->image['title'] . "\n" . "" . $this->image['url'] . "\n" . "" . $this->image['link'] . "\n"; if( $this->image['description'] ) { $out .= "" . $this->image['description'] . "\n"; } if ($this->image['w'] && $this->image['h']) { $out .= "" . $this->image['w'] . "\n" . "" . $this->image['h'] . "\n"; } $out .= "\n"; } // per ogni item stampa tutte le coppie chiave valore for ($i = 0, $c = count($this->Articles); $i < $c; $i++) { $out .= "\n"; foreach($this -> Articles[$i] as $k=>$v) { $k1=$k; if ($k=="guid"){$k1='guid isPermaLink="false"';} $out .= "<".$k1.">".$v."\n"; } $out .= "\n"; } $out .= "\n"; // True output if (!$save || !$path ) { header("Content-type: application/xml"); echo trim($out); return true; } else { $fh = fopen($path, 'w'); if($fh) { fwrite($fh, $out); fclose($fh); return true; } return false; } } }