Ver Mensaje Individual
  #15 (permalink)  
Antiguo 13/09/2008, 09:23
Avatar de the_web_saint
the_web_saint
 
Fecha de Ingreso: mayo-2008
Ubicación: localhost/tierra/america/panama
Mensajes: 1.229
Antigüedad: 16 años, 10 meses
Puntos: 43
Respuesta: Pregunta programacion PHP

hice unas pruebas con el KSES:

Aquí les dejo el resultado:

form:
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>NUCKLEAR</title>
</head>

<body>
<?php
include '../kses.php';

$allowed = array('b' => array(),
                 
'i' => array(),
                 
'a' => array('href'  => array('minlen' => 3'maxlen' => 50),
                              
'title' => array('valueless' => 'n')),
                 
'p' => array('align' => 1,
                              
'dummy' => array('valueless' => 'y')),
                 
'img' => array('src' => 1), # FIXME
                 
'font' => array('size' =>
                                         array(
'minval' => 4'maxval' => 20)),
                 
'br' => array());
if(isset(
$_POST['entrada']))
{
    
$val=$_POST['entrada'];
    
$val stripslashes($val);
    
$sal kses($val$allowed, array('http''https'));
}
else
{
    
$val="Introduzca el texto HTML";
    
$sal="No se ha introducido texto HTML";
}
?>
<form name="form1" id="form1" method="post">
<div style="border:#003366 solid 1px; background-color:#FFFFCC; width:50%;">
<table width="100%">
<tr>
    <td width="20%"><label for="entrada">Entrada: </label></td><td width="80%"><textarea name="entrada" rows="5" cols="30" onclick="if(this.value=='Introduzca el texto HTML'){this.value='';}"><?php echo htmlspecialchars($val); ?></textarea></td>
</tr>
<tr>
    <td><label for="salida">Salida: </label></td><td><textarea name="salida" rows="5" cols="30" readonly="readonly"><?php echo htmlspecialchars($sal); ?></textarea></td>
</tr>
<tr>
    <td colspan="2" align="center"><input type="submit" name="Enviar" value="Enviar" /></td>
</tr>
</table>
</div>
</form>
<br /><br />
<h3>Interpretaci&oacute;n:</h3>
<div style="border:solid #003366 1px; background-color:#FFFFCC; color:#000000; width:50%;">
<?php echo $sal;?>
</div>
</body>
</html>
el script que hace la validacion lo pueden bajar de aqui
http://sourceforge.net/projects/kses
ya que esta muy largo para publicarlo aqui!

Saludos
__________________
..::The Saint::..
El pesimista se queja del viento; el optimista espera que cambie; el realista ajusta las velas.

Última edición por the_web_saint; 13/09/2008 a las 09:28 Razón: KSES