-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5 from Thunder07/website_ui
Website UI update 3
- Loading branch information
Showing
16 changed files
with
1,829 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
require_once __DIR__ . "/../include/ErrorPage.class.php"; | ||
require_once __DIR__ . "/../include/login.phpbb.class.php"; | ||
|
||
function returnJSONAndDie($code, $msg) | ||
{ | ||
echo json_encode(array("code" => $code, "msg" => $msg)); | ||
die(); | ||
} | ||
|
||
$_user = phpBBuser::getInstance(); | ||
if(!$_user->isLoggedIn()) | ||
{ | ||
returnJSONAndDie(-1, ErrorPage::$MSG_NOT_LOGGED_IN_EDIT_ERROR); | ||
} | ||
else | ||
{ | ||
if(!$_user->hasPermission('u_edit_games')) | ||
{ | ||
returnJSONAndDie(-1, ErrorPage::$MSG_NO_PERMISSION_TO_EDIT_ERROR); | ||
} | ||
} | ||
|
||
|
||
$GameArrayFields = ['GameTitle', 'Overview', 'ReleaseDateRevised', 'Players', 'coop', 'Developer', 'Publisher', 'Youtube']; | ||
foreach($GameArrayFields as $field) | ||
{ | ||
if(!isset($_REQUEST[$field])) | ||
{ | ||
returnJSONAndDie(-1, ErrorPage::$MSG_MISSING_PARAM_ERROR . ": ($field)."); | ||
} | ||
if(empty($_REQUEST[$field]) && ($field != 'Youtube' && $field != 'Overview' && $field != 'Publisher')) | ||
{ | ||
returnJSONAndDie(-1, "field is empty: ($field)."); | ||
} | ||
} | ||
|
||
$date = explode('-', $_REQUEST['ReleaseDateRevised']); | ||
if(!checkdate($date[1], $date[2], $date[0])) | ||
{ | ||
returnJSONAndDie(-1, "Invalid Date Format"); | ||
} | ||
|
||
|
||
require_once __DIR__ . "/../../include/TGDB.API.php"; | ||
|
||
try | ||
{ | ||
|
||
$API = TGDB::getInstance(); | ||
$res = $API->InsertGame($_user->GetUserID(), $_REQUEST['GameTitle'], $_REQUEST['Overview'], $_REQUEST['Youtube'], $_REQUEST['ReleaseDateRevised'], | ||
$_REQUEST['Players'], $_REQUEST['coop'], $_REQUEST['Developer'], $_REQUEST['Publisher']); | ||
|
||
if($res) | ||
{ | ||
returnJSONAndDie(1, $res); | ||
} | ||
|
||
} | ||
catch (Exception $e) | ||
{ | ||
error_log($e); | ||
} | ||
returnJSONAndDie(-1, "Unexpected Error has occured, Please try again!!"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
require_once __DIR__ . "/../include/ErrorPage.class.php"; | ||
require_once __DIR__ . "/../include/login.phpbb.class.php"; | ||
|
||
function returnJSONAndDie($code, $msg) | ||
{ | ||
echo json_encode(array("code" => $code, "msg" => $msg)); | ||
die(); | ||
} | ||
|
||
$_user = phpBBuser::getInstance(); | ||
if(!$_user->isLoggedIn()) | ||
{ | ||
returnJSONAndDie(-1, ErrorPage::$MSG_NOT_LOGGED_IN_EDIT_ERROR); | ||
} | ||
else | ||
{ | ||
if(!$_user->hasPermission('m_delete_games')) | ||
{ | ||
returnJSONAndDie(-1, ErrorPage::$MSG_NO_PERMISSION_TO_EDIT_ERROR); | ||
} | ||
} | ||
|
||
if(!isset($_REQUEST['game_id']) || !is_numeric($_REQUEST['game_id'])) | ||
{ | ||
returnJSONAndDie(-1, ErrorPage::$MSG_MISSING_PARAM_ERROR); | ||
} | ||
|
||
require_once __DIR__ . "/../../include/TGDB.API.php"; | ||
|
||
try | ||
{ | ||
|
||
$API = TGDB::getInstance(); | ||
if(empty($API->GetGameByID($_REQUEST['game_id'], 0, 1))) | ||
{ | ||
returnJSONAndDie(0, "No game in record to delete."); | ||
} | ||
|
||
$covers = $API->GetGameBoxartByID($_REQUEST['game_id'], 0, 99, 'ALL'); | ||
|
||
if(!empty($covers) && ($covers = $covers[$_REQUEST['game_id']])) | ||
{ | ||
$sizes = ["original", "small", "thumb", "cropped_center_thumb", "medium", "large"]; | ||
foreach($covers as $cover) | ||
{ | ||
foreach($sizes as $size) | ||
{ | ||
$image_to_delete = __DIR__ . "/../../cdn/images/$size/" . $cover->filename; | ||
if(file_exists($image_to_delete)) | ||
{ | ||
unlink($image_to_delete); | ||
} | ||
} | ||
} | ||
} | ||
|
||
$API->DeleteAllGameImages($_user->GetUserID(), $_REQUEST['game_id']); | ||
$res = $API->DeleteGame($_user->GetUserID(), $_REQUEST['game_id']); | ||
|
||
returnJSONAndDie(1, "success!!"); | ||
|
||
|
||
} | ||
catch (Exception $e) | ||
{ | ||
error_log($e); | ||
} | ||
returnJSONAndDie(-1, "Unexpected Error has occured, Please try again!!"); |
Oops, something went wrong.