function getRSS() { $url = 'http://www.tgcom.mediaset.it/rss/ultimissime.xml'; $db = new owdb(); $db->connect(DBURL); $db->query("select * from rss where id = 1"); $row = $db->fetch_object(); if(!$row) { $xmlstr = urlencode(file_get_contents($url)); $db->insert('rss', array('id','xml','updated'), array(1,$xmlstr,time())); } else { $xmlstr = $row->xml; if(($row->updated + 900) < time()) { $xmlstr = urlencode(file_get_contents($url)); $db->update('rss', array('xml','updated'), array($xmlstr,time()), 'id = 1'); } } $db->close(); $pos = 0; while(true) { $item = striptag('%3Citem%3E','%3C%2Fitem%3E',$xmlstr,$pos); if(!is_integer($pos)) break; $pos1 = 0; $title = striptag('%3Ctitle%3E','%3C%2Ftitle%3E',$item,$pos1); $pos1 = 0; $description = striptag('%3Cdescription%3E','%3C%2Fdescription%3E',$item,$pos1); $data = trim(substr($description, 1, 10)); $arr[] = $data." ".$title.substr($description, 10); } return $arr; } }