public function __construct($resource) { //$this->webDownloads = intval($resource->webDownloads); //$this->ingameDownloads = intval($resource->ingameDownloads); //$this->updateDownloads = intval($resource->updateDownloads); //$this->downloads = $this->webDownloads + $this->ingameDownloads + $this->updateDownloads; //print_r($resource); $this->id = intval($resource->id); $this->board = intval($resource->board); $this->blid = intval($resource->blid); $this->name = $resource->name; $this->description = $resource->description; $this->approved = intval($resource->approved); //$this->rating = floatval($resource->rating); $this->version = $resource->version; $this->authorInfo = json_decode($resource->authorInfo); //$this->file = intval($resource->file); $this->filename = $resource->filename; $this->deleted = intval($resource->deleted); $this->reviewInfo = json_decode($resource->reviewInfo); $this->betaVersion = $resource->betaVersion; $this->rating = $resource->rating; $this->uploadDate = $resource->uploadDate; $this->url = "https://s3.amazonaws.com/" . urlencode(AWSFileManager::getBucket()) . "/addons/" . $this->id; }
public function __construct($resource) { $this->id = intval($resource->id); $this->blid = intval($resource->blid); $this->name = $resource->name; $this->bricks = intval($resource->bricks); $this->description = $resource->description; $this->filename = $resource->filename; $this->url = "https://s3.amazonaws.com/" . urlencode(AWSFileManager::getBucket()) . "/builds/" . $this->id; }
public function __construct($resource) { $this->id = intval($resource->id); $this->blid = intval($resource->blid); $this->name = $resource->name; $this->filename = $resource->filename; $this->description = $resource->description; $this->url = "http://s3.amazonaws.com/" . urlencode(AWSFileManager::getBucket()) . "/screenshots/" . $this->id; $this->thumburl = "http://s3.amazonaws.com/" . urlencode(AWSFileManager::getBucket()) . "/screenshots/thumb/" . $this->id; $this->x = $resource->x; $this->y = $resource->y; $this->ext = @$resource->ext; }
public function getDiff() { $fileNew = realpath($this->getFile()); $fileOld = dirname(__DIR__) . '/../addons/files/local/' . $this->aid . '.zip'; if (!is_file($fileOld)) { $path = realpath(dirname(__DIR__) . '/../addons/files/local/'); $fh = fopen($path . '/' . $this->aid . '.zip', 'w'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, "http://" . AWSFileManager::getBucket() . "/addons/" . $this->aid . "_1"); curl_setopt($ch, CURLOPT_FILE, $fh); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // this will follow redirects curl_exec($ch); curl_close($ch); fclose($fh); } $fileOld = realpath(dirname(__DIR__) . '/../addons/files/local/' . $this->aid . '.zip'); $zipNew = new ZipArchive(); $zipOld = new ZipArchive(); $resNew = $zipNew->open($fileNew); $resOld = $zipOld->open($fileOld); if ($resNew === TRUE && $resOld === TRUE) { $newFiles = array(); for ($i = 0; $i < $zipNew->numFiles; $i++) { $newFiles[] = $zipNew->getNameIndex($i); } $oldFiles = []; for ($i = 0; $i < $zipOld->numFiles; $i++) { $oldFiles[] = $zipOld->getNameIndex($i); } $added = array_diff($newFiles, $oldFiles); $removed = array_diff($oldFiles, $newFiles, ["glass.json", "version.json"]); $commonFiles = array_intersect($newFiles, $oldFiles); $commonFiles = array_diff($commonFiles, ["glass.json", "version.json"]); $diff = []; foreach ($commonFiles as $fi) { if (strpos($fi, ".cs") == strlen($fi) - 3) { $newStr = $zipNew->getFromName($fi); $oldStr = $zipOld->getFromName($fi); if (trim($newStr) != trim($oldStr)) { $diff[$fi] = Diff::toTable(Diff::compare($oldStr, $newStr)); } } } $ret = ["added" => $added, "removed" => $removed, "changes" => $diff]; return $ret; } else { return false; } }
$repo = new stdClass(); $repo->name = "Blockland Glass Generated Repo"; $ao = 'add-ons'; $repo->{$ao} = array(); foreach ($addonIds as $id) { $obj = AddonManager::getFromId($id); if (!is_object($obj)) { $addon = new stdClass(); $addon->id = $id; $addon->error = "Unable to create object"; array_push($repo->{$ao}, $addon); continue; } //$webUrl = "api.blocklandglass.com"; $webUrl = "api.blocklandglass.com"; $cdnUrl = AWSFileManager::getBucket(); $addon = new stdClass(); $addon->name = substr($obj->getFilename(), 0, strlen($obj->getFilename()) - 4); //$addon->description = str_replace("\r\n", "<br>", $obj->getDescription()); $chanObj = new stdClass(); $chanObj->name = "stable"; $chanObj->version = $obj->getVersion(); $chanObj->restartRequired = $obj->getRestartVersion(); $chanObj->file = "http://" . $webUrl . "/api/2/download.php?type=addon_update&id=" . $obj->getId() . "&branch=1"; $chanObj->changelog = "http://" . $webUrl . "/api/2/changelog.php?id=" . $obj->getId() . "&branch=1"; if (isset($_REQUEST['legacy']) && $_REQUEST['legacy'] == 1 && $id != 11) { $chanObj->name = "*"; } if ($id == 193) { $chanObj->name = "*"; }
echo $_GET['id']; ?> ">Click here!</a> </div> </div> <hr /> <div style="text-align:center"><img src="/img/rtb_logo.gif"></div> <hr /> <?php if ($addonData->glass_id == 0 || $addonData->approved != 1) { ?> <div style="text-align: center"> <?php $id = "RTB"; $class = "red"; echo '<a href="http://' . AWSFileManager::getBucket() . '/rtb/' . $addonData->filename . '" class="btn dlbtn ' . $class . '"><b>' . ucfirst($id) . '</b><span style="font-size:9pt"><br />Imported Archive</span></a>'; ?> </div> <?php } else { $addon = AddonManager::getFromId($addonData->glass_id); ?> <p style="text-align:center">This add-on has been imported to <a href="/addons/addon.php?id=<?php echo $addon->getId(); ?> "><?php echo $addon->getName(); ?> </a></p> <?php }
public static function injectVersionInfo($aid, $branchId, $file) { $addonObject = AddonManager::getFromID($aid); $branchName[1] = "stable"; $branchName[2] = "beta"; if ($branchId == 1) { $v = $addonObject->getVersion(); } else { $v = $addonObject->getBetaVersion(); } $versionData = new stdClass(); $versionData->version = $v; $versionData->channel = $branchName[$branchId]; $mainRepo = new stdClass(); $mainRepo->url = "http://api.blocklandglass.com/api/2/repository.php"; $mainRepo->format = "JSON"; $mainRepo->id = $aid; $backupRepo = new stdClass(); $backupRepo->url = "http://" . AWSFileManager::getBucket() . "/repository.txt"; $backupRepo->format = "JSON"; $backupRepo->id = $aid; $versionData->repositories = [$mainRepo, $backupRepo]; $workingDir = dirname(dirname(__DIR__)) . "/addons/upload/files/"; $tempFile = $workingDir . "temp/" . $addonObject->getId() . "version.json"; if (!is_dir($workingDir . "temp")) { mkdir($workingDir . "temp", 0777, true); } $res = file_put_contents($tempFile, json_encode($versionData)); if ($res === false) { return false; } $zip = new ZipArchive(); $res = $zip->open($file); if ($res === TRUE) { $zip->addFile($tempFile, 'version.json'); $zip->close(); unlink($tempFile); } else { return false; } }
} if ($type == "addon_update") { StatManager::downloadAddonID($id, "update"); } else { StatManager::downloadAddonID($id, "ingame"); } $head = 'Location: http://' . AWSFileManager::getBucket() . '/addons/' . $id . '_' . $branch; if ($debug) { echo $head; } else { header($head); } $ao = AddonManager::getFromID($id); /* //ideal code? need to review how stats work and are kept //(object, type[0=web, 1=ingame, 2=update], increment) AddonManager::incrementDailyDownloads($ao, 1 ,1); AddonManager::incrementWeeklyDownloads($ao, 1, 1); AddonManager::incrementTotalDownloads($ao, 1, 1); */ } else { if ($type == "rtb") { $filename = $_REQUEST['fn']; $head = 'Location: http://' . AWSFileManager::getBucket() . '/rtb/' . $filename; if ($debug) { echo $head; } else { header($head); } } }
<?php require_once realpath(dirname(__DIR__) . "/private/class/AddonManager.php"); require_once realpath(dirname(__DIR__) . "/private/class/AWSFileManager.php"); require_once realpath(dirname(__DIR__) . "/private/class/StatManager.php"); $id = $_REQUEST['id']; $addonObject = AddonManager::getFromId($id); if ($addonObject !== false) { StatManager::downloadAddon($addonObject); if (isset($_REQUEST['beta'])) { $bid = $_REQUEST['beta'] == 1 ? 2 : 1; } else { $bid = 1; } //echo 'Location: http://' . AWSFileManager::getBucket() . '/addons/' . $id . "_" . $bid; header('Location: http://' . AWSFileManager::getBucket() . '/addons/' . $id . "_" . $bid); } else { header('Status: 404'); header('Location: /error.php'); }