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); redirect("/games/pbs/config?id=".$placeid); } } } setRegularGame($placeid); } return "Error converting to PBS"; } $alert = ""; if(isset($_GET['id'])) { $id = (int)$_GET['id']; if(getAssetInfo($id)->isPersonalServer) { 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'; } $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 = ""; } elseif (strlen($_POST['placename']) < 3) { $alert = ""; } elseif (strlen($_POST['placename']) > 50) { $alert = ""; } elseif(strlen($_POST['description']) > 1000) { $alert = ""; } elseif ($_POST['gdskill'][1] < 1) //cant have max players under 1 { $alert = ""; } elseif ($_POST['gdskill'][1] > 12) //cant have max players over 12 { $alert = ""; } elseif ($dimensionsfail) { $alert = ""; } 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(); // ... 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 = ""; } else { redirect("config?id={$id}"); } } } 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 redirect("config?id={$id}"); } 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 } redirect("config?id={$id}"); } // ... } } } if (isset($_POST['SubmitPBSSuperflat'])) { $upload = convertToPBSPlace("Superflat", $id); if ($upload !== true) { $alert = ""; } else { $alert = ""; } } if (isset($_POST['SubmitPBSRugged'])) { $upload = convertToPBSPlace("Rugged", $id); if ($upload !== true) { $alert = ""; } else { $alert = ""; } } if (isset($_POST['SubmitPBSHappyHome'])) { $upload = convertToPBSPlace("HappyHome", $id); if ($upload !== true) { $alert = ""; } else { $alert = ""; } } if (isset($_POST['SubmitPBSBaseplate'])) { $upload = convertToPBSPlace("Baseplate", $id); if ($upload !== true) { $alert = ""; } else { $alert = ""; } } if (isset($_POST['PBSNoSelection'])) { $alert = ""; } if (isset($_POST['SubmitPlace'])) { $place = newPlace(); if ($place !== true) { $alert = ""; } else { $alert = ""; } } } else { redirect("/"); //not owner or not admin } } else { redirect("/"); //place doesnt exist } } else { redirect("/"); //no url parameters } $gearshtml = ""; if ($gearsportion) { $gearshtml = <<
Allowed Gear Genres
EOT; } $body = << {$alert}
Configure Place
Convert to PBS

{$gamemaxplayers}
If you'd like to use the last Studio position as the Thumbnail, check it below
When you update this place through Studio with this ticked, the Thumbnail will update with the current position

Custom Game Thumbnails cannot be above 1920x1080
If no custom Thumbnail is provided, a default will be used

{$gearshtml}
EOT; pageHandler(); $ph->body = $body; $ph->pageTitle("Config"); $ph->output();