2021-03-09 14:04:59 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2021-03-10 08:46:22 +00:00
|
|
|
* @param string $gameFileName
|
|
|
|
* @param string $gameFileTmp
|
2021-03-12 13:06:10 +00:00
|
|
|
* @return string
|
2021-03-09 14:04:59 +00:00
|
|
|
*/
|
|
|
|
|
2021-03-12 13:06:10 +00:00
|
|
|
function ZipFileHandler(string $gameFileName, string $gameFileTmp){
|
2021-03-09 14:04:59 +00:00
|
|
|
$fileExtGame = explode('.', $gameFileName);
|
|
|
|
$fileActualExtGame = strtolower(end($fileExtGame));
|
|
|
|
|
2021-03-12 13:06:10 +00:00
|
|
|
$headerType = mime_content_type($gameFileTmp);
|
|
|
|
$headerTypeMatch = array('application/zip');
|
|
|
|
|
|
|
|
if(in_array($headerType,$headerTypeMatch)){
|
2021-03-09 14:04:59 +00:00
|
|
|
$gameFileNewName = uniqid("", true). "." . $fileActualExtGame;
|
|
|
|
if(empty($gameFileName)){
|
2021-03-22 08:43:33 +00:00
|
|
|
echo http_response_code(400);
|
2021-03-09 14:04:59 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
rename($gameFileTmp,"../../Games/".$gameFileNewName);
|
|
|
|
return $gameFileNewName;
|
2021-03-12 13:06:10 +00:00
|
|
|
}else{
|
2021-03-19 12:25:27 +00:00
|
|
|
echo "Wrong file type";
|
2021-03-22 08:43:33 +00:00
|
|
|
echo http_response_code(400);
|
2021-03-17 08:43:09 +00:00
|
|
|
exit();
|
2021-03-09 14:04:59 +00:00
|
|
|
}
|
2021-03-10 08:46:22 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $thumbnailFileName
|
|
|
|
* @param string $thumbnailFileTmp
|
2021-03-12 13:06:10 +00:00
|
|
|
* @return string
|
2021-03-10 08:46:22 +00:00
|
|
|
*/
|
2021-03-12 13:06:10 +00:00
|
|
|
function imagesFileHandler(string $thumbnailFileName, string $thumbnailFileTmp){
|
2021-03-10 08:46:22 +00:00
|
|
|
$fileExtThumb = explode('.', $thumbnailFileName);
|
|
|
|
$fileActualExtThumb = strtolower(end($fileExtThumb));
|
2021-03-09 14:04:59 +00:00
|
|
|
|
2021-03-12 13:06:10 +00:00
|
|
|
$headerType = mime_content_type($thumbnailFileTmp);
|
|
|
|
$headerTypeMatch = array('image/png', 'image/jpeg','image/gif', 'image/svg+xml',);
|
2021-03-10 08:46:22 +00:00
|
|
|
|
2021-03-12 13:06:10 +00:00
|
|
|
if(in_array($headerType,$headerTypeMatch)){
|
2021-03-10 08:46:22 +00:00
|
|
|
$thumbnailFileNewName = uniqid("", true). "." . $fileActualExtThumb;
|
|
|
|
if(empty($thumbnailFileName)){
|
2021-03-22 08:43:33 +00:00
|
|
|
echo http_response_code(400);
|
2021-03-10 08:46:22 +00:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
rename($thumbnailFileTmp,"../../../Frontend/images/".$thumbnailFileNewName);
|
|
|
|
return $thumbnailFileNewName;
|
2021-03-12 13:06:10 +00:00
|
|
|
}else{
|
2021-03-19 12:25:27 +00:00
|
|
|
echo "Wrong file type";
|
2021-03-22 08:43:33 +00:00
|
|
|
echo http_response_code(400);
|
2021-03-17 08:43:09 +00:00
|
|
|
exit();
|
2021-03-10 08:46:22 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2021-03-09 14:04:59 +00:00
|
|
|
}
|