embed .php into .html page keeping .html extension help!
- ukshopsnet
- Novice


- Joined: Aug 03, 2003
- Posts: 21
- Loc: HIGH PEAK, UK
- Status: Offline
Hi
Couple of questions:
1. Trying to get a modification on the code below, so that I can display any predefined search I like, for example, for my finance page I can have results on the page for the keyword 'loans'. I want the search box to still be usable for any other search the visitor chooses. This way I can create lots of predefined searches and get the pages keyworded and fully optimised - and get lots of search engine interest in these pages.
2. I want to embed the xml .php feed into a html page and keep the .html extension - this way I can use existing pages with good search engine listings to display the feed - is this possible???????
Mirago XML Parser Source Code (my user id is omitted from code)
--------------------------------------------------------------------------------
<?php
function status($message) {
return "onMouseOver=\"window.status='$message'; return true;\" onMouseOut=\"window.status=''; return true;\"";
}
function displayResult($resultid, $title, $abstract, $redir, $url) {
global $offset, $webtag;
$statusbar = status("visit: $url");
If (substr($redir,0,65)<>substr($url,0,65)) {
If ($resultid==1) {
echo "<b>Featured Sites</b>";
$webtag=0;
}
} else {
If ($webtag<>1) {
echo "<b>Web Results</b>";
$webtag = 1;
}
}
echo "<DL>\n<DT><A $statusbar HREF=\"$redir\"><b>".($offset + $resultid).". $title</b></a></DT>";
echo "<DD>$abstract</DD>\n<DD>$url</DD>\n</DL>\n";
}
// handles the attributes for opening tags
// $attrs is a multidimensional array keyed by attribute
// name and having the value of that attribute
function startElement($parser, $name, $attrs=''){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
if ($currenttag == "") { $parenttag = $currenttag; }
$currenttag = $name;
if (count($attrs) > 0) {
foreach($attrs as $keys) {
// print ($keys);
if ($name == "RESULTSET") {
$resultset = $attrs;
}
if ($name == "RESULT") {
$resultid = $attrs["ID"]+1;
//print ($attrs["ID"]);
}
}
}
}
// $current_tag lets us know what tag we are currently
// dealing with - we use that later in the characterData
// function.
function endElement($parser, $name, $attrs=''){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
global $Atitle, $Aabstract, $Aredir, $Aurl;
if ($name == "RESULT") {
//displayResult($resultid, $title, $abstract, $redir, $url);
array_push($Atitle, $title);
array_push($Aabstract, $abstract);
array_push($Aredir, $redir);
array_push($Aurl, $url);
$title = "";
$abstract = "";
$redir = "";
$url = "";
}
$currenttag = "";
}
// this function is passed data between elements
function characterData($parser, $data){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid, $alttxt;
//$data =~ s/£/£/;
if (($currenttag == "ALT") && ($data != "\n")) { $alttxt = $data; }
if (($currenttag == "TITLE") && ($data != "\n")) { $title = $title . $data; }
if (($currenttag == "ABSTRACT") && ($data != "\n")) { $abstract = $abstract . $data; }
if (($currenttag == "URL") && ($data != "\n")) { $url = $url . $data; }
if (($currenttag == "REDIR") && ($data != "\n")) { $redir = $redir . $data; }
}
global $qry, $nres, $nfs, $offset, $details;
global $ass, $fsonly, $ns, $hl, $alt, $alttxt;
global $querykey, $queryvar;
foreach($_REQUEST As $querykey => $queryvar) {
eval("\$$querykey = \"$queryvar\";");
}
$qry = stripslashes($qry);
$nres == 0 ? $nres = 10 : 0;
$nfs == "" ? $nfs = 3 : 0;
$offset == "" ? $offset = 0: 0;
$details == "" ? $details = 1 : 0;
$fsonly == "" ? $fsonly = 0: 0;
$hl == "" ? $hl = 0: 0;
$alt == "" ? $alt = 0: 0;
// $ns == "" ? $ns = 0: 0;
$Atitle = array();
$Aabstract = array();
$Aredir = array();
$Aurl = array();
$xml_feed = "http://www.mirago.co.uk/scripts/xmlhandler.aspx?";
$xml_feed .= "&qry=" . urlencode($qry);
$xml_feed .= "&ass=" . $ass;
$xml_feed .= "&details=". $details;
$xml_feed .= "&nres=" . $nres;
$xml_feed .= "&offset=" . $offset;
$xml_feed .= "&nfs=" . $nfs;
$xml_feed .= "&fsonly=" . $fsonly;
$xml_feed .= "&hl=" . $hl;
$xml_feed .= "&ns=" . $ns;
$xml_feed .= "&alt=" . $alt;
$pagelink = getenv("SCRIPT_NAME") . "?qry=" . urlencode($qry) . "&ass=$ass&nres=$nres&details=$details&fsonly=$fsonly&hl=$hl&nfs=$nfs&ns=$ns&alt=$alt";
// what are we parsing?
$type = 'ISO-8859-1';
// create our parser
$xml_parser = xml_parser_create($type);
// set some parser options
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $type);
// this tells PHP what functions to call when it finds an element
// these funcitons also handle the element's attributes
xml_set_element_handler($xml_parser, 'startElement','endElement');
// this tells PHP what function to use on the character data
xml_set_character_data_handler($xml_parser, 'characterData');
if (!($fp = fopen($xml_feed, 'r'))) {
die("Could not open $xml_feed for parsing!\n");
}
// loop through the file and parse baby!
while ($data = fread ($fp, 4096)) {
// if (!($data = utf8_encode($data))) {
// echo 'ERROR'."\n";
// }
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf( "XML error: %s at line %d\n\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
?>
<html>
<head>
<title>Mirago XML PHP Example</title>
<STYLE>
DT {
font-family:Tahoma;
font-size:12px;
font-weight:bold;
}
DD {
font-family:Tahoma;
font-size:12px;
font-weight:normal;
}
P {
font-family:Tahoma;
font-size:12px;
font-weight:normal;
}
input {font-family:Tahoma; font-size:11px;}
</STYLE>
</head>
<body>
<h1 style="font-family:Tahoma;font-size:18px;font-weight:bold">Mirago Search Results</h1>
<p style="font-family:Tahoma;font-size:12px;">
<form name="xmlsearch" action=<? echo '"' . getenv('SCRIPT_NAME') . '"' ?> method="GET">
<input type="hidden" name="ass" value="1000">
<input type="text" name="qry" size=25 style="font-size:12px" value=<? echo '"'.htmlspecialchars($qry).'"' ?>>
<input type="submit" name="cmdSearch" value="Search" style="font-family:Verdana;font-size:12px;"><br>
<b>Options</b>
<div style="font-family:Tahoma;font-size:12px">
<input type="checkbox" name="details" value="1"<? if ($details == 1) { echo " checked"; } ?>> Show Details
<input type="checkbox" name="fsonly" value="1"<? if ($fsonly == "1") { echo " checked"; } ?>> Featured Sites Only<br>
<input type="checkbox" name="hl" value="1"<? if ($hl == "1") { echo " checked"; } ?>> Highlight Search Terms<br>
<input type="checkbox" name="ns" value="1"<? if ($ns == "1") { echo " checked"; } ?>> Precise Match Featured Sites<br>
<input type="checkbox" name="alt" value="1"<? if ($alt == "1") { echo " checked"; } ?>> Alternate Search Terms<br>
<input type="text" name="nfs" size=1 maxlength=2 value=<?echo "\"$nfs\"" ?>> No of Featured Sites to Display<br>
<input type="text" name="nres" size=1 maxlength=2 value=<?echo "\"$nres\"" ?>> No of Results to Display<br>
</div></form>
<p style="font-size:14px;">
<?
if ($qry != "") echo "You searched for <b>". htmlspecialchars($qry) . "</b> : ";
if ($resultset["NUMRESULTS"] != 0) {
echo "Showing Results " . ($offset+1) . " - " . ($offset + $resultset["NUMRESULTS"]);
} else {
If ($qry<>"") {echo "No results were returned";}
}
echo "<br><hr size=1>";
// This outputs the alternate search terms
if ($alttxt != "") {
global $altterms;
$altterms = explode(", ",$alttxt);
echo "<br><b>Also Try The Following Searches:</b><br>";
foreach ($altterms as $alttxt) {
if ($altterms[0] != $alttxt) { echo", ";}
echo "<a href=?qry=".urlencode($alttxt).">".$alttxt."</a>";
}
echo "<br><br>";
}
for ($i = 1; $i <= $resultset["NUMRESULTS"]; $i++) {
$title = array_shift($Atitle);
$abstract = array_shift($Aabstract);
$redir = array_shift($Aredir);
$url = array_shift($Aurl);
displayResult($i, $title, $abstract, $redir, $url);
}
if (($resultset["MORERESULTS"] == "True") || ($offset < "0")) {
echo "<p align=right style=font-size:14px;font-family:Verdana>";
if ($offset != "0") { echo "<a " . status("Previous $nres Results") . " href=\"$pagelink&offset=" . ($offset-$nres) ."\"><b><< Previous results</b></a> "; }
if (($resultset["MORERESULTS"] == "True") && ($offset < (200 - $nres))) { echo "<a ". status("Next $nres Results") . " href=\"$pagelink&offset=" . ($offset+$nres) ."\"><b>More results >></b></a>"; }
}
?>
<hr size=1>
<p align=center>© 2003 Mirago PLC</p>
</body>
</html>
Couple of questions:
1. Trying to get a modification on the code below, so that I can display any predefined search I like, for example, for my finance page I can have results on the page for the keyword 'loans'. I want the search box to still be usable for any other search the visitor chooses. This way I can create lots of predefined searches and get the pages keyworded and fully optimised - and get lots of search engine interest in these pages.
2. I want to embed the xml .php feed into a html page and keep the .html extension - this way I can use existing pages with good search engine listings to display the feed - is this possible???????
Mirago XML Parser Source Code (my user id is omitted from code)
Code: [ Select ]
--------------------------------------------------------------------------------
<?php
function status($message) {
return "onMouseOver=\"window.status='$message'; return true;\" onMouseOut=\"window.status=''; return true;\"";
}
function displayResult($resultid, $title, $abstract, $redir, $url) {
global $offset, $webtag;
$statusbar = status("visit: $url");
If (substr($redir,0,65)<>substr($url,0,65)) {
If ($resultid==1) {
echo "<b>Featured Sites</b>";
$webtag=0;
}
} else {
If ($webtag<>1) {
echo "<b>Web Results</b>";
$webtag = 1;
}
}
echo "<DL>\n<DT><A $statusbar HREF=\"$redir\"><b>".($offset + $resultid).". $title</b></a></DT>";
echo "<DD>$abstract</DD>\n<DD>$url</DD>\n</DL>\n";
}
// handles the attributes for opening tags
// $attrs is a multidimensional array keyed by attribute
// name and having the value of that attribute
function startElement($parser, $name, $attrs=''){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
if ($currenttag == "") { $parenttag = $currenttag; }
$currenttag = $name;
if (count($attrs) > 0) {
foreach($attrs as $keys) {
// print ($keys);
if ($name == "RESULTSET") {
$resultset = $attrs;
}
if ($name == "RESULT") {
$resultid = $attrs["ID"]+1;
//print ($attrs["ID"]);
}
}
}
}
// $current_tag lets us know what tag we are currently
// dealing with - we use that later in the characterData
// function.
function endElement($parser, $name, $attrs=''){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
global $Atitle, $Aabstract, $Aredir, $Aurl;
if ($name == "RESULT") {
//displayResult($resultid, $title, $abstract, $redir, $url);
array_push($Atitle, $title);
array_push($Aabstract, $abstract);
array_push($Aredir, $redir);
array_push($Aurl, $url);
$title = "";
$abstract = "";
$redir = "";
$url = "";
}
$currenttag = "";
}
// this function is passed data between elements
function characterData($parser, $data){
global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid, $alttxt;
//$data =~ s/£/£/;
if (($currenttag == "ALT") && ($data != "\n")) { $alttxt = $data; }
if (($currenttag == "TITLE") && ($data != "\n")) { $title = $title . $data; }
if (($currenttag == "ABSTRACT") && ($data != "\n")) { $abstract = $abstract . $data; }
if (($currenttag == "URL") && ($data != "\n")) { $url = $url . $data; }
if (($currenttag == "REDIR") && ($data != "\n")) { $redir = $redir . $data; }
}
global $qry, $nres, $nfs, $offset, $details;
global $ass, $fsonly, $ns, $hl, $alt, $alttxt;
global $querykey, $queryvar;
foreach($_REQUEST As $querykey => $queryvar) {
eval("\$$querykey = \"$queryvar\";");
}
$qry = stripslashes($qry);
$nres == 0 ? $nres = 10 : 0;
$nfs == "" ? $nfs = 3 : 0;
$offset == "" ? $offset = 0: 0;
$details == "" ? $details = 1 : 0;
$fsonly == "" ? $fsonly = 0: 0;
$hl == "" ? $hl = 0: 0;
$alt == "" ? $alt = 0: 0;
// $ns == "" ? $ns = 0: 0;
$Atitle = array();
$Aabstract = array();
$Aredir = array();
$Aurl = array();
$xml_feed = "http://www.mirago.co.uk/scripts/xmlhandler.aspx?";
$xml_feed .= "&qry=" . urlencode($qry);
$xml_feed .= "&ass=" . $ass;
$xml_feed .= "&details=". $details;
$xml_feed .= "&nres=" . $nres;
$xml_feed .= "&offset=" . $offset;
$xml_feed .= "&nfs=" . $nfs;
$xml_feed .= "&fsonly=" . $fsonly;
$xml_feed .= "&hl=" . $hl;
$xml_feed .= "&ns=" . $ns;
$xml_feed .= "&alt=" . $alt;
$pagelink = getenv("SCRIPT_NAME") . "?qry=" . urlencode($qry) . "&ass=$ass&nres=$nres&details=$details&fsonly=$fsonly&hl=$hl&nfs=$nfs&ns=$ns&alt=$alt";
// what are we parsing?
$type = 'ISO-8859-1';
// create our parser
$xml_parser = xml_parser_create($type);
// set some parser options
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $type);
// this tells PHP what functions to call when it finds an element
// these funcitons also handle the element's attributes
xml_set_element_handler($xml_parser, 'startElement','endElement');
// this tells PHP what function to use on the character data
xml_set_character_data_handler($xml_parser, 'characterData');
if (!($fp = fopen($xml_feed, 'r'))) {
die("Could not open $xml_feed for parsing!\n");
}
// loop through the file and parse baby!
while ($data = fread ($fp, 4096)) {
// if (!($data = utf8_encode($data))) {
// echo 'ERROR'."\n";
// }
if (!xml_parse($xml_parser, $data, feof($fp))) {
die(sprintf( "XML error: %s at line %d\n\n",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
}
xml_parser_free($xml_parser);
?>
<html>
<head>
<title>Mirago XML PHP Example</title>
<STYLE>
DT {
font-family:Tahoma;
font-size:12px;
font-weight:bold;
}
DD {
font-family:Tahoma;
font-size:12px;
font-weight:normal;
}
P {
font-family:Tahoma;
font-size:12px;
font-weight:normal;
}
input {font-family:Tahoma; font-size:11px;}
</STYLE>
</head>
<body>
<h1 style="font-family:Tahoma;font-size:18px;font-weight:bold">Mirago Search Results</h1>
<p style="font-family:Tahoma;font-size:12px;">
<form name="xmlsearch" action=<? echo '"' . getenv('SCRIPT_NAME') . '"' ?> method="GET">
<input type="hidden" name="ass" value="1000">
<input type="text" name="qry" size=25 style="font-size:12px" value=<? echo '"'.htmlspecialchars($qry).'"' ?>>
<input type="submit" name="cmdSearch" value="Search" style="font-family:Verdana;font-size:12px;"><br>
<b>Options</b>
<div style="font-family:Tahoma;font-size:12px">
<input type="checkbox" name="details" value="1"<? if ($details == 1) { echo " checked"; } ?>> Show Details
<input type="checkbox" name="fsonly" value="1"<? if ($fsonly == "1") { echo " checked"; } ?>> Featured Sites Only<br>
<input type="checkbox" name="hl" value="1"<? if ($hl == "1") { echo " checked"; } ?>> Highlight Search Terms<br>
<input type="checkbox" name="ns" value="1"<? if ($ns == "1") { echo " checked"; } ?>> Precise Match Featured Sites<br>
<input type="checkbox" name="alt" value="1"<? if ($alt == "1") { echo " checked"; } ?>> Alternate Search Terms<br>
<input type="text" name="nfs" size=1 maxlength=2 value=<?echo "\"$nfs\"" ?>> No of Featured Sites to Display<br>
<input type="text" name="nres" size=1 maxlength=2 value=<?echo "\"$nres\"" ?>> No of Results to Display<br>
</div></form>
<p style="font-size:14px;">
<?
if ($qry != "") echo "You searched for <b>". htmlspecialchars($qry) . "</b> : ";
if ($resultset["NUMRESULTS"] != 0) {
echo "Showing Results " . ($offset+1) . " - " . ($offset + $resultset["NUMRESULTS"]);
} else {
If ($qry<>"") {echo "No results were returned";}
}
echo "<br><hr size=1>";
// This outputs the alternate search terms
if ($alttxt != "") {
global $altterms;
$altterms = explode(", ",$alttxt);
echo "<br><b>Also Try The Following Searches:</b><br>";
foreach ($altterms as $alttxt) {
if ($altterms[0] != $alttxt) { echo", ";}
echo "<a href=?qry=".urlencode($alttxt).">".$alttxt."</a>";
}
echo "<br><br>";
}
for ($i = 1; $i <= $resultset["NUMRESULTS"]; $i++) {
$title = array_shift($Atitle);
$abstract = array_shift($Aabstract);
$redir = array_shift($Aredir);
$url = array_shift($Aurl);
displayResult($i, $title, $abstract, $redir, $url);
}
if (($resultset["MORERESULTS"] == "True") || ($offset < "0")) {
echo "<p align=right style=font-size:14px;font-family:Verdana>";
if ($offset != "0") { echo "<a " . status("Previous $nres Results") . " href=\"$pagelink&offset=" . ($offset-$nres) ."\"><b><< Previous results</b></a> "; }
if (($resultset["MORERESULTS"] == "True") && ($offset < (200 - $nres))) { echo "<a ". status("Next $nres Results") . " href=\"$pagelink&offset=" . ($offset+$nres) ."\"><b>More results >></b></a>"; }
}
?>
<hr size=1>
<p align=center>© 2003 Mirago PLC</p>
</body>
</html>
- --------------------------------------------------------------------------------
- <?php
- function status($message) {
- return "onMouseOver=\"window.status='$message'; return true;\" onMouseOut=\"window.status=''; return true;\"";
- }
- function displayResult($resultid, $title, $abstract, $redir, $url) {
- global $offset, $webtag;
- $statusbar = status("visit: $url");
- If (substr($redir,0,65)<>substr($url,0,65)) {
- If ($resultid==1) {
- echo "<b>Featured Sites</b>";
- $webtag=0;
- }
- } else {
- If ($webtag<>1) {
- echo "<b>Web Results</b>";
- $webtag = 1;
- }
- }
- echo "<DL>\n<DT><A $statusbar HREF=\"$redir\"><b>".($offset + $resultid).". $title</b></a></DT>";
- echo "<DD>$abstract</DD>\n<DD>$url</DD>\n</DL>\n";
- }
- // handles the attributes for opening tags
- // $attrs is a multidimensional array keyed by attribute
- // name and having the value of that attribute
- function startElement($parser, $name, $attrs=''){
- global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
- if ($currenttag == "") { $parenttag = $currenttag; }
- $currenttag = $name;
- if (count($attrs) > 0) {
- foreach($attrs as $keys) {
- // print ($keys);
- if ($name == "RESULTSET") {
- $resultset = $attrs;
- }
- if ($name == "RESULT") {
- $resultid = $attrs["ID"]+1;
- //print ($attrs["ID"]);
- }
- }
- }
- }
- // $current_tag lets us know what tag we are currently
- // dealing with - we use that later in the characterData
- // function.
- function endElement($parser, $name, $attrs=''){
- global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
- global $Atitle, $Aabstract, $Aredir, $Aurl;
- if ($name == "RESULT") {
- //displayResult($resultid, $title, $abstract, $redir, $url);
- array_push($Atitle, $title);
- array_push($Aabstract, $abstract);
- array_push($Aredir, $redir);
- array_push($Aurl, $url);
- $title = "";
- $abstract = "";
- $redir = "";
- $url = "";
- }
- $currenttag = "";
- }
- // this function is passed data between elements
- function characterData($parser, $data){
- global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid, $alttxt;
- //$data =~ s/£/£/;
- if (($currenttag == "ALT") && ($data != "\n")) { $alttxt = $data; }
- if (($currenttag == "TITLE") && ($data != "\n")) { $title = $title . $data; }
- if (($currenttag == "ABSTRACT") && ($data != "\n")) { $abstract = $abstract . $data; }
- if (($currenttag == "URL") && ($data != "\n")) { $url = $url . $data; }
- if (($currenttag == "REDIR") && ($data != "\n")) { $redir = $redir . $data; }
- }
- global $qry, $nres, $nfs, $offset, $details;
- global $ass, $fsonly, $ns, $hl, $alt, $alttxt;
- global $querykey, $queryvar;
- foreach($_REQUEST As $querykey => $queryvar) {
- eval("\$$querykey = \"$queryvar\";");
- }
- $qry = stripslashes($qry);
- $nres == 0 ? $nres = 10 : 0;
- $nfs == "" ? $nfs = 3 : 0;
- $offset == "" ? $offset = 0: 0;
- $details == "" ? $details = 1 : 0;
- $fsonly == "" ? $fsonly = 0: 0;
- $hl == "" ? $hl = 0: 0;
- $alt == "" ? $alt = 0: 0;
- // $ns == "" ? $ns = 0: 0;
- $Atitle = array();
- $Aabstract = array();
- $Aredir = array();
- $Aurl = array();
- $xml_feed = "http://www.mirago.co.uk/scripts/xmlhandler.aspx?";
- $xml_feed .= "&qry=" . urlencode($qry);
- $xml_feed .= "&ass=" . $ass;
- $xml_feed .= "&details=". $details;
- $xml_feed .= "&nres=" . $nres;
- $xml_feed .= "&offset=" . $offset;
- $xml_feed .= "&nfs=" . $nfs;
- $xml_feed .= "&fsonly=" . $fsonly;
- $xml_feed .= "&hl=" . $hl;
- $xml_feed .= "&ns=" . $ns;
- $xml_feed .= "&alt=" . $alt;
- $pagelink = getenv("SCRIPT_NAME") . "?qry=" . urlencode($qry) . "&ass=$ass&nres=$nres&details=$details&fsonly=$fsonly&hl=$hl&nfs=$nfs&ns=$ns&alt=$alt";
- // what are we parsing?
- $type = 'ISO-8859-1';
- // create our parser
- $xml_parser = xml_parser_create($type);
- // set some parser options
- xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
- xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $type);
- // this tells PHP what functions to call when it finds an element
- // these funcitons also handle the element's attributes
- xml_set_element_handler($xml_parser, 'startElement','endElement');
- // this tells PHP what function to use on the character data
- xml_set_character_data_handler($xml_parser, 'characterData');
- if (!($fp = fopen($xml_feed, 'r'))) {
- die("Could not open $xml_feed for parsing!\n");
- }
- // loop through the file and parse baby!
- while ($data = fread ($fp, 4096)) {
- // if (!($data = utf8_encode($data))) {
- // echo 'ERROR'."\n";
- // }
- if (!xml_parse($xml_parser, $data, feof($fp))) {
- die(sprintf( "XML error: %s at line %d\n\n",
- xml_error_string(xml_get_error_code($xml_parser)),
- xml_get_current_line_number($xml_parser)));
- }
- }
- xml_parser_free($xml_parser);
- ?>
- <html>
- <head>
- <title>Mirago XML PHP Example</title>
- <STYLE>
- DT {
- font-family:Tahoma;
- font-size:12px;
- font-weight:bold;
- }
- DD {
- font-family:Tahoma;
- font-size:12px;
- font-weight:normal;
- }
- P {
- font-family:Tahoma;
- font-size:12px;
- font-weight:normal;
- }
- input {font-family:Tahoma; font-size:11px;}
- </STYLE>
- </head>
- <body>
- <h1 style="font-family:Tahoma;font-size:18px;font-weight:bold">Mirago Search Results</h1>
- <p style="font-family:Tahoma;font-size:12px;">
- <form name="xmlsearch" action=<? echo '"' . getenv('SCRIPT_NAME') . '"' ?> method="GET">
- <input type="hidden" name="ass" value="1000">
- <input type="text" name="qry" size=25 style="font-size:12px" value=<? echo '"'.htmlspecialchars($qry).'"' ?>>
- <input type="submit" name="cmdSearch" value="Search" style="font-family:Verdana;font-size:12px;"><br>
-
- <b>Options</b>
- <div style="font-family:Tahoma;font-size:12px">
- <input type="checkbox" name="details" value="1"<? if ($details == 1) { echo " checked"; } ?>> Show Details
-
- <input type="checkbox" name="fsonly" value="1"<? if ($fsonly == "1") { echo " checked"; } ?>> Featured Sites Only<br>
- <input type="checkbox" name="hl" value="1"<? if ($hl == "1") { echo " checked"; } ?>> Highlight Search Terms<br>
- <input type="checkbox" name="ns" value="1"<? if ($ns == "1") { echo " checked"; } ?>> Precise Match Featured Sites<br>
- <input type="checkbox" name="alt" value="1"<? if ($alt == "1") { echo " checked"; } ?>> Alternate Search Terms<br>
- <input type="text" name="nfs" size=1 maxlength=2 value=<?echo "\"$nfs\"" ?>> No of Featured Sites to Display<br>
- <input type="text" name="nres" size=1 maxlength=2 value=<?echo "\"$nres\"" ?>> No of Results to Display<br>
-
- </div></form>
- <p style="font-size:14px;">
- <?
- if ($qry != "") echo "You searched for <b>". htmlspecialchars($qry) . "</b> : ";
- if ($resultset["NUMRESULTS"] != 0) {
- echo "Showing Results " . ($offset+1) . " - " . ($offset + $resultset["NUMRESULTS"]);
- } else {
- If ($qry<>"") {echo "No results were returned";}
- }
- echo "<br><hr size=1>";
- // This outputs the alternate search terms
- if ($alttxt != "") {
- global $altterms;
- $altterms = explode(", ",$alttxt);
- echo "<br><b>Also Try The Following Searches:</b><br>";
- foreach ($altterms as $alttxt) {
- if ($altterms[0] != $alttxt) { echo", ";}
- echo "<a href=?qry=".urlencode($alttxt).">".$alttxt."</a>";
- }
- echo "<br><br>";
- }
- for ($i = 1; $i <= $resultset["NUMRESULTS"]; $i++) {
- $title = array_shift($Atitle);
- $abstract = array_shift($Aabstract);
- $redir = array_shift($Aredir);
- $url = array_shift($Aurl);
- displayResult($i, $title, $abstract, $redir, $url);
- }
- if (($resultset["MORERESULTS"] == "True") || ($offset < "0")) {
- echo "<p align=right style=font-size:14px;font-family:Verdana>";
- if ($offset != "0") { echo "<a " . status("Previous $nres Results") . " href=\"$pagelink&offset=" . ($offset-$nres) ."\"><b><< Previous results</b></a> "; }
- if (($resultset["MORERESULTS"] == "True") && ($offset < (200 - $nres))) { echo "<a ". status("Next $nres Results") . " href=\"$pagelink&offset=" . ($offset+$nres) ."\"><b>More results >></b></a>"; }
- }
- ?>
- <hr size=1>
- <p align=center>© 2003 Mirago PLC</p>
- </body>
- </html>
- Anonymous
- Bot


- Joined: 25 Feb 2008
- Posts: ?
- Loc: Ozzuland
- Status: Online
April 27th, 2004, 3:35 pm
Page 1 of 1
To Reply to this topic you need to LOGIN or REGISTER. It is free.
Post Information
- Total Posts in this topic: 2 posts
- Users browsing this forum: No registered users and 118 guests
- You cannot post new topics in this forum
- You cannot reply to topics in this forum
- You cannot edit your posts in this forum
- You cannot delete your posts in this forum
- You cannot post attachments in this forum

