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

  • ukshopsnet
  • Novice
  • Novice
  • No Avatar
  • Registrado: Ago 03, 2003
  • Mensajes: 21
  • Loc: HIGH PEAK, UK
  • Status: Offline

Nota Abril 27th, 2004, 3:35 pm

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)

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>
&nbsp;
<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
&nbsp;&nbsp;&nbsp;&nbsp;
<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>
&nbsp;
</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>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; }
  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>&copy; 2003 Mirago PLC</p>
</body>
</html>
  1. --------------------------------------------------------------------------------
  2. <?php
  3. function status($message) {
  4.  return "onMouseOver=\"window.status='$message'; return true;\" onMouseOut=\"window.status=''; return true;\"";
  5. }
  6. function displayResult($resultid, $title, $abstract, $redir, $url) {
  7.  global $offset, $webtag;
  8.  $statusbar = status("visit: $url");
  9.  If (substr($redir,0,65)<>substr($url,0,65)) {
  10.   If ($resultid==1) {
  11.   echo "<b>Featured Sites</b>";
  12.   $webtag=0;
  13.   }
  14.  } else {
  15.   If ($webtag<>1) {
  16.   echo "<b>Web Results</b>";
  17.   $webtag = 1;
  18.   }
  19.  }
  20.  echo "<DL>\n<DT><A $statusbar HREF=\"$redir\"><b>".($offset + $resultid).". $title</b></a></DT>";
  21.  echo "<DD>$abstract</DD>\n<DD>$url</DD>\n</DL>\n";
  22. }
  23. // handles the attributes for opening tags
  24. // $attrs is a multidimensional array keyed by attribute
  25. // name and having the value of that attribute
  26. function startElement($parser, $name, $attrs=''){
  27.  global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
  28.  if ($currenttag == "") { $parenttag = $currenttag; }
  29. $currenttag = $name;
  30.  if (count($attrs) > 0) {
  31.  foreach($attrs as $keys) {
  32. //   print ($keys);
  33.   if ($name == "RESULTSET") {
  34.    $resultset = $attrs;
  35.   }
  36.   if ($name == "RESULT") {
  37.    $resultid = $attrs["ID"]+1;
  38.    //print ($attrs["ID"]);
  39.   }
  40.   }
  41.  }
  42. }
  43. // $current_tag lets us know what tag we are currently
  44. // dealing with - we use that later in the characterData
  45. // function.
  46. function endElement($parser, $name, $attrs=''){
  47.  global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid;
  48.  global $Atitle, $Aabstract, $Aredir, $Aurl;
  49.  if ($name == "RESULT") {
  50.  //displayResult($resultid, $title, $abstract, $redir, $url);
  51.   array_push($Atitle, $title);
  52.   array_push($Aabstract, $abstract);
  53.   array_push($Aredir, $redir);
  54.   array_push($Aurl, $url);
  55.   $title = "";
  56.   $abstract = "";
  57.   $redir = "";
  58.   $url = "";
  59.  }
  60.  $currenttag = "";
  61. }
  62. // this function is passed data between elements
  63. function characterData($parser, $data){
  64.  global $currenttag, $parenttag, $title, $abstract, $redir, $url, $resultset, $resultid, $alttxt;
  65.  //$data =~ s/£/£/;
  66.  if (($currenttag == "ALT") && ($data != "\n")) { $alttxt = $data; }
  67.  if (($currenttag == "TITLE") && ($data != "\n")) { $title = $title . $data; }
  68.  if (($currenttag == "ABSTRACT") && ($data != "\n")) { $abstract = $abstract . $data; }
  69.  if (($currenttag == "URL") && ($data != "\n")) { $url = $url . $data; }
  70.  if (($currenttag == "REDIR") && ($data != "\n")) { $redir = $redir . $data; }
  71. }
  72. global $qry, $nres, $nfs, $offset, $details;
  73. global $ass, $fsonly, $ns, $hl, $alt, $alttxt;
  74. global $querykey, $queryvar;
  75. foreach($_REQUEST As $querykey => $queryvar) {
  76.  eval("$$querykey = \"$queryvar\";");
  77. }
  78. $qry = stripslashes($qry);
  79. $nres == 0 ? $nres = 10 : 0;
  80. $nfs == "" ? $nfs = 3 : 0;
  81. $offset == "" ? $offset = 0: 0;
  82. $details == "" ? $details = 1 : 0;
  83. $fsonly == "" ? $fsonly = 0: 0;
  84. $hl == "" ? $hl = 0: 0;
  85. $alt == "" ? $alt = 0: 0;
  86. // $ns == "" ? $ns = 0: 0;
  87. $Atitle = array();
  88. $Aabstract = array();
  89. $Aredir = array();
  90. $Aurl = array();
  91. $xml_feed = "http://www.mirago.co.uk/scripts/xmlhandler.aspx?";
  92. $xml_feed .= "&qry="   . urlencode($qry);
  93. $xml_feed .= "&ass="   . $ass;
  94. $xml_feed .= "&details=". $details;
  95. $xml_feed .= "&nres="  . $nres;
  96. $xml_feed .= "&offset=" . $offset;
  97. $xml_feed .= "&nfs=" . $nfs;
  98. $xml_feed .= "&fsonly=" . $fsonly;
  99. $xml_feed .= "&hl=" . $hl;
  100. $xml_feed .= "&ns=" . $ns;
  101. $xml_feed .= "&alt=" . $alt;
  102. $pagelink = getenv("SCRIPT_NAME") . "?qry=" . urlencode($qry) . "&ass=$ass&nres=$nres&details=$details&fsonly=$fsonly&hl=$hl&nfs=$nfs&ns=$ns&alt=$alt";
  103. // what are we parsing?
  104. $type = 'ISO-8859-1';
  105. // create our parser
  106. $xml_parser = xml_parser_create($type);
  107. // set some parser options
  108. xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
  109. xml_parser_set_option($xml_parser, XML_OPTION_TARGET_ENCODING, $type);
  110. // this tells PHP what functions to call when it finds an element
  111. // these funcitons also handle the element's attributes
  112. xml_set_element_handler($xml_parser, 'startElement','endElement');
  113. // this tells PHP what function to use on the character data
  114. xml_set_character_data_handler($xml_parser, 'characterData');
  115. if (!($fp = fopen($xml_feed, 'r'))) {
  116. die("Could not open $xml_feed for parsing!\n");
  117. }
  118. // loop through the file and parse baby!
  119. while ($data = fread ($fp, 4096)) {
  120. // if (!($data = utf8_encode($data))) {
  121. // echo 'ERROR'."\n";
  122. // }
  123. if (!xml_parse($xml_parser, $data, feof($fp))) {
  124. die(sprintf( "XML error: %s at line %d\n\n",
  125. xml_error_string(xml_get_error_code($xml_parser)),
  126. xml_get_current_line_number($xml_parser)));
  127. }
  128. }
  129. xml_parser_free($xml_parser);
  130. ?>
  131. <html>
  132.  <head>
  133.   <title>Mirago XML PHP Example</title>
  134.   <STYLE>
  135. DT {
  136.  font-family:Tahoma;
  137.  font-size:12px;
  138.  font-weight:bold;
  139. }
  140. DD {
  141.  font-family:Tahoma;
  142.  font-size:12px;
  143.  font-weight:normal;
  144. }
  145. P {
  146.  font-family:Tahoma;
  147.  font-size:12px;
  148.  font-weight:normal;
  149. }
  150. input {font-family:Tahoma; font-size:11px;}
  151.   </STYLE>
  152.  </head>
  153. <body>
  154. <h1 style="font-family:Tahoma;font-size:18px;font-weight:bold">Mirago Search Results</h1>
  155. <p style="font-family:Tahoma;font-size:12px;">
  156. <form name="xmlsearch" action=<? echo '"' . getenv('SCRIPT_NAME') . '"' ?> method="GET">
  157. <input type="hidden" name="ass" value="1000">
  158. <input type="text" name="qry" size=25 style="font-size:12px" value=<? echo '"'.htmlspecialchars($qry).'"' ?>>
  159. <input type="submit" name="cmdSearch" value="Search" style="font-family:Verdana;font-size:12px;"><br>
  160. &nbsp;
  161. <b>Options</b>
  162. <div style="font-family:Tahoma;font-size:12px">
  163. <input type="checkbox" name="details" value="1"<? if ($details == 1) { echo " checked"; } ?>> Show Details
  164. &nbsp;&nbsp;&nbsp;&nbsp;
  165. <input type="checkbox" name="fsonly" value="1"<? if ($fsonly == "1") { echo " checked"; } ?>> Featured Sites Only<br>
  166. <input type="checkbox" name="hl" value="1"<? if ($hl == "1") { echo " checked"; } ?>> Highlight Search Terms<br>
  167. <input type="checkbox" name="ns" value="1"<? if ($ns == "1") { echo " checked"; } ?>> Precise Match Featured Sites<br>
  168. <input type="checkbox" name="alt" value="1"<? if ($alt == "1") { echo " checked"; } ?>> Alternate Search Terms<br>
  169. <input type="text" name="nfs" size=1 maxlength=2 value=<?echo "\"$nfs\"" ?>> No of Featured Sites to Display<br>
  170. <input type="text" name="nres" size=1 maxlength=2 value=<?echo "\"$nres\"" ?>> No of Results to Display<br>
  171. &nbsp;
  172. </div></form>
  173. <p style="font-size:14px;">
  174. <?
  175.  if ($qry != "") echo "You searched for <b>". htmlspecialchars($qry) . "</b> : ";
  176.  if ($resultset["NUMRESULTS"] != 0) {
  177.   echo "Showing Results " . ($offset+1) . " - " . ($offset + $resultset["NUMRESULTS"]);
  178.  } else {
  179.   If ($qry<>"") {echo "No results were returned";}
  180.  }
  181. echo "<br><hr size=1>";
  182. // This outputs the alternate search terms
  183. if ($alttxt != "") {
  184.   global $altterms;
  185.   $altterms = explode(", ",$alttxt);
  186. echo "<br><b>Also Try The Following Searches:</b><br>";
  187. foreach ($altterms as $alttxt) {
  188. if ($altterms[0] != $alttxt) { echo", ";}
  189. echo "<a href=?qry=".urlencode($alttxt).">".$alttxt."</a>";
  190. }
  191. echo "<br><br>";
  192. }
  193. for ($i = 1; $i <= $resultset["NUMRESULTS"]; $i++) {
  194.  $title = array_shift($Atitle);
  195.  $abstract = array_shift($Aabstract);
  196.  $redir = array_shift($Aredir);
  197.  $url = array_shift($Aurl);
  198.  displayResult($i, $title, $abstract, $redir, $url);
  199. }
  200. if (($resultset["MORERESULTS"] == "True") || ($offset < "0")) {
  201.   echo "<p align=right style=font-size:14px;font-family:Verdana>";
  202.   if ($offset != "0") { echo "<a " . status("Previous $nres Results") . " href=\"$pagelink&offset=" . ($offset-$nres) ."\"><b><< Previous results</b></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"; }
  203.   if (($resultset["MORERESULTS"] == "True") && ($offset < (200 - $nres))) { echo "<a ". status("Next $nres Results") . " href=\"$pagelink&offset=" . ($offset+$nres) ."\"><b>More results >></b></a>"; }
  204. }
  205. ?>
  206. <hr size=1>
  207. <p align=center>&copy; 2003 Mirago PLC</p>
  208. </body>
  209. </html>
  • Anonymous
  • Bot
  • No Avatar
  • Registrado: 25 Feb 2008
  • Mensajes: ?
  • Loc: Ozzuland
  • Status: Online

Nota Abril 27th, 2004, 3:35 pm

  • Managedlinks
  • Proficient
  • Proficient
  • No Avatar
  • Registrado: Mar 31, 2004
  • Mensajes: 294
  • Status: Offline

Nota Abril 28th, 2004, 6:58 pm

Esta página te muestra cómo hacer páginas html trabajo como php

http://www.managedlinks.com/htaccess.html

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
 
 

© 2011 Unmelted, LLC. Ozzu® es una marca registrada de Unmelted, LLC