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; function rss ($url) { $this->url = $url; $this->channel = new channel; $this->parse(); } function parse() { $this->fpurl = fopen($this->url,'r'); while(!feof($this->fpurl)) { $again_end=false; $line = trim(fgets($this->fpurl,100000)); $label = ""; $type_label = ""; $is_label = false; $content = ""; $within_channel=false; $len_line = strlen($line)-1; for ($i = 0; $i <= $len_line; $i++) { $character = substr($line,$i,1); switch ($character) { case "<": // Empieza una etiqueta $again_end=false; $is_label = true; $label .= $character; break; case ">": // Termina una etiqueta if ($again_end) { $content.=">"; $again_end=true; } else { $again_end=true; $label .= $character; $is_label = true; } break; default: if ($is_label) { if ($again_end) { $content.=$character; $again_end=true; } else { $type_label .= $character; $label.=$character; $again_end=false; } } else { $content .= $character; $again_end=false; } } } $content=str_replace('<','<',$content); switch ($type_label) { 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=$content; } else { if ($this->in_image) { $this->channel->image->title=$content; } else { $this->channel->title=$content; } } } 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=$content; } else { if ($this->in_image) { $this->channel->image->link=$content; } else { $this->channel->link=$content; } } } 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=$content; } else { $this->channel->description=$content; } } break; case "language/language": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->language=$content; } } break; case "copyright/copyright": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->copyright=$content; } } break; case "managingEditor/managingEditor": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->managingEditor=$content; } } break; case "webMaster/webMaster": if ($this->in_channel) { if ($this->in_item) { } else { $this->channel->webMaster=$content; } } 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=$content; } 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=$content; } 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=$content; } else { } } break; case "url/url": if ($this->in_channel) { if ($this->in_item) { } else { if ($this->in_image) { $this->channel->image->url=$content; } else { } } } break; } } } function display() { include("template.html.php"); } } //$oRss = new rss("http://www.securiteam.com/securiteam.rss"); ?>