$authorDat[] = $author; $branchId["stable"] = 1; $branchId["unstable"] = 2; $branchId["development"] = 3; $file["stable"] = $res->file_stable; $versionData = array(); foreach ($file as $branch => $fid) { if ($fid != 0) { $version = new stdClass(); $fileRes = $mysql->query("SELECT * FROM `addon_files` WHERE `id`='" . $fid . "'"); $hash = $fileRes->fetch_object()->hash; $oldfile = $dir . $hash . ".zip"; $bid = $branchId[$branch]; echo "Uploading {$oldfile} to AWS as {$res->id}_{$bid}.zip"; //AWSFileManager::upload("addons/{$res->id}_{$bid}", $oldfile); AWSFileManager::uploadNewAddon($res->id, $bid, $res->filename, $oldfile); $updateRes = $mysql->query("SELECT *\nFROM `addon_updates`\nWHERE `aid` = '" . $aid . "'\nAND `branch`='" . $bid . "' ORDER BY `time` DESC\nLIMIT 0 , 1"); if ($updateRes->num_rows == 0) { $version->version = "0.0.0"; $version->restart = "0.0.0"; } else { $obj = $updateRes->fetch_object(); $version->version = $obj->version; $version->restart = $obj->version; //not worth it } $versionData[$branch] = $version; } } $db->query($sql = "INSERT INTO `addon_addons` (`id`, `board`, `blid`, `name`, `filename`, `description`, `version`, `authorInfo`, `reviewInfo`, `deleted`, `approved`, `uploadDate`) VALUES " . "('" . $db->sanitize($res->id) . "'," . "NULL," . "'" . $db->sanitize($res->author) . "'," . "'" . $db->sanitize($res->name) . "'," . "'" . $db->sanitize($res->filename) . "'," . "'" . $db->sanitize($res->description) . "'," . "'" . $db->sanitize($versionData['stable']->version) . "'," . "'" . $db->sanitize(json_encode($authorDat)) . "'," . "''," . "'0'," . "'0'," . "CURRENT_TIMESTAMP);"); echo $db->error();
public static function approveUpdate($update) { $database = new DatabaseManager(); AddonManager::verifyTable($database); $id = $update->getId(); if ($update->status !== null) { throw new Exception("Attempted to approve already approved update"); } $update->status = true; $database->query("UPDATE `addon_updates` SET `approved` = b'1' WHERE `id` = '" . $database->sanitize($id) . "'"); $database->query("UPDATE `addon_addons` SET `version` = '" . $database->sanitize($update->version) . "' WHERE `id` = '" . $database->sanitize($update->aid) . "'"); AddonFileHandler::injectGlassFile($update->aid, $update->getFile()); AddonFileHandler::injectVersionInfo($update->aid, 1, $update->getFile()); AWSFileManager::uploadNewAddon($update->aid, 1, $update->getAddon()->getFilename(), $update->getFile()); $params = new stdClass(); $addon = new stdClass(); $addon->type = "addon"; $addon->id = $update->getAddon()->getId(); $params->vars[] = $addon; NotificationManager::createNotification($manager, 'Your update to $1 was approved', $params); @unlink($update->getFile()); }