prepare("UPDATE assets SET Hash = :hash WHERE id = :i");
$set->bindParam(":hash", $gamehash, PDO::PARAM_INT);
$set->bindParam(":i", $placeid, PDO::PARAM_INT);
$set->execute();
if ($set->rowCount() > 0)
{
//trust mysql!!
$deletepersistence = $GLOBALS['pdo']->prepare("DELETE FROM persistence WHERE placeid = :i");
$deletepersistence->bindParam(":i", $placeid, PDO::PARAM_INT);
$deletepersistence->execute();
handleRenderPlace($placeid);
WebContextManager::Redirect("/games/pbs/config?id=".$placeid);
}
}
}
Game::SetToPlace($placeid);
}
return "Error converting to PBS";
}
$alert = "";
if(isset($_GET['id']))
{
$id = (int)$_GET['id'];
if(getAssetInfo($id)->isPersonalServer)
{
WebContextManager::Redirect("/games/pbs/config?id=".$id);
}
//Query
$q = $pdo->prepare("SELECT * FROM assets WHERE id = :i");
$q->bindParam(":i", $id, PDO::PARAM_INT);
$q->execute();
if($q->rowCount() > 0)
{
if (isOwner($id) or $user->IsAdmin()) //if the user is the owner of the game, or staff
{
//item parameters
$gameinfo = getAssetInfo($id);
$gamename = cleanOutput($gameinfo->Name);
$gamedescription = cleanOutput($gameinfo->Description, false); //pass false to not replace linebreaks with html
$gamecreator = $gameinfo->CreatorId;
$gamemaxplayers = $gameinfo->MaxPlayers;
$gamerender = handleGameThumb($id);
$commentsstatus = '';
if ($gameinfo->IsCommentsEnabled == true)
{
$commentsstatus = 'checked';
}
$chatclassic = "";
$chatbubble = "";
$chatclassicbubble = "";
switch (Game::GetChatStyle($id))
{
case 0:
$chatclassic = "checked";
break;
case 1:
$chatbubble = "checked";
break;
case 2:
$chatclassicbubble = "checked";
break;
default:
$chatclassicbubble = "checked";
break;
}
$thumbnailstatus = '';
if (isPlaceUsingRender($id))
{
$thumbnailstatus = 'checked';
}
//...
if (isset($_POST['Submit']))
{
//some important parameters
//file parameters
$thumbnailfileExtensionsAllowed = ['png']; // These will be the only file extensions allowed
//upload parameters
$thumbnailuploadDirectory = $GLOBALS['thumbnailCDNPath']; //directory where the textures are stored
$thumbnailHash = genAssetHash(16);
//$thumbnailuploadDirectory = "../thumbnails/places/"; //directory where the games thumbnails are stored
// ...
//temp file locations
$thumbnailfileName = $_FILES['thumbnail_file']['name'];
$thumbnailfileTmpName = $_FILES['thumbnail_file']['tmp_name']; //location of the uploaded png file (temp directory)
$thumbnailfileExtension = strtolower(end(explode('.',$thumbnailfileName)));
// ...
$usedefaultthumb = false;
if(!file_exists($_FILES['thumbnail_file']['tmp_name']) || !is_uploaded_file($_FILES['thumbnail_file']['tmp_name']))
{
$usedefaultthumb = true;
}
//check dimensions
$filecheckfail = false;
$dimensionsfail = false;
//check the image if it exists
if (!$usedefaultthumb)
{
if (in_array($thumbnailfileExtension,$thumbnailfileExtensionsAllowed)) //make sure .png file extension
{
$isimage = @imagecreatefrompng($_FILES['thumbnail_file']['tmp_name']); //check if the file is actually a PNG image
if ($isimage)
{
$imagedetails = getimagesize($_FILES['thumbnail_file']['tmp_name']);
$width = $imagedetails[0];
$height = $imagedetails[1];
if ($width > 1920) //over 1920 width, too big
{
$dimensionsfail = true;
}
if ($height > 1080) //over 1080 height, too big
{
$dimensionsfail = true;
}
}
else
{
$filecheckfail = true;
}
}
else
{
$filecheckfail = true;
}
}
if ($filecheckfail)
{
$alert = "
Invalid thumbnail file, must be .PNG
";
}
elseif (strlen($_POST['placename']) < 3)
{
$alert = "Place name too short, must be over 3 characters
";
}
elseif (strlen($_POST['placename']) > 50)
{
$alert = "Place name too long, must be under 50 characters
";
}
elseif(strlen($_POST['description']) > 1000)
{
$alert = "Place description too long, must be under 1k characters
";
}
elseif ($_POST['gdskill'][1] < 1) //cant have max players under 1
{
$alert = "An error occurred
";
}
elseif ($_POST['gdskill'][1] > 12) //cant have max players over 12
{
$alert = "An error occurred
";
}
elseif ($dimensionsfail)
{
$alert = "Thumbnail resolution cannot be over 1920x1080
";
}
else //all checks passed, do the do
{
//$
//update place name
$c = $pdo->prepare("UPDATE assets SET Name = :n WHERE id = :i");
$c->bindParam(":n", cleanInput($_POST['placename']), PDO::PARAM_STR); //item name
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
// ...
//update place description
$c = $pdo->prepare("UPDATE assets SET Description = :n WHERE id = :i");
$c->bindParam(":n", cleanInput($_POST['description']), PDO::PARAM_STR); //item description
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
// ...
//update place max players
$c = $pdo->prepare("UPDATE assets SET MaxPlayers = :n WHERE id = :i");
$c->bindParam(":n", $_POST['gdskill'][1], PDO::PARAM_INT); //item price
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
// ...
//update place chat style
if (isset($_POST['chatstyle_classic_checkbox'])) {
Game::SetChatStyle($id, 0);
} else if (isset($_POST['chatstyle_bubble_checkbox'])) {
Game::SetChatStyle($id, 1);
} else if (isset($_POST['chatstyle_classicbubble_checkbox'])) {
Game::SetChatStyle($id, 2);
}
if (isset($_POST['comments_checkbox']))
{
//update IsCommentsEnabled to enabled
$comments = 1;
$c = $pdo->prepare("UPDATE assets SET IsCommentsEnabled = :n, Updated = UNIX_TIMESTAMP() WHERE id = :i");
$c->bindParam(":n", $comments, PDO::PARAM_INT); //item name
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
// ...
}
else
{
//update IsCommentsEnabled to disabled
$comments = 0;
$c = $pdo->prepare("UPDATE assets SET IsCommentsEnabled = :n, Updated = UNIX_TIMESTAMP() WHERE id = :i");
$c->bindParam(":n", $comments, PDO::PARAM_INT); //item name
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
// ...
}
if (isset($_POST['thumbnail_checkbox']))
{
if (!isPlaceUsingRender($id))
{
$placepost = handleRenderPlace($id);
if ($placepost !== true) {
$alert = "".$placepost."
";
}
}
}
else
{
//grab place image hash
//files in proper places
if (!$usedefaultthumb) //if custom thumb uploaded
{
$GLOBALS['pdo']->exec("LOCK TABLES assets WRITE"); //lock since this stuff is sensitive
$b = $GLOBALS['pdo']->prepare("SELECT * FROM assets");
$b->execute();
//grab auto increment values
$autoincrement = $b->rowCount() + 1; //initial auto increment value
//add texture to assets
$assetname = $gamename . " Thumbnail";
$x = $GLOBALS['pdo']->prepare("INSERT INTO `assets`(`id`, `AssetTypeId`, `Name`, `Description`, `Created`, `Updated`, `CreatorId`, `TargetId`, `PriceInAlphabux`, `Sales`, `IsNew`, `IsForSale`, `IsPublicDomain`, `IsLimited`, `IsLimitedUnique`, `IsApproved`, `Remaining`, `MinimumMembershipLevel`, `ContentRatingTypeId`, `Favorited`, `Visited`, `MaxPlayers`, `UpVotes`, `DownVotes`, `Hash`) VALUES (:aid,1,:aname,'Place Thumbnail',UNIX_TIMESTAMP(),UNIX_TIMESTAMP(),:oid,:aid2,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,:hash)");
$x->bindParam(":aid", $autoincrement, PDO::PARAM_INT);
$x->bindParam(":aname", $assetname, PDO::PARAM_STR);
$x->bindParam(":oid", $gamecreator, PDO::PARAM_INT);
$x->bindParam(":aid2", $autoincrement, PDO::PARAM_INT);
$x->bindParam(":hash", $thumbnailHash, PDO::PARAM_STR);
$x->execute();
//update place thumbhash
$c = $pdo->prepare("UPDATE assets SET IconImageAssetId = :n WHERE id = :i");
$c->bindParam(":n", $autoincrement, PDO::PARAM_INT); //item price
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
$GLOBALS['pdo']->exec("UNLOCK TABLES");
resize(768, 432, $thumbnailuploadDirectory . $thumbnailHash, $_FILES['thumbnail_file']['tmp_name']);
setPlaceUsingCustomThumbnail($id); //set not using rendered thumb
}
else
{
if (isPlaceUsingRender($id))
{
$thumb = rand(4, 6);
//update place icon
$c = $pdo->prepare("UPDATE assets SET IconImageAssetId = :iiad WHERE id = :i");
$c->bindParam(":iiad", $thumb, PDO::PARAM_INT); //item name
$c->bindParam(":i", $id, PDO::PARAM_INT); //catalog id
$c->execute();
// ...
setPlaceUsingCustomThumbnail($id); //set not using rendered thumb
}
}
// ...
}
WebContextManager::Redirect("config?id={$id}");
}
}
if (isset($_POST['SubmitPBSSuperflat']))
{
$upload = convertToPBSPlace("Superflat", $id);
if ($upload !== true)
{
$alert = "" . $upload . "
";
}
else
{
$alert = "Created Personal Server
";
}
}
if (isset($_POST['SubmitPBSRugged']))
{
$upload = convertToPBSPlace("Rugged", $id);
if ($upload !== true)
{
$alert = "" . $upload . "
";
}
else
{
$alert = "Created Personal Server
";
}
}
if (isset($_POST['SubmitPBSHappyHome']))
{
$upload = convertToPBSPlace("HappyHome", $id);
if ($upload !== true)
{
$alert = "" . $upload . "
";
}
else
{
$alert = "Created Personal Server
";
}
}
if (isset($_POST['SubmitPBSBaseplate']))
{
$upload = convertToPBSPlace("Baseplate", $id);
if ($upload !== true)
{
$alert = "" . $upload . "
";
}
else
{
$alert = "Created Personal Server
";
}
}
if (isset($_POST['PBSNoSelection']))
{
$alert = "Please choose a template
";
}
if (isset($_POST['SubmitPlace']))
{
$place = newPlace();
if ($place !== true)
{
$alert = "" . $place . "
";
}
else
{
$alert = "Created place
";
}
}
}
else
{
WebContextManager::Redirect("/"); //not owner or not admin
}
}
else
{
WebContextManager::Redirect("/"); //place doesnt exist
}
}
else
{
WebContextManager::Redirect("/"); //no url parameters
}
$gearshtml = "";
if ($gearsportion)
{
$gearshtml = <<
Allowed Gear Genres
EOT;
}
$body = <<
{$alert}
EOT;
pageHandler();
$ph->body = $body;
$ph->pageTitle("Config");
$ph->output();