integrar. php en. html mantenimiento de la página. html prórroga ayuda!
- ukshopsnet
- Novice


- Registrado: Ago 03, 2003
- Mensajes: 21
- Loc: HIGH PEAK, UK
- Status: Offline
Hola
Un par de preguntas:
1. Tratar de conseguir una modificación en el código de abajo, de modo que puede mostrar cualquier búsqueda predefinidos que me gusta, por ejemplo, de mi página de la financiación que puede tener resultados en la página de la palabra clave "préstamos". Quiero que el cuadro de búsqueda para seguir siendo útil para cualquier búsqueda de otros que el visitante elija. De esta manera puedo crear un montón de búsquedas predefinidas y recibe las páginas de palabra clave y totalmente optimizado - y consigue mucho interés del motor de búsqueda en estas páginas.
2. Quiero integrar el código XML. Piensos php en una página html y mantener la extensión. Html - de esta manera puedo utilizar páginas existentes con los listados de motores de búsqueda para mostrar buena la alimentación - es posible esto ???????
Mirago XML Parser Código Fuente (mi ID de usuario se omite en código)
--------------------------------------------------------------------------------
<?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>
Un par de preguntas:
1. Tratar de conseguir una modificación en el código de abajo, de modo que puede mostrar cualquier búsqueda predefinidos que me gusta, por ejemplo, de mi página de la financiación que puede tener resultados en la página de la palabra clave "préstamos". Quiero que el cuadro de búsqueda para seguir siendo útil para cualquier búsqueda de otros que el visitante elija. De esta manera puedo crear un montón de búsquedas predefinidas y recibe las páginas de palabra clave y totalmente optimizado - y consigue mucho interés del motor de búsqueda en estas páginas.
2. Quiero integrar el código XML. Piensos php en una página html y mantener la extensión. Html - de esta manera puedo utilizar páginas existentes con los listados de motores de búsqueda para mostrar buena la alimentación - es posible esto ???????
Mirago XML Parser Código Fuente (mi ID de usuario se omite en código)
Código: [ 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


- Registrado: 25 Feb 2008
- Mensajes: ?
- Loc: Ozzuland
- Status: Online
Abril 27th, 2004, 3:35 pm
Página 1 de 1
Para responder a este tema que necesita para ingresar o registrarse. Es gratis.
Publicar Información
- Total de mensajes en este tema: 2 mensajes
- Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 102 invitados
- No puede abrir nuevos temas en este Foro
- No puede responder a temas en este Foro
- No puede editar sus mensajes en este Foro
- No puede borrar sus mensajes en este Foro
- No puede enviar adjuntos en este Foro

