A reversion of Lighttpd’s dir-generator.php
I got the dir-generator.php worked in my own server, but I found that in some particular circumstance the script worked not very well. For instance, if the filenames has Chinese words, the script displays it in error codes, and because the script uses PHP function filesize() and filemtime() to get the file size and mtime, if the file is very large (for example 4GB), the functions will not work. Even worse, the PHP function is_file() cannot work with large file either, and it makes the large file disappear from the directories list. For normal user, it is very hard to deal with these problem, and maybe they will drop the script.
I tried to solved these problems, and it works well now, so I post the revision of dir-generator.php. Hope it helps
1.The encoding problems, just change the function htmlentities’s arguments to make the filename encoded with UTF-8
2.I wrote two functions real_filesize() and real_filemtime() to get the file’s real size and mtime. Please notice that real_filesize() and real_filemtime() just called the command “stat” in bash to get the real size and mtime, so it only works on Linux servers. Hope somebody can fix it with better way.
3.Change
elseif(is_file($path.'/'.$item)) {
to
else{
In my opinion, in a dir list, there are only files and directories, so if it is not directory, it is files, so it is no necessary to use elseif, just else is OK.
and it works well now
你好,我给学校做一个开源软件镜像站,用到lighttpd的遍历目录,想自己用dir-generator.php实现,但总是只能在根目录下才能用。比如:我把所有文件和文件夹放到var/www/rsync下,lighttpd设置为server.document-root = “/var/www/rsync”,然后把dir-generator.php也放在这里。但只有访问localhost的时候可以,点下级目录时就不行了,请问这个你是如何解决的?
谢谢。
如果方便的话,请发邮件给我,再次感谢~
Mail: jishunan@gmail.com
[回复]