--- fileshare.module	Fri May 25 20:15:50 2007
+++ fileshare.module.orig	Fri May 25 19:42:08 2007
@@ -623,69 +623,52 @@ function _fileshare_handler($node) {
   while (false !== ($fileget = readdir($handle))) { // read directory
     $file[] = $fileget; // create file array
   }
-  
-  for ($x=0; $x <= (count($file) -1); $x++) { // pre sort filesystem entries into folders and files
-    if (is_dir($node->_basepath.$node->_filepath.$dir.'/'.$file[$x])) {
-      $f1[] = $file[$x];
-    } else {
-      $f2[] = $file[$x];
-    }
-  }
-  
-  sort($f1);  // sort folder array
-  
-  if (is_array($f1)) { // could be empty folder!
-  	sort($f2);  // sort file array
-  }
-  
-  for ($x=0; $x <= (count($f1) -1); $x++) { // loop through rows of array
-    if ($f1[$x] != '_previews' && $f1[$x] != '.' && $f1[$x] != '..') {
+  sort($file);  // sort directory array
+  for ($x=0; $x <= (count($file) -1); $x++) { // loop through rows of array
+    if (substr($file[$x], 0, 1) != "." && $file[$x] != '_previews') {
+      if (is_dir($node->_basepath.$node->_filepath.$dir.'/'.$file[$x])) {
         $output .= '<div class="fs_row">'."\n";
         $output .= '<div class="fs_data">'."\n";
         if ($modify) { 
           $output .= '<a href="javascript:submitDelete(\''
-            .$dir.'/'.$f1[$x].'\');" alt="delete file" class="fs_delete">'
+            .$dir.'/'.$file[$x].'\');" alt="delete file" class="fs_delete">'
             ."&nbsp;</a>\n";
         }
         $output .= "</div>\n";
         $output .= '<a href="javascript:;" onclick="fileshare_folder(this,\''.$pre.$tag.'\');" ';
-        $output .= 'alt="'.$node->_basepath.$node->_filepath.$dir.'/'.$f1[$x].'" ';
+        $output .= 'alt="'.$node->_basepath.$node->_filepath.$dir.'/'.$file[$x].'" ';
         $output .= 'name="'.url('fileshare/handler/'.$node->nid
-          ,'dir='.$dir.'/'.$f1[$x]
+          ,'dir='.$dir.'/'.$file[$x]
           .'&pre='.$pre.$tag).'" ';
         $output .= 'class="fs_closed">'."\n";
-        $output .= $f1[$x]; 
+        $output .= $file[$x]; 
         $output .= "</a>\n";
         $output .= "</div>\n";
         $output .= '<div class="fs_nest" id="'.$pre.$tag.'"></div>'."\n"; 
         ++$tag;
-    }
-  }
-  
-  if (is_array($f1)) {
-    for ($x=0; $x <= (count($f2) -1); $x++) { // loop through rows of array
+      } else {
         $output .= '<div class="fs_row">'."\n";
         $output .= '<div class="fs_data">'."\n";
-        $output .= '<b>'.date("j/n/y",filemtime($node->_basepath.$node->_filepath.$dir.'/'.$f2[$x])).'</b>';
-        $output .= '<i>'._resize_bytes(filesize($node->_basepath.$node->_filepath.$dir.'/'.$f2[$x])).'</i>';
+        $output .= '<b>'.date("j/n/y",filemtime($node->_basepath.$node->_filepath.$dir.'/'.$file[$x])).'</b>';
+        $output .= '<i>'._resize_bytes(filesize($node->_basepath.$node->_filepath.$dir.'/'.$file[$x])).'</i>';
           // allow deletion if modify was checked and access permissions are met
         if ($modify) { 
           $output .= '<a href="javascript:submitDelete(\''
-            .$dir.'/'.$f2[$x].'\');" alt="delete file" class="fs_delete">'
+            .$dir.'/'.$file[$x].'\');" alt="delete file" class="fs_delete">'
             ."&nbsp;</a>\n";
         }
         $output .= "</div>\n";
       if ($download) {
           if ($node->_method) { 
-            $output .= '<a href="'.url('fileshare/files/'.$node->nid.$dir.'/'.$f2[$x]).'" class="fs_file">'."\n"; // _method is private
+            $output .= '<a href="'.url('fileshare/files/'.$node->nid.$dir.'/'.$file[$x]).'" class="fs_file">'."\n"; // _method is private
           } else { 
-            $output .= '<a href="'.base_path().$node->_basepath.$node->_filepath.$dir.'/'.$f2[$x].'" class="fs_file">'."\n"; // _method is public
+            $output .= '<a href="'.base_path().$node->_basepath.$node->_filepath.$dir.'/'.$file[$x].'" class="fs_file">'."\n"; // _method is public
           }
         } else {
           $output .= '<div class="fs_file">';
         }
         if (_tf($node->_thumbs) == 1) { // check to for display of image previews (1 == true)
-          $preview = $node->_basepath.$node->_filepath.'/_previews/'.substr($f2[$x],0,-3);
+          $preview = $node->_basepath.$node->_filepath.'/_previews/'.substr($file[$x],0,-3);
           $exts = array('jpg','gif');
           foreach ($exts as $ext) {
             if (file_exists($preview.$ext)) { // check to see if preview file is there 
@@ -693,11 +676,12 @@ function _fileshare_handler($node) {
             }
           }
         }
-        $output .= $f2[$x];
+        $output .= $file[$x];
         if ($download) { $output .= "</a>\n"; } else { $output .= "</div>\n"; }
         $output .= '</div>'."\n";
       }
     }
+  }
   closedir($handle);
   if ($output == '') { // Safari needs some output returned to the jahHandler
     echo "&nbsp;";
