Add permissions checks everywhere;

This commit is contained in:
Benjamin Bouvier 2017-05-22 17:47:32 +02:00
Родитель dcdf2ba2e3
Коммит 443bba25a8
34 изменённых файлов: 240 добавлений и 334 удалений

Просмотреть файл

@ -1,104 +0,0 @@
<?php
/**
* Verification library for the BrowserID / Persona authentication system
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* @category Auth
* @package Auth_BrowserID
* @author Francois Marier <francois@mozilla.com>
* @copyright 2013 Mozilla Foundation
* @license http://mozilla.org/MPL/2.0/
* @link http://pear.php.net/package/Auth_BrowserID
* @since File available since Release 0.1.0
*/
class Auth_BrowserID
{
/**
* Scheme, hostname and port
*/
protected $audience;
/**
* Verification type: 'local' or 'remote'
*/
protected $type;
/**
* URL of the remote verifier
*/
protected $verifierUrl;
/**
* Constructor
*
* @param string $audience The scheme, hostname and port of the server
* @param string $type The type of verification ('local' or 'remote')
* @param string $verifierUrl The URL to use for remote verification
*/
public function __construct($audience, $type = 'remote', $verifierUrl = 'https://verifier.login.persona.org/verify')
{
$this->audience = $audience;
$this->type = $type;
$this->verifierUrl = $verifierUrl;
}
/**
* Verify the validity of the assertion received from the user
*
* @param string $assertion The assertion as received from the login dialog
* @param boolean $type The type of verification ('local' or 'remote')
* @return object The response from the Persona online verifier
*/
public function verifyAssertion($assertion)
{
if ($this->type === 'local') {
return $this->verifyLocally($assertion);
} else {
return $this->verifyRemotely($assertion);
}
}
/**
* Contact the identity provider directly when verifying the
* validity of the assertion.
*
* @param string $assertion The assertion as received from the login dialog
* @return object The response from the Persona online verifier
*/
private function verifyLocally($assertion)
{
// Mozilla currently recommends against local verification
// since the details of the certificate format are not yet finalized and
// may change.
throw new Exception("Not implemented.");
}
/**
* Use the verification service at verifier.login.persona.org to
* verify the validity of the assertion.
*
* @param string $assertion The assertion as received from the login dialog
* @return object The response from the Persona online verifier
*/
private function verifyRemotely($assertion)
{
$postdata = 'assertion=' . urlencode($assertion) . '&audience=' . urlencode($this->audience);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->verifierUrl);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
$response = curl_exec($ch);
curl_close($ch);
return json_decode($response);
}
}

Просмотреть файл

@ -6,7 +6,7 @@
if (strpos($_SERVER['SCRIPT_FILENAME'], "UPDATE.php") !== false)
die("Please rename this file to something more unknown.");
require_once("internals.php");
require_once("lib/internals.php");
init_database();

Просмотреть файл

@ -35,11 +35,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("internals.php");
if (!has_permissions()) {
die("You need to be logged in.");
}
require_once("lib/internals.php");
check_permissions();
require_once("lib/DB/Mode.php");
require_once("lib/DB/Machine.php");

Просмотреть файл

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("internals.php");
require_once("lib/internals.php");
require_once("regressions/data-func.php");
init_database();
@ -11,41 +11,42 @@ $subtest = GET_bool("subtest");
$id = GET_int("id");
if ($subtest) {
$score_id = get("breakdown", $id, "score_id");
$score_id = get("breakdown", $id, "score_id");
$prev_breakdown_id = imm_prev_suite_test($id);
$prev_score_id = get("breakdown", $prev_breakdown_id, "score_id");
$prev_build_id = get("score", $prev_score_id, "build_id");
$query = mysql_query("SELECT awfy_regression.id, noise, status
$prev_breakdown_id = imm_prev_suite_test($id);
$prev_score_id = get("breakdown", $prev_breakdown_id, "score_id");
$prev_build_id = get("score", $prev_score_id, "build_id");
$query = mysql_query("SELECT awfy_regression.id, noise, status
FROM `awfy_regression_breakdown`
LEFT JOIN awfy_regression
ON awfy_regression.id = awfy_regression_breakdown.regression_id
WHERE breakdown_id = ".$id." AND
prev_build_id = ".$prev_build_id);
} else {
$score_id = $id;
$score_id = $id;
$prev_score_id = imm_prev_($id);
$prev_build_id = get("score", $prev_score_id, "build_id");
$query = mysql_query("SELECT awfy_regression.id, noise, status
$prev_score_id = imm_prev_($id);
$prev_build_id = get("score", $prev_score_id, "build_id");
$query = mysql_query("SELECT awfy_regression.id, noise, status
FROM `awfy_regression_score`
LEFT JOIN awfy_regression
ON awfy_regression.id = awfy_regression_score.regression_id
WHERE score_id = ".$id." AND
prev_build_id = ".$prev_build_id);
}
$data = Array("regression" => Array());
if (mysql_num_rows($query) >= 1) {
$result = mysql_fetch_object($query);
$result = mysql_fetch_object($query);
$data["regression"]["id"] = $result->id;
if ($result->noise)
$data["regression"]["status"] = "noise";
else
$data["regression"]["status"] = $result->status;
if ($result->noise)
$data["regression"]["status"] = "noise";
else
$data["regression"]["status"] = $result->status;
} else {
$data["regression"]["status"] = "no";
$data["regression"]["status"] = "no";
}
$data["info"] = get("score", $score_id, "extra_info");
echo json_encode($data);
echo json_encode($data);

Просмотреть файл

@ -1,6 +1,6 @@
<?php
include "internals.php";
include "lib/internals.php";
global $config;

Просмотреть файл

@ -1,27 +1,27 @@
<?php
class Slack {
// (string) $message - message to be passed to Slack
// (string) $icon - You can set up custom emoji icons to use with each message
public static function log($message, $icon = ":longbox:")
{
global $config;
// (string) $message - message to be passed to Slack
// (string) $icon - You can set up custom emoji icons to use with each message
public static function log($message, $icon = ":longbox:")
{
global $config;
$data = "payload=" . json_encode(array(
"text" => $message,
"icon_emoji" => $icon
));
// You can get your webhook endpoint from your Slack settings
$url = $config->slack_webhook;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
$data = "payload=" . json_encode(array(
"text" => $message,
"icon_emoji" => $icon
));
// You can get your webhook endpoint from your Slack settings
$url = $config->slack_webhook;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
}

Просмотреть файл

@ -35,7 +35,7 @@ class Config {
}
function throw_exception($exception) {
throw new Exception($exception);
throw new Exception($exception);
}
function init_database()
@ -49,8 +49,8 @@ function username()
{
if (!isset($_SESSION['persona']))
return "guest";
else
return $_SESSION['persona'];
return $_SESSION['persona'];
}
function has_permissions()
@ -61,20 +61,28 @@ function has_permissions()
# Test here which persons have permission to see all benchmarks
if (preg_match("/^[0-9A-Za-z.]*@mozilla\.com$/", $_SESSION['persona'])) {
return true;
} else {
$split = explode("@", $_SESSION['persona'], 2);
if ($split[1] == "gmail.com") {
if ($split[0] == "hv1989")
return true;
} else if ($split[1] == "googlemail.com") {
if ($split[0] == "evilpies")
return true;
}
}
}
$split = explode("@", $_SESSION['persona'], 2);
if ($split[0] == 'hv1989' && split[1] == "gmail.com") {
return true;
}
if ($split[0] == "evilpies" && $split[1] == "googlemail.com") {
return true;
}
return false;
}
function check_permissions()
{
if (!has_permissions()) {
die('You must be logged in to visit this page.');
}
}
function GET_bool($name)
{
if (isset($_GET[$name]))
@ -192,66 +200,66 @@ function awfy_query($query)
return $result;
}
if (!function_exists("mysql_connect")){
/* warning: fatal error "cannot redeclare" if a function was disabled in php.ini with disable_functions:
disable_functions =mysql_connect,mysql_pconnect,mysql_select_db,mysql_ping,mysql_query,mysql_fetch_assoc,mysql_num_rows,mysql_fetch_array,mysql_error,mysql_insert_id,mysql_close,mysql_real_escape_string,mysql_data_seek,mysql_result
*/
if (!function_exists("mysql_connect")) {
/* warning: fatal error "cannot redeclare" if a function was disabled in php.ini with disable_functions:
disable_functions =mysql_connect,mysql_pconnect,mysql_select_db,mysql_ping,mysql_query,mysql_fetch_assoc,mysql_num_rows,mysql_fetch_array,mysql_error,mysql_insert_id,mysql_close,mysql_real_escape_string,mysql_data_seek,mysql_result
*/
function mysql_connect($host, $username, $password){
function mysql_connect($host, $username, $password){
global $dbconnect;
$dbconnect = mysqli_connect($host, $username, $password);
return $dbconnect;
}
}
function mysql_pconnect($host, $username, $password){
global $dbconnect;
$dbconnect = mysqli_connect("p:".$host, $username, $password);
return $dbconnect;
}
}
function mysql_select_db($db){
global $dbconnect;
return mysqli_select_db ( $dbconnect,$db );
}
}
function mysql_ping($dbconnect){
return mysqli_ping ( $dbconnect );
}
}
function mysql_query($stmt){
global $dbconnect;
global $dbconnect;
return mysqli_query ($dbconnect, $stmt );
}
}
function mysql_fetch_assoc($erg){
return mysqli_fetch_assoc ($erg );
}
}
function mysql_num_rows($e){
return mysqli_num_rows ($e );
}
}
function mysql_affected_rows($e=NULL){
return mysqli_affected_rows ($e );
}
}
function mysql_fetch_array($e){
return mysqli_fetch_array ($e );
}
}
function mysql_error(){
global $dbconnect;
global $dbconnect;
return mysqli_error ($dbconnect);
}
}
function mysql_insert_id(){
global $dbconnect;
global $dbconnect;
return mysqli_insert_id ($dbconnect);
}
}
function mysql_close(){
return true;
}
}
function mysql_escape_string($s){
global $dbconnect;
global $dbconnect;
return mysqli_real_escape_string($dbconnect,$s);
}
}
function mysql_real_escape_string($s){
global $dbconnect;
global $dbconnect;
return mysqli_real_escape_string($dbconnect,$s);
}
}
function mysql_data_seek($re,$row){
return mysqli_data_seek($re,$row);
}
}
function mysql_result($res,$row=0,$col=0){
$numrows = mysqli_num_rows($res);
if ($numrows && $row <= ($numrows-1) && $row >=0){

Просмотреть файл

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
include "../internals.php";
include "../lib/internals.php";
init_database();

Просмотреть файл

@ -6,7 +6,7 @@
error_reporting(-1);
include "../internals.php";
include "../lib/internals.php";
init_database();

Просмотреть файл

@ -39,6 +39,7 @@
</header>
<div class='container content' ng-view><div>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
@ -47,23 +48,7 @@
ga('create', 'UA-58850314-2', 'auto');
ga('send', 'pageview');
</script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//arewefastyet.com/piwik/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//arewefastyet.com/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>

Просмотреть файл

@ -3,13 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
if (!has_permissions())
die();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);

Просмотреть файл

@ -3,13 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
if (!has_permissions())
die();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);

Просмотреть файл

@ -3,19 +3,17 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
if (!has_permissions())
die();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
$regression_id = (int)$request->regression_id;
foreach($request->noise->score as $score_id => $noise) {
foreach($request->noise->score as $score_id => $noise) {
$noise = (int)$noise;
$score_id = (int)$score_id;
$query = mysql_query("UPDATE awfy_regression_score SET noise = $noise
@ -24,7 +22,7 @@ foreach($request->noise->score as $score_id => $noise) {
") or die(mysql_error());
}
foreach($request->noise->breakdown as $score_id => $noise) {
foreach($request->noise->breakdown as $score_id => $noise) {
$noise = (int)$noise;
$score_id = (int)$score_id;
$query = mysql_query("UPDATE awfy_regression_breakdown SET noise = $noise

Просмотреть файл

@ -3,13 +3,11 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
if (!has_permissions())
die();
$postdata = file_get_contents("php://input");
$request = json_decode($postdata);
@ -22,7 +20,6 @@ $query = mysql_query("UPDATE awfy_regression SET status = '$status' WHERE id = $
$extra = "Changed status to ".$status;
$query = mysql_query("INSERT INTO awfy_regression_status
(regression_id, name, extra, stamp)
VALUES
('$regression_id', '$name', '$extra', UNIX_TIMESTAMP())
VALUES
('$regression_id', '$name', '$extra', UNIX_TIMESTAMP())
") or die(mysql_error());

Просмотреть файл

@ -3,6 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../lib/internals.php");
check_permissions();
function prev_($sort_order_id, $machine, $mode, $suite, $limit = 1) {
$limit = (int) $limit;
$query = "SELECT awfy_score.id, score, cset

Просмотреть файл

@ -3,44 +3,48 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("data-func.php");
init_database();
$amount = Array();
$query = mysql_query("SELECT awfy_regression.id, build_id FROM awfy_regression
INNER JOIN awfy_build ON awfy_build.id = build_id
WHERE (mode_id = 14 OR
mode_id = 28 or
mode_id = 33 or
mode_id = 26 or
mode_id = 32 or
mode_id = 20) AND
status != 'fixed' AND status != 'improvement'");
INNER JOIN awfy_build ON awfy_build.id = build_id
WHERE (mode_id = 14 OR
mode_id = 28 or
mode_id = 33 or
mode_id = 26 or
mode_id = 32 or
mode_id = 20) AND
status != 'fixed' AND status != 'improvement'");
while ($regs = mysql_fetch_object($query)) {
$qScore = mysql_query("SELECT count(*) as count FROM awfy_regression_score
$qScore = mysql_query("SELECT count(*) as count FROM awfy_regression_score
WHERE regression_id = ".$regs->id);
$score = mysql_fetch_object($qScore);
$qBreakdown = mysql_query("SELECT count(*) as count FROM awfy_regression_breakdown
$score = mysql_fetch_object($qScore);
$qBreakdown = mysql_query("SELECT count(*) as count FROM awfy_regression_breakdown
WHERE regression_id = ".$regs->id);
$breakdown = mysql_fetch_object($qBreakdown);
$qDate = mysql_query("SELECT finish_stamp FROM awfy_build
$breakdown = mysql_fetch_object($qBreakdown);
$qDate = mysql_query("SELECT finish_stamp FROM awfy_build
LEFT JOIN awfy_run ON awfy_run.id = awfy_build.run_id
WHERE awfy_build.id = ".$regs->build_id);
$date = mysql_fetch_object($qDate);
$date_str = date("Y", $date->finish_stamp).",".(date("m", $date->finish_stamp)*1-1).",".date("d", $date->finish_stamp);
$amount[$date_str] += $score->count + $breakdown->count;
$date = mysql_fetch_object($qDate);
$date_str = date("Y", $date->finish_stamp).",".(date("m", $date->finish_stamp)*1-1).",".date("d", $date->finish_stamp);
$amount[$date_str] += $score->count + $breakdown->count;
}
echo "[";
$first = true;
foreach ($amount as $key => $value) {
if (!$first)
echo ',';
if (!$first)
echo ',';
echo '{"c":[{"v":"Date('.$key.')"},{"v":'.$value.'}]}';
$first = false;
$first = false;
}
echo "]";
?>

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
require_once("../lib/ScoreTools.php");
@ -24,4 +26,4 @@ else
$list = ScoreTools::nextList($score, (int)$request->amount);
$last = array_pop($list);
echo ScoreTools::build($last)->run()->approx_stamp();
echo ScoreTools::build($last)->run()->approx_stamp();

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
require_once("data-func.php");

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("../lib/DB/Regression.php");
require_once("../lib/VersionControl.php");

Просмотреть файл

@ -3,7 +3,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
@ -13,11 +14,12 @@ $request = json_decode($postdata);
$query = mysql_query("SELECT *
FROM awfy_regression_status
WHERE regression_id = '".(int)$request->id."'
WHERE regression_id = '".(int)$request->id."'
ORDER BY stamp DESC") or die(mysql_error());
$data = array();
while ($output = mysql_fetch_assoc($query)) {
$data[] = $output;
$data[] = $output;
}
echo json_encode($data);

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
init_database();
require_once("data-func.php");
@ -19,10 +21,10 @@ $ids = array();
$single = true;
if (isset($request->ids)) {
for ($i=0; $i < count($request->ids); $i++)
$ids[] = (int)$request->ids[$i];
$ids[] = (int)$request->ids[$i];
$single = false;
} else {
$ids[] = (int)$request->id;
$ids[] = (int)$request->id;
}
$minimal = isset($request->minimal) ? !!$request->minimal : false;

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("data-func.php");
init_database();

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("data-func.php");
init_database();

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("data-func.php");
init_database();

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("data-func.php");
init_database();

Просмотреть файл

@ -1,3 +1,10 @@
<?php
require_once("../lib/internals.php");
check_permissions();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html ng-app="awfyApp">
<head>
@ -58,22 +65,7 @@
ga('create', 'UA-58850314-2', 'auto');
ga('send', 'pageview');
</script>
</script>
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//arewefastyet.com/piwik/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 1]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//arewefastyet.com/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
</body>
</html>

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("../lib/RetriggerController.php");
init_database();
@ -22,4 +24,3 @@ $retrigger = RetriggerController::fromMachine($machine_id, $mode_id);
$retrigger->convertToRevision($mode_id, $revision, $run_before_id, $run_after_id);
$retrigger->selectBenchmarks($benchmarks);
$retrigger->enqueueNow();

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("../lib/RetriggerController.php");
require_once("../lib/VersionControl/HGWeb.php");
require_once("../lib/DB/ControlTasks.php");

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("../lib/RetriggerController.php");
require_once("../lib/VersionControl/HGWeb.php");
require_once("../lib/DB/ControlTasks.php");

Просмотреть файл

@ -3,7 +3,9 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("../internals.php");
require_once("../lib/internals.php");
check_permissions();
require_once("../lib/RetriggerController.php");
require_once("../lib/VersionControl/HGWeb.php");
require_once("../lib/DB/ControlTasks.php");

Просмотреть файл

@ -1,3 +1,10 @@
<?php
require_once("../lib/internals.php");
check_permissions();
?>
<html>
<head>
<style>
@ -162,7 +169,7 @@ $(function() {
<label>Benchmarks:
<select multiple id='benchmarks'>
</select>
</select>
</label>

Просмотреть файл

@ -41,45 +41,45 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("internals.php");
require_once("lib/internals.php");
check_permissions();
require_once("lib/DB/QueuedTask.php");
require_once("lib/DB/TaskRecipe.php");
init_database();
if (!has_permissions()) {
die("You need to be logged in.");
} else if (isset($_POST["task"])) {
if (isset($_POST["task"])) {
$recipe = new TaskRecipe((int)$_POST["task"]);
$task = $recipe->fill($_POST);
$email = isset($_POST["email"]) ? username() : "";
$recipe = new TaskRecipe((int)$_POST["task"]);
$task = $recipe->fill($_POST);
$email = isset($_POST["email"]) ? username() : "";
$id = QueuedTask::insert($recipe->control_unit_id(), $task, $email);
$id = QueuedTask::insert($recipe->control_unit_id(), $task, $email);
echo "Task submitted. <br />Results will become visible on <a href='https://arewefastyet.com/task_info.php?id=$id'>https://arewefastyet.com/task_info.php?id=$id</a>";
echo "Task submitted. <br />Results will become visible on <a href='https://arewefastyet.com/task_info.php?id=$id'>https://arewefastyet.com/task_info.php?id=$id</a>";
} else {
$recipes = TaskRecipe::all();
$recipes_json = [];
foreach ($recipes as $recipe) {
$recipes_json[] = array(
"id" => $recipe->id,
"name" => $recipe->name(),
"description" => $recipe->description(),
"task" => $recipe->task(),
"inputs" => $recipe->inputs()
);
}
?>
<script>
var recipes = <?php echo json_encode($recipes_json); ?>
</script>
<form method=POST>
<h2>Schedule a task</h2>
<div class='dashboard_content'></div>
<script src='schedule.js'></script>
<script>init_schedule();</script>
</form>
<?php
$recipes = TaskRecipe::all();
$recipes_json = [];
foreach ($recipes as $recipe) {
$recipes_json[] = array(
"id" => $recipe->id,
"name" => $recipe->name(),
"description" => $recipe->description(),
"task" => $recipe->task(),
"inputs" => $recipe->inputs()
);
}
?>
<script>
var recipes = <?php echo json_encode($recipes_json); ?>
</script>
<form method=POST>
<h2>Schedule a task</h2>
<div class='dashboard_content'></div>
<script src='schedule.js'></script>
<script>init_schedule();</script>
</form>
<?php
}
?>
</div>

Просмотреть файл

@ -3,7 +3,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("internals.php");
require_once("lib/internals.php");
require_once("lib/RetriggerController.php");
require_once("lib/DB/TaskQueue.php");
require_once("lib/DB/QueuedTask.php");
@ -23,14 +23,14 @@ if ($unit = GET_int("unit")) {
RetriggerController::fillQueue($unit);
$task = $queue->get_oldest_available_queued_task();
if (!$task) {
echo json_encode(Array(
"task" => "sleep 60",
"id" => 0
));
if (!$task) {
echo json_encode(Array(
"task" => "sleep 60",
"id" => 0
));
sleep(5);
die();
}
die();
}
$task->setStarted();
@ -46,13 +46,13 @@ if ($unit = GET_int("unit")) {
$task = new QueuedTask($task_id);
$task->setFinished();
if (isset($_POST["output"]))
$task->setOutput($_POST["output"]);
$task->setOutput($_POST["output"]);
if ($task->hasEmail()) {
mail($task->email(), "AreWeFastYet task ".$task_id." finished",
"Task ".$task_id." has finished.\r\n".
"You can see the results on https://arewefastyet.com/task_info.php?id=".$task_id);
}
if ($task->hasEmail()) {
mail($task->email(), "AreWeFastYet task ".$task_id." finished",
"Task ".$task_id." has finished.\r\n".
"You can see the results on https://arewefastyet.com/task_info.php?id=".$task_id);
}
die();
}

Просмотреть файл

@ -35,11 +35,8 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
require_once("internals.php");
if (!has_permissions()) {
die("You need to be logged in.");
}
require_once("lib/internals.php");
check_permissions();
require_once("lib/RetriggerController.php");
require_once("lib/DB/TaskQueue.php");