public function download($path, $filename = null, $nosniff = true) { $filename = is_null($filename) ? Gongo_File_Path::basename($path) : $filename; if ($nosniff) { header('X-Content-Type-Options: nosniff'); } header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download"); header("Content-Description: File Transfer"); header("Content-Disposition: attachment; filename={$filename}"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize($path)); readfile($path); exit; }
static function mvDir($src, $dst, $overwrite = false) { $success = true; if (!file_exists($src)) { return false; } if (!file_exists($dst)) { self::makeDir($dst); } if (!is_dir($dst)) { return false; } $dstpath = rtrim($dst, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . Gongo_File_Path::basename($src); if (!$overwrite && file_exists($dstpath)) { return false; } if (is_file($src)) { if (!self::mv($src, $dstpath)) { return false; } } else { if (is_dir($src)) { self::makeDir($dstpath); $src = rtrim($src, DIRECTORY_SEPARATOR); foreach (scandir($src) as $filename) { if ($filename === '.' || $filename === '..') { continue; } if ($filename[0] === '.') { continue; } if (!self::mvDir($src . DIRECTORY_SEPARATOR . $filename, $dstpath, $overwrite)) { $success = false; } } self::rmDir($src); } } return $success; }