<?php /** * @param string $gameFileName * @param string $gameFileTmp * @return string|null */ function ZipFileHandler(string $gameFileName, string $gameFileTmp): ?string { $fileExtGame = explode('.', $gameFileName); $fileActualExtGame = strtolower(end($fileExtGame)); $allowedFileTypeGame = array('zip'); if(in_array($fileActualExtGame,$allowedFileTypeGame)){ $gameFileNewName = uniqid("", true). "." . $fileActualExtGame; if(empty($gameFileName)){ header("location: ../../../Frontend/index.php?error=emptyFile"); exit(); } rename($gameFileTmp,"../../Games/".$gameFileNewName); return $gameFileNewName; } return NULL; } /** * @param string $thumbnailFileName * @param string $thumbnailFileTmp * @return string|null */ function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp): ?string { $fileExtThumb = explode('.', $thumbnailFileName); $fileActualExtThumb = strtolower(end($fileExtThumb)); $allowedFileTypeThumbnail = array('gif', 'jpeg', 'png', 'svg', 'jpg', 'jfif', 'pjpeg', 'pjp', 'webp'); if(in_array($fileActualExtThumb,$allowedFileTypeThumbnail)){ $thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb; if(empty($thumbnailFileName)){ header("location: ../../../Frontend/index.php?error=emptyFile"); exit(); } rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName); return $thumbnailFileNewName; } return NULL; }