PHP5中访问文件系统的函数的完整列表是什么?


What is the complete list of functions which has access to the filesystem in PHP5?

这是一个我已经开始并想要完成的列表。我希望创建一个完整的从文件系统读取或写入的函数列表。见下文。我漏掉了哪些?由于

readfile, fpassthru, file, file_get_contents, system, fopen, symlink, rename, copy, exec, passthru, pcntl_exec, backtick_operator, shell_exec, popen, proc_open, chmod, chown, chgrp, touch, dl, highlight_file, show_source, mkdir, rmdir, posix_mkfifo, dbase_open, dbmopen, filepro, pg_lo_import, move_uploaded_file, link

该列表可用于扫描潜在的性能问题(许多天真的开发人员没有意识到访问文件系统太慢),定位潜在的恶意代码、后门等。

这在可利用的PHP函数中列出。还要记住,"命令执行"功能也可以用来访问文件系统,这是一个很可能更大的问题。

> // open filesystem handler fopen
> tmpfile bzopen gzopen // write to
> filesystem (partially in combination
> with reading) chgrp chmod chown copy
> file_put_contents lchgrp lchown link
> mkdir move_uploaded_file rename rmdir
> symlink tempnam touch unlink imagepng - 2nd parameter is a path. 
> imagewbmp  - 2nd parameter is a path.  
> image2wbmp - 2nd parameter is a path.  
> imagejpeg  - 2nd parameter is a path. 
> imagexbm   - 2nd parameter is a path. 
> imagegif   - 2nd parameter is a path. 
> imagegd    - 2nd parameter is a path. 
> imagegd2   - 2nd parameter is a path. 
> iptcembed ftp_get ftp_nb_get // read from
> filesystem file_exists
> file_get_contents file fileatime
> filectime filegroup fileinode
> filemtime fileowner fileperms filesize
> filetype glob is_dir is_executable
> is_file is_link is_readable
> is_uploaded_file is_writable
> is_writeable linkinfo lstat
> parse_ini_file pathinfo readfile
> readlink realpath stat gzfile
> readgzfile getimagesize
> imagecreatefromgif imagecreatefromjpeg
> imagecreatefrompng imagecreatefromwbmp
> imagecreatefromxbm imagecreatefromxpm
> ftp_put ftp_nb_put exif_read_data
> read_exif_data exif_thumbnail
> exif_imagetype hash_file
> hash_hmac_file hash_update_file
> md5_file sha1_file highlight_file
> show_source php_strip_whitespace
> get_meta_tags

文件系统功能列表通过php.net

@hsz提到了一组函数,但也有:

  • http://www.php.net/manual/en/ref.fileinfo.php
  • http://www.php.net/manual/en/ref.dir.php
  • http://www.php.net/manual/en/ref.dio.php

考虑在chroot环境中运行PHP来保护您的文件系统,而不是限制PHP函数的使用。

查看apache文档中的chrootdir指令