Пример #1
0
            $details .= 'p' . $row['probid'] . " in contest c" . $row['cid'] . ': ' . $chk_err . "\n";
        }
    }
    if (!$DB->q("MAYBEVALUE SELECT count(testcaseid) FROM testcase\n \t               WHERE input IS NOT NULL AND output IS NOT NULL AND\n \t               probid = %i", $row['probid'])) {
        $details .= 'p' . $row['probid'] . " in contest c" . $row['cid'] . ": missing in/output testcase.\n";
    }
}
foreach (array('input', 'output') as $inout) {
    $mismatch = $DB->q("SELECT probid, rank FROM testcase\n\t                    WHERE md5({$inout}) != md5sum_{$inout}");
    while ($r = $mismatch->next()) {
        $details .= 'p' . $r['probid'] . ": testcase #" . $r['rank'] . " MD5 sum mismatch between {$inout} and md5sum_{$inout}\n";
    }
}
$oversize = $DB->q("SELECT probid, rank, OCTET_LENGTH(output) AS size\n                    FROM testcase WHERE OCTET_LENGTH(output) > %i", dbconfig_get('output_limit') * 1024);
while ($r = $oversize->next()) {
    $details .= 'p' . $r['probid'] . ": testcase #" . $r['rank'] . " output size (" . printsize($r['size']) . ") exceeds output_limit\n";
}
$has_errors = $details != '';
$probs = $DB->q("TABLE SELECT probid, cid FROM contestproblem WHERE color IS NULL");
foreach ($probs as $probdata) {
    $details .= 'p' . $probdata['probid'] . " in contest c" . $probdata['cid'] . ": has no color\n";
}
result('problems, languages, teams', 'Problems integrity', $details == '' ? 'O' : ($has_errors ? 'E' : 'W'), $details);
flushresults();
// LANGUAGES
$res = $DB->q('SELECT * FROM language ORDER BY langid');
$details = '';
$langseverity = 'W';
while ($row = $res->next()) {
    $CHECKER_ERRORS = array();
    check_language($row);
Пример #2
0
    if (IS_ADMIN) {
        echo '<th scope="col">upload new</th>';
    }
    ?>
<th scope="col">sample</th><th scope="col">description / image</th><th></th>
</tr></thead>
<tbody>
<?php 
}
foreach ($data as $rank => $row) {
    foreach ($INOROUT as $inout) {
        echo '<tr' . ($inout == 'output' ? ' class="testcase-middle"' : '') . '>';
        if ($inout == 'input') {
            echo "<td rowspan=\"2\" class=\"testrank\">" . "<a href=\"./testcase.php?probid=" . urlencode($probid) . "&amp;rank={$rank}&amp;move=up\">&uarr;</a>{$rank}" . "<a href=\"./testcase.php?probid=" . urlencode($probid) . "&amp;rank={$rank}&amp;move=down\">&darr;</a></td>";
        }
        echo "<td class=\"filename\"><a href=\"./testcase.php?probid=" . urlencode($probid) . "&amp;rank={$rank}&amp;fetch=" . $inout . "\">" . filebase($probid, $rank) . substr($inout, 0, -3) . "</a></td>" . "<td class=\"size\">" . printsize($row["size_{$inout}"]) . "</td>" . "<td class=\"md5\">" . htmlspecialchars($row["md5sum_{$inout}"]) . "</td>";
        if (IS_ADMIN) {
            echo "<td>" . addFileField("update_" . $inout . "[{$rank}]") . "</td>";
        }
        if ($inout == 'input') {
            if (IS_ADMIN) {
                echo "<td rowspan=\"2\"\tclass=\"testsample\" onclick=\"editTcSample({$rank})\">" . addSelect("sample[{$rank}]", array("no", "yes"), $row['sample'], true) . "</td>";
                // hide sample dropdown field if javascript is enabled
                echo "<script type=\"text/javascript\" language=\"JavaScript\">" . "hideTcSample({$rank}, '" . printyn($row['sample']) . "');</script>";
                echo "<td class=\"testdesc\" onclick=\"editTcDesc({$rank})\">" . "<textarea id=\"tcdesc_{$rank}\" name=\"description[{$rank}]\" cols=\"50\" rows=\"1\">" . htmlspecialchars($row['description']) . "</textarea></td>" . "<td rowspan=\"2\" class=\"editdel\">" . "<a href=\"delete.php?table=testcase&amp;testcaseid={$row['testcaseid']}&amp;referrer=" . urlencode('testcase.php?probid=' . $probid) . "\">" . "<img src=\"../images/delete.png\" alt=\"delete\"" . " title=\"delete this testcase\" class=\"picto\" /></a></td>";
            } else {
                echo "<td rowspan=\"2\" align=\"testsample\">" . printyn($row['issample']) . "</td>";
                echo "<td class=\"testdesc\">" . htmlspecialchars($row['description']) . "</td>";
            }
        } else {
            echo '<td class="testimage filename">';
Пример #3
0
 * under the GNU GPL. See README and COPYING for details.
 */
require 'init.php';
$title = 'Executables';
require LIBWWWDIR . '/header.php';
echo "<h1>Executables</h1>\n\n";
// Select all data, sort problems from the current contest on top.
$res = $DB->q('SELECT execid, description, md5sum, type, OCTET_LENGTH(zipfile) AS size
               FROM executable ORDER BY execid');
if ($res->count() == 0) {
    echo "<p class=\"nodata\">No executables defined</p>\n\n";
} else {
    echo "<table class=\"list sortable\">\n<thead>\n" . "<tr><th scope=\"col\">ID</th><th scope=\"col\">type</th>" . "<th scope=\"col\">description</th>" . "<th scope=\"col\">size</th><th scope=\"col\">md5</th>" . "<th></th><th></th></tr></thead>\n<tbody>\n";
    $lastcid = -1;
    while ($row = $res->next()) {
        $link = '<a href="executable.php?id=' . urlencode($row['execid']) . '">';
        echo "<tr><td class=\"execid\">" . $link . htmlspecialchars($row['execid']) . "</a>" . "</td><td>" . $link . htmlspecialchars($row['type']) . "</a>" . "</td><td>" . $link . htmlspecialchars(str_cut($row['description'], 40)) . "</a>" . "</td><td class=\"size\">" . $link . printsize($row['size']) . "</a>" . "</td><td class=\"md5\">" . $link . htmlspecialchars($row['md5sum']) . "</a>" . "</td>";
        if (IS_ADMIN) {
            echo '<td title="export executable as zip-file"><a href="executable.php?fetch&amp;id=' . urlencode($row['execid']) . '"><img src="../images/b_save.png" alt="export" /></a></td>' . "<td class=\"editdel\">" . editLink('executable', $row['execid']) . "&nbsp;" . delLink('executable', 'execid', $row['execid']) . "</td>";
        }
        echo "</tr>\n";
    }
    echo "</tbody>\n</table>\n\n";
}
if (IS_ADMIN) {
    echo "<p>" . addLink('executable') . "</p>\n\n";
    if (class_exists("ZipArchive")) {
        echo "\n" . addForm('executable.php', 'post', null, 'multipart/form-data') . 'Executable archive(s): ' . addSelect('type', $executable_types) . addFileField('executable_archive[]', null, ' required multiple accept="application/zip"') . addSubmit('Upload', 'upload') . addEndForm() . "\n";
    }
}
require LIBWWWDIR . '/footer.php';
Пример #4
0
function check_add($probid, $rank, $FILES)
{
    global $DB;
    $result = '';
    if (!empty($_FILES['add_input']['name']) || !empty($_FILES['add_output']['name'])) {
        $content = array();
        foreach ($FILES as $file) {
            if (empty($_FILES['add_' . $file]['name'])) {
                warning("No {$file} file specified for new testcase, ignoring.");
            } else {
                checkFileUpload($_FILES['add_' . $file]['error']);
                $content[$file] = file_get_contents($_FILES['add_' . $file]['tmp_name']);
            }
        }
        $DB->q("INSERT INTO testcase\n\t\t        (probid,rank,md5sum_input,md5sum_output,input,output,description,sample)\n\t\t        VALUES (%i,%i,%s,%s,%s,%s,%s,%i)", $probid, $rank, md5(@$content['input']), md5(@$content['output']), @$content['input'], @$content['output'], @$_POST['add_desc'], isset($_POST['add_sample']));
        if (!empty($content['image'])) {
            list($thumb, $type) = get_image_thumb_type($content['image']);
            $DB->q('UPDATE testcase SET image = %s, image_thumb = %s, image_type = %s
			        WHERE probid = %i AND rank = %i', @$content['image'], $thumb, $type, $probid, $rank);
        }
        auditlog('testcase', $probid, 'added', "rank {$rank}");
        $result .= "<li>Added new testcase {$rank} from files " . specialchars($_FILES['add_input']['name']) . " (" . printsize($_FILES['add_input']['size']) . ") and " . specialchars($_FILES['add_output']['name']) . " (" . printsize($_FILES['add_output']['size']) . ").";
        if ($_FILES['add_output']['size'] > dbconfig_get('output_limit') * 1024) {
            $result .= "<br /><b>Warning: output file size exceeds " . "<code>output_limit</code> of " . dbconfig_get('output_limit') . " kB. This will always result in wrong answers!</b>";
        }
        if (empty($content['input']) || empty($content['output'])) {
            $result .= "<br /><b>Warning: empty testcase file(s)!</b>";
        }
        $result .= "</li>\n";
    }
    return $result;
}