source: admin/WebConsole/dirphp.php @ 8c7b374

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 8c7b374 was 9f1274e, checked in by ramon <ramongomez@…>, 7 years ago

#804: Sustituir funciones para compatibilidad con PHP 7 (split por explode y ereg... por preg_...).

git-svn-id: https://opengnsys.es/svn/branches/version1.1@5619 a21b9725-9963-47de-94b9-378ad31fedc9

  • Property mode set to 100644
File size: 1.7 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                        $fp = fopen($archivo,"w");
53                        fwrite($fp, $buffer,strlen($buffer));
54                        fclose($fp);
55}
56?>
Note: See TracBrowser for help on using the repository browser.