html head title title head body php function get_num_lines dir dir dir

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<html>
<head>
<title></title>
</head>
<body>
<?php
function get_num_lines($dir){
$d = dir($dir);
$tmp=array();
while (false !== ($entry = $d->read())) {
if (preg_match("#^.*\.php$#is",$entry)){
$fs=filesize($dir.$entry);
$lines=count(file($dir.$entry));
$tmp[$dir.$entry]=array($fs,$lines,($lines?$fs/$lines:0));
}
if ($entry!='.'&&$entry!='..'&&is_dir($dir.$entry)){
$tmp+=get_num_lines($dir.$entry.'/');
}
//print_r($tmp);
}
$d->close();
return $tmp;
}
$tmp=(get_num_lines('./'));
$size=0;
$lines=0;
foreach($tmp as $f){
$size+=$f[0];
$lines+=$f[1];
}
$tmp['all']=array($size,$lines,$size/$lines);
print_r($tmp);
?>
</body>
</html>