Пример #1
0
 static function GetFTPRoot($conn_id, $testDir)
 {
     $ftp_root = false;
     //attempt to find the ftp_root
     $testDir = $testDir . '/';
     $array = ftp_nlist($conn_id, '.');
     if (!$array) {
         return false;
     }
     $possible = array();
     foreach ($array as $file) {
         if ($file[0] == '.') {
             continue;
         }
         //is the $file within the $testDir.. not the best test..
         $pos = strpos($testDir, '/' . $file . '/');
         if ($pos === false) {
             continue;
         }
         $possible[] = substr($testDir, $pos);
     }
     $possible[] = '/';
     //test this too
     foreach ($possible as $file) {
         if (gpftp::TestFTPDir($conn_id, $file, $testDir)) {
             $ftp_root = $file;
             break;
         }
     }
     return $ftp_root;
 }