[ 'txt' => 'efbbbf', // UTF-8 encoded text files (BOM) ], 'pdf' => [ 'pdf' => '25504446', // PDF files always start with "%PDF" in hex ], 'image' => [ 'jpeg' => 'ffd8ffe0', // JPEG 'png' => '89504e47', // PNG 'gif' => '47494638', // GIF 'bmp' => '424d', // BMP 'webp' => '52494646', // WebP starts with "RIFF" 'tiff' => '49492a00' // TIFF ], 'video' => [ 'mp4' => '00000018', // MP4 //'avi' => '52494646', // AVI starts with "RIFF" bah relou du coup c'est pareil que webp 'mkv' => '1a45dfa3', // MKV 'mov' => '00000014' // MOV ], 'html' => [ 'html' => '3c68746d', // HTML documents start with " $signature) { if (strpos($fileSignature, $signature) === 0) { return 1; // Plain text file } } // Check for PDF foreach ($signatures['pdf'] as $format => $signature) { if (strpos($fileSignature, $signature) === 0) { return 3; // PDF file } } // Check for images foreach ($signatures['image'] as $format => $signature) { if (strpos($fileSignature, $signature) === 0) { return 2; // Image file } } // Check for videos foreach ($signatures['video'] as $format => $signature) { if (strpos($fileSignature, $signature) === 0) { return 4; // Video file } } // Check for HTML documents foreach ($signatures['html'] as $format => $signature) { if (strpos($fileSignature, $signature) === 0) { return 5; // HTML file } } return 0; // Unknown or unsupported file type } ?>