ICEH 2.0 - Indentador de Códigos para Entorno Html
He mejorado el script de indentación web. Inicialmente iba a poner otro código aquí y no encontraba el indentador, así que cogí el código que hay más abajo en este blog y lo rehíce de un modo mas bonito y eficaz.
ARCHIVO: INDEX.PHP <!-- ------------------ --> <!-- | By Aladaris 2007 |--> <!-- ------------------ --> <!-- Se hace uso del script descargar.php obtenido en http://www.php.net --> <!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>Indentador</title> <link rel="STYLESHEET" type="text/css" href="estilo.css"> </head> <body> <? if(trim($HTTP_POST_VARS["inicial"]) != "") { $code = $HTTP_POST_VARS["inicial"]; $code = str_replace("<","&·lt;",$code); $code = str_replace(">","&·gt;",$code); $code = str_replace(" ","&·nbsp;",$code); $code = str_replace("\'","&·#39;",$code); $code = str_replace('\"',"&·quot;",$code); $code = str_replace("\\\\","&·#92",$code); $code = nl2br($code); // Sustituimos los saltos de línea por <br> $numero = rand(0, 500); $numero = $numero - ($numero%5); $salida = fopen("indentado".$numero.".txt","w"); fputs($salida, $code); fclose($salida); echo ('<p><a href="descargar.php?f=indentado'.$numero.'.txt&num='.$numero.'">Descargar codigo identado</a></p>'); } else { ?> <table id="tabla" align="center"> <tr> <FORM ACTION="" METHOD="post"> <td><textarea name="inicial" id="inicial"></textarea></td></tr> <tr><td align="right"><input type="submit" value="Indentar" id="boton"></td></tr> </form> <tr><td><a href="descargar.php?f=index.php">Descargar indentador</a></td></tr> <tr><td><a href="descargar.php?f=descargar.php">Descargar el Script de descargas</a></td></tr> <tr><td><a href="descargar.php?f=estilo.css">Descargar la hoja de estilo (CSS)</a></td></tr> </table> <? } ?> </body> </html> |
ARCHIVO: DESCARGAR.PHP <?php //Script conseguido en http://www.php.net/ $archivos = array("indentado".$_GET["num"].".txt", "index.php", "descargar.php", "estilo.css"); $f = $_GET["f"]; if(strpos($f,"/")!==false){ die("<b>ERROR:</b> No puedes navegar por otros directorios"); } if(!in_array($f,$archivos)){ die("<b>ERROR:</b> No tienes permiso descargar $f"); } header("Content-type: application/octet-stream"); header("Content-Disposition: attachment; filename=\"$f\"\n"); $fp=fopen("$f", "r"); fpassthru($fp); ?> |
ARCHIVO: ESTILO.CSS /* Hoja d estilo para el indentador web. By Aladaris 2007 */ body { font-family: Arial, Helvetica, sans-serif; background-color: #CCC; font-size: x-small; padding-left: 5px; } a:link {text-decoration: none; color: #000;} a:visited {text-decoration: none; color: #000;} a:hover {text-decoration: underline; color: #393; background-color: #000;} a:active {text-decoration: none; color: 393;} #inicial { /* Estilo del textarea */ width: 800px; height: 600px; color: #393; background-color: #000; border: dotted #CCC; } #boton { /* Estilo del boton */ height: 30px; color: #393; background-color: #000; border: 1 #CCC; font-size: x-small; } #tabla { /* Estilo de la tabla */ background-color: #999; } |