source: admin/WebConsole/dirphp.php @ c8a14ec

918-git-images-111dconfigfileconfigure-oglivegit-imageslgromero-new-oglivemainmaint-cronmount-efivarfsmultivmmultivm-ogboot-installerogClonningEngineogboot-installer-jenkinsoglive-ipv6test-python-scriptsticket-301ticket-50ticket-50-oldticket-577ticket-585ticket-611ticket-612ticket-693ticket-700ubu24tplunification2use-local-agent-oglivevarios-instalacionwebconsole3
Last change on this file since c8a14ec was 3ec149c, checked in by alonso <alonso@…>, 15 years ago

git-svn-id: https://opengnsys.es/svn/trunk@1314 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 1.8 KB
Line 
1<?php
2listar_directorios_ruta("./");
3function listar_directorios_ruta($ruta){
4   // abrir un directorio y listarlo recursivo
5   if (is_dir($ruta)) {
6      if ($dh = opendir($ruta)) {
7         while (($file = readdir($dh)) !== false) {
8                        if($file !=".svn" && $file!="." && $file!=".."){
9                                //esta línea la utilizaríamos si queremos listar todo lo que hay en el directorio
10                                //mostraría tanto archivos como directorios
11                                //echo "<br>Nombre de archivo: $file : Es un: " . filetype($ruta . $file);
12                                if (is_dir($ruta . $file) && $file!="." && $file!=".."){
13                                   //solo si el archivo es un directorio, distinto que "." y ".."
14                                   echo "<br>Directorio: $ruta$file";
15                                   listar_directorios_ruta($ruta . $file . "/");
16                                }
17                                else{
18                                        //echo "<br>Archivp:$file";
19                                        //if($file=="aulas.php")
20                                                procesaarchivo($ruta,$file);
21                                }       
22                        }
23                }
24      closedir($dh);
25      }
26   }else
27      echo "<br>No es ruta valida";
28}
29 function procesaarchivo($ruta,$file){
30                        $meta='<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">';
31                        $archivo=realpath($ruta.$file);
32                        echo "<br>Procesando Archivo:".$file;
33
34                        $tam=filesize($archivo);
35                        $fp = fopen($archivo, "rb");
36                        $buffer = fread($fp, $tam);
37                        fclose($fp);
38                       
39                        $pos = strpos($buffer,'<HEAD>
40        <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">');
41                        if($pos==0)
42                                $pos = strpos($buffer,'<head>');
43                        if($pos==0)
44                                return;
45                               
46                        $dpl=strlen('<HEAD>'); 
47                        $prebuffer=substr($buffer,0,$pos+$dpl);
48                        $posbuffer=substr($buffer,$pos+$dpl);
49                       
50                        $buffer=$prebuffer."\n\t".$meta.$posbuffer;
51
52                        /*
53                        $buffer=ereg_replace( "<"," ",$buffer);
54                        $buffer=ereg_replace( ">"," ",$buffer);
55                        $buffer=ereg_replace( "[\n\r]","<BR>",$buffer);
56                        echo $buffer;
57                        */
58                       
59                        $fp = fopen($archivo,"w");
60                        fwrite($fp, $buffer,strlen($buffer));
61                        fclose($fp);
62}
63?>
Note: See TracBrowser for help on using the repository browser.