<?php /* -*- Mode: PHP; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=2 et tw=80 : */ // Returns all builders belonging to a branch with the following format: // [ { "name": "...", "buildername": "...", "hidden": 0/1 }, ... ] // hidden:0 may be ommitted. require_once 'config.php'; require_once 'inc/Communication.php'; Headers::send(Headers::ALLOW_CROSS_ORIGIN | Headers::NO_CACHE, "application/json"); $branch = requireStringParameter('branch', $_GET); $stmt = $db->prepare("\n SELECT name, buildername, hidden\n FROM builders\n WHERE branch = :branch\n ORDER BY buildername ASC;"); $stmt->execute(array(":branch" => $branch)); // mysql returns everything as string, so we need to manually cast to bool :-( $result = array(); while ($builder = $stmt->fetch(PDO::FETCH_ASSOC)) { $builder['hidden'] = $builder['hidden'] != "0"; $result[] = $builder; } echo json_encode($result) . "\n";
/* vim: set sw=2 ts=2 et tw=80 : */ require_once 'config.php'; require_once 'inc/Communication.php'; Headers::send(Headers::ALLOW_CROSS_ORIGIN, "application/json"); $id = requireStringParameter('id', $_POST); if (is_numeric($id)) { // $id is a Buildbot ID. $stmt = $db->prepare("\n SELECT id\n FROM runs\n WHERE buildbot_id = :id;"); $stmt->execute(array(":id" => $id)); $run = $stmt->fetchColumn(); if (!$run) { die("No build with that id in database."); } } else { // $id is not a Buildbot ID; it could be a Tinderbox result ID. // TBPL with Tinderbox backend doesn't know the Buildbot ID of a run, // so it lets us figure it out from the slave name and the start time // of the run. $slave = requireStringParameter('machinename', $_POST); $starttime = +requireStringParameter('starttime', $_POST); $stmt = $db->prepare("\n SELECT id\n FROM runs\n WHERE slave = :slave AND starttime = FROM_UNIXTIME(:starttime);"); $stmt->execute(array(":slave" => $slave, ":starttime" => $starttime)); $run = $stmt->fetchColumn(); if (!$run) { die("No build with that slave/starttime combination in database."); } } $who = requireStringParameter('who', $_POST); $note = requireStringParameter('note', $_POST); $stmt = $db->prepare("\n INSERT INTO runs_notes\n SET run_id = :run, who = :who, note = :note, ip = :ip;"); $stmt->execute(array(':run' => $run, ':who' => $who, ':note' => $note, ':ip' => $_SERVER['REMOTE_ADDR']));
<?php /* -*- Mode: PHP; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=2 et tw=80 : */ require_once 'config.php'; require_once 'inc/Communication.php'; Headers::send(Headers::ALLOW_CROSS_ORIGIN | Headers::NO_CACHE, "application/json"); $branch = requireStringParameter('branch', $_GET); $rev = requireStringParameter('rev', $_GET); $noIgnore = isset($_GET['noignore']) && $_GET['noignore'] == '1'; $result = array(); $stmt = $db->prepare("\n SELECT runs.id, buildbot_id AS _id, buildername, slave, result,\n unix_timestamp(starttime) AS starttime,\n unix_timestamp(endtime) AS endtime\n FROM runs LEFT JOIN builders USING (buildername)\n WHERE runs.branch = :branch AND runs.revision = :revision\n AND runs.buildername IS NOT NULL\n " . ($noIgnore ? "" : "AND builders.hidden != TRUE")); $stmt->execute(array(":branch" => $branch, ":revision" => $rev)); while ($run = $stmt->fetch(PDO::FETCH_ASSOC)) { $notes = $db->prepare("\n SELECT who, note,\n unix_timestamp(timestamp) AS timestamp\n FROM runs_notes\n WHERE run_id = :runid\n ORDER BY timestamp ASC;"); $notes->execute(array(":runid" => $run['id'])); $run["notes"] = $notes->fetchAll(PDO::FETCH_ASSOC); unset($run["id"]); // don’t need the sql internal id $result[] = $run; } echo json_encode($result) . "\n";
<?php /* -*- Mode: PHP; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set sw=2 ts=2 et tw=80 : */ // Returns the change history of the builder identified by $_GET['name']. // [ { "date": 1306421449, "action": "insert / hide / unhide", "who": "...", "reason": "..." }, ... ] require_once 'config.php'; require_once 'inc/Communication.php'; Headers::send(Headers::ALLOW_CROSS_ORIGIN | Headers::NO_CACHE, "application/json"); $name = requireStringParameter('name', $_GET); $stmt = $db->prepare("\n SELECT unix_timestamp(date) AS date, action, who, reason\n FROM builders_history\n JOIN builders ON (builders.id = builder_id)\n WHERE name = :name;"); $stmt->execute(array(":name" => $name)); $result = $stmt->fetchAll(PDO::FETCH_ASSOC); echo json_encode($result) . "\n";
// be made. It has the following format: // { 'name of builder': 'hide / unhide', ... } // Unlisted builders stay unchanged. require_once 'config.php'; if (!defined('SHERIFF_PASSWORD')) { die('Sheriff password missing.'); } require_once 'inc/Communication.php'; Headers::send(Headers::ALLOW_CROSS_ORIGIN, "application/json"); if (requireStringParameter('password', $_POST) != SHERIFF_PASSWORD) { die('{"error": "password"}'); } $ip = $_SERVER['REMOTE_ADDR']; $actions = json_decode(requireStringParameter('actions', $_POST)); $who = requireStringParameter('who', $_POST); $reason = requireStringParameter('reason', $_POST); $db->beginTransaction(); foreach ($actions as $name => $action) { $stmt = $db->prepare("\n SELECT id, hidden\n FROM builders\n WHERE name = :name;"); $stmt->execute(array(":name" => $name)); $current = $stmt->fetch(PDO::FETCH_ASSOC); if (!$current) { continue; } $currentlyHidden = $current['hidden'] == "1"; if ($currentlyHidden && $action != 'unhide' || !$currentlyHidden && $action != 'hide') { continue; } $newHidden = $action == 'hide'; $stmt = $db->prepare("\n UPDATE builders\n SET hidden = :hidden\n WHERE id = :id;"); $stmt->execute(array(":id" => $current["id"], ":hidden" => $newHidden));