php fcount dir opendir while read readdir dir false if read read read

 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
<?php
$fcount = 0;
$dir = opendir(".");
while (($read = readdir($dir)) !== false)
{
if ($read != "." & $read != ".." & $read != "data" & $read != "index.php" & $read != "style.css" & $read != "count.php" & $read != "count.txt")
{
$size = filesize($read);
$size = $size/1024;
$size = strtok($size, ".");
if (is_file($read))
$fcount++;
if (is_file($read))
{
$file = $read.".txt";
$f = fopen("data/$file", "r");
$count = fread($f, 100);
fclose($f);
echo "<a href='count.php?file=$read'>$read</a><p class=text>[paзмep: $size kb] [скачано: $count раз(а)</p>";
}
else
{
$d = chdir("./");
echo "<a href='index.php?d=$read'><p>$read</p></a>";
}
}
}
echo "<br>files: $fcount";
closedir($dir);
?>