Example #1
0
 $linesubmission = @file_get_contents($_SESSION["locr"] . $ds . "private" . $ds . 'run-using-command.config');
 if (trim($linesubmission) == '1') {
     $strtmp .= "<br><br><center><b>To submit a program, use the command-line tool:</b>\n<br>" . "<pre>boca-submit-run USER PASSWORD PROBLEM LANGUAGE FILE</pre><br>" . "where USER is your username, PASSWORD is your password, <br>" . "PROBLEM is one of { ";
     $prob = DBGetProblems($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usertype"] == 'judge');
     for ($i = 0; $i < count($prob); $i++) {
         $strtmp .= $prob[$i]["problem"] . " ";
     }
     $strtmp .= "} and<br>LANGUAGE is one of { ";
     $lang = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
     for ($i = 0; $i < count($lang); $i++) {
         $strtmp .= $lang[$i]["name"] . " ";
     }
     $strtmp .= "}<br>FILE is your submission file<br><br>\n";
 } else {
     $strtmp .= "<br><br><center><b>To submit a program, just fill in the following fields:</b></center>\n" . "<form name=\"form1\" enctype=\"multipart/form-data\" method=\"post\" action=\"" . $runteam . "\">\n" . "  <input type=hidden name=\"confirmation\" value=\"noconfirm\" />\n" . "  <center>\n" . "    <table border=\"0\">\n" . "      <tr> \n" . "        <td width=\"25%\" align=right>Problem:</td>\n" . "        <td width=\"75%\">\n" . "          <select name=\"problem\" onclick=\"Arquivo()\">\n";
     $prob = DBGetProblems($_SESSION["usertable"]["contestnumber"], $_SESSION["usertable"]["usertype"] == 'judge');
     $strtmp .= "<option selected value=\"-1\"> -- </option>\n";
     for ($i = 0; $i < count($prob); $i++) {
         $strtmp .= "<option value=\"" . $prob[$i]["number"] . "\">" . $prob[$i]["problem"] . "</option>\n";
     }
     $strtmp .= "\t  </select>\n" . "        </td>\n" . "      </tr>\n" . "      <tr> \n" . "        <td width=\"25%\" align=right>Language:</td>\n" . "        <td width=\"75%\"> \n" . "          <select name=\"language\" onclick=\"Arquivo()\">\n";
     $lang = DBGetLanguages($_SESSION["usertable"]["contestnumber"]);
     $strtmp .= "<option selected value=\"-1\"> -- </option>\n";
     for ($i = 0; $i < count($lang); $i++) {
         $strtmp .= "<option value=\"" . $lang[$i]["number"] . "\">" . $lang[$i]["name"] . "</option>\n";
     }
     $strtmp .= "\t  </select>\n" . "        </td>\n" . "      </tr>\n" . "      <tr> \n" . "        <td width=\"25%\" align=right>Source code:</td>\n" . "        <td width=\"75%\">\n" . "\t  <input type=\"file\" name=\"sourcefile\" size=\"40\" onclick=\"Arquivo()\">\n" . "        </td>\n" . "      </tr>\n" . "    </table>\n" . "  </center>\n" . "  <script language=\"javascript\">\n" . "    function conf() {\n" . "      if (document.form1.problem.value != '-1' && document.form1.language.value != '-1') {\n" . "       if (confirm(\"Confirm submission?\")) {\n" . "        document.form1.confirmation.value='confirm';\n" . "       }\n" . "      } else {\n" . "        alert('Invalid problem and/or language');\n" . "      }\n" . "    }\n" . "  </script>\n" . "  <center>\n" . "      <input type=\"submit\" name=\"Submit\" value=\"Send\" onClick=\"conf()\">\n" . "      <input type=\"reset\" name=\"Submit2\" value=\"Clear\">\n" . "  </center>\n" . "</form>\n";
 }
 $conf = globalconf();
 $strtmp1 = "<!-- " . time() . " --> <?php exit; ?>\t" . encryptData($strcolors, $conf["key"], false) . "\n" . encryptData($strtmp, $conf["key"], false);
 $randnum = session_id() . "_" . rand();
Example #2
0
function DBRunReport($contest, $site)
{
    $c = DBConnect();
    $sql = "select r.runnumber as number, u.usernumber as un, u.username as user, r.rundatediff as timestamp, " . "p.problemname as problem, l.langname as language, a.runanswer as answer, a.yes as yes " . "from runtable as r, problemtable as p, langtable as l, answertable as a, usertable as u " . "where r.contestnumber={$contest} and p.contestnumber=r.contestnumber and " . "r.runproblem=p.problemnumber and l.contestnumber=r.contestnumber and " . "l.langnumber=r.runlangnumber and a.answernumber=r.runanswer and " . "a.contestnumber=r.contestnumber and (r.runstatus = 'judged' or r.runstatus = 'judged+') and " . "u.usernumber=r.usernumber and u.contestnumber={$contest} and " . "u.usersitenumber=r.runsitenumber and u.usertype='team'";
    if ($site != "") {
        $sql .= " and r.runsitenumber={$site}";
    }
    $xdados = array();
    $xuser = array();
    $xuserfull = array();
    $xuseryes = array();
    $xproblem = array();
    $xproblemyes = array();
    $xusername = array();
    $r = DBExec($c, "select usernumber as un, username as name, userfullname as fullname " . "from usertable where contestnumber={$contest} " . "and usersitenumber={$site} and " . "usertype='team' and userlastlogin is not null and userenabled='t'", "DBRunReport(get users)");
    $n = DBnlines($r);
    for ($i = 0; $i < $n; $i++) {
        $a = DBRow($r, $i);
        $xusername[$a['un']] = $a['name'];
        $xuserfull[$a['name']] = $a['fullname'];
    }
    ksort($xusername);
    $pr = DBGetProblems($contest);
    for ($i = 0; $i < count($pr); $i++) {
        $xproblem[$pr[$i]['problem']] = 0;
        $xproblemyes[$pr[$i]['problem']] = 0;
        $xcolor[$pr[$i]['problem']] = $pr[$i]['color'];
    }
    $xlanguage = array();
    $xlanguageyes = array();
    $xanswer = array();
    $xtimestamp = array();
    $xtimestampyes = array();
    $r = DBExec($c, $sql, "DBRunReport(get runs)");
    $n = DBnlines($r);
    for ($i = 0; $i < $n; $i++) {
        $a = DBRow($r, $i);
        $xdados[$i] = $a;
        // # of runs by team
        if (isset($xuser[$a['user']])) {
            $xuser[$a['user']]++;
        } else {
            $xuser[$a['user']] = 1;
        }
        // # of runs by problem
        if (isset($xproblem[$a['problem']])) {
            $xproblem[$a['problem']]++;
        } else {
            $xproblem[$a['problem']] = 1;
        }
        if ($a['yes'] == 't') {
            if (isset($xuseryes[$a['user']])) {
                $xuseryes[$a['user']]++;
            } else {
                $xuseryes[$a['user']] = 1;
            }
            $xproblemyes[$a['problem']]++;
        }
        // # of runs by language
        if (isset($xlanguage[$a['language']])) {
            $xlanguage[$a['language']]++;
        } else {
            $xlanguage[$a['language']] = 1;
        }
        if ($a['yes'] == 't') {
            if (isset($xlanguageyes[$a['language']])) {
                $xlanguageyes[$a['language']]++;
            } else {
                $xlanguageyes[$a['language']] = 1;
            }
        }
        // # of runs by answer
        if (isset($xanswer[$a['answer']])) {
            $xanswer[$a['answer']]++;
        } else {
            $xanswer[$a['answer']] = 1;
        }
        // time of the runs
        array_push($xtimestamp, $a['timestamp']);
        if ($a['yes'] == 't') {
            array_push($xtimestampyes, $a['timestamp']);
        }
        // # of runs by answer by problem
        if (isset($xpa[$a['problem']][$a['answer']])) {
            $xpa[$a['problem']][$a['answer']]++;
        } else {
            $xpa[$a['problem']][$a['answer']] = 1;
        }
        // # of runs by language by problem
        if (isset($xpl[$a['problem']][$a['language']])) {
            $xpl[$a['problem']][$a['language']]++;
        } else {
            $xpl[$a['problem']][$a['language']] = 1;
        }
        // # of runs by answer by language
        if (isset($xla[$a['language']][$a['answer']])) {
            $xla[$a['language']][$a['answer']]++;
        } else {
            $xla[$a['language']][$a['answer']] = 1;
        }
        // # of runs by problem by user
        // negative sign means team got an yes for the problem
        if (!isset($xup[$a['user']][$a['problem']])) {
            $xup[$a['user']][$a['problem']] = 0;
        }
        if ($xup[$a['user']][$a['problem']] < 0) {
            $xup[$a['user']][$a['problem']]--;
        } else {
            $xup[$a['user']][$a['problem']]++;
            if ($a['yes'] == 't') {
                $xup[$a['user']][$a['problem']] = -$xup[$a['user']][$a['problem']];
            }
        }
    }
    ksort($xuser);
    ksort($xuseryes);
    ksort($xproblem);
    ksort($xproblemyes);
    ksort($xlanguage);
    ksort($xlanguageyes);
    ksort($xanswer);
    sort($xtimestamp);
    sort($xtimestampyes);
    $x = array('color' => $xcolor, 'user' => $xuser, 'useryes' => $xuseryes, 'username' => $xusername, 'userfull' => $xuserfull, 'problem' => $xproblem, 'problemyes' => $xproblemyes, 'language' => $xlanguage, 'languageyes' => $xlanguageyes, 'answer' => $xanswer, 'timestamp' => $xtimestamp, 'timestampyes' => $xtimestampyes, 'pa' => $xpa, 'pl' => $xpl, 'la' => $xla, 'up' => $xup);
    return $x;
}
Example #3
0
        }
    } else {
        echo base64_encode(serialize(array()));
    }
    exit;
}
if (!$redo) {
    $conf = globalconf();
    $strtmp = decryptData(substr($strtmp, strpos($strtmp, "\n")), $conf["key"], 'score');
    if ($strtmp == "") {
        $redo = TRUE;
    }
}
if ($redo) {
    $strtmp = "<script language=\"JavaScript\" src=\"" . $loc . "/hide.js\"></script>\n";
    $pr = DBGetProblems($_SESSION["usertable"]["contestnumber"]);
    $ct = DBGetActiveContest();
    $contest = $ct['contestnumber'];
    $duration = $ct['contestduration'];
    if (!isset($hor)) {
        $hor = -1;
    }
    if ($hor > $duration) {
        $hor = $duration;
    }
    $level = $s["sitescorelevel"];
    if ($level <= 0) {
        $level = -$level;
    } else {
        $des = true;
    }
Example #4
0
function DBScore($contest, $verifylastmile, $hor = -1, $globalsite = '0')
{
    $c = DBConnect();
    $r = DBExec($c, "select sitenumber as number from sitetable where contestnumber={$contest} and siteactive='t'", "DBScore(get site)");
    $n = DBnlines($r);
    if ($n == 0) {
        LOGError("Unable to get site information. No active sites available (contest={$contest})");
        MSGError("Unable to get site information. No active sites available. Contact an admin now!");
        exit;
    }
    $a = array();
    $resp = array();
    $whichsites = explode(',', $globalsite);
    for ($i = 0; $i < $n; $i++) {
        $a = DBRow($r, $i);
        if (in_array($a["number"], $whichsites) || in_array(0, $whichsites)) {
            list($resp1, $data0) = DBScoreSite($contest, $a["number"], $verifylastmile, $hor);
            $resp = array_merge($resp, $resp1);
        }
    }
    $ds = DIRECTORY_SEPARATOR;
    if ($ds == "") {
        $ds = "/";
    }
    $probs = DBGetProblems($contest);
    $nprobs = count($probs);
    $scoreitems = glob($_SESSION['locr'] . $ds . "private" . $ds . "remotescores" . $ds . "score*.dat", GLOB_NOSORT);
    array_multisort(array_map('filemtime', $scoreitems), SORT_NUMERIC, SORT_DESC, $scoreitems);
    foreach ($scoreitems as $fname) {
        $namear = explode('_', $fname);
        $overloadsite = -1;
        if (isset($namear[3]) && trim($namear[2]) != '' && is_numeric($namear[2])) {
            $overloadsite = $namear[2];
        }
        $fc = file_get_contents($fname);
        if (($arr = unserialize(base64_decode($fc))) === false) {
            LOGError("File " . sanitizeText($fname) . " is not compatible");
        } else {
            if (is_array($arr)) {
                if (isset($arr['site'])) {
                    $site = $arr['site'];
                    if ($overloadsite > 0) {
                        $site = $overloadsite;
                    }
                    if (!in_array($site, $whichsites) && !in_array(0, $whichsites)) {
                        continue;
                    }
                    $fine = 1;
                    reset($resp);
                    while (list($e, $c) = each($resp)) {
                        if ($resp[$e]['site'] == $site) {
                            $fine = 0;
                            break;
                        }
                    }
                    if ($fine) {
                        list($arr, $data0) = DBScoreSite($contest, $site, $verifylastmile, $hor, $arr);
                        reset($arr);
                        while (list($ee, $cc) = each($arr)) {
                            if ($site != $arr[$ee]['site']) {
                                $arr[$ee] = null;
                                unset($arr[$ee]);
                            } else {
                                // just to make the color of the other site changed to the color of the problem in this site
                                while (list($e2, $c2) = each($arr[$ee]["problem"])) {
                                    for ($prob = 0; $prob < $nprobs; $prob++) {
                                        if ($probs[$prob]['number'] == $e2) {
                                            $arr[$ee]['problem'][$e2]['color'] = $probs[$prob]['color'];
                                            $arr[$ee]['problem'][$e2]['colorname'] = $probs[$prob]['colorname'];
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        $resp = array_merge($resp, $arr);
                    }
                } else {
                    // old version -- just for compatibility ---
                    while (list($ee, $cc) = each($arr)) {
                        $fine = 1;
                        reset($resp);
                        while (list($e, $c) = each($resp)) {
                            if ($resp[$e]['site'] == $arr[$ee]['site']) {
                                $fine = 0;
                                break;
                            }
                        }
                        if ($fine == 0) {
                            $arr[$ee] = null;
                        } else {
                            // just to make the color of the other site changed to the color of the problem in this site
                            while (list($e2, $c2) = each($arr[$ee]["problem"])) {
                                for ($prob = 0; $prob < $nprobs; $prob++) {
                                    if ($probs[$prob]['number'] == $e2) {
                                        $arr[$ee]['problem'][$e2]['color'] = $probs[$prob]['color'];
                                        $arr[$ee]['problem'][$e2]['colorname'] = $probs[$prob]['colorname'];
                                        break;
                                    }
                                }
                            }
                        }
                    }
                    $resp = array_merge($resp, $arr);
                    // ---- end of old version ---
                }
            }
            //		MSGError("got scores from $fname");
        }
    }
    if (($result = ordena($resp)) === false) {
        LOGError("Error while sorting scores (contest={$contest}).");
        MSGError("Error while sorting scores. Contact an admin now!");
    }
    return $result;
}