PHP directory list from remote server

前端 未结 3 506
粉色の甜心
粉色の甜心 2020-12-01 17:37

How can i use opendir function to read the directory list of a remote server knowing its IP address?

3条回答
  •  渐次进展
    2020-12-01 18:02

    For files/folders that are visible to the public you can do it with this script: No FTP, no strugglin. It will give you back all filenames in a remote folder. If you can open the folder with a browser, you can also read it with php. Happy leeching ;)

    UPDATE: This only lists the files that are available for the public, for sure not files that are only visible for a certain user!

    function get_text($filename) {
    
        $fp_load = fopen("$filename", "rb");
    
        if ( $fp_load ) {
    
                while ( !feof($fp_load) ) {
                    $content .= fgets($fp_load, 8192);
                }
    
                fclose($fp_load);
    
                return $content;
    
        }
    }
    
    
    $matches = array();
    
    preg_match_all("/(a href\=\")([^\?\"]*)(\")/i", get_text('http://www.xxxxx.com/my/cool/remote/dir'), $matches);
    
    foreach($matches[2] as $match) {
        echo $match . '
    '; }

提交回复
热议问题