(.+?)%is";
$urlparts = parse_url($url);
if ($urlparts[path] == "") $url .= "/";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 8);
$data = curl_exec($ch)
or die("Error reading RSS data.");
curl_close($ch);
$match_count = preg_match_all($itemregexp, $data, $items);
$match_count = ($match_count > $nritems) ? $nritems : $match_count;
for ($i=0; $i< $match_count; $i++) {
$body = $items[1][$i];
preg_match ("%rssi1 *\" *>(.+?)%is", $body, $subj);
$title = $subj[1];
$item_url = get_link($body, $url);
$desc = stristr($body, "");
$desc = substr(trim(strip_tags($desc)),0,54);
$desc = substr($desc, 0, strrpos($desc, " ")) . " ...";
$desc = htmlentities($desc);
if ($ds== "y") {
$output .= "document.write(\"\")\n";
$output .= "document.write(\"". $desc ."\")\n";
} else {
$output .= htmlentities($title) ."\")\n";
}
}
print "\n";
print htmlspecialchars($output);
print "
\n";
print "
";
}
function get_link($body, $url) {
if (stristr($body, "rssi2\" href")) {
$linkurl = stristr($body, "rssi2\" href");
$linkurl = substr($linkurl, strpos($linkurl, "\"")+1);
$linkurl = substr($linkurl, strpos($linkurl, "\"")+1);
$linkurl = substr($linkurl, 0, strpos($linkurl, "\""));
$linkurl = trim($linkurl);
return $linkurl;
} else {
return $url;
}
}
parse_html($url, $ds, $nritems);
?>