The guts of this function is also present is admin/modules/blocks.php BlocksAdd().
Seems to me that a new function that pulls an RSS feed into a mutidimensional array should be created and this function called where necessary such as in headlines() and BlocksAdd()
functions are below:
function headlines($bid) {
global $prefix;
$result = mysql_query("select title, content, url, refresh, time from $prefix"._blocks." where bid='$bid'");
list($title, $content, $url, $refresh, $otime) = mysql_fetch_row($result);
$title = "$title";
$past = time()-$refresh;
if ($otime $title";
$content = ""._RSSPROBLEM."";
$result = mysql_query("update $prefix"._blocks." set content='$content', time='$btime' where bid='$bid'");
themesidebox($title, $content);
return;
}
if ($fp) {
fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0rn");
fputs($fp, "HOST: " . $rdf['host'] . "rnrn");
while(!feof($fp)) {
$pagetext = fgets($fp,300);
$lines[] = chop($pagetext);
}
fputs($fp,"Connection: closernrn");
fclose($fp);
for ($j=0;$j",$lines[$j])) { // Assume this as start point in most RSS/RDF feeds
$startnum = $j;
break;
}
}
$content = "";
for ($i=$startnum;$i(.*)",$lines[$i],$regs)) {
$title2 = $regs[1];
$title2 = str_replace("&","&",$title2);
$titlearray[] = htmlspecialchars($title2,ENT_QUOTES); // should transform most html characters
}
else if (ereg("(.*)",$lines[$i],$regs)) {
$link[] = $regs[1];
}
else if (ereg("(.*)",$lines[$i],$regs)) {
$description[] = $regs[1];
}
if ($lines[0] == "") {
$content = ""._RSSPROBLEM."";
$title = "$title";
$result = mysql_query("update $prefix"._blocks." set content='$content', time='$btime' where bid='$bid'");
themesidebox($title, $content);
return;
}
}
for($i=0;$i· <a href>$titlearray[$i]
n";
if($description[$i]) {
$content .= "$description[$i]
";
}
}
$title = "$title";
for ($i=0;$i(.*)",$lines[$i],$regs)) {
$url = $regs[1];
break;
}
}
$siteurl = ereg_replace("http://","",$url);
$content .= "
<a href>"._HREADMORE."";
}
$result = mysql_query("update $prefix"._blocks." set content='$content', time='$btime' where bid='$bid'");
}
themesidebox($title, $content);
}
function BlocksAdd($title, $content, $url, $position, $active, $refresh, $headline) {
global $prefix;
if ($headline != 0) {
$result = mysql_query("select sitename, headlinesurl from $prefix"._headlines." where hid='$headline'");
list ($title, $url) = mysql_fetch_row($result);
}
$result = mysql_query("SELECT weight FROM $prefix"._blocks." WHERE position='$position' ORDER BY weight DESC");
list ($weight) = mysql_fetch_array($result);
$weight++;
$title = stripslashes(FixQuotes($title));
$content = stripslashes(FixQuotes($content));
$bkey = "";
$btime = "";
if ($url != "") {
$btime = time();
if (!ereg("http://",$url)) {
$url = "http://$url";
}
$rdf = parse_url($url);
$fp = fsockopen($rdf['host'], 80, $errno, $errstr, 15);
if (!$fp) {
rssfail();
exit;
}
if ($fp) {
fputs($fp, "GET " . $rdf['path'] . "?" . $rdf['query'] . " HTTP/1.0rn");
fputs($fp, "HOST: " . $rdf['host'] . "rnrn");
while(!feof($fp)) {
$pagetext = fgets($fp,300);
$lines[] = chop($pagetext);
}
fputs($fp,"Connection: closernrn");
fclose($fp);
for ($j=0;$j",$lines[$j])) { // Assume this as start point in most RSS/RDF feeds
$startnum = $j;
break;
}
}
$content = "";
for ($i=$startnum;$i(.*)",$lines[$i],$regs)) {
$title2 = $regs[1];
$title2 = str_replace("&","&",$title2);
$titlearray[] = htmlspecialchars($title2,ENT_QUOTES); // should transform most html characters
}
else if (ereg("(.*)",$lines[$i],$regs)) {
$link[] = $regs[1];
}
else if (ereg("(.*)",$lines[$i],$regs)) {
$description[] = $regs[1];
}
if ($lines[0] == "") {
$content = ""._RSSPROBLEM."";
$title = "$title";
$result = mysql_query("update $prefix"._blocks." set content='$content', time='$btime' where bid='$bid'");
themesidebox($title, $content);
return;
}
}
}
for($i=0;$i· $titlearray[$i]
n";
if($description[$i]) {
$content .= "$description[$i]
";
}
}
}
if (($link) AND ($title2)) {
$siteurl = ereg_replace("http://","",$url);
$content .= "
"._HREADMORE."";
}
if ($content == "") {
rssfail();
} else {
$content = addslashes($content);
$result = mysql_query("insert into $prefix"._blocks." values (NULL, '$bkey', '$title', '$content', '$url', '$position', '$weight', '$active', '$refresh', '$btime')") or die(mysql_errno(). ": ".mysql_error());
Header("Location: admin.php?op=BlocksAdmin");
}
}
1105