예제 #1
0
파일: fcontest.php 프로젝트: sbaldrich/boca
function DBSiteEndNow($contest, $site, $w = 0)
{
    $s = DBSiteInfo($contest, $site);
    if (!$s["siterunning"]) {
        return false;
    }
    if ($w == 0) {
        $t = time();
    } else {
        $t = $w;
    }
    $c = DBConnect();
    DBExec($c, "begin work");
    DBExec($c, "lock table runtable");
    $a = DBGetRow("select max(rundate) as t from runtable where contestnumber={$contest} and " . "runsitenumber={$site} and not runstatus ~ 'deleted'", 0);
    if ($a["t"] >= $t) {
        LOGLevel("Unable to stop a contest before an existing run", 2);
        MSGError("Impossible to stop a contest before an existing run");
        DBExec($c, "commit work");
        return false;
    }
    DBExec($c, "update sitetimetable set siteenddate={$t}, updatetime=" . time() . " " . "where contestnumber={$contest} and sitenumber={$site} and siteenddate=0");
    DBExec($c, "commit work");
    LOGLevel("Site {$site} (contest={$contest}) stopped at " . dateconv(time()), 2);
    return true;
}
예제 #2
0
파일: flog.php 프로젝트: justomiguel/boca
function DBLogInContest($name, $pass, $contest, $msg = true)
{
    $b = DBGetRow("select * from contesttable where contestnumber={$contest}", 0, null, "DBLogIn(get active contest)");
    if ($b == null) {
        LOGLevel("There is no contest {$contest}.", 0);
        if ($msg) {
            MSGError("There is no contest {$contest}, contact an admin.");
        }
        return false;
    }
    $d = DBSiteInfo($b["contestnumber"], $b["contestlocalsite"], null, false);
    if ($d == null) {
        if ($msg) {
            MSGError("There is no active site, contact an admin.");
        }
        return false;
    }
    $a = DBGetRow("select * from usertable where username='******' and contestnumber=" . $b["contestnumber"] . " and " . "usersitenumber=" . $b["contestlocalsite"], 0, null, "DBLogIn(get user)");
    if ($a == null) {
        if ($msg) {
            LOGLevel("User {$name} tried to log in contest {$contest} but it does not exist.", 2);
            MSGError("User does not exist or incorrect password.");
        }
        return false;
    }
    $a = DBUserInfo($b["contestnumber"], $b["contestlocalsite"], $a['usernumber'], null, false);
    $_SESSION['usertable'] = $a;
    $p = myhash($a["userpassword"] . session_id());
    $_SESSION['usertable']['userpassword'] = $p;
    if ($a["userpassword"] != "" && $p != $pass) {
        LOGLevel("User {$name} tried to log in contest {$contest} but password was incorrect.", 2);
        if ($msg) {
            MSGError("Incorrect password.");
        }
        unset($_SESSION["usertable"]);
        return false;
    }
    if ($d["sitepermitlogins"] == "f" && $a["usertype"] != "admin" && $a["usertype"] != "judge" && $a["usertype"] != "site") {
        LOGLevel("User {$name} tried to login contest {$contest} but logins are denied.", 2);
        if ($msg) {
            MSGError("Logins are not allowed.");
        }
        unset($_SESSION["usertable"]);
        return false;
    }
    if ($a["userenabled"] != "t") {
        LOGLevel("User {$name} tried to log in contest {$contest} but it is disabled.", 2);
        if ($msg) {
            MSGError("User disabled.");
        }
        unset($_SESSION["usertable"]);
        return false;
    }
    $gip = getIP();
    if ($a["userip"] != $gip && $a["userip"] != "" && $a["usertype"] != "score") {
        LOGLevel("User {$name} is using two different IPs: " . $a["userip"] . "(" . dateconv($a["userlastlogin"]) . ") and " . $gip, 1);
        if ($msg && $a["usertype"] != "admin") {
            MSGError("You are using two distinct IPs. Admin notified.");
        }
    }
    if ($a["userpermitip"] != "") {
        $ips = explode(';', $a["userpermitip"]);
        $gips = explode(';', $gip);
        if (count($gips) < count($ips)) {
            IntrusionNotify("Invalid IP: " . $gip);
            ForceLoad("index.php");
        }
        for ($ipss = 0; $ipss < count($ips); $ipss++) {
            $gipi = $gips[$ipss];
            $ipi = $ips[$ipss];
            if (!match_network($ipi, $gipi)) {
                IntrusionNotify("Invalid IP: " . $gip);
                ForceLoad("index.php");
            }
        }
    }
    $c = DBConnect();
    $t = time();
    if ($a["usertype"] == "team" && $a["usermultilogin"] != "t" && $a["userpermitip"] == "") {
        $r = DBExec($c, "update usertable set userip='" . $gip . "', updatetime=" . time() . ", userpermitip='" . $gip . "'," . "userlastlogin={$t}, usersession='" . session_id() . "' where username='******' and contestnumber=" . $b["contestnumber"] . " and usersitenumber=" . $b["contestlocalsite"], "DBLogIn(update session)");
    } else {
        DBExec($c, "begin work");
        $sql = "update usertable set usersessionextra='" . session_id() . "' where username='******' and contestnumber=" . $b["contestnumber"] . " and usersitenumber=" . $b["contestlocalsite"] . " and (usersessionextra='' or userip != '" . $gip . "' or userlastlogin<=" . ($t - 86400) . ")";
        DBExec($c, $sql);
        DBExec($c, "update usertable set userip='" . $gip . "', updatetime=" . time() . ", userlastlogin={$t}, " . "usersession='" . session_id() . "' where username='******' and contestnumber=" . $b["contestnumber"] . " and usersitenumber=" . $b["contestlocalsite"], "DBLogIn(update user)");
        if ($name == 'admin') {
            list($clockstr, $clocktime) = siteclock();
            if ($clocktime < -600) {
                DBExec($c, "update contesttable set contestunlockkey='' where contestnumber=" . $b["contestnumber"], "DBLogInContest(update contest)");
            }
        }
        DBExec($c, "commit work");
    }
    LOGLevel("User {$name} authenticated (" . $gip . ")", 2);
    return $a;
}
예제 #3
0
파일: log.php 프로젝트: sbaldrich/boca
  <td><b><a href="log.php?order=type&limit=<?php 
echo $limit;
?>
">Type</a></b></td>
  <td><b>Date</b></td>
  <td><b>Description</b></td>
  <td><b>Status</b></td>
 </tr>
<?php 
for ($i = 0; $i < count($log); $i++) {
    echo " <tr>\n";
    echo "  <td nowrap><a href=\"log.php?site=" . $log[$i]["site"] . "&limit={$limit}\">" . $log[$i]["site"] . "</a></td>\n";
    echo "  <td nowrap><a href=\"log.php?user="******"user"] . "&limit={$limit}\">" . $log[$i]["user"] . "</a></td>\n";
    echo "  <td nowrap><a href=\"log.php?ip=" . $log[$i]["ip"] . "&limit={$limit}\">" . $log[$i]["ip"] . "</a></td>\n";
    echo "  <td nowrap><a href=\"log.php?type=" . $log[$i]["type"] . "&limit={$limit}\">" . $log[$i]["type"] . "</a></td>\n";
    echo "  <td nowrap>" . dateconv($log[$i]["date"]) . "</td>\n";
    echo "  <td nowrap>" . $log[$i]["data"] . "</td>\n";
    echo "  <td nowrap>" . $log[$i]["status"] . "</td>\n";
    echo "</tr>\n";
}
echo "</table>\n";
?>
<br>
<center>
<a href="log.php?limit=50<?php 
echo $get;
?>
">50</a>
<a href="log.php?limit=200<?php 
echo $get;
?>
예제 #4
0
파일: user.php 프로젝트: sbaldrich/boca
     echo "  <td nowrap>" . $usr[$i]["userpermitip"] . "*&nbsp;</td>\n";
 } else {
     echo "  <td nowrap>" . $usr[$i]["userip"] . "&nbsp;</td>\n";
 }
 if ($usr[$i]["userlastlogin"] < 1) {
     echo "  <td nowrap>never</td>\n";
 } else {
     echo "  <td nowrap>" . dateconv($usr[$i]["userlastlogin"]) . "</td>\n";
 }
 if ($usr[$i]["usersession"] != "") {
     echo "  <td nowrap><a href=\"javascript: conf2('user.php?logout=1&site=" . $usr[$i]["usersitenumber"] . "&user="******"usernumber"] . "')\">Force Logout</a></td>\n";
 } else {
     if ($usr[$i]["userlastlogout"] < 1) {
         echo "  <td nowrap>never</td>\n";
     } else {
         echo "  <td nowrap>" . dateconv($usr[$i]["userlastlogout"]) . "</td>\n";
     }
 }
 if ($usr[$i]["userenabled"] == "t") {
     echo "  <td nowrap>Yes</td>\n";
 } else {
     echo "  <td nowrap>No</td>\n";
 }
 if ($usr[$i]["usermultilogin"] == "t") {
     echo "  <td nowrap>Yes</td>\n";
 } else {
     echo "  <td nowrap>No</td>\n";
 }
 echo "  <td nowrap>" . $usr[$i]["userfullname"] . "&nbsp;</td>\n";
 echo "  <td nowrap>" . $usr[$i]["userdesc"] . "&nbsp;</td>\n";
 echo "</tr>";
예제 #5
0
파일: site.php 프로젝트: sbaldrich/boca
<?php 
$n = count($sitetime);
for ($i = 0; $i < $n; $i++) {
    echo "<tr>";
    echo "<td nowrap align=right>";
    echo dateconv($sitetime[$i]["sitestartdate"]);
    echo "</td>";
    echo "<td nowrap align=left>";
    if ($sitetime[$i]["siteenddate"] == 0) {
        if ($st["siterunning"]) {
            echo "still open";
        } else {
            echo "auto-ended";
        }
    } else {
        echo dateconv($sitetime[$i]["siteenddate"]);
    }
    echo "</td>";
    echo "</tr>";
}
?>
</table>
</center>

<?php 
if ($main || $site == $ct["contestlocalsite"]) {
    ?>
  <center>
    <table border="0">
      <tr>
<td nowrap width="50%" align=right>
예제 #6
0
파일: index.php 프로젝트: sbaldrich/boca
  </tr>
</table>
<?php 
} else {
    if ($idextra == "<OK>") {
        echo "<u>Data sent correctly to main server</u><br><br>";
    } else {
        echo "<u>Error sending data to main server</u><br><br>";
    }
    $ac['CONTESTREC'] = array('number' => -1, 'name' => -1, 'startdate' => -1, 'duration' => -1, 'lastmileanswer' => -1, 'lastmilescore' => -1, 'penalty' => -1, 'maxfilesize' => -1, 'updatetime' => -1);
    $ac['ANSWERREC'] = array('number' => -1, 'name' => -1, 'yes' => -1, 'updatetime' => -1);
    $ac['LANGUAGEREC'] = array('number' => -1, 'name' => -1, 'filepath' => -1, 'filename' => -1, 'comppath' => -1, 'compname' => -1, 'problemnumber' => -1, 'updatetime' => -1);
    $ac['PROBLEMREC'] = array('number' => -1, 'name' => -1, 'fullname' => -1, 'basename' => -1, 'inputfilename' => -1, 'inputfilepath' => -1, 'solfilename' => -1, 'solfilepath' => -1, 'descfilename' => -1, 'descfilepath' => -1, 'tl' => -1, 'fake' => -1, 'updatetime' => -1);
    $ac['SITETIME'] = array('site' => -1, 'start' => -1, 'enddate' => -1, 'updatetime' => -1);
    $ac['SITEREC'] = array('sitenumber' => -1, 'site' => -1, 'number' => -1, 'sitename' => -1, 'siteip' => -1, 'siteduration' => -1, 'sitelastmileanswer' => -1, 'sitelastmilescore' => -1, 'sitejudging' => -1, 'sitetasking' => -1, 'siteautoend' => -1, 'siteglobalscore' => -1, 'siteactive' => -1, 'sitescorelevel' => -1, 'sitepermitlogins' => -1, 'siteautojudge' => -1, 'sitenextuser' => -1, 'sitenextclar' => -1, 'sitenextrun' => -1, 'sitenexttask' => -1, 'sitemaxtask' => -1, 'sitechiefname' => -1, 'updatetime' => -1);
    $ac['USERREC'] = array('site' => -1, 'user' => -1, 'number' => -1, 'username' => -1, 'updatetime' => -1, 'usericpcid' => -1, 'userfull' => -1, 'userdesc' => -1, 'type' => -1, 'enabled' => -1, 'multilogin' => -1, 'userip' => -1, 'userlastlogin' => -1, 'userlastlogout' => -1, 'permitip' => -1);
    $ac['CLARREC'] = array('site' => -1, 'user' => -1, 'number' => -1, 'problem' => -1, 'question' => -1, 'clarnumber' => -1, 'clardate' => -1, 'clardatediff' => -1, 'clardatediffans' => -1, 'claranswer' => -1, 'clarstatus' => -1, 'clarjudge' => -1, 'clarjudgesite' => -1, 'updatetime' => -1);
    $ac['RUNREC'] = array('site' => -1, 'user' => -1, 'number' => -1, 'runnumber' => -1, 'problem' => -1, 'lang' => -1, 'filename' => -1, 'filepath' => -1, 'rundate' => -1, 'rundatediff' => -1, 'rundatediffans' => -1, 'runanswer' => -1, 'runstatus' => -1, 'runjudge' => -1, 'runjudgesite' => -1, 'runjudge1' => -1, 'runjudgesite1' => -1, 'runanswer1' => -1, 'runjudge2' => -1, 'runjudgesite2' => -1, 'runanswer2' => -1, 'autoip' => -1, 'autobegindate' => -1, 'autoenddate' => -1, 'autoanswer' => -1, 'autostdout' => -1, 'autostderr' => -1, 'updatetime' => -1);
    $ac['TASKREC'] = array('site' => -1, 'user' => -1, 'desc' => -1, 'number' => -1, 'tasknumber' => -1, 'color' => -1, 'colorname' => -1, 'updatetime' => -1, 'filename' => -1, 'filepath' => -1, 'sys' => -1, 'status' => -1, 'taskdate' => -1, 'taskdatediff' => -1, 'taskdatediffans' => -1, 'taskstaffnumber' => -1, 'taskstaffsite' => -1);
    if (importFromXML($id, $ac, $_SESSION["usertable"]["contestnumber"])) {
        echo "<u>Data received correctly from main server at " . dateconv(time()) . "</u>";
    } else {
        echo "<u>Error receiving data from main server at " . dateconv(time()) . "</u>";
    }
    //	echo "<pre>" . $id . "</pre>";
    echo "<br><br><b>waiting for next round...</b>";
}
?>
</body>
</html>