| /**************************** * Get all the files in the directory * [$dir] Folder path ****************************/ function Deepscandir ($dir) { $FILEARR = Array (); $DIRARR = Array (); $dir = RTrim ($dir, '//'); if (Is_dir ($dir)) { $dirHandle = Opendir ($dir); while (false!== ($fileName = Readdir ($dirHandle))) { $subFile = $dir. Directory_separator. $fileName; if (Is_file ($subFile)) { $FILEARR [] = $subFile; } ElseIf (Is_dir ($subFile) && str_replace ('. ', ', $fileName)!= ') { $DIRARR [] = $subFile; $arr = $this->deepscandir ($subFile); $DIRARR = Array_merge ($DIRARR, $arr [' dir ']); $FILEARR = Array_merge ($FILEARR, $arr [' file ']); } } Closedir ($dirHandle); } Return Array ( ' dir ' => $dirArr, ' File ' => $fileArr ); } /* * Replace the path available in the app, in the Web folder */ Public Function Ok_web () { Find characters $yuanlai = Array ( '/resources/', '/uploads/', '/web/', ' href= '/', '/web ', ' typedir+\ '/\ ' +v.aid+ ', ' V.litpic ', ); Substitution character $tihuan = Array ( '".. /resources/', '".. /uploads/', '"', ' href= '. /index.html "', '', ' V.aid+ ', '".." +v.litpic ' );
Folder to find $dir = WEBROOT. ' /app/web '; Get files $dirs = $this->deepscandir ($dir); File string substitution foreach ($dirs [' file '] as $file) { $file = ' g:\hospital\hospital\admin/app/web\yiyuanzhuanjia.html '; $txt = file_get_contents ($file); $txt = Str_replace ($yuanlai, $tihuan, $txt); File_put_contents ($file, $txt); Echo $txt; exit; }
} |