$sQuery = "\n    SELECT COUNT(" . $sIndexColumn . ")\n    FROM   {$sTable}\n    {$sWhere}\n    {$sOrder}\n";
$db->query($sQuery);
list($iFilteredTotal) = $db->get_row($sQuery, ARRAY_N);
/*
 * Output
 */
$output = array("sEcho" => intval($_GET['sEcho']), "iTotalRecords" => $iTotal, "iTotalDisplayRecords" => $iFilteredTotal, "aaData" => array());
$sQuery = "\n    SELECT " . str_replace(" , ", " ", implode(", ", $aColumns)) . "\n    FROM   {$sTable}\n    {$sWhere}\n    {$sOrder}\n    {$sLimit}\n";
$cshows = false;
if ($current_user->is_valid() && contest_passed($cid)) {
    $cshows = true;
}
$isv = $current_user->is_codeviewer();
foreach ((array) $db->get_results($sQuery, ARRAY_A) as $aRow) {
    $row = array();
    $aRow["language"] = match_lang($aRow["language"]);
    if ($aRow["memory_used"] != 0) {
        $aRow["memory_used"] .= " KB";
        $aRow["time_used"] .= " ms";
    } else {
        $aRow["memory_used"] = "";
        if ($aRow["time_used"] != 0) {
            $aRow["time_used"] .= " ms";
        } else {
            $aRow["time_used"] = "";
        }
    }
    $aRow["length(source)"] .= " B";
    if (!$current_user->match($aRow["username"]) && !$current_user->is_root() && $hidedt) {
        $aRow["memory_used"] = "";
        $aRow["time_used"] = "";
Beispiel #2
0
    $cnt++;
    $row = array();
    for ($i = 0; $i < count($aColumns); $i++) {
        if ($i == 0) {
            $row[] = intval($_GET['iDisplayStart']) + $cnt;
        } else {
            if ($aColumns[$i] == "time_used") {
                $row[] = $aRow[$i] . " ms";
            } else {
                if ($aColumns[$i] == "memory_used") {
                    $row[] = $aRow[$i] . " KB";
                } else {
                    if ($aColumns[$i] == "length(source)") {
                        $row[] = $aRow[$i] . " B";
                    } else {
                        if ($aColumns[$i] == "language") {
                            $row[] = match_lang($aRow[$i]);
                        } else {
                            if ($aColumns[$i] != ' ') {
                                /* General output */
                                $row[] = $aRow[$i];
                            }
                        }
                    }
                }
            }
        }
    }
    $output['aaData'][] = $row;
}
echo json_encode($output);
Beispiel #3
0
include_once dirname(__FILE__) . "/../functions/contests.php";
include_once dirname(__FILE__) . "/../functions/runs.php";
$runid = convert_str($_GET['runid']);
$cid = run_get_val($runid, "contest_belong");
$uname = run_get_val($runid, "username");
$query = "select result,memory_used,time_used,username,source,language,pid,isshared,contest_belong from status where runid='{$runid}'";
$ret = $db->get_row($query, ARRAY_A);
if (!$current_user->is_valid()) {
    unset($ret);
    $ret["code"] = 1;
    $ret["msg"] = "Permission denined. Please login.";
} else {
    if (!($ret["isshared"] == TRUE && ($cid == "0" || contest_passed($cid)) || $current_user->match($uname) || $current_user->is_codeviewer())) {
        unset($ret);
        $ret["code"] = 1;
        $ret["msg"] = "Permission denined.";
    } else {
        $ret["source"] = htmlspecialchars($ret["source"]);
        $ret["language"] = match_lang($ret["language"]);
        if ($current_user->match($uname) || $current_user->is_root()) {
            $ret["control"] = 1;
        } else {
            $ret["control"] = 0;
        }
        if ($_GET["cid"] != "") {
            $ret["pid"] = contest_get_label_from_pid($cid, $ret["pid"]);
        }
        $ret["code"] = 0;
    }
}
echo json_encode($ret);