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;
public static function getBuildPrimaryScreenshot($bid) { $sid = apc_fetch('buildPrimaryScreenshot_' . $bid, $success); if (!$success) { $database = new DatabaseManager(); ScreenshotManager::verifyTable($database); $resource = $database->query("SELECT `sid` FROM `build_screenshotmap` WHERE\n\t\t\t\t`bid` = '" . $database->sanitize($bid) . "' AND\n\t\t\t\t`primary` = 1 LIMIT 1"); if (!$resource) { throw new Exception("Database error: " . $database->error()); } if ($resource->num_rows == 0) { $resource->close(); return false; } $row = $resource->fetch_object(); $sid = ScreenshotManager::getFromID($row->sid); $resource->close(); apc_store('buildPrimaryScreenshot_' . $bid, $sid, ScreenshotManager::$buildScreenshotsCacheTime); } return $sid; }