creator != SESSION["userId"]) pageBuilder::errorCode(404); if($item->type == 19) Catalog::$GearAttributes = json_decode($item->gear_attributes, true); $alert = false; if($_SERVER['REQUEST_METHOD'] == 'POST') { $name = $_POST['name'] ?? ""; $description = $_POST['description'] ?? ""; $comments = isset($_POST['comments']) && $_POST['comments'] == "on"; $sale = isset($_POST['sell']) && $_POST['sell'] == "on"; $sell_for_price = isset($_POST['sell-for-currency']) && $_POST['sell-for-currency'] == "on"; $price = $sell_for_price && isset($_POST['sell-price']) ? $_POST['sell-price'] : false; $file = $_FILES["file"] ?? false; Catalog::ParseGearAttributes(); if($sale && $sell_for_price && $price === "") $sell_for_price = $price = false; if(!strlen($name)) $alert = ["text" => "Item name cannot be empty", "color" => "danger"]; else if(Polygon::IsExplicitlyFiltered($name)) $alert = ["text" => "The name contains inappropriate text", "color" => "danger"]; else if(mb_strlen($name, "utf-8") > 50) $alert = ["text" => "Item name cannot be any longer than 50 characters", "color" => "danger"]; else if(strlen($description) > 1000) $alert = ["text" => "Item description cannot be any longer than 1000 characters", "color" => "danger"]; else if(Polygon::IsExplicitlyFiltered($description)) $alert = ["text" => "The description contains inappropriate text", "color" => "danger"]; else if($sale && $sell_for_price && !is_numeric($price)) $alert = ["text" => "Item price is invalid", "color" => "danger"]; else if($sale && $sell_for_price && $price < 0) $alert = ["text" => "Item price cannot be less than zero", "color" => "danger"]; else if($sale && $sell_for_price && $price > (2**31)) $alert = ["text" => "Item price is too large", "color" => "danger"]; else { $item->name = $name; $item->description = $description; $item->comments = $comments; if($item->type != 1) $item->sale = $sale; if(in_array($item->type, [2, 8, 11, 12, 17, 18, 19])) $item->price = $price; if($item->type == 10) $item->publicDomain = $item->sale; if($item->type == 19) $item->gear_attributes = json_encode(Catalog::$GearAttributes); if($file && $file["size"]) { if($isAdmin && !in_array($item->type, [1, 3, 10])) { copy($file["tmp_name"], $_SERVER['DOCUMENT_ROOT']."/asset/files/".$item->id); if($item->type == 10) Gzip::Compress($_SERVER['DOCUMENT_ROOT']."/asset/files/".$item->id); } elseif($item->type == 3) { $image = new Upload($file); if(!$image->uploaded) { $alert = ["text" => "Failed to process image - please contact an admin", "color" => "danger"]; } else { $image->allowed = ['image/png', 'image/jpg', 'image/jpeg']; $image->image_convert = 'png'; Thumbnails::UploadAsset($image, $item->id, 75, 75); Thumbnails::UploadAsset($image, $item->id, 100, 100); Thumbnails::UploadAsset($image, $item->id, 110, 110); Thumbnails::UploadAsset($image, $item->id, 250, 250); Thumbnails::UploadAsset($image, $item->id, 352, 352); Thumbnails::UploadAsset($image, $item->id, 420, 230); Thumbnails::UploadAsset($image, $item->id, 420, 420); } } } $query = $pdo->prepare("UPDATE assets SET name = :name, description = :description, comments = :comments, sale = :sale, price = :price, gear_attributes = :gear, updated = UNIX_TIMESTAMP() WHERE id = :id"); $query->bindParam(":name", $item->name, PDO::PARAM_STR); $query->bindParam(":description", $item->description, PDO::PARAM_STR); $query->bindParam(":comments", $item->comments, PDO::PARAM_INT); $query->bindParam(":sale", $item->sale, PDO::PARAM_INT); $query->bindParam(":price", $item->price, PDO::PARAM_INT); $query->bindParam(":gear", $item->gear_attributes, PDO::PARAM_STR); $query->bindParam(":id", $item->id, PDO::PARAM_STR); $query->execute(); $alert = ["text" => "Your changes to this item have been saved (".date('h:i:s A').")", "color" => "primary"]; } } pageBuilder::$pageConfig['title'] = "Configure ".Catalog::GetTypeByNum($item->type); pageBuilder::buildHeader(); ?>