Code: Select all
<?php
$request = new \phpbb\request\request();
$gameaccid = $user->data['user_id'];
$userpaidtf = $user->data['user_indielix_paid'];
include("dbconnectfile.php");
$stmt = $conn->prepare("SELECT COUNT(AccountID) FROM indielix_gameaccount WHERE AccountID='$gameaccid'");
$stmt->bind_param('i');
$stmt->bind_result($totalusersgames);
$stmt->execute();
$row = $stmt->fetch();
$conn->close();
$submittf = (isset($_POST['addgamesubmit'])) ? true : false;
if ($submittf == true) {
include("dbconnectfile.php");
$gamename = $conn->real_escape_string(request_var('inputGameName', '0'));
$gamewebsite = $conn->real_escape_string(request_var('inputGameWebsite', '0'));
$gameshortdescription = $conn->real_escape_string(request_var('gameshortdescription', '0'));
$gamedescription = $conn->real_escape_string(request_var('gamedescription', '0'));
$gamedescription = $conn->real_escape_string(request_var('gamedescription', '0'));
$gametags = strtolower($conn->real_escape_string(request_var('gametags', '0')));
$gamestartdate = $conn->real_escape_string(request_var('inputGameStartDate', '0'));
$gamecategory = $conn->real_escape_string(request_var('gamecategory', '0'));
$gameprogress = $conn->real_escape_string(request_var('releasestate', '0'));
$gameios = $conn->real_escape_string(request_var('iosSupport', '0'));
$gameandroid = $conn->real_escape_string(request_var('androidSupport', '0'));
$gamemicrosoft = $conn->real_escape_string(request_var('microsoftSupport', '0'));
$gameiosurl = $conn->real_escape_string(request_var('inputGameIos', '0'));
$gameandroidurl = $conn->real_escape_string(request_var('inputGameAndroid', '0'));
$gamemicrosofturl = $conn->real_escape_string(request_var('inputGameMicrosoft', '0'));
$gamefeaturedimage2 = $request->file('featuredimage');
$gamefeaturedimage = $gamefeaturedimage2['name'];
function uniqidReal($length = 13) {
if (function_exists("random_bytes")) {
$bytes = random_bytes(ceil($length / 2));
}
elseif (function_exists("openssl_random_pseudo_bytes")) {
$bytes = openssl_random_pseudo_bytes(ceil($length / 2));
}
else {
throw new Exception("no cryptographically secure random function available");
}
return substr(bin2hex($bytes), 0, $length);
}
function uploadImage($featuredimage){
$target_dir = "images/";
$target_file = $target_dir . $featuredimage;
$uploadOk = 1;
$imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION));
if ($gamefeaturedimage2['size'] > 30000000) {
$message = "Only images under 3MB are allowed!";
writeEMes($message);
$uploadOk = 0;
}
if($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg") {
$message = "Only .jpg and .png image formats are allowed!";
writeEMes($message);
$uploadOk = 0;
}
if ($uploadOk == 0) {
}
else{
if (move_uploaded_file($gamefeaturedimage2['tmp_name'], $target_file)){
}
else {
$message = "Failed to add image! $target_file";
writeEMes($message);
}
}
}
$temp = explode(".", $gamefeaturedimage);
$id1 = uniqid();
$id2 = uniqidReal();
$hid = $id1."".$id2;
$featuredimage = $hid.".".end($temp);
uploadImage($featuredimage);
$imagepath = "images/$featuredimage";
$info = getimagesize($imagepath);
$aspectratio = $info[1] / $info[0];
if($aspectratio == 0.5625){
$gameidentification = uniqid()."".uniqidReal();
include("dbconnectfile.php");
$addgame = "INSERT INTO indielix_games (GameID, GameName, GameDescription, GameShortDescription, GameWebsite, GameTags, GameOS1, GameOS2, GameOS3, GameIos, GameAndroid, GameWinPhone, GameFeaturedImage, GameStartDate, GameState, GameProgress) VALUES ('$gameidentification', '$gamename', '$gamedescription', '$gameshortdescription', '$gamewebsite', '$gametags', '$gameios', '$gameandroid', '$gamemicrosoft', '$gameiosurl', '$gameandroidurl', '$gamemicrosofturl', '$featuredimage', '$gamestartdate', '99', '$gameprogress')";
if($conn->query($addgame)){
include("dbconnectfile.php");
$addgamecat = "INSERT INTO indielix_gamecategory (GameID, CategoryID) VALUES ('$gameidentification', '$gamecategory')";
if($conn->query($addgamecat)){
include("dbconnectfile.php");
$addgameacc = "INSERT INTO indielix_gameaccount (GameID, AccountID) VALUES ('$gameidentification', '$gameaccid')";
if($conn->query($addgameacc)){
$message = "Game has been added! Please wait between 24 and 48 hours for it to be approved by the team!";
writeSMes($message);
}
else{
$message = "Error adding game to system!";
writeEMes($message);
}
$conn->close();
}
else{
$message = "Error adding game to system!";
writeEMes($message);
}
$conn->close();
}
else{
$message = "Error adding game to system!";
writeEMes($message);
}
$conn->close();
}
else{
unlink($imagepath);
$message = "Featured image must have the 16:9 aspect ratio! $aspectratio $featuredimage";
writeEMes($message);
}
}
if($userpaidtf == 0){
if($totalusersgames >= 1){
include_once('message.php');
$message = "Only one game per user";
writeEMes($message);
}
}
else{
include('addgameformpart.php');
}
?>