Esempio n. 1
0
{
    global $Conf, $User, $Pset, $Info, $Commit, $Qreq;
    $Info = ContactView::user_pset_info($User, $Pset);
    if (($Commit = $Qreq->newcommit) == null) {
        $Commit = $Qreq->commit;
    }
    if (!$Info->set_commit($Commit)) {
        $Conf->ajaxExit(array("ok" => false, "error" => $Info->repo ? "No repository." : "Commit " . htmlspecialchars($Commit) . " isn’t connected to this repository."));
    }
    return $Info;
}
ContactView::set_path_request(array("/@", "/@/p", "/@/p/h/f", "/@/p/f", "/p/h/f", "/p/f"));
$Qreq = make_qreq();
// user, pset, runner
$User = $Me;
if (isset($Qreq->u) && !($User = ContactView::prepare_user($Qreq->u))) {
    exit;
}
assert($User == $Me || $Me->isPC);
$Pset = ContactView::find_pset_redirect($Qreq->pset);
$Psetid = $Pset->id;
// repo
$Info = user_pset_info();
$Repo = $Info->repo;
$Commit = $Info->commit_hash();
$RecentCommits = $Info->recent_commits();
if (!$Repo || !$Commit || !$Info->can_view_repo_contents || !$Qreq->file) {
    exit;
}
// file
$result = $Repo->gitrun("git cat-file blob {$Commit}:" . escapeshellarg($Qreq->file));
Esempio n. 2
0
<?php

// diff.php -- Peteramati diff page
// HotCRP and Peteramati are Copyright (c) 2006-2015 Eddie Kohler and others
// See LICENSE for open-source distribution terms
require_once "src/initweb.php";
ContactView::set_path_request(array("/@", "/@/p", "/@/p/h", "/@/p/h/h", "/p/h/h"));
if ($Me->is_empty()) {
    $Me->escape();
}
global $User, $Pset, $Info;
$User = $Me;
if (isset($_REQUEST["u"]) && !($User = ContactView::prepare_user($_REQUEST["u"]))) {
    redirectSelf(array("u" => null));
}
assert($User == $Me || $Me->isPC);
Ht::stash_script("peteramati_uservalue=" . json_encode($Me->user_linkpart($User)));
$Pset = ContactView::find_pset_redirect(@$_REQUEST["pset"]);
$Info = ContactView::user_pset_info($User, $Pset);
if (!get($_GET, "commit") || !get($_GET, "commit1") || $Pset->gitless) {
    $Me->escape();
}
$diff_options = ["wdiff" => false];
$hasha = $hashb = $hasha_mine = $hashb_mine = null;
$hrecent = $Pset->handout_commits();
if ($hasha = git_commit_in_list($hrecent, $_GET["commit"])) {
    $diff_options["hasha_hrepo"] = true;
} else {
    $hasha = $hasha_mine = $Info->set_commit($_GET["commit"]);
}
if ($hashb = git_commit_in_list($hrecent, $_GET["commit1"])) {
Esempio n. 3
0
<?php

// profile.php -- Peteramati user profile page
// HotCRP and Peteramati are Copyright (c) 2006-2015 Eddie Kohler and others
// Distributed under an MIT-like license; see LICENSE
require_once "src/initweb.php";
ContactView::set_path_request(array("/u"));
if ($Me->is_empty()) {
    $Me->escape();
}
global $User, $Pset, $Info, $Commit;
$User = $Me;
if (isset($_REQUEST["u"]) && (!$Me->isPC || !($User = ContactView::prepare_user($_REQUEST["u"])))) {
    redirectSelf(array("u" => null));
}
assert($User == $Me || $Me->isPC);
assert($Me->privChair);
if (@$_POST["enable"] && check_post()) {
    UserActions::enable(array($User->contactId), $Me);
    redirectSelf();
}
if (@$_POST["disable"] && check_post()) {
    UserActions::disable(array($User->contactId), $Me);
    redirectSelf();
}
if (@$_POST["update"] && check_post()) {
    $ck = $cv = array();
    $roles = 0;
    if (@$_POST["pctype"] === "chair") {
        $roles |= Contact::ROLE_CHAIR | Contact::ROLE_PC;
    } else {
Esempio n. 4
0
<?php

// face.php -- Peteramati face page
// HotCRP and Peteramati are Copyright (c) 2006-2015 Eddie Kohler and others
// See LICENSE for open-source distribution terms
require_once "src/initweb.php";
ContactView::set_path_request(array("/u"));
if ($Me->is_empty()) {
    $Me->escape();
}
global $User, $Pset, $Info;
$User = $Me;
if (isset($_REQUEST["u"])) {
    $User = ContactView::prepare_user($_REQUEST["u"]);
}
if (isset($_REQUEST["imageid"])) {
    if ($User && ($User === $Me || $Me->isPC) && $_REQUEST["imageid"] && ($result = Dbl::qe("select mimetype, `data` from ContactImage where contactId=? and contactImageId=?", $User->contactId, $_REQUEST["imageid"])) && ($row = edb_row($result))) {
        header("Content-Type: {$row['0']}");
        header("Cache-Control: public, max-age=31557600");
        header("Expires: " . gmdate("D, d M Y H:i:s", $Now + 31557600) . " GMT");
        if (!$zlib_output_compression) {
            header("Content-Length: " . strlen($row[1]));
        }
        print $row[1];
    } else {
        header("Content-Type: image/gif");
        if (!$zlib_output_compression) {
            header("Content-Length: 43");
        }
        print "GIF89a€!ù,D;";
    }
Esempio n. 5
0
function runmany($qreq)
{
    global $Conf, $Me;
    if (!($pset = $Conf->pset_by_key($qreq->pset)) || $pset->disabled) {
        return $Conf->errorMsg("No such pset");
    } else {
        if ($pset->gitless) {
            return $Conf->errorMsg("Pset has no repository");
        }
    }
    $users = array();
    foreach ($qreq as $k => $v) {
        if (substr($k, 0, 4) == "s61_" && $v && ($uname = urldecode(substr($k, 4))) && ($user = ContactView::prepare_user($uname, $pset))) {
            $users[] = $Me->user_linkpart($user);
        }
    }
    if (empty($users)) {
        return $Conf->errorMsg("No users selected.");
    }
    go(hoturl_post("run", array("pset" => $pset->urlkey, "run" => $qreq->runner, "runmany" => join(" ", $users))));
    redirectSelf();
}
Esempio n. 6
0
{
    global $Conf, $User, $Pset, $Info, $Qreq;
    $Info = ContactView::user_pset_info($User, $Pset);
    if (($Commit = $Qreq->newcommit) == null) {
        $Commit = $Qreq->commit;
    }
    if (!$Info->set_commit($Commit)) {
        $Conf->ajaxExit(array("ok" => false, "error" => $Info->repo ? "No repository." : "Commit " . htmlspecialchars($Commit) . " isn’t connected to this repository."));
    }
    return $Info;
}
ContactView::set_path_request(array("/@", "/@/p", "/@/p/H", "/p", "/p/H", "/p/u", "/p/u/H"));
$Qreq = make_qreq();
// user, pset, runner
$User = $Me;
if ($Qreq->u !== null && !($User = ContactView::prepare_user($Qreq->u))) {
    $Conf->ajaxExit(["ok" => false]);
}
assert($User == $Me || $Me->isPC);
$Pset = ContactView::find_pset_redirect($Qreq->pset);
$Psetid = $Pset->id;
// XXX this should be under `api`
if ($Qreq->flag && check_post($Qreq) && user_pset_info()) {
    $flags = (array) $Info->current_info("flags");
    if ($Qreq->flagid && !isset($flags["t" . $Qreq->flagid])) {
        json_exit(["ok" => false, "error" => "No such flag"]);
    }
    if (!$Qreq->flagid) {
        $Qreq->flagid = "t" . $Now;
    }
    $flag = get($flags, $Qreq->flagid, []);
Esempio n. 7
0
function runmany()
{
    global $Conf, $Me;
    if (!($pset = Pset::find(@$_REQUEST["pset"])) || $pset->disabled) {
        return $Conf->errorMsg("No such pset");
    } else {
        if ($pset->gitless) {
            return $Conf->errorMsg("Pset has no repository");
        }
    }
    $users = array();
    foreach ($_POST as $k => $v) {
        if (substr($k, 0, 4) == "s61_" && $v && ($uname = substr($k, 4)) && ($user = ContactView::prepare_user($uname, $pset))) {
            $users[] = $Me->user_linkpart($user);
        }
    }
    if (!count($users)) {
        return $Conf->errorMsg("No users selected.");
    }
    go(hoturl_post("run", array("pset" => $pset->urlkey, "run" => $_REQUEST["runner"], "runmany" => join(" ", $users))));
    redirectSelf();
}