public static function loadBasicDummyData() { TestManager::clearDatabase(); $database = new DatabaseManager(); UserManager::verifyTable($database); AddonManager::verifyTable($database); BoardManager::verifyTable($database); TagManager::verifyTable($database); GroupManager::verifyTable($database); DependencyManager::verifyTable($database); CommentManager::verifyTable($database); RatingManager::verifyTable($database); BuildManager::verifyTable($database); StatManager::verifyTable($database); ScreenshotManager::verifyTable($database); if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('General Content', 'general_content_bg', 'Bricks, Events, Sounds, Prints, Environments, and much more!')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Minigames', 'minigames_bg', 'Weapons, Vehicles, Gamemodes, and all your gaming needs!')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Client Mods', 'client_mods_bg', 'Mods that run on your client.')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `addon_boards` (name, video, description) VALUES ('Bargain Bin', 'bargain_bin_bg', 'A home for \\'special\\' content.')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `users` (username, blid, password, email, salt, verified) VALUES ('testuser', '4833', '1d8436e97ef95a7a6151f47b909167c77cfe1985ee5500efa8d46cfe825abc59', '*****@*****.**', '273eb4', '1')")) { throw new Exception("Database error: " . $database->error()); } //the default json types likely need to be reworked if (!$database->query("INSERT INTO `addon_addons` (board, blid, name, filename, description, approved, versionInfo, authorInfo, reviewInfo) VALUES ('1', '4833', 'crapy adon', 'sciprt_hax.zip', 'bad addone pls delete', '1', '{}', '[]', '[]')")) { throw new Exception("Database error: " . $database->error()); } StatManager::addStatsToAddon(1); if (!$database->query("INSERT INTO `addon_tags` (name, base_color, icon) VALUES ('dum tag', 'ff6600', 'brokenimage')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `addon_tagmap` (aid, tid) VALUES ('1', '1')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `group_groups` (leader, name, description, color, icon) VALUES ('4833', 'legion of dumies', 'a group for people who just want to be in a group', '00ff00', 'brokenimage')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `group_usermap` (gid, blid, administrator) VALUES ('1', '4833', '1')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `addon_comments` (blid, aid, comment) VALUES ('4833', '1', 'glorious addon comrade')")) { throw new Exception("Database error: " . $database->error()); } if (!$database->query("INSERT INTO `addon_ratings` (blid, aid, rating) VALUES ('4833', '1', '1')")) { throw new Exception("Database error: " . $database->error()); } }
require_once realpath(dirname(__DIR__) . "/class/UserManager.php"); require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php"); // require_once(realpath(dirname(__DIR__) . "/class/TagManager.php")); // require_once(realpath(dirname(__DIR__) . "/class/DependencyManager.php")); $build = BuildManager::getFromID($_GET['id'] + 0); if ($build === false) { $response = ["redirect" => "/builds/index.php"]; return $response; } $user = UserManager::getFromBLID($build->blid); // $tagIDs = $build->getTags(); // $dependencyIDs = $build->getDependencies(); // $tags = []; // $dependencies = []; // // foreach($tagIDS as $tid) { // $tags[] = TagManager::getFromID($tid); // } // // foreach($dependencyIDs as $did) { // $dependencies[] = DependencyManager::getFromID($did); // } $screenshotIDs = ScreenshotManager::getScreenshotsFromBuild($build->id); $primaryScreenshotID = ScreenshotManager::getBuildPrimaryScreenshot($build->id); $screenshots = []; foreach ($screenshotIDs as $sid) { $screenshots[$sid] = ScreenshotManager::getFromID($sid); } //to do: replace "downloads" with "stats" $response = ["build" => $build, "user" => $user, "downloads" => $build->getTotalDownloads(), "screenshots" => ["data" => $screenshots, "primaryid" => $primaryScreenshotID]]; return $response;
if ($check === false) { $response = ["message" => "Invalid image uploaded", "build" => $build, "user" => $user]; return $response; } $uploadExt = pathinfo($_FILES['screenshots']['name'], PATHINFO_EXTENSION); if ($uploadExt != "png" && $uploadExt != "jpg") { $response = ["message" => "Only .png and .jpg screenshots are allowed", "build" => $build, "user" => $user]; return $response; } require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php"); if ($_FILES['screenshots']['size'] > ScreenshotManager::$maxFileSize) { $response = ["message" => "File too large - The maximum Screenshot file size is 3 MB", "build" => $build, "user" => $user]; return $response; } require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php"); ScreenshotManager::uploadScreenshotForBuild($build, $uploadExt, $tempPath); $changed = true; } $subResponse = BuildManager::updateBuild($build, $_POST['buildname'], $_POST['description']); if ($subResponse['message'] !== "") { $response = ["message" => $subResponse['message'], "build" => $build, "user" => $user]; return $response; } else { if ($changed) { $response = ["message" => "Screenshots Updated", "build" => $build, "user" => $user]; return $response; } else { $response = ["message" => "No changes were made", "build" => $build, "user" => $user]; return $response; } }
public static function setBuildPrimaryScreenshot($sid, $bid) { //we don't care if this returns true or false, this is to ensure the mapping exists ScreenshotManager::addScreenshotToBuild($sid, $bid); $database = new DatabaseManager(); ScreenshotManager::verifyTable($database); if (!$database->query("UPDATE `build_screenshotmap` SET `primary` = '0' WHERE\n\t\t\t`bid` = '" . $database->sanitize($bid) . "'")) { throw new Exception("Database error: " . $database->error()); } //$oldPrimaryID = getBuildPrimaryScreenshot($bid); // //if($oldPrimaryID !== false) { // if(!$database->query("UPDATE `build_screenshotmap` SET `primary` = '0' WHERE // `sid` = '" . $database->sanitize($oldPrimaryID) . "'")) { // throw new Exception("Database error: " . $database->error()); // } // apc_delete('ScreenshotObject_' . $oldPrimaryID); //} if (!$database->query("UPDATE `build_screenshotmap` SET `primary` = '1' WHERE\n\t\t\t`bid` = '" . $database->sanitize($bid) . "' AND\n\t\t\t`sid` = '" . $database->sanitize($sid) . "'")) { throw new Exception("Database error: " . $database->error()); } apc_delete('buildPrimaryScreenshot_' . $bid); return true; }
if ($check === false) { $response = ["message" => "Invalid image uploaded", "addon" => $addon, "user" => $user]; return $response; } $uploadExt = pathinfo($_FILES['screenshots']['name'], PATHINFO_EXTENSION); if ($uploadExt != "png" && $uploadExt != "jpg") { $response = ["message" => "Only .png and .jpg screenshots are allowed", "addon" => $addon, "user" => $user]; return $response; } require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php"); if ($_FILES['screenshots']['size'] > ScreenshotManager::$maxFileSize) { $response = ["message" => "File too large - The maximum Screenshot file size is 3 MB", "addon" => $addon, "user" => $user]; return $response; } require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php"); ScreenshotManager::uploadScreenshotForAddon($addon, $tempPath); $changed = true; } if (!isset($_POST['addonname']) && !isset($_POST['description'])) { $response = ["message" => "Some form elements missing", "addon" => $addon, "user" => $user]; return $response; } $subResponse = []; if (isset($_POST['addonname'])) { $subResponse[] = AddonManager::updateName($addon, $_POST['addonname']); } if (isset($_POST['description'])) { $subResponse[] = AddonManager::updateDescription($addon, $_POST['description']); } if (sizeof($subResponse) > 0) { $response = ["addon" => $addon, "user" => $user];
echo '<a href="/addons/download.php?id=' . $addonObject->getId() . '&beta=0" class="btn dlbtn ' . $class . '"><b>' . ucfirst($id) . '</b><span style="font-size:9pt"><br />v' . $version . '</span></a>'; if ($addonObject->hasBeta()) { $id = "beta"; $class = "red"; echo '<a href="/addons/download.php?id=' . $addonObject->getId() . '&beta=1" class="btn dlbtn ' . $class . '"><b>' . ucfirst($id) . '</b><span style="font-size:9pt"><br />v' . $addonObject->getBetaVersion() . '</span></a>'; } ?> </div> <div class="screenshots" style="text-align:center;margin: 0 auto"> <?php $screenshots = ScreenshotManager::getScreenshotsFromAddon($_GET['id']); if (sizeof($screenshots) > 0) { echo "<hr />"; } foreach ($screenshots as $sid) { $ss = ScreenshotManager::getFromId($sid); echo "<div style=\"padding: 5px; margin: 10px 10px; background-color: #eee; display:inline-block; width: 128px; vertical-align: middle\">"; echo "<a target=\"_blank\" href=\"/addons/screenshot.php?id=" . $sid . "\">"; echo "<img src=\"" . $ss->getThumbUrl() . "\" /></a>"; echo "</div>"; } ?> </div> <?php $deps = DependencyManager::getDependenciesFromAddonID($_GET['id']); if (sizeof($deps) > 0) { echo "<hr /><div style=\"text-align:center\">"; echo "<b>This add-on has some dependencies or add-ons that it requires to run:</b><br/><br/>"; foreach ($deps as $did) { $dep = DependencyManager::getFromId($did); $rid = $dep->getRequired();
} if (!isset($_POST['submit'])) { $response = ["message" => "Upload a Screenshot"]; return $response; } if (!isset($_POST['csrftoken']) || $_POST['csrftoken'] != $_SESSION['csrftoken']) { $response = ["message" => "Cross site request forgery attempt blocked"]; return $response; } if (!isset($_FILES['uploadfile']['name']) || !$_FILES['uploadfile']['size']) { //if(!count($_FILES['uploads']['uploadfile'])) { $response = ["message" => "No file was selected to be uploaded"]; return $response; } $uploadExt = pathinfo($_FILES['uploadfile']['name'], PATHINFO_EXTENSION); $uploadExt = strtolower($uploadExt); if ($uploadExt != "png" && $uploadExt != "jpg") { $response = ["message" => "Only .png and .jpg screenshots are allowed"]; return $response; } require_once realpath(dirname(__DIR__) . "/class/ScreenshotManager.php"); if ($_FILES['uploadfile']['size'] > ScreenshotManager::$maxFileSize) { $response = ["message" => "File too large - The maximum build file size is 3 MB"]; return $response; } $tempPath = $_FILES['uploadfile']['tmp_name']; if ($_screenshotContext == "addon") { ScreenshotManager::uploadScreenshotForAddon(AddonManager::getFromId($_GET['id']), $uploadExt, $tempPath); } $response = ["message" => "idk"]; return $response;
<?php require_once realpath(dirname(__DIR__) . "/private/class/ScreenshotManager.php"); $ss = ScreenshotManager::getFromId($_GET['id']); echo "<img src=\"" . $ss->getUrl() . "\" />";