Пример #1
0
<?php

require "./navigation.php";
?>

<?php 
include_once "./FCKeditor/fckeditor.php";
$cid = @$_GET['cid'];
$pid = @$_GET['pid'];
if ($cid) {
    $problem = new ContestProblem($cid);
    $contest = new ContestsTbl($cid);
    $contest->Get();
    $contest_title = $contest->detail['title'];
} else {
    $problem = new ProblemTbl();
    $cid = 0;
}
if (!$problem->Get($pid)) {
    MsgAndRedirect("No such problem", "index.php");
}
$title = $problem->detail['title'];
?>
<form action="process.php?act=EditContestProblem" method="post" enctype="multipart/form-data">
    <input type="hidden" name="avail" value="1" />
    <input name="cid" type="hidden" id="cid" value="<?php 
echo $cid;
?>
">
    <table id="tb" width="100%" class="ui-widget tblcontainer ui-widget-content ui-corner-all">
        <caption>Edit problems</caption>
Пример #2
0
<?php

require "./navigation.php";
$pid = safeget('pid');
$cid = 0;
$problem = new ProblemTbl($pid);
$problem->Get() or error("Invalid Problem ID");
$problem = $problem->detail;
$cid = 0;
$status_vals = array("", "Accepted", "Wrong Answer", "Compile Error", "Runtime Error", "Time Limit Exceeded", "Memory Limit Exceeded", "Output Limit Exceeded", "Presentation Error", "Restrict Function", "Running", "Other", "Waiting");
$display_status = array("", _("Accepted "), _("Wrong Answer"), _("Compile Error"), _("Runtime Error"), _("Time Limit Exceeded"), _("Memory Limit Exceeded"), _("Output Limit Exceeded"), _("Presentation Error"), _("Restrict Function"), _("Running"), _("Other"), _("Waiting"));
?>

<script language="javascript" type="text/javascript" src="../js/edit_area/edit_area_compressor.php"></script>
<link type="text/css" rel="stylesheet" href="../css/submit.css"/>
<script type="text/javascript">
    function initEditor() {
        var langName = ["c", "cpp", "pas"];
        editAreaLoader.init({
            id : "source"        // textarea id
            ,
            syntax: langName[lang-1]            // syntax to be uses for highgliting
            ,
            start_highlight: true        // to display with highlight mode on start-up
            ,
            replace_tab_by_spaces: 4
            ,
            allow_toggle: false
            ,
            allow_resize: false
            ,
Пример #3
0
function CheckProblem(&$arg)
{
    if (!isset($arg["pid"])) {
        Fail("Invalid problem ID!");
    }
    $pid = $arg["pid"];
    if (isset($arg["cid"])) {
        $cid = $arg["cid"];
    } else {
        $cid = "";
    }
    if ($cid) {
        $problem = new ContestProblem($cid);
    } else {
        $problem = new ProblemTbl();
    }
    if (!$problem->Get($pid)) {
        Fail("Invalid problem ID!");
    }
    Output("status", $problem->detail["title"]);
}
Пример #4
0
/**
 * Submit Source code to server
 * @global type $login_uid
 * @global type $login_username
 * @global type $logged
 * @param type $arg
 * @return mixed if success, return sid. otherwise error message
 */
function submit_source($pid, $cid, $language, $source)
{
    if (!is_logged()) {
        return "Invalid login";
    }
    $pid = intval(trim($pid));
    $source = trim($source);
    if ($cid) {
        $problem = new ContestProblem($cid);
        if (!is_contest_accessible($cid)) {
            return "You can't access to the contest";
        }
        if (is_contest_ended($cid) && !is_contest_modifiable($cid)) {
            return "Contest is finished";
        }
    } else {
        $problem = new ProblemTbl();
    }
    if (!$problem->Get($pid)) {
        return "Invalid Problem ID!";
    }
    $acutal_cid = $problem->detail['cid'];
    if (!$cid && $acutal_cid) {
        // this is a problem automaticly added after the end of contest
        if (!is_contest_accessible($acutal_cid)) {
            return "You can't access to this problem";
        }
        if (!is_contest_modifiable($acutal_cid) && !is_contest_ended($acutal_cid)) {
            return "Contest is not finished. Can't submit to normal problem";
        }
    }
    $sdata = array();
    $sdata["contest"] = $cid;
    if ($language < 1 || $language > 4) {
        return "Invalid language!";
    }
    $sdata['language'] = $language;
    $app_config = get_app_config();
    $codelength = strlen($source);
    if ($codelength > $app_config['max_sourcecode_length']) {
        return "Size of your submittion exceeds limitation.";
    }
    if ($codelength == 0) {
        return "You can't submit an empty source code";
    }
    $sdata['uid'] = get_uid();
    $sdata['time'] = date("Y-m-d H:i:s");
    if ($cid) {
        $sdata['pid'] = $problem->detail['pid'];
        $cpid = $pid;
        $pid = $sdata['pid'];
    } else {
        $sdata['pid'] = $pid;
    }
    $sdata['codelength'] = $codelength;
    $sdata['sourcecode'] = mysql_real_escape_string($source);
    $status = new StatusTbl();
    $status->detail = $sdata;
    $status_id = $status->Add();
    $user = new UserTbl(get_uid());
    $user->Get();
    $user->update['submissions'] = $user->detail['submissions'] + 1;
    $user->Update();
    $problem = new ProblemTbl($pid);
    $problem->Get();
    $problem->update['submissions'] = $problem->detail['submissions'] + 1;
    $problem->Update();
    if ($cid) {
        $con_status = new ContestStatus($cid);
        $con_status->detail = array('cid' => $cid, 'sid' => $status_id, 'cpid' => $cpid);
        $con_status->Add();
    }
    $queue = new QueueTbl();
    $queue->detail['sid'] = $status_id;
    if ($cid) {
        $queue->detail['cid'] = $cid;
        $queue->detail['cpid'] = $cpid;
    }
    $queue->Add();
    return $status_id;
}
Пример #5
0
function StdSubmit(&$arg)
{
    $pid = safefetch($arg, 'pid');
    $source = isset($arg['source']) ? $arg['source'] : '';
    $language = safefetch($arg, 'language');
    $cid = 0;
    $ret = submit_source($pid, $cid, $language, $source);
    if (is_numeric($ret)) {
        // success
        $sid = intval($ret);
        $problem = new ProblemTbl($pid);
        $problem->Get();
        $problem->update['stdsid'] = $sid;
        $problem->Update();
        MsgAndRedirect('stdprogram.php?pid=' . $pid);
    } else {
        MsgAndRedirect('stdprogram.php?pid=' . $pid, $ret);
    }
}
Пример #6
0
    <thead>
        <tr class="ui-widget-header">
            <th>PID</th>
            <th>CPID</th>
            <th>Title</th>
            <th>Operation</th>
            <th>Export/Data</th>
            <th>Testing</th>
            <th>Rejudge</th>
        </tr>
    </thead>
    <tbody>
        <?php 
while ($rs->MoveNext()) {
    $pid = $rs->Fields['pid'];
    $problemTbl = new ProblemTbl($pid);
    if (!$problemTbl->Get()) {
        continue;
    }
    $problem = $problemTbl->detail;
    $quickarg = "cid={$cid}&pid={$cpidIndex[$problem['pid']]}";
    ?>
            <tr>
                <td> <?php 
    echo $problem['pid'];
    ?>
 </td>
                <td> <?php 
    echo $cpidIndex[$problem['pid']];
    ?>
 </td>
Пример #7
0
/**
 * Registering problem into contest
 * @param type $pid
 * @param type $cid
 * @param type $cpid 
 */
function set_problem_cid($pid, $cid, $cpid)
{
    $problem = new ProblemTbl($pid);
    $problem->Get() or error('Error setting problem cid');
    $problem->update['cid'] = $cid;
    $problem->Update();
    $contest_problem = new ContestProblem($cid);
    $contest_problem->detail = array("cpid" => $cpid, "cid" => $cid, "pid" => $pid);
    $contest_problem->Add();
}