2021-03-10 13:16:08 +00:00
|
|
|
<?php
|
|
|
|
require_once "../../../bootstrap.php";
|
|
|
|
require_once('../Group/Group.php');
|
|
|
|
require_once('FileHandler.php');
|
|
|
|
use Backend\Models\GameData;
|
|
|
|
|
2021-03-16 11:46:44 +00:00
|
|
|
if(isLogin()){
|
2021-03-10 13:16:08 +00:00
|
|
|
if(isset($_POST['submitUpdate'])){
|
|
|
|
$gameFile = $_FILES['gameFile'];
|
|
|
|
$desc = $_POST['description'];
|
|
|
|
$title = $_POST['gameTitle'];
|
|
|
|
$thumbnail = $_FILES['thumbnailFile'];
|
|
|
|
$isWebBased = isset( $_POST['isWebBased']);
|
|
|
|
|
|
|
|
$gameFileName = $_FILES['gameFile']['name'];//Game name
|
|
|
|
$gameFileTmp = $_FILES['gameFile']['tmp_name'];//Tmp location of the file
|
|
|
|
$gameFileError = $_FILES['gameFile']['error'];//File error
|
|
|
|
|
|
|
|
$thumbnailFileName = $_FILES['thumbnailFile']['name'];//Game name
|
|
|
|
$thumbnailFileTmp = $_FILES['thumbnailFile']['tmp_name'];//Tmp location of the file
|
|
|
|
$thumbnailFileError =$_FILES['thumbnailFile']['error'];//File error
|
|
|
|
|
|
|
|
|
|
|
|
//Get the group
|
|
|
|
$group = groupViaToken($_SESSION['token']);
|
|
|
|
//Get the game data, from the group
|
|
|
|
$gameData = GameData::find($group->game_data_id);
|
|
|
|
$gameData->game_name = $title;
|
|
|
|
if(isset($gameData) && $gameFileError === 0){
|
|
|
|
unlink("../../Games/".$gameData->game_link);
|
|
|
|
$gameData->game_link = ZipFileHandler($gameFileName,$gameFileTmp);
|
|
|
|
}
|
|
|
|
$gameData->description = $desc;
|
|
|
|
if(isset($thumbnail) && $thumbnailFileError === 0){
|
|
|
|
unlink("../../../Frontend/images/".$gameData->img);
|
|
|
|
$gameData->img = imagesFileHandler($thumbnailFileName,$thumbnailFileTmp);
|
|
|
|
}
|
|
|
|
$gameData->is_web_Based = $isWebBased;
|
2021-03-19 12:25:27 +00:00
|
|
|
if(!$gameData->save()){
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(500);
|
2021-03-19 12:25:27 +00:00
|
|
|
}else{
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(201);
|
2021-03-19 12:25:27 +00:00
|
|
|
}
|
|
|
|
|
2021-03-17 08:43:09 +00:00
|
|
|
}else{
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(400);
|
2021-03-10 13:16:08 +00:00
|
|
|
}
|
|
|
|
}else{
|
2021-03-23 12:39:44 +00:00
|
|
|
http_response_code(401);
|
|
|
|
echo json_encode(["message" => "is not login"]);
|
2021-03-10 13:16:08 +00:00
|
|
|
}
|