image = new image; $this->items = new items; } } class item { var $title; var $link; var $description; var $author; var $category; var $comments; var $enclosure; var $guid; var $source; function set_object ($attrib, $value) { $this->$attrib = $value; } } class items { var $litems; var $num_items; function items() { $this->num_items = 0; } function add_item() { $this->litems[$this->num_items+1] = new item; $this->num_items += 1; } } class rss { var $version; var $url = ''; var $ubicacion = ''; var $in_item; var $in_channel; var $in_image; var $template = ""; function rss ($url) { $this->url = $url; $this->channel = new channel; $this->parse(); } function parse() { $this->fpurl = fopen($this->url,'r'); while(!feof($this->fpurl)) { $otra_vez_fin=false; $line = trim(fgets($this->fpurl,100000)); $line = str_replace("\t","",$line); $etiqueta = ""; $tipo_etiqueta = ""; $es_etiqueta = false; $contenido = ""; $dentro_de_channel=false; $len_linea = strlen($line)-1; for ($i = 0; $i <= $len_linea; $i++) { $caracter = substr($line,$i,1); switch ($caracter) { case "<": // Empieza una etiqueta $otra_vez_fin=false; $es_etiqueta = true; $etiqueta .= $caracter; break; case ">": // Termina una etiqueta if ($otra_vez_fin) { $contenido.=">"; $otra_vez_fin=true; } else { $otra_vez_fin=true; $etiqueta .= $caracter; $es_etiqueta = true; } break; default: if ($es_etiqueta) { if ($otra_vez_fin) { $contenido.=$caracter; $otra_vez_fin=true; } else { $tipo_etiqueta .= $caracter; $etiqueta.=$caracter; $otra_vez_fin=false; } } else { $contenido .= $caracter; $otra_vez_fin=false; } } } $contenido=str_replace('<','<',$contenido); switch ($tipo_etiqueta) { case "channel": $this->in_channel=true; break; case "image": $this->in_image=true; break; case "item": $this->in_item=true; $this->channel->items->add_item(); break; case "/item": $this->in_item=false; break; case "/image": $this->in_image=false; break; case "/channel"; $this->in_channel=false; break; case "title/title": if ($this->in_channel) { if ($this->in_item) { $l_i = $this->channel->items->num_items; $this->channel->items->litems[$l_i]->title=$contenido; } else { if ($this->in_image) { $this->channel->image->title=$contenido; } else { $this->channel->title=$contenido; } } } break; case "link/link": if ($this->in_channel) { if ($this->in_item) { $l_i = $this->channel->items->num_items; $this->channel->items->litems[$l_i]->link=$contenido; } else { if ($this->in_image) { $this->channel->image->link=$contenido; } else { $this->channel->link=$contenido; } } } break; case "description/description": if ($this->in_channel) { if ($this->in_item) { $l_i = $this->channel->items->num_items; $this->channel->items->litems[$l_i]->description=$contenido; } else { $this->channel->description=$contenido; } } break; case "language/language": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->language=$contenido; } } break; case "copyright/copyright": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->copyright=$contenido; } } break; case "managingEditor/managingEditor": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->managingEditor=$contenido; } } break; case "webMaster/webMaster": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->webMaster=$contenido; } } break; case "guid isPermaLink=\"true\"/guid": if ($this->in_channel) { if ($this->in_item) { $l_i = $this->channel->items->num_items; $this->channel->items->litems[$l_i]->guid=$contenido; } else { } } break; case "guid/guid": if ($this->in_channel) { if ($this->in_item) { $l_i = $this->channel->items->num_items; $this->channel->items->litems[$l_i]->guid=$contenido; } else { } } break; case "category/category": if ($this->in_channel) { if ($this->in_item) { $l_i = $this->channel->items->num_items; $this->channel->items->litems[$l_i]->category=$contenido; } else { } } break; case "url/url": if ($this->in_channel) { if ($this->in_item) { } else { if ($this->in_image) { $this->channel->image->url=$contenido; } else { } } } break; } } } function set_Template($template) { $this->template=$template; } function display() { if (!empty($this->template)){ include($this->template); } else { include("/home2/angel/media/html/php/template.html.php"); } } } //$oRss = new rss("http://www.securiteam.com/securiteam.rss"); ?>