Ver Mensaje Individual
  #14 (permalink)  
Antiguo 31/10/2007, 14:39
Avatar de Italico76
Italico76
 
Fecha de Ingreso: abril-2007
Mensajes: 3.303
Antigüedad: 17 años, 11 meses
Puntos: 292
Al pastear debo usar stripslashes() y queda OK

El codigo original (donde los enlaces son PASTEADOS desde una FORM) funciona SOLO si utilizo la funcion stripslashes () para pre-procesar la entrada y eliminar los \'

Aqui la VERSION DEFINITIVA:


Código PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Parserseo de enlaces</title>
</head>

<body>
  
      
<div align="center">
<form method="post" action="anal-def.php">
<textarea name="entrada" cols="45" rows="5"></textarea>
      <p/>      
      <input type="submit" value="Enviar"/>
</form>
  </div>
  <?php procesa(); ?>  
  </body>
</html>

<?php

Function procesa(){

if (isset(
$_POST["entrada"])) {

$enlaces $_POST["entrada"];  // tomo de la veriable "entrada" del Form
$enlaces stripslashes ($enlaces); // elimino \'    <<<<<
$texto =str_replace("\"" "'" ,$enlaces);  //reemplazo comillas dobles [ chr(34) ] por simples

$a = array("/\<li\>\<a href=\'(.*?)\'(.*?)\>(.*?)\<\/a\>(.*?)\<\/li\>/is");

// HREF
$b = array("$1"."<br />");  // los <br/> son esteticos
$href preg_replace($a$b$texto);
//echo $href;

//ANCHOR
$c = array("$3"."<br />");
$textodentroa preg_replace($a$c$texto);
//echo $textodentroa;

//DESCRIPCION ENTRE </a> y <li>
$d = array("$4"."<br />");
$textodespuesa preg_replace($a$d$texto);
//echo $textodespuesa;

//TITLE="......"
$e = array("$2"."<br />");
$title preg_replace($a$e$texto);

//TITLE ( limpio)
$a=array("#title[[:blank:]]*?=[[:blank:]]*?\'(.*?)\'#");
$b = array("$1");
$title_solved preg_replace($a$b$title);
echo 
$title_solved;

  
  
//Print_r ($urls);  
  //Print count($urls);
 
}
}
?>

Última edición por Italico76; 31/10/2007 a las 14:52