rendered paste body<?php
class xItem {
var $xTitle;
var $xLink;
var $xDescription;
var $xThumb;
}
// general vars
$sTitle = "";
$sLink = "";
$sDescription = "";
$sThumb = "";
$arItems = array();
$itemCount = 0;
// ********* Start User-Defined Vars ************
// rss url goes here
$uFile = "http://video.google.com/videofeed?type=search&q=gross&num=10&output=rss";
// descriptions (true or false) goes here
$bDesc = true;
// font goes here
$uFont = "Verdana, Arial, Helvetica, sans-serif";
$uFontSize = "2";
// ********* End User-Defined Vars **************
function startElement($parser, $name, $attrs) {
global $curTag;
$curTag .= "^$name";
}
function endElement($parser, $name) {
global $curTag;
$caret_pos = strrpos($curTag,'^');
$curTag = substr($curTag,0,$caret_pos);
}
function characterData($parser, $data) { global $curTag; // get the Channel information first
global $sTitle, $sLink, $sDescription, $sThumb;
$titleKey = "^RSS^CHANNEL^TITLE";
$linkKey = "^RSS^CHANNEL^LINK";
$descKey = "^RSS^CHANNEL^ITEM^MEDIA:GROUP^MEDIA:DESCRIPTION";
$thumbKey = "^RSS^CHANNEL^ITEM^MEDIA:GROUP^MEDIA:THUMBNAIL";
if ($curTag == $titleKey) {
$sTitle = $data;
}
elseif ($curTag == $linkKey) {
$sLink = $data;
}
elseif ($curTag == $descKey) {
$sDescription = $data;
}
elseif ($curTag == $thumbKey) {
$sThumb = $data;
}
// now get the items
global $arItems, $itemCount;
$itemTitleKey = "^RSS^CHANNEL^ITEM^TITLE";
$itemLinkKey = "^RSS^CHANNEL^ITEM^GUID";
$itemDescKey = "^RSS^CHANNEL^ITEM^MEDIA:GROUP^MEDIA:DESCRIPTION";
$itemThumbKey = "^RSS^CHANNEL^ITEM^MEDIA:GROUP^MEDIA:DESCRIPTION^MEDIA:THUMBNAIL";
$embed = "^RSS^CHANNEL^ITEM^DESCRIPTION";
if ($curTag == $itemTitleKey) {
// make new xItem
$arItems[$itemCount] = new xItem();
// set new item object's properties
$arItems[$itemCount]->xTitle = $data;
}
elseif ($curTag == $itemLinkKey) {
$arItems[$itemCount]->xLink = $data;
}
elseif ($curTag == $itemThumbKey) {
$arItems[$itemCount]->xThumb = $data;
}
elseif ($curTag == $description) {
$arItems[$itemCount]->description = $data;
}
elseif ($curTag == $itemDescKey) {
$arItems[$itemCount]->xDescription = $data;
// increment item counter
$itemCount++;
}
}
// main loop
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!($fp = fopen($uFile,"r"))) {
die ("could not open RSS for input");
}
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($xml_parser)), xml_get_current_line_number($xml_parser)));
}
}
?>
<html>
<body>
<font face = "<?php echo($uFont); ?>" size = "<?php echo($uFontSize); ?>"><a href = "<?php echo($sLink); ?>"><?php echo($sTitle); ?></a></font>
<br>
<br>
<?php
foreach ($arItems as &$txItem) {
if ($txItem->xLink ==''){}else {echo "\n\n<a href=$txItem->xLink>";}
echo($embed);
echo($xThumb);
if ($txItem->xTitle ==''){}else { echo "$txItem->xTitle</a>\n";}
$description = str_replace("\n", "", "$txItem->xDescription");
echo ($description);
echo "<br>";
}
?>
</body>
</html>