با سلام
بچه ها من یه اسکریپت php دارم که فایلهای مثلا پوشه files رو چک میکنه و اسم فایلها رو با حجم و هش برام لیست میکنه:
مثل این:
اما سوال من اینه که نمیخوام "/." اول اسم فایلها باشه باید چیکار کنم؟!
این هم کدها:
update.php
echo.php
dir.php
ممنون
بچه ها من یه اسکریپت php دارم که فایلهای مثلا پوشه files رو چک میکنه و اسم فایلها رو با حجم و هش برام لیست میکنه:
مثل این:
کد:
./dir.php 9e72b711c24294c992824fbe9014f815 124 ./echo.php 51324b9fc549f4b06148e4ff7674518e 239 ./New Text Document.txt d41d8cd98f00b204e9800998ecf8427e 0 ./update.php 90d1bd336fd6604a9bff164099349766 910
اما سوال من اینه که نمیخوام "/." اول اسم فایلها باشه باید چیکار کنم؟!
این هم کدها:
update.php
PHP:
<?PHP
require_once "./dir.php";
require_once "./echo.php";
function getFileList($dir)
{
// array to hold return value
$retval = array();
// add trailing slash if missing
// if(substr($dir, -1) != "/") $dir .= "/";
// open pointer to directory and read list of files
$d = @dir($dir) or die("getFileList: Failed opening directory $dir for reading");
while(false !== ($entry = $d->read())) {
// skip hidden files
if($entry[0] == ".") continue;
if(is_dir("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry/",
"size" => 0,
"Stream" => md5_file("$dir$entry")
);
} elseif(is_readable("$dir$entry")) {
$retval[] = array(
"name" => "$dir$entry",
"size" => filesize("$dir$entry"),
"Stream" => md5_file("$dir$entry")
);
}
}
$d->close();
return $retval;
}
?>
echo.php
PHP:
<?PHP
// output file list as HTML table
foreach($dirlist as $file) {
echo "<tr>\n";
echo "<td>{$file['name']}</td>\n";
echo "<td>{$file['Stream']}</td>\n";
echo "<td>{$file['size']}</td>\n";
}
echo "\n";
?>
dir.php
PHP:
<?PHP
// examples for scanning the current directory
$dirlist = getFileList(".");
$dirlist = getFileList("./");
?>
ممنون