Exemplo n.º 1
0
if (isset($mo_request[1]) && is_numeric($mo_request[1])) {
    $problem = new Problem($mo_request[1]);
    $problem->load();
    if (!$problem->getPID()) {
        require_once $mo_theme_floder . '404.php';
    }
    if (isset($_POST['lang']) && isset($_POST['code']) && $user->getUID()) {
        // 提交solution
        if (!b_check_code()) {
            echo '提交错误!请检查格式以及是否已经登录!';
        } else {
            $new_sid = mo_add_new_solution($mo_request[1], $_POST['lang'], $_POST['code']);
            echo '提交成功!<a href="/?r=solution/' . $new_sid . '">点此</a>查看详情!';
        }
    }
    echo '<h2>' . $problem->getInfo('title') . '</h2>';
    echo '<em>标签:' . $problem->getInfo('tag') . '<br>';
    echo '时间限制:' . $problem->getInfo('time_limit') . 'MS 内存限制:' . $problem->getInfo('memory_limit') . 'MB</em>';
    echo '<h3>问题描述</h3>';
    echo $problem->getInfo('description');
    echo '<br>提交人数:' . $problem->getInfo('try') . ' AC人数:' . $problem->getInfo('solved') . '<br>';
    echo '<h3>提交代码</h3>';
    echo '<form name="form1" method="post" action="">
				语言:
				<p>
				  <label>
					<input name="lang" type="radio" required id="lang-1" value="1" checked>
					C/C++</label>
				  </p>
				<p>代码:</p>
				<p>
Exemplo n.º 2
0
if (!$app->user->isLogin()) {
    die('<center><a href=\'admin/status.php?action=login&url=../index.php\'>Please login or register first!</a></center>');
}
if ($app->user->getPower() != 0) {
    die('<center><a href=\'admin/status.php?action=login&url=../index.php\'>Please login or register first!</a></center>');
}
if (isset($_GET['action'])) {
    if ($_GET['action'] == "delete") {
        $db = new MySQL();
        $db->from("Problem")->where("`id`='" . intval($_GET['id']) . "'")->delete();
    }
}
if (isset($_POST['submit'])) {
    require_once "classes/Problem.php";
    $pro = new Problem($_POST['pid'], $_POST['oj']);
    $pro_info = $pro->getInfo();
    $db = new MySQL();
    $num = $db->from("Problem")->select("max(cast(id as signed))")->fetch_one();
    //Just a hack for PHP <= 5.3
    $db->value(array('id' => intval($num['max(cast(id as signed))']) + 1, 'pid' => $_POST['pid'], 'title' => get_magic_quotes_gpc() ? $pro_info['title'] : addslashes($pro_info['title']), 'oj' => $_POST['oj']))->insert("Problem");
    $alert = "Problem " . $pro_info['title'] . " added !";
}
if (isset($_POST['time'])) {
    $app->setting->set("startTime", strtotime($_POST['stime']));
    $app->setting->set("endTime", strtotime($_POST['etime']));
    $alert = "Start at " . $_POST['stime'] . " and end at " . $_POST['etime'];
}
if (isset($_POST['clean'])) {
    $db = new MySQL();
    $db->from("Problem")->delete();
    $db->from("Record")->delete();