Example #1
0
 protected function bindFields(\PDOStatement $statment, File $file)
 {
     $statment->bindValue(':fileName', $file->getFileName());
     $statment->bindValue(':fileType', $file->getFileType());
     $statment->bindValue(':fileSize', $file->getFileSize());
     $statment->bindValue(':fileMediaInfo', $file->getFileMediaInfo());
     $statment->bindValue(':fileKey', $file->getFileKey());
 }
Example #2
0
 function File($name, $location)
 {
     $this->name = $name;
     $this->location = $location;
     $this->type = File::getFileType($this->location->getDir(true, false, false, 0) . $this->getName());
     $this->size = File::getFileSize($this->location->getDir(true, false, false, 0) . $this->getName());
     $this->modTime = filemtime($this->location->getDir(true, false, false, 0) . $this->getName());
 }
 function sum_dir($start_dir, $ignore_files, $levels = 1)
 {
     if ($dir = opendir($start_dir)) {
         $total = 0;
         while (($file = readdir($dir)) !== false) {
             if (!in_array($file, $ignore_files)) {
                 if (is_dir($start_dir . '/' . $file) && $levels - 1 >= 0) {
                     $total += $this->sum_dir($start_dir . '/' . $file, $ignore_files, $levels - 1);
                 } elseif (is_file($start_dir . '/' . $file)) {
                     $total += File::getFileSize($start_dir . '/' . $file) / 1024;
                 }
             }
         }
         closedir($dir);
         return $total;
     }
 }
Example #4
0
 /**
  * function return set file to user
  *
  * @param File $oFile file object
  *
  * @param bool $dispositionInline if true then diposition is 'inline' else
  * 									disposition is 'attachment', default -
  * 									true (disposition 'inline')
  * @return bool is file sent
  */
 function downloadFile($oFile, $dispositionInline = false)
 {
     if (empty($oFile)) {
         $this->farrErrors[] = "File not set";
         return false;
     }
     if (!$oFile->getFileMimeType()) {
         $this->farrErrors[] = "File mime type not set";
         return false;
     }
     $disposition = $dispositionInline ? $disposition = 'inline' : ($disposition = 'attachment');
     header('Content-type: ' . $oFile->getFileMimeType());
     header('Content-Disposition: ' . $disposition . '; filename="' . $oFile->getFileUserName() . '"');
     header('Content-Length: ' . $oFile->getFileSize());
     readfile($oFile->getFilePath() . $oFile->getFileName());
     return true;
 }
Example #5
0
             $izeinm = $totalsize / 1024 / 1024;
             if ($izeinm > $maxfilesize) {
                 $zip->close();
                 unlink($file);
                 $_SESSION['error'] = $setUp->formatsize($totalsize) . ": " . $encodeExplorer->getString("size_exceeded");
                 header('Location:' . $script_url);
                 exit;
             } else {
                 $zip->addFile($myfile, $filename);
                 $logger->logDownload("./" . urldecode(base64_decode($pezzo)));
             }
         }
     }
     $zip->close();
     $filename = $time . ".zip";
     $file_size = File::getFileSize($file);
     $content_type = "application/zip";
     $disposition = "attachment";
     if (stripos($useragent, 'android') !== false) {
         // download file if Android
         $downloader->androidDownload($file, $filename, $file_size);
     } else {
         // resumable download
         $downloader->resumableDownload($file, $filename, $file_size, $content_type, $disposition);
     }
     unlink($file);
     exit;
 }
 $_SESSION['error'] = "<i class=\"fa fa-ban\"></i> Access denied";
 header('Location:' . $script_url);
 exit;
Example #6
0
 $hash = $datarray['hash'];
 $time = $datarray['time'];
 if ($passa === true) {
     if ($downloader->checkTime($time) == true) {
         print "<div class=\"intero centertext bigzip\">\n            <a class=\"btn btn-primary btn-lg centertext\" href=\"" . $zip_url . "\"><i class=\"fa fa-cloud-download fa-5x\"></i><br>" . ".zip</a></div>";
         print "<div class=\"intero\"><ul class=\"multilink\">";
         $pieces = explode(",", $datarray['attachments']);
         $totalsize = 0;
         $salt = $setUp->getConfig('salt');
         foreach ($pieces as $pezzo) {
             $myfile = urldecode(base64_decode($pezzo));
             $filepathinfo = Utils::mbPathinfo($myfile);
             $filename = $filepathinfo['basename'];
             $extension = strtolower($filepathinfo['extension']);
             $supah = md5($hash . $salt . $pezzo);
             $filesize = File::getFileSize($myfile);
             $totalsize += $filesize;
             if (array_key_exists($extension, $_IMAGES)) {
                 $thisicon = $_IMAGES[$extension];
             } else {
                 $thisicon = "fa-file-o";
             }
             if ($setUp->getConfig('enable_prettylinks') == true) {
                 $downlink = "download/" . $pezzo . "/h/" . $hash . "/sh/" . $supah;
             } else {
                 $downlink = "doc-admin/doc-downloader.php?q=" . $pezzo . "&h=" . $hash . "&sh=" . $supah;
             }
             print "<li><a class=\"btn btn-primary\" href=\"" . $downlink . "\">" . "<span class=\"pull-left small\"><i class=\"fa " . $thisicon . " fa-2x\"></i> " . $filename . "</span>" . "<span class=\"pull-right small\">" . $setUp->formatsize($filesize) . " <i class=\"fa fa-download fa-2x\"></i></span></a></li>";
         }
         print "</ul></div>";
         // check number of files and total size
Example #7
0
 /**
  * Get file info before processing download
  *
  * @param string $getfile file to download
  * @param string $playmp3 check audio
  *
  * @return $headers array
  */
 public function getHeaders($getfile, $playmp3 = false)
 {
     global $utils;
     $headers = array();
     $audiofiles = array('mp3', 'MP3', 'wav', 'WAV');
     $trackfile = "./" . urldecode(base64_decode($getfile));
     $file = "." . $trackfile;
     $filepathinfo = $utils->mbPathinfo($file);
     $filename = $filepathinfo['basename'];
     $dirname = $filepathinfo['dirname'] . "/";
     $ext = $filepathinfo['extension'];
     $file_size = File::getFileSize($file);
     $disposition = "inline";
     if ($ext == "pdf" || $ext == "PDF") {
         $content_type = "application/pdf";
     } elseif ($ext == "zip" || $ext == "ZIP") {
         $content_type = "application/zip";
         $disposition = "attachment";
     } elseif (in_array($ext, $audiofiles) && $playmp3 == "play") {
         $content_type = "audio/mp3";
     } else {
         $content_type = "application/force-download";
     }
     $headers['file'] = $file;
     $headers['filename'] = $filename;
     $headers['file_size'] = $file_size;
     $headers['content_type'] = $content_type;
     $headers['disposition'] = $disposition;
     $headers['trackfile'] = $trackfile;
     $headers['dirname'] = $dirname;
     return $headers;
 }