...
*/
/*
ryan format:
I can't vouch for this link
what we need to add is this part
rel="nofollow"
Title
Description
*/
// save $name from start_tag, because it is not available on tag_contents
$current = "";
$lineArray = array();
function init($name) {
global $lineArray;
$lineArray[0] = '';
$lineArray[3] = ''; // Title
$lineArray[4] = '
';
$lineArray[5] = ''; // Description
$lineArray[6] = '
';
}
function start_tag($parser, $name, $attribs) {
global $current, $lineArray;
$current = $name;
if ($name == "LISTING") {
init($name);
}
// if ($name == "URL") {
// if (is_array($attribs)) {
// while(list($key,$val) = each($attribs)) {
// echo strtolower($key)."=\"".$val."\"";
// }
// }
}
function end_tag($parser, $name) {
global $lineArray;
if ($name == "LISTING") {
foreach ($lineArray as $value) {
echo $value;
}
}
}
// Since the tag_contents() functions doesn’t get the name of the current tag from
// the parser, we have to manually provide it that information. In our start_tag()
// function, we set a global variable $current to the current tag name. The rest of
// the code is just checks to see which tag we are on, and print out the appropriate tags.
function tag_contents($parser, $data) {
global $current, $lineArray;
if ($current == "TITLE") {
$lineArray[3] .= $data;
} elseif ($current == "DESCRIPTION") {
$lineArray[5] .= $data;
} elseif ($current == "URI") {
$lineArray[1] .= $data;
}
}
function searchFeed($trackID, $excID, $pID, $cat, $nl, $page, $ip) {
if (!($xmlparser = xml_parser_create()) ) {
die ('');
}
// set function name to call when tags are encountered
xml_set_element_handler($xmlparser, "start_tag", "end_tag");
// set function name to call when tags contents encountered
xml_set_character_data_handler($xmlparser, "tag_contents");
$searchfeed = "http://www.searchfeed.com/rd/feed/XMLFeed.jsp?ADULT=0&trackID=" . $trackID .
"&excID=" . $excID .
"&pID=" . $pID .
"&cat=" . urlencode($cat) .
"&nl=" . $nl .
"&page=" . $page .
"&ip=" . $ip;
$handle = @fopen ($searchfeed, "r");
if (!$handle) { echo ''; exit; }
while ($buffer = fread($handle, 4096)) {
if (!xml_parse($xmlparser, $buffer, feof($handle))) {
// $reason = xml_error_string(xml_get_error_code($xmlparser));
// $reason .= xml_get_current_line_number($xmlparser);
die('');
}
}
@fclose($handle);
xml_parser_free($xmlparser);
}
?>