Example #1
0
 }
 $level = $s["sitescorelevel"];
 if ($level <= 0) {
     $level = -$level;
 } else {
     $des = true;
 }
 if (($s = DBSiteInfo($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"])) == null) {
     ForceLoad("index.php");
 }
 $score = DBScore($_SESSION["usertable"]["contestnumber"], $ver, $hor * 60, $s["siteglobalscore"]);
 if ($_SESSION["usertable"]["usertype"] != "score" && $_SESSION["usertable"]["usertype"] != "admin" && $level > 3) {
     $level = 3;
 }
 $minu = 3;
 $rn = DBRecentNews($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usersitenumber"], $ver, $minu);
 if (count($rn) > 0 && $level > 3) {
     $strtmp .= "<table border=0><tr>";
     $strtmp .= "<td>News (last {$minu}'): &nbsp;</td>\n";
     for ($i = 0; $i < count($rn); $i++) {
         $strtmp .= "<td width=200>";
         if ($rn[$i]["yes"] == 't') {
             $strtmp .= "<img alt=\"" . $rn[$i]["colorname"] . ":\" width=\"28\" " . "src=\"" . balloonurl($rn[$i]["color"]) . "\" />";
         } else {
             $strtmp .= "<img alt=\"\" width=\"22\" " . "src=\"{$loc}/images/bigballoontransp-blink.gif\" />\n";
         }
         $strtmp .= $rn[$i]["problemname"] . ": " . $rn[$i]["userfullname"] . " (" . (int) ($rn[$i]["time"] / 60) . "')";
         $strtmp .= "</td>\n";
     }
     $strtmp .= "</tr></table>";
 }
Example #2
0
function DBScoreSite($contest, $site, $verifylastmile, $hor = -1, $data = null)
{
    if (($blocal = DBSiteInfo($contest, $_SESSION["usertable"]["usersitenumber"])) == null) {
        exit;
    }
    if (($b = DBSiteInfo($contest, $site, null, false)) == null) {
        $b = $blocal;
    }
    if (($ct = DBContestInfo($contest)) == null) {
        exit;
    }
    $t = time();
    $ta = $blocal["currenttime"];
    if ($hor >= 0) {
        $ta = $hor;
    }
    if ($verifylastmile) {
        $tf = $b["sitelastmilescore"];
    } else {
        $tf = $b["siteduration"];
    }
    if ($data != null && is_numeric($data)) {
        if ($data < $ta) {
            $ta = $data;
        }
        $data = null;
    }
    $data0 = array();
    if ($data == null) {
        $c = DBConnect();
        $resp = array();
        $r = DBExec($c, "select * from usertable where contestnumber={$contest} and usersitenumber={$site} and " . "usertype='team' and userlastlogin is not null and userenabled='t'", "DBScoreSite(get users)");
        $n = DBnlines($r);
        for ($i = 0; $i < $n; $i++) {
            $a = DBRow($r, $i);
            $resp[$a["usernumber"]]["user"] = $a["usernumber"];
            $resp[$a["usernumber"]]["site"] = $a["usersitenumber"];
            $resp[$a["usernumber"]]["username"] = $a["username"];
            $resp[$a["usernumber"]]["usertype"] = $a["usertype"];
            $resp[$a["usernumber"]]["userfullname"] = $a["userfullname"];
            $resp[$a["usernumber"]]["totaltime"] = 0;
            $resp[$a["usernumber"]]["totalcount"] = 0;
            $resp[$a["usernumber"]]["problem"] = array();
        }
        $r = DBExec($c, "select r.usernumber as user, p.problemname as problemname, r.runproblem as problem, " . "p.problemcolor as color, p.problemcolorname as colorname, " . "r.rundatediff as time, r.rundatediffans as anstime, a.yes as yes, r.runanswer as answer from " . "runtable as r, answertable as a, problemtable as p where r.runanswer=a.answernumber and " . "a.contestnumber={$contest} and p.problemnumber=r.runproblem and p.contestnumber={$contest} and " . "r.contestnumber={$contest} and r.runsitenumber={$site} and (r.runstatus ~ 'judged' or r.runstatus ~ 'judged+') and " . "r.rundatediff>=0 and r.rundatediff<={$tf} and r.rundatediffans<={$ta} " . "order by r.usernumber, r.runproblem, r.rundatediff", "DBScoreSite(get runs)");
        $n = DBnlines($r);
        $a = array();
        for ($i = 0; $i < $n; $i++) {
            $a[$i] = DBRow($r, $i);
        }
        $data0['n'] = $n;
        $data0['resp'] = $resp;
        $data0['a'] = $a;
        $data0['site'] = $site;
    } else {
        $resp = $data['resp'];
        $n = $data['n'];
        $a = $data['a'];
    }
    $i = 0;
    while ($i < $n) {
        if ($a[$i]["anstime"] > $ta) {
            $i++;
            continue;
        }
        $user = $a[$i]["user"];
        $problem = $a[$i]["problem"];
        $time = 0;
        $k = 0;
        if (!isset($resp[$user])) {
            $i++;
            continue;
        }
        $resp[$user]["user"] = $user;
        $resp[$user]["site"] = $site;
        $resp[$user]["problem"][$problem]["name"] = $a[$i]["problemname"];
        $resp[$user]["problem"][$problem]["color"] = $a[$i]["color"];
        $resp[$user]["problem"][$problem]["colorname"] = $a[$i]["colorname"];
        $resp[$user]["problem"][$problem]["solved"] = false;
        $resp[$user]["problem"][$problem]["judging"] = false;
        $resp[$user]["problem"][$problem]["time"] = 0;
        $resp[$user]["problem"][$problem]["penalty"] = 0;
        $resp[$user]["problem"][$problem]["count"] = 0;
        while ($i < $n && $a[$i]["anstime"] <= $ta && $a[$i]["user"] == $user && $a[$i]["problem"] == $problem && $a[$i]["yes"] != 't') {
            $time += (int) ($ct["contestpenalty"] / 60);
            $k++;
            $i++;
        }
        $resp[$user]["problem"][$problem]["count"] = $k;
        if ($i >= $n) {
            break;
        }
        if ($a[$i]["anstime"] <= $ta && $a[$i]["user"] == $user && $a[$i]["problem"] == $problem && $a[$i]["yes"] == 't') {
            $timet = (int) ($a[$i]["time"] / 60);
            if (!isset($resp[$user]["first"]) || $timet < $resp[$user]["first"]) {
                $resp[$user]["first"] = $timet;
            }
            $time += $timet;
            $resp[$user]["problem"][$problem]["time"] = $timet;
            $resp[$user]["problem"][$problem]["penalty"] = $time;
            $resp[$user]["problem"][$problem]["solved"] = true;
            $resp[$user]["problem"][$problem]["count"]++;
            $resp[$user]["totaltime"] += $time;
            $resp[$user]["totalcount"]++;
        }
        while ($i < $n && $a[$i]["user"] == $user && $a[$i]["problem"] == $problem) {
            $i++;
        }
    }
    if ($data == null) {
        $aa = DBRecentNews($contest, $site, $verifylastmile, $ta);
        $data0['aa'] = $aa;
    } else {
        $aa = $data['aa'];
    }
    for ($i = 0; $i < count($aa); $i++) {
        if ($aa[$i]["fut"] == 't') {
            $resp[$aa[$i]["usernumber"]]["problem"][$aa[$i]["problemnumber"]]["judging"] = true;
        }
    }
    if (($result = ordena($resp)) === false) {
        LOGError("Error while sorting scores (contest={$contest}, site={$site}).");
        MSGError("Error while sorting scores. Contact an admin now!");
    }
    return array($result, $data0);
}