The problem that I am having is that any time an "&" appears in a post, the $content string doesn't show up, and the post appears blank.
I've tried all of the following, to no avail:
$content = str_replace("&", "", $content);
$content = str_replace("&", "&", $content);
$content = str_replace("&", "", $content);
$content = str_replace("amp;", "", $content);
Code: Select all
<?php
$insideitem = false;
$tag = "";
$title = "";
$author = "";
$date = "";
$month = "";
$day = "";
$year = "";
$content = "";
$loopnum = 0;
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $author, $date, $content;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ENTRY") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $author, $date, $month, $day, $year, $content, $loopnum;
if ($name == "ENTRY") {
$title = str_replace("'", "\'", $title);
$content = str_replace("\n", "", $content);
$content = str_replace("'", "\'", $content);
$content = str_replace("[url]", "<a href=\'", $content);
$content = str_replace("[/url/]", "\'>", $content);
$content = str_replace("[/url]", "</a>", $content);
echo 'document.write(\'<tr>\');
';
printf('document.write(\'<td class="windowbg" valign="top"><img id="p%s" src="http://l4eclan.com/images/blogavatars/%s.gif" style="display: none" /></td>\');', $loopnum, trim($author));
echo '
document.write(\'<td class="windowbg2">\');
';
printf('document.write(\'<b><a onclick="display(%s)" style="color: #0099FF; cursor: pointer">%s</a></b>\');', $loopnum, trim($title));
printf('document.write(\'<p id="t%s" style="display: none"><br /><br />%s</p></td>\');', $loopnum, trim($content));
printf('document.write(\'<td colspan="2" class="windowbg" valign="top"><center><b>%s<b></center></td>\');', trim($author));
printf('document.write(\'<td class="windowbg2" valign="top"><center>%s %s, %s</center></td>\');', $month, $day, $year);
echo '
document.write(\'</tr>\');
';
$title = "";
$author = "";
$date = "";
$content = "";
$loopnum = $loopnum + 1;
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $author, $date, $month, $day, $year, $content;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "NAME":
$author .= $data;
break;
case "CREATED":
$date .= $data;
break;
case "DIV":
$content .= $data;
break;
case "BR":
$content .= "<br />" . $data;
break; }
switch (substr($date,5,2)) {
case "01":
$month = "January";
case "02":
$month = "February";
case "03":
$month = "March";
case "04":
$month = "April";
case "05":
$month = "May";
case "06":
$month = "June";
case "07":
$month = "July";
case "08":
$month = "August";
case "09":
$month = "Semptember";
case "10":
$month = "October";
case "11":
$month = "November";
case "12":
$month = "December";
break; }
$day = (substr($date,8,2));
$year = (substr($date,0,4));
}
}
echo '
document.write(\'<table id="forCat" style="display: none;">\');
document.write(\'<tr>\');
document.write(\'<td class="windowbg" colspan="4"><b><font size="2">Recent Posts on the L4E Blog</font></b></td>\');
document.write(\'<td class="windowbg" align="center">[<a href="http://www.blogger.com/post-create.g?blogID=19669778" target="_blank">New Post</a>] [<a href="http://l4ewakamolking.proboards39.com/index.cgi?action=display&board=L4Earchives&thread=1150270549&page=1"><font style="color: #0099FF">?</font></a>]</td>\');
document.write(\'</tr>\');
';
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen("http://l4eblog.blogspot.com/atom.xml","r")
or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
xml_parse($xml_parser, $data, feof($fp))
or die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
fclose($fp);
xml_parser_free($xml_parser);
echo '
document.write(\'</table>\'); document.write(\'<script type="text/javascript">function display(num) { if (document.getElementById("p" + num).style.display == "none") { document.getElementById("p" + num).style.display="inline"; document.getElementById("t" + num).style.display="inline"; } else { document.getElementById("p" + num).style.display="none"; document.getElementById("t" + num).style.display="none"; } }</script>\');
';
?>