/**
  * Return child files and folders
  * @param string $pattern Filter pattern
  * @param boolean $secured Default TRUE, it only must be used by programmatic calls
  * @return array of type driverFileManagerFile
  */
 public function getChilds($pattern = "*", $secured = true)
 {
     $node = driverNodes::getNodes(array('nodetype' => 'file', 'where' => '`parent` = ' . $this->getId()), $secured);
     $resp = array();
     foreach ($node as $key => $file) {
         $eFile = new driverFileManagerFile((object) $file);
         if (fnmatch($pattern, $eFile->getName())) {
             $resp[] = $eFile;
         }
     }
     return $resp;
 }
 /**
  * 
  * @param driverFileManagerFile $file
  * @param integer $maxSpeed
  * @param boolean $doStream
  * @return boolean
  */
 public static function downloadFile(&$file, $maxSpeed = 100, $doStream = false)
 {
     if (connection_status() != 0) {
         return false;
     }
     //    in some old versions this can be pereferable to get extention
     //    $extension = strtolower(end(explode('.', $fileName)));
     //$extension = pathinfo($fileName, PATHINFO_EXTENSION);
     $contentType = $file->getMimetype();
     header("Cache-Control: public");
     header("Content-Transfer-Encoding: binary\n");
     header("Content-Type: {$contentType}");
     $contentDisposition = 'attachment';
     if ($doStream == true) {
         /* extensions to stream */
         //                $array_listen = array('mp3', 'm3u', 'm4a', 'mid', 'ogg', 'ra', 'ram', 'wm',
         //                    'wav', 'wma', 'aac', '3gp', 'avi', 'mov', 'mp4', 'mpeg', 'mpg', 'swf', 'wmv', 'divx', 'asf');
         //                if (in_array($extension, $array_listen)) {
         $contentDisposition = 'inline';
         //                }
     }
     //            if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
     //                $fileName = preg_replace('/\./', '%2e', $fileName, substr_count($fileName, '.') - 1);
     //                header("Content-Disposition: $contentDisposition;
     //                    filename=\"$fileName\"");
     //            } else {
     //                header("Content-Disposition: $contentDisposition;
     //                    filename=\"$fileName\"");
     //            }
     header("Content-Disposition: {$contentDisposition};\r\n                    filename=\"{$file->getName()}\"");
     header("Accept-Ranges: bytes");
     $range = 0;
     $size = $file->fileSize();
     if (isset($_SERVER['HTTP_RANGE'])) {
         list($a, $range) = explode("=", $_SERVER['HTTP_RANGE']);
         str_replace($range, "-", $range);
         $size2 = $size - 1;
         $new_length = $size - $range;
         header("HTTP/1.1 206 Partial Content");
         header("Content-Length: {$new_length}");
         header("Content-Range: bytes {$range}{$size2}/{$size}");
     } else {
         $size2 = $size - 1;
         header("Content-Range: bytes 0-{$size2}/{$size}");
         header("Content-Length: " . $size);
     }
     if ($size == 0) {
         die('Zero byte file! Aborting download');
     }
     set_magic_quotes_runtime(0);
     $fp = fopen($file->getRealpath(), "rb");
     fseek($fp, str_replace('-', '', $range));
     while (!feof($fp) and connection_status() == 0) {
         set_time_limit(0);
         print fread($fp, 1024 * $maxSpeed);
         flush();
         ob_flush();
         sleep(1);
     }
     fclose($fp);
     return connection_status() == 0 and !connection_aborted();
 }