1 <style> 2 3 ul{ 4 width: 100%;; 5 } 6 li{ 7 float: left; 8 margin-right: 5px;; 9 10 } 11 #content{ 12 width: 100%; 13 14 } 15 </style> 16 <?php 17 //$dir = dirname(getcwd()); 18 //$filepath = $dir.‘\\‘.‘communication‘.‘\\‘.‘mod_index.php‘; 19 header("Content-Type:text/html;Charset=utf-8"); 20 $path = dirname(getcwd()); 21 $direction = dir($path); 22 23 $allow = array( 24 25 ); 26 $result = array(); 27 getTables($direction); 28 $direction->close(); 29 printTable($result); 30 31 32 /** 33 * 获得此目录下的所有php文件查询语句使用到的table表名 34 * @param $direction 目录控制句柄 35 */ 36 function getTables($direction){ 37 global $allow,$result; 38 while(($file = $direction->read()) != false){ 39 $tables = array(); 40 if($file != ‘.‘ && $file != ‘..‘ && strpos($file,‘.‘) && strstr($file,‘.‘) == ‘.php‘){ 41 $filepath = getPath($direction->path,$file); 42 $content = file_get_contents($filepath); 43 preg_match_all("/DB_TABLEPRE.[\"|‘]([^\s‘\"]*)/i",$content,$tables); 44 $tables = array_unique($tables[1]); 45 $result = array_merge($result,$tables); 46 }elseif(is_dir($childdir = getPath($direction->path,$file))){ 47 if(in_array($file,$allow)){ 48 $dir = dir($childdir); 49 getTables($dir); 50 $dir->close(); 51 }else{ 52 continue; 53 } 54 } 55 } 56 } 57 58 59 /** 获得完成路径 60 * @param $dir 61 * @param $file 62 * @return string 63 */ 64 function getPath($dir,$file){ 65 return $dir.‘\\‘.$file; 66 } 67 68 /** 打印表格 69 * @param $arr 70 */ 71 function printTable($arr){ 72 $arr = array_unique($arr); 73 $html = ‘<div id="content"><ul>‘; 74 $num = 0; 75 foreach($arr as $k){ 76 $html .= "<li>$num :".$k." </li>"; 77 $num++; 78 } 79 $html .= ‘</ul></div>‘; 80 echo $html; 81 echo "<div style=‘display: inherit‘>数据表的个数为:".count($arr)."</div>"; 82 }
时间: 2024-11-05 11:00:53