Beispiel #1
0
     $index = 1;
 } else {
     $index = 0;
 }
 // for each file, link, or directory listed in the current directory
 // seperate the raw data into readable variables
 for ($indexNew = 0; $index < count($files); $index++, $indexNew++) {
     $data[$indexNew] = remove_ws($files[$index]);
 }
 // sort through directory listing
 for ($index = 0; $index < count($data); $index++) {
     // put directories into a list
     if (isDir($data[$index][0])) {
         $dir_list[count($dir_list)] = $data[$index];
     } else {
         if (isLink($data[$index][0])) {
             // get the links name, and what it points at
             list($name, $addr) = split(" -> ", $data[$index][8]);
             // overwrite the link name so that it just has the name to be displayed
             $data[$index][8] = $name;
             // store the link pointer as the whole path
             if (substr($addr, 0, 1) != '/') {
                 $addr = $sess_Data["dir"] . "/" . $addr;
             }
             // attempt to change to the link, if it fails it is a file
             // this needs work, what if you don't have permission
             $RESULT = @ftp_chdir($fp, $addr);
             if ($RESULT) {
                 $dir_list[count($dir_list)] = $data[$index];
             } else {
                 $file_list[count($file_list)] = $data[$index];
Beispiel #2
0
 /**
  * Recursively delete a directory
  * @param string $dir
  * @return bool
  */
 private function _rmrecursive($dir)
 {
     // When the directory is a symlink, don't delete recursively. That would
     // f**k up the plugins.
     if (isLink($dir)) {
         return @unlink(realpath2($dir));
     }
     $handle = opendir($dir);
     while (false != ($item = readdir($handle))) {
         if (!in_array($item, array('.', '..'))) {
             $path = $dir . '/' . $item;
             if (isLink($path)) {
                 $result = @unlink(realpath2($path));
             } elseif (is_file($path)) {
                 $result = @unlink(realpath2($path));
             } elseif (is_dir($path)) {
                 $result = $this->_rmrecursive(realpath2($path));
             } else {
                 $result = @unlink(realpath2($path));
             }
             if (!$result) {
                 return false;
             }
         }
     }
     closedir($handle);
     if (!rmdir($dir)) {
         return false;
     }
     return true;
 }