embed. en php. page html maintien. extension html help!
- ukshopsnet
- Novice


- Inscription: Aoû 03, 2003
- Messages: 21
- Loc: HIGH PEAK, UK
- Status: Offline
Salut
Couple de questions:
1. Essayant d'obtenir une modification sur le code ci-dessous, afin que je puisse afficher n'importe quelle recherche prédéfinie qui me plaît, par exemple, pour ma page des finances, je peut avoir des résultats sur la page pour le mot clé «prêts». Je veux que la boîte de recherche pour être encore utilisable pour toute autre recherche, le visiteur choisit. De cette façon je peux créer un bon nombre de recherches prédéfinies et obtenir les pages keyworded et entièrement optimisé - et faites beaucoup d'intérêt des moteurs de recherche dans ces pages.
2. Je veux intégrer le XML. Feed PHP dans une page html et de conserver l'extension. Html - de cette façon je peux utiliser des pages existantes avec des annonces de bonnes moteur de recherche pour afficher le flux - est-ce possible ???????
Mirago XML Parser Code Source (mon ID utilisateur est omis dans le 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 de questions:
1. Essayant d'obtenir une modification sur le code ci-dessous, afin que je puisse afficher n'importe quelle recherche prédéfinie qui me plaît, par exemple, pour ma page des finances, je peut avoir des résultats sur la page pour le mot clé «prêts». Je veux que la boîte de recherche pour être encore utilisable pour toute autre recherche, le visiteur choisit. De cette façon je peux créer un bon nombre de recherches prédéfinies et obtenir les pages keyworded et entièrement optimisé - et faites beaucoup d'intérêt des moteurs de recherche dans ces pages.
2. Je veux intégrer le XML. Feed PHP dans une page html et de conserver l'extension. Html - de cette façon je peux utiliser des pages existantes avec des annonces de bonnes moteur de recherche pour afficher le flux - est-ce possible ???????
Mirago XML Parser Code Source (mon ID utilisateur est omis dans le 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


- Inscription: 25 Feb 2008
- Messages: ?
- Loc: Ozzuland
- Status: Online
Avril 27th, 2004, 3:35 pm
Page 1 sur 1
Pour répondre à ce sujet, vous devez vous connecter ou vous enregistrer. Il est gratuit.
Afficher de l'information
- Total des messages de ce sujet: 2 messages
- Utilisateurs parcourant ce forum: Aucun utilisateur enregistré et 139 invités
- Vous ne pouvez pas poster de nouveaux sujets
- Vous ne pouvez pas répondre aux sujets
- Vous ne pouvez pas éditer vos messages
- Vous ne pouvez pas supprimer vos messages
- Vous ne pouvez pas joindre des fichiers

