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-16 11:46:44 +00:00
|
|
|
header("location: ../../../Frontend/index.html?error=emptyFile");
|
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-16 11:46:44 +00:00
|
|
|
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
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-16 11:46:44 +00:00
|
|
|
header("location: ../../../Frontend/index.html?error=emptyFile");
|
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-16 11:46:44 +00:00
|
|
|
header("location: location: ../../../Frontend/index.html?error=Wrong%20File%20Type");
|
2021-03-10 08:46:22 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2021-03-09 14:04:59 +00:00
|
|
|
}
|