====== DownloadUtility ======
**Layer:** ''Utility'' · **Source:** ''lib/utility/download-handler.php:16'' (lines 16–208)
----
class DownloadUtility
Core utility class for handling file downloads
======= Docblock Metadata =======
^ Tag ^ Value ^
| ''@category'' | Utility Class |
| ''@author'' | M.Noermoehammad |
| ''@license'' | MIT |
| ''@version'' | 1.0 |
| ''@since'' | Since Release 1.0 |
======= Inheritance =======
//No parent, interface or trait. This is a root type.//
======= Constants (2) =======
^ Visibility ^ Name ^ Value ^ Line ^
| ''-'' | ''CHUNK_SIZE'' | ''8192;'' | 18 |
| ''-'' | ''DEFAULT_EXPIRY'' | ''28800;'' | 19 |
======= Properties (0) =======
//None declared.//
======= Methods (9) =======
^ Visibility ^ Method ^ Summary ^ Line ^
| public static | ''setDownloadHeaders()'' | Set download headers for file delivery | 29 |
| public static | ''validateDownloadRequest()'' | Validate download request by identifier | 45 |
| public static | ''isHotlinkingAllowed()'' | Check if hotlinking is allowed based on referer | 57 |
| public static | ''isMimeTypeAllowed()'' | Check if MIME type is allowed based on settings | 77 |
| public static | ''deliverFile()'' | Deliver file to client with streaming | 91 |
| public static | ''getMimeType()'' | Get MIME type of a file | 117 |
| public static | ''sanitizeFilePath()'' | Sanitize file path to prevent traversal attacks | 143 |
| public static | ''isExpired()'' | Check if download link has expired | 164 |
| private static | ''getMimeTypeDictionary()'' | Get basic MIME type dictionary | 174 |
======== setDownloadHeaders() ========
public static function setDownloadHeaders($filename, $mimeType, $filesize)
//lines 29–37 (9)//
Set download headers for file delivery
^ Parameter ^ Type ^ Default ^ Description ^
| ''$filename'' | ''(untyped)'' | //required// | //none// |
| ''$mimeType'' | ''(untyped)'' | //required// | //none// |
| ''$filesize'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — void
======== validateDownloadRequest() ========
public static function validateDownloadRequest($identifier)
//lines 45–48 (4)//
Validate download request by identifier
^ Parameter ^ Type ^ Default ^ Description ^
| ''$identifier'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — bool
======== isHotlinkingAllowed() ========
public static function isHotlinkingAllowed($referer, $allowedDomains = [])
//lines 57–69 (13)//
Check if hotlinking is allowed based on referer
^ Parameter ^ Type ^ Default ^ Description ^
| ''$referer'' | ''(untyped)'' | //required// | //none// |
| ''$allowedDomains'' | ''(untyped)'' | ''[]'' | //none// |
**Returns:** ''(none declared)'' — bool
======== isMimeTypeAllowed() ========
public static function isMimeTypeAllowed($mimeType)
//lines 77–81 (5)//
Check if MIME type is allowed based on settings
^ Parameter ^ Type ^ Default ^ Description ^
| ''$mimeType'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — bool
======== deliverFile() ========
public static function deliverFile($filepath, $filename, $mimeType)
//lines 91–109 (19)//
Deliver file to client with streaming
^ Parameter ^ Type ^ Default ^ Description ^
| ''$filepath'' | ''(untyped)'' | //required// | //none// |
| ''$filename'' | ''(untyped)'' | //required// | //none// |
| ''$mimeType'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — void
======== getMimeType() ========
public static function getMimeType($filepath)
//lines 117–135 (19)//
Get MIME type of a file
^ Parameter ^ Type ^ Default ^ Description ^
| ''$filepath'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — string
======== sanitizeFilePath() ========
public static function sanitizeFilePath($filename)
//lines 143–156 (14)//
Sanitize file path to prevent traversal attacks
^ Parameter ^ Type ^ Default ^ Description ^
| ''$filename'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — string|false
======== isExpired() ========
public static function isExpired($beforeExpired)
//lines 164–167 (4)//
Check if download link has expired
^ Parameter ^ Type ^ Default ^ Description ^
| ''$beforeExpired'' | ''(untyped)'' | //required// | //none// |
**Returns:** ''(none declared)'' — bool
======== getMimeTypeDictionary() ========
private static function getMimeTypeDictionary()
//lines 174–207 (34)//
Get basic MIME type dictionary
//Takes no parameters.//
**Returns:** ''(none declared)'' — array
----
//This page is generated from source by 'tools/gendoc'. Edits will be overwritten.//