Esempio n. 1
0
function status_mysql_condition($get, $field)
{
    global $where, $get_page;
    if (strlen($_GET[$get]) > 0) {
        $temp = intval(get_to_mysql($_GET[$get]));
        if (strlen($where) > 0) {
            $where = $where . ' and ';
        }
        $where = $where . " (submit_status.{$field} {$temp}) ";
        if ($get != 'top' && $get != 'bottom') {
            if (strlen($get_page) > 0) {
                $get_page = $get_page . '&';
            }
            $get_page = $get_page . $get . '=' . intval(urlencode(stripslashes($_GET[$get])));
        }
    }
}
Esempio n. 2
0
include 'include/header.php';
?>

<table class="table_list wide_list" border=1>
	<tr>
		<th>ID</th>
		<th width=60%>Title</th>
		<th>Start time</th>
		<th>Type</th>
		<th>State</th>
	</tr>
<?php 
$query = "select *,start_time>now() as pending,end_time<now() as ended from contest ";
$where = '';
if (isset($_GET['top'])) {
    $clist_top = intval(get_to_mysql($_GET['top']));
    $where = "contest_id<{$clist_top} ";
}
if (isset($_GET['show'])) {
    $clist_show = $_GET['show'];
}
if ($clist_show == 'Scheduled') {
    if (strlen($where) > 0) {
        $where = $where . 'and ';
    }
    $where = $where . 'start_time>now() ';
} else {
    if ($clist_show == 'Past') {
        if (strlen($where) > 0) {
            $where = $where . 'and ';
        }
Esempio n. 3
0
    if ($_GET['order'] == 'memory') {
        $pro_order = "order by cost_mem {$pro_asc},cost_time {$pro_asc},code_length {$pro_asc},submit_id {$pro_asc} ";
    } else {
        if ($_GET['order'] == 'code') {
            $pro_order = "order by code_length {$pro_asc},cost_time {$pro_asc},cost_mem {$pro_asc},submit_id {$pro_asc} ";
        } else {
            if ($_GET['order'] == 'submit') {
                $pro_order = "order by submit_id {$pro_asc} ";
            }
        }
    }
}
$pro_limit = "limit {$status_limit} ";
$pro_rank = 1;
if (isset($_GET['top'])) {
    $pro_limit_top = get_to_mysql($_GET['top']);
    $pro_limit = "limit {$pro_limit_top},{$status_limit} ";
    $pro_rank = $pro_limit_top + 1;
}
$pro_page_pre = $pro_rank - $status_limit - 1;
if ($pro_page_pre < 0) {
    $pro_page_pre = 0;
}
$pro_page_next = $pro_rank + $status_limit - 1;
//$query=$query . $pro_order . $pro_limit;
$query = 'select accept.*,count(*) as cnt from ( ' . $query . $pro_order . ') as accept group by accept.user_id ' . $pro_order . $pro_limit;
$ret = oj_query($query);
while ($row = mysql_fetch_assoc($ret)) {
    $pro_stat_hide = $pro_banned && $row['user_id'] != $_SESSION['user_id'] && !$_SESSION['is_admin'];
    echo '<tr>';
    echo '<td>' . $pro_rank . '</td>';
Esempio n. 4
0
<?php

require_once 'include/function.php';
if (!isset($_SESSION['user_id'])) {
    redirect("error.php?msg=" . urlencode("Please longin first!"));
}
$user_id = get_to_mysql($_SESSION['user_id']);
$rank_top = 0;
$rank_size = 20;
if (isset($_GET['top'])) {
    $rank_top = $_GET['top'];
}
if (isset($_GET['size'])) {
    $rank_size = $_GET['size'];
}
$receive = true;
//read receive mails
if (isset($_GET['send'])) {
    $receive = false;
}
//send box
if ($receive) {
    $query = "select mail_id,from_user_id,mail_time,title,readed from mails " . "where to_user_id=" . intval($user_id) . " and reader_del=0 order by mail_time desc limit {$rank_top},{$rank_size}";
    $ret = oj_query($query);
} else {
    $query = "select mail_id,to_user_id,mail_time,title from mails " . "where from_user_id=" . intval($user_id) . " and writer_del=0 order by mail_time desc limit {$rank_top},{$rank_size}";
    $ret = oj_query($query);
}
set_ojinfo('title', 'ECUST Online Judge - ShowMails');
include 'include/header.php';
?>
Esempio n. 5
0
$query = "select max(pro_id),min(pro_id) from problems";
$ret = oj_query($query);
$row = mysql_fetch_row($ret);
$max_pro = $row[0];
$min_pro = $row[1];
$rank_top = $min_pro;
$rank_size = 100;
$rank_sort = 1;
if (isset($_GET['rank_top'])) {
    $rank_top = get_to_mysql(intval($_GET['rank_top']));
}
if (isset($_GET['rank_size'])) {
    $rank_size = get_to_mysql(intval($_GET['rank_size']));
}
if (isset($_GET['rank_sort'])) {
    $rank_sort = get_to_mysql($_GET['rank_sort']);
}
$query_t = "select pro_id, title, add_time, banned, accepted, submits from problems ";
$rank_max = $rank_top + $rank_size;
$query_t = $query_t . "where pro_id>={$rank_top} and pro_id<{$rank_max} order by ";
if ($rank_sort == 1) {
    $query = $query_t . "pro_id asc ";
} else {
    if ($rank_sort == 2) {
        $query = $query_t . "accepted asc, submits asc ";
    } else {
        if ($rank_sort == 3) {
            $query = $query_t . "submits asc, accepted asc ";
        } else {
            if ($rank_sort == 4) {
                $query = $query_t . "accepted/submits asc, accepted asc, submits asc ";
Esempio n. 6
0
    redirect('error.php?msg=' . urlencode('Please login first.'));
}
$update_id = $_SESSION['user_id'];
$query = "select * from users where user_id=" . intval($update_id);
$ret = oj_query($query);
$row = mysql_fetch_assoc($ret);
if (empty($row['user_id'])) {
    redirect('error.php?msg=' . urlencode('No such user.'));
}
if (isset($_POST['pwd'])) {
    $old_pwd = get_to_mysql($_POST['pwd']);
    $new_pwd = get_to_mysql($_POST['newpwd']);
    $new_email = get_to_mysql($_POST['email']);
    $new_nick = get_to_mysql($_POST['nick']);
    $new_school = get_to_mysql($_POST['school']);
    $new_fromaddr = get_to_mysql($_POST['fromaddr']);
    if ($old_pwd != $row['user_pwd']) {
        redirect('modifyuser.php?msg=' . urlencode('Wrong password.'));
    }
    $query = "update users set emailaddr='{$new_email}', nick_name='{$new_nick}', school='{$new_school}', fromaddr='{$new_fromaddr}' ";
    if (strlen($new_pwd) == 32) {
        $query = $query . ",user_pwd='{$new_pwd}' ";
    }
    $query = $query . "where user_id=" . intval($update_id);
    $ret = oj_query($query);
    set_ojinfo('title', 'ECUST Online Judge - Update your info');
    include 'include/header.php';
    echo "<center><h1>Update success</h1></center>";
} else {
    function draw_fillin($left, $name, $right)
    {
Esempio n. 7
0
    redirect('error.php?msg=' . urlencode('Please login first.'));
}
$problem_id = 0;
$contest_id = 0;
$reply_id = 0;
if (isset($_POST['problem_id'])) {
    $problem_id = intval(get_to_mysql($_POST['problem_id']));
}
if (isset($_POST['contest_id'])) {
    $contest_id = intval(get_to_mysql($_POST['contest_id']));
}
if (isset($_POST['reply_id'])) {
    $reply_id = intval(get_to_mysql($_POST['reply_id']));
}
$title = get_to_mysql($_POST['title']);
$content = get_to_mysql($_POST['content']);
if (strlen($title) == 0) {
    $title = 'No title';
}
$query = 'insert into discuss_info (user_id,pro_id,contest_id,title,content,reply_time) ' . "values ({$_SESSION['user_id']},{$problem_id},{$contest_id},'{$title}','{$content}',now())";
$ret = oj_query($query);
$ret = oj_query('select last_insert_id()');
$row = mysql_fetch_row($ret);
$message_id = $row[0];
if ($reply_id == 0) {
    $reply_id = $message_id;
}
$query = "update discuss_info set reply_id={$message_id},topic_id={$reply_id} where message_id={$message_id}";
$ret = oj_query($query);
while ($reply_id != 0) {
    $query = "update discuss_info set reply_id={$message_id} where message_id={$reply_id}";
Esempio n. 8
0
//$_POST['end_time']
//$_POST['att_pwd']如果为空则是public的比赛
//$_POST['att_pwd2']无用
require_once 'include/function.php';
if (!isset($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Please login first'));
}
if (!permission_admin($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Access denied'));
}
if (isset($_POST['title'])) {
    $addc_title = get_to_mysql($_POST['title']);
    $addc_desc = get_to_mysql($_POST['description']);
    $addc_start = get_to_mysql($_POST['start_time']);
    $addc_end = get_to_mysql($_POST['end_time']);
    $addc_pwd = get_to_mysql($_POST['att_pwd']);
    if (empty($addc_pwd)) {
        $addc_pub = 1;
    } else {
        $addc_pub = 0;
    }
    $query = 'insert into contest (title,start_time,end_time,description,ispub,att_pwd) values ' . "('{$addc_title}','{$addc_start}','{$addc_end}','{$addc_desc}',{$addc_pub},'{$addc_pwd}') ";
    $ret = oj_query($query);
    $ret = oj_query('select last_insert_id()');
    $row = mysql_fetch_row($ret);
    redirect("showcontest.php?contest_id={$row[0]}");
}
set_ojinfo('title', 'ECUST Online Judge - Add contest');
include 'include/header.php';
function draw_fillin($left, $input, $name, $prop = '', $right = '')
{
Esempio n. 9
0
<?php

require_once 'include/function.php';
if (isset($_GET['user_id'])) {
    $user_id = intval(get_to_mysql($_GET['user_id']));
} else {
    if (isset($_GET['user_name'])) {
        $user_name = get_to_mysql($_GET['user_name']);
        $query = "select user_id from users where name='{$user_name}'";
        $ret = oj_query($query);
        $row = mysql_fetch_row($ret);
        if (empty($row[0])) {
            redirect("error.php?msg=" . urlencode("No such User."));
        }
        $user_id = $row[0];
    } else {
        if (isset($_SESSION['user_id'])) {
            $user_id = mysql_real_escape_string($_SESSION['user_id']);
        } else {
            redirect("error.php?msg=" . urlencode("No such User."));
        }
    }
}
$query = "select name,emailaddr,submits,solved,last_login_time,reg_time,nick_name,school,fromaddr from users where user_id='{$user_id}'";
$ret = oj_query($query);
$row = mysql_fetch_assoc($ret);
if (empty($row['name'])) {
    redirect("error.php?msg=" . urlencode("No such User."));
}
$user_name = htmlspecialchars($row['name']);
$user_email = htmlspecialchars($row['emailaddr']);
Esempio n. 10
0
$from_user_id = $_SESSION['user_id'];
if (isset($_GET['name'])) {
    $to_user_name = $_GET['name'];
} else {
    if (isset($_POST['to'])) {
        $to_user_name = $_POST['to'];
    }
}
if (strlen($to_user_name) > 0) {
    $to_user_id = name_to_user_id(get_to_mysql($to_user_name));
}
set_ojinfo('title', 'ECUST Online Judge - SendMail');
include 'include/header.php';
if (isset($_POST['to'])) {
    $title = get_to_mysql($_POST['title']);
    $text = get_to_mysql($_POST['textarea']);
    $query = "insert into mails (to_user_id,from_user_id,mail_time,title,content,readed,reader_del,writer_del)" . " values({$to_user_id}, {$from_user_id}, now(), '{$title}', '{$text}', 0, 0, 0)";
    oj_query($query);
    echo "<center><h1>Send Mail Successfully!</h1></center>";
} else {
    ?>
<center><h1 style="color:#00f;">Write Mail</h1></center>
<form name="form1" method="post" action="mailsend.php" onsubmit="return check_mail()">
  <label><strong>To(name):</strong>
  <input name="to" type="text" id="mail_to" size="25" <?php 
    if (strlen($to_user_name) > 0) {
        echo 'value="' . get_to_html($to_user_name) . '"';
    }
    ?>
>
  </label>
Esempio n. 11
0
<?php

//$_GET['pro_id']题目号
//$_GET['confirm']表示需要经过确认
require_once 'include/function.php';
if (!isset($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Please login first'));
}
if (!$_SESSION['is_admin']) {
    redirect('error.php?msg=' . urlencode('Access denied'));
}
if (!empty($_GET['pro_id'])) {
    $pro_id = get_to_mysql($_GET['pro_id']);
    $query = "select pro_id from problems where pro_id={$pro_id}";
    $ret = oj_query($query);
    $row = mysql_fetch_row($ret);
    if (!isset($row[0])) {
        redirect('error.php?msg=' . urlencode('No such problem'));
    }
}
set_ojinfo('title', 'ECUST Online Judge - Rejudge');
include 'include/header.php';
if (empty($_GET['pro_id'])) {
    echo '<center>';
    echo '<form action="admin_rejudge.php" method="get">';
    echo 'Problem ID:<input name="pro_id"><br>';
    echo '<input type="hidden" name="confirm" value="1">';
    echo '<input type="submit" value="Rejudge">';
    echo '</form>';
    echo '</center>';
} else {
Esempio n. 12
0
<?php

//$_GET['field']={name|email|nick|school|from}|{title|source|tag},默认title
//$_GET['text']搜索的东西,对tag而言:mark_id
//$_GET['order']=对题目搜索:{id|title|solved|ac|submit|ratio|source},默认solved
require_once 'include/function.php';
if (empty($_GET['field'])) {
    redirect('error.php?msg=' . urlencode('Please select field'));
}
$search_field = get_to_mysql($_GET['field']);
$search_text = get_to_mysql($_GET['text']);
$search_url = 'search.php?text=' . urlencode($search_text) . '&field=' . urlencode($search_field);
$search_table = $search_array[$search_field];
if (!isset($search_table)) {
    $search_table = $search_array['title'];
}
if ($search_table[1] == 'user_mark') {
    if (!isset($_SESSION['user_id'])) {
        redirect('error.php?msg=' . urlencode('Please login first'));
    }
    if (!is_numeric($search_text)) {
        redirect('error.php?msg=' . urlencode('Failed to search'));
    }
}
set_ojinfo('title', 'ECUST Online Judge - Search');
include 'include/header.php';
Draw_search_box($search_field, get_to_html($_GET['text']));
echo '<table class="table_list row_hover" border=1>';
if ($search_table[1] == 'users') {
    $query = 'select user_id,name,emailaddr,submits,solved,nick_name,school,fromaddr ' . "from users where {$search_table[0]} like '%{$search_text}%' " . 'order by solved desc,submits asc ';
    $ret = oj_query($query);
Esempio n. 13
0
    $pro_id = get_to_html($_GET['pro_id']);
}
if (isset($_POST['title'])) {
    $pro_title = get_to_mysql($_POST['title']);
    $pro_des = get_to_mysql($_POST['description']);
    $pro_in = get_to_mysql($_POST['input']);
    $pro_out = get_to_mysql($_POST['output']);
    $pro_samin = get_to_mysql($_POST['sample_input']);
    $pro_samout = get_to_mysql($_POST['sample_output']);
    $pro_hint = get_to_mysql($_POST['hint']);
    $pro_source = get_to_mysql($_POST['source']);
    $pro_tle = get_to_mysql($_POST['time_limit']);
    $pro_ctle = get_to_mysql($_POST['case_time_limit']);
    $pro_mle = get_to_mysql($_POST['mem_limit']);
    $pro_ban = get_to_mysql($_POST['banned']);
    $pro_spj = get_to_mysql($_POST['isspj']);
    if (empty($pro_ban)) {
        $pro_ban = 0;
    }
    if (empty($pro_spj)) {
        $pro_spj = 0;
    }
    if (0 != $pro_id) {
        $query = "update problems set title='{$pro_title}',description='{$pro_des}',input='{$pro_in}',output='{$pro_out}', " . "sample_input='{$pro_samin}',sample_output='{$pro_samout}',hint='{$pro_hint}',source='{$pro_source}', " . "time_limit={$pro_tle},case_time_limit={$pro_ctle},mem_limit={$pro_mle},add_time=now(), " . "banned={$pro_ban},isspj={$pro_spj} " . "where pro_id={$pro_id} ";
    } else {
        $query = 'insert into problems (title,description,input,output,sample_input,sample_output,hint ' . ',source,time_limit,case_time_limit,mem_limit,add_time,banned,isspj) ' . "values ('{$pro_title}','{$pro_des}','{$pro_in}','{$pro_out}','{$pro_samin}','{$pro_samout}','{$pro_hint}','{$pro_source}', " . "{$pro_tle},{$pro_ctle},{$pro_mle},now(),{$pro_ban},{$pro_spj}) ";
    }
    $ret = oj_query($query);
    if (0 == $pro_id) {
        $ret = oj_query('select last_insert_id()');
        $row = mysql_fetch_row($ret);
Esempio n. 14
0
<?php

if (!isset($_GET['cid'])) {
    die('Unknow contest id!');
}
require_once dirname(__FILE__) . '/../include/function.php';
$cid = intval(get_to_mysql($_GET['cid']));
$res = oj_query('Select title, start_time, end_time, description, ispub, start_time<now() as start, end_time<now() as end From contest Where contest_id=' . $cid);
$contest = mysql_fetch_array($res);
$problems = array();
if (empty($contest)) {
    die('Contest not founded!');
}
$basedir = '../resource/files/';
$filename = $_GET['cid'] . '_' . $contest['title'] . '_source.zip';
if (false == file_exists($basedir . $filename)) {
    if (!(isset($_SESSION['user_id']) && permission_admin($_SESSION['user_id']))) {
        die('Permission deny!');
    }
    if (0 == intval($contest['start'])) {
        die('Contest has not began!');
    }
    if (0 == intval($contest['end'])) {
        die('Contest has not ended!');
    }
    $readme = "Contest: \t{$contest['title']}\r\n\r\nStart time: \t{$contest['start_time']}\r\nEnd time: \t{$contest['end_time']}\r\n\r\nDescript:\r\n {$contest['description']}\r\n\r\nProblem List:\r\n";
    $res = oj_query('Select problems.pro_id, title, new_id From contest_problems, problems Where problems.pro_id=contest_problems.pro_id and contest_id=' . $cid);
    $contest_problem_map = array();
    while ($contest_problem = mysql_fetch_array($res)) {
        $contest_problem_map[$contest_problem['pro_id']] = chr(64 + intval($contest_problem['new_id'])) . '_' . $contest_problem['title'];
        $problems[$contest_problem_map[$contest_problem['pro_id']]] = array();
Esempio n. 15
0
<?php

//$_GET['sender']=1表示是从发件箱过来的
require_once 'include/function.php';
if (!isset($_SESSION['user_id'])) {
    redirect("error.php?msg=" . urlencode("Please login first!"));
}
$my_user_id = get_to_mysql($_SESSION['user_id']);
if (!isset($_GET['mail_id'])) {
    redirect("error.php?msg=" . urlencode("The Mail is not exsisted!"));
}
$mail_id = get_to_mysql($_GET['mail_id']);
$query = "select * from mails where mail_id=" . intval($mail_id);
$ret = oj_query($query);
$row = mysql_fetch_assoc($ret);
if (empty($row['mail_id'])) {
    redirect("error.php?msg=" . urlencode("The Mail is not exsisted!"));
}
$to_user_id = $row['to_user_id'];
$from_user_id = $row['from_user_id'];
$mail_time = htmlspecialchars($row['mail_time']);
$title = htmlspecialchars($row['title']);
$content = htmlspecialchars($row['content']);
if ($my_user_id != $to_user_id && $my_user_id != $from_user_id) {
    redirect("error.php?msg=" . urlencode("You cannot read this mail!"));
}
if ($to_user_id == $my_user_id) {
    $query = "update mails set readed=1 where mail_id=" . intval($mail_id);
    oj_query($query);
}
set_ojinfo('title', 'ECUST Online Judge - Read mail');
Esempio n. 16
0
/**
 * log in.
 * if the user id and password is correct, return success
 * @param string $login_name The key of the option's name
 * @param string $login_pwd The key of the option's name
 * @return string return success if the user id and password is correct, or return error message
 * @example get_ojinfo('title');
 */
function oj_login($login_name, $login_pwd)
{
    if (strlen($login_pwd) != 32) {
        return 'Please make sure that you have enabled the Javascript.';
    }
    $login_name = get_to_mysql($login_name);
    $login_pwd = get_to_mysql($login_pwd);
    $query = "select user_pwd,user_id,name from users where name='{$login_name}'";
    $ret = oj_query($query);
    $row = mysql_fetch_row($ret);
    if (empty($row[0])) {
        return 'Wrong User ID.';
    }
    if ($row[0] != $login_pwd) {
        return 'Wrong Password.';
    }
    // banned?
    $login_id = $row[1];
    $login_name = $row[2];
    $_SESSION['user_name'] = $login_name;
    $_SESSION['user_id'] = $login_id;
    $_SESSION['is_admin'] = permission_admin($login_id);
    $_SESSION['is_judger'] = permission_judger($login_id);
    $login_ip = get_ip();
    $query = "update users set last_login_ip='{$login_ip}', last_login_time=now() where user_id=" . intval($login_id);
    $ret = oj_query($query);
    return 'success';
}
Esempio n. 17
0
<?php

//$_GET['submit_id']:�ύ���
require_once 'include/function.php';
if (!isset($_GET['submit_id'])) {
    redirect('status.php');
}
if (!isset($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Please login first'));
}
$code_id = get_to_mysql($_GET['submit_id']);
$query = "select user_id from submit_status where submit_id=" . intval($code_id);
$ret = oj_query($query);
$row = mysql_fetch_row($ret);
if (!isset($row[0])) {
    redirect('error.php?msg=' . urlencode('No such submission'));
}
if ($row[0] != $_SESSION['user_id'] && !$_SESSION['is_admin']) {
    redirect('error.php?msg=' . urlencode('This is not your code'));
}
$query = "select code_content from code_info where submit_id=" . intval($code_id);
$ret = oj_query($query);
$row = mysql_fetch_row($ret);
if (!isset($row[0])) {
    redirect('error.php?msg=' . urlencode("Can't find the code"));
}
set_ojinfo('title', 'ECUST Online Judge - View code');
set_ojinfo('highlight');
include 'include/header.php';
?>
Esempio n. 18
0
if (!isset($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Please login first'));
}
if (!permission_admin($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Access denied'));
}
if (!isset($_GET['contest_id'])) {
    redirect('error.php?msg=' . urlencode('Please select contest'));
}
$editc_id = get_to_html($_GET['contest_id']);
if (isset($_POST['title'])) {
    $editc_title = get_to_mysql($_POST['title']);
    $editc_desc = get_to_mysql($_POST['description']);
    $editc_start = get_to_mysql($_POST['start_time']);
    $editc_end = get_to_mysql($_POST['end_time']);
    $editc_pwd = get_to_mysql($_POST['att_pwd']);
    if (empty($editc_pwd)) {
        $editc_pub = 1;
    } else {
        $editc_pub = 0;
    }
    $query = "update contest set title='{$editc_title}',start_time='{$editc_start}',end_time='{$editc_end}'," . "description='{$editc_desc}',ispub={$editc_pub},att_pwd='{$editc_pwd}' " . "where contest_id={$editc_id} ";
    $ret = oj_query($query);
    redirect("showcontest.php?contest_id={$editc_id}");
}
$query = 'select * from contest where contest_id=' . $editc_id;
$ret = oj_query($query);
$row = mysql_fetch_assoc($ret);
set_ojinfo('title', 'ECUST Online Judge - Edit contest');
include 'include/header.php';
function draw_fillin($left, $input, $name, $prop = '', $right = '', $value = '')
Esempio n. 19
0
if (!isset($_POST['code'])) {
    $code = "";
} else {
    $code = get_to_mysql($_POST['code']);
}
$length = strlen($code);
if ($length > 0) {
    //�ύ
    if ($length > $code_limit) {
        redirect("error.php?msg=" . urlencode("Source code is too long!"));
    }
    $pro_id = intval(get_to_mysql($_POST['pro_id']));
    $language = get_to_mysql($_POST['language']);
    $contest_id = 0;
    if (!empty($_POST['contest_id'])) {
        $contest_id = intval(get_to_mysql($_POST['contest_id']));
        $query = "select pro_id from contest_problems where contest_id=" . $contest_id . " and pro_id=" . $pro_id;
        $ret = oj_query($query);
        $row = mysql_fetch_row($ret);
        if (!isset($row[0])) {
            redirect('error.php?msg=' . urlencode('No such problem in such contest'));
        }
        $query = "select end_time>=now() and start_time<=now() from contest where contest_id=" . $contest_id;
        $ret = oj_query($query);
        $row = mysql_fetch_row($ret);
        if (!$row[0]) {
            redirect('error.php?msg=' . urlencode('Contest ended'));
        }
    }
    $query = "select * from problems where pro_id=" . $pro_id;
    $ret = oj_query($query);
Esempio n. 20
0
//admin的添加新tag:
//$_POST['mark_des']
//$_POST['fore_color_r'],g,b
//$_POST['back_color_r'],g,b
require_once 'include/function.php';
if (!isset($_SESSION['user_id'])) {
    redirect('error.php?msg=' . urlencode('Please login first.'));
}
if (!isset($_GET['pro_id'])) {
    redirect('problemlist.php');
}
$user_id = $_SESSION['user_id'];
$pro_id = intval($_GET['pro_id']);
$is_admin = isset($_SESSION['user_id']) && permission_admin($_SESSION['user_id']);
if (strlen($_POST['mark_des']) > 0) {
    $new_mark_des = get_to_mysql($_POST['mark_des']);
    $new_fore_color = $_POST['fore_color_r'] * 65536 + $_POST['fore_color_g'] * 256 + $_POST['fore_color_b'];
    $new_back_color = $_POST['back_color_r'] * 65536 + $_POST['back_color_g'] * 256 + $_POST['back_color_b'];
    $query = 'insert into config_mark (mark_des,fore_color,back_color) values ' . "('{$new_mark_des}',{$new_fore_color},{$new_back_color})";
    $ret = oj_query($query);
}
$query = "select mark_id from user_mark where user_id=" . intval($user_id) . " and pro_id=" . intval($pro_id);
$ret = oj_query($query);
while ($row = mysql_fetch_row($ret)) {
    $tag_marked[$row[0]] = 1;
}
if (isset($_POST['action'])) {
    $old_marked = $tag_marked;
    if (!empty($_POST['new_tag'])) {
        foreach ($_POST['new_tag'] as $key => $val) {
            if (isset($old_marked[(int) $val])) {