2024-10-10
This commit is contained in:
8
web/admin/admin-bar.php
Normal file
8
web/admin/admin-bar.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<div class="navbar">
|
||||
<div class="navbar-inner navbar-fixed-top" style="visibility: visible; position: fixed;">
|
||||
<a class='brand' href="<?php echo $OJ_HOME?>">
|
||||
ADMIN PANEL
|
||||
</a>
|
||||
<div class="nav-collapse"><ul class="nav pull-right"><li class="return"><a href="../">Return</a></li></ul></div>
|
||||
</div>
|
||||
</div>
|
||||
25
web/admin/admin-header.php
Normal file
25
web/admin/admin-header.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
ini_set("memory_limit", "1024M"); //set this bigger to import big files.
|
||||
ini_set("max_execution_time", "600");
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once ("../include/my_func.inc.php");
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel=stylesheet href='../include/hoj.css' type='text/css'>
|
||||
<script src="../template/bs3/jquery.min.js"></script>
|
||||
<script>
|
||||
$("document").ready(function (){
|
||||
$("form").append("<div id='csrf' />");
|
||||
$("#csrf").load("../csrf.php");
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])||isset($_SESSION[$OJ_NAME.'_'.'password_setter']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
require_once("../template/$OJ_TEMPLATE/css.php");
|
||||
if(file_exists("../lang/$OJ_LANG.php")) require_once("../lang/$OJ_LANG.php");
|
||||
?>
|
||||
<iframe src="../session.php" height=0px width=0px ></iframe>
|
||||
297
web/admin/admin.css
Normal file
297
web/admin/admin.css
Normal file
@@ -0,0 +1,297 @@
|
||||
/*!
|
||||
* author slixurd
|
||||
* For the Online Judge Admin page
|
||||
*/
|
||||
|
||||
@import url(../bootstrap/css/bootstrap.css);
|
||||
|
||||
.menu-btn{
|
||||
|
||||
text-decoration: none;
|
||||
padding: 5px 10px;
|
||||
display: list-item;
|
||||
background: #242a2f;
|
||||
min-width: 168px;
|
||||
border: none;
|
||||
color: #faf7f9;
|
||||
font-weight: bold;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
text-shadow: -0.8px 0.5px 0.4px #333;
|
||||
margin-top: 3px;
|
||||
width: 100%;
|
||||
text-align: center;
|
||||
box-shadow: 0 0 4px 0 #242a2f;
|
||||
-webkit-box-shadow: 0 0 4px 0 #242a2f;
|
||||
-moz-box-shadow: 0 0 4px 0 #242a2f;
|
||||
background-image: -webkit-linear-gradient(bottom, #242a2f, #1a1f1b);
|
||||
|
||||
|
||||
}
|
||||
|
||||
.top-space{
|
||||
margin-top: 52px;
|
||||
}
|
||||
|
||||
body{
|
||||
background-image: url("../image/back.png");
|
||||
opacity: 0.95;
|
||||
}
|
||||
|
||||
.menu-group{
|
||||
padding-top: 15px;
|
||||
}
|
||||
|
||||
.col{
|
||||
background:#f9f9f9;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
box-shadow: 0 0 18px 0 #242a2f;
|
||||
-webkit-box-shadow: 0 0 18px 0 #242a2f;
|
||||
-moz-box-shadow: 0 0 18px 0 #242a2f;
|
||||
min-width: 240px;
|
||||
}
|
||||
|
||||
.align-center{
|
||||
left:auto;
|
||||
text-align:center;
|
||||
text-align:-webkit-center;
|
||||
vertical-align: center;
|
||||
|
||||
}
|
||||
|
||||
.clear-float{
|
||||
float: none;
|
||||
}
|
||||
|
||||
.btn-group .btn{
|
||||
float: none;
|
||||
}
|
||||
|
||||
div .bottom-space{
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.marginTop{
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.news-header{
|
||||
padding-top: 15px;
|
||||
font-size: 22px;
|
||||
}
|
||||
.news-content{
|
||||
background:#f9f9f9;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
box-shadow: 0 0 18px 0 #242a2f;
|
||||
-webkit-box-shadow: 0 0 18px 0 #242a2f;
|
||||
-moz-box-shadow: 0 0 18px 0 #242a2f;
|
||||
min-width: 708px;
|
||||
max-width: 900px;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
text-align: center;
|
||||
padding-bottom: 6px;
|
||||
}
|
||||
|
||||
.h2-head{
|
||||
padding-top: 30px;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
.h-head{
|
||||
padding-top: 30px;
|
||||
padding-bottom: 15px;
|
||||
font-size: 28px;
|
||||
}
|
||||
|
||||
.a-color{
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
button a:hover{
|
||||
color:#04ca3f;
|
||||
}
|
||||
|
||||
.add-contest-p p{
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.add-contest-p input{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.bk{
|
||||
background:#f9f9f9;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
box-shadow: 0 0 18px 0 #242a2f;
|
||||
-webkit-box-shadow: 0 0 18px 0 #242a2f;
|
||||
-moz-box-shadow: 0 0 18px 0 #242a2f;
|
||||
min-width: 240px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
}
|
||||
|
||||
.button-align input{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.content-center{
|
||||
margin-left:auto;margin-right:auto;margin-top:20px;
|
||||
left:auto;
|
||||
text-align:center;
|
||||
text-align:-webkit-center;
|
||||
vertical-align: center;
|
||||
|
||||
}
|
||||
|
||||
.padding-center{
|
||||
padding-top: 10px;
|
||||
padding-bottom: 15px;
|
||||
}
|
||||
|
||||
.content-center input{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.content-center div{
|
||||
padding-top: 5px;
|
||||
}
|
||||
|
||||
.text-notcenter{
|
||||
margin-left:auto;
|
||||
margin-right:auto;
|
||||
margin-top:20px;
|
||||
text-align:center;
|
||||
text-align:-webkit-center;
|
||||
vertical-align: center;
|
||||
|
||||
|
||||
}
|
||||
.changepass{
|
||||
margin: 0 auto;
|
||||
width: 280px;
|
||||
font-size: 16px;
|
||||
height: 175px;
|
||||
padding-top: 10px;
|
||||
background:#f9f9f9;
|
||||
-webkit-border-radius: 5px;
|
||||
border-radius: 5px;
|
||||
-moz-border-radius: 5px;
|
||||
box-shadow: 0 0 18px 0 #242a2f;
|
||||
-webkit-box-shadow: 0 0 18px 0 #242a2f;
|
||||
-moz-box-shadow: 0 0 18px 0 #242a2f;
|
||||
padding-left: 20px;
|
||||
padding-right: 20px;
|
||||
margin-top: 45px;
|
||||
}
|
||||
.changepass .change{
|
||||
margin: 0 auto;
|
||||
width:170px;
|
||||
font-size: 20px;
|
||||
margin-top: 20px;
|
||||
}
|
||||
.changepass .btn{
|
||||
margin-left: 110px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
.changepass .in{
|
||||
width: 80%;
|
||||
}
|
||||
.changepass .in-title{
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
.msg{
|
||||
width: 530px;
|
||||
height: 550px;
|
||||
margin: 30px auto;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.msg .btn{
|
||||
width: 140px;
|
||||
margin-left: 195px;
|
||||
}
|
||||
|
||||
.rejudge{
|
||||
width: 300px;
|
||||
height: 240px;
|
||||
margin: 30px auto;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.span10 hr{
|
||||
border-top: 1px solid rgb(209, 209, 208);
|
||||
}
|
||||
|
||||
.give-source{
|
||||
width: 300px;
|
||||
height: 310px;
|
||||
margin: 30px auto;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.give-source input{
|
||||
width: 95%;
|
||||
}
|
||||
|
||||
.database{
|
||||
width: 460px;
|
||||
height: 250px;
|
||||
margin: 30px auto;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
}
|
||||
|
||||
.database .btn{
|
||||
margin-top: 15px;
|
||||
}
|
||||
|
||||
.copy-problem{
|
||||
width: 400px;
|
||||
height: 370px;
|
||||
margin: 30px auto;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
padding-top: 10px;
|
||||
font-size: 14px;
|
||||
|
||||
}
|
||||
.copy-problem ol {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.changeid{
|
||||
width: 600px;
|
||||
height: 210px;
|
||||
margin: 30px auto;
|
||||
padding-left: 15px;
|
||||
padding-right: 15px;
|
||||
padding-top: 10px;
|
||||
font-size: 14px;
|
||||
}
|
||||
.changeid input{
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.menu-btn a:hover{
|
||||
color: red;
|
||||
text-decoration: none;
|
||||
}
|
||||
.menu-btn .a-color{
|
||||
width: 120px;
|
||||
}
|
||||
|
||||
.return{
|
||||
font-size: 20px;
|
||||
float: right;
|
||||
}
|
||||
56
web/admin/ajax.php
Normal file
56
web/admin/ajax.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
if($_SERVER['REQUEST_METHOD']=="POST"){
|
||||
$m=$_POST["m"];
|
||||
if($m=="problem_add_source"){
|
||||
$pid=intval($_POST['pid']);
|
||||
$new_source=($_POST['ns']);
|
||||
$sql= "update problem set source=concat(source,' ',?) where problem_id=?";
|
||||
echo pdo_query($sql,$new_source,$pid);
|
||||
}
|
||||
if($m=="problem_update_time"){
|
||||
$pid=intval($_POST['pid']);
|
||||
$time=intval($_POST['t']);
|
||||
$sql= "update problem set time_limit=? where problem_id=?";
|
||||
echo pdo_query($sql,$time,$pid);
|
||||
}
|
||||
if($m=="problem_get_title"){
|
||||
$pid=intval($_POST['pid']);
|
||||
$sql= "select title,source from problem where problem_id=?";
|
||||
$row=mysql_query_cache($sql,$pid)[0];
|
||||
echo $row['title']." <span class='label label-success'>".$row['source']."</span>";
|
||||
}
|
||||
if($m=="user_update_nick"){
|
||||
$user_id=$_POST['user_id'];
|
||||
$nick=$_POST['nick'];
|
||||
$sql= "update users set nick=? where user_id=?";
|
||||
echo pdo_query($sql,$nick,$user_id);
|
||||
$sql= "update solution set nick=? where user_id=?";
|
||||
pdo_query($sql,$nick,$user_id);
|
||||
}
|
||||
if($m=="user_update_school"){
|
||||
$user_id=$_POST['user_id'];
|
||||
$school=$_POST['school'];
|
||||
$sql= "update users set school=? where user_id=?";
|
||||
echo pdo_query($sql,$school,$user_id);
|
||||
}
|
||||
if($m=="user_update_group_name"){
|
||||
$user_id=$_POST['user_id'];
|
||||
$group_name=$_POST['group_name'];
|
||||
$sql="update users set group_name=? where user_id=?";
|
||||
echo pdo_query($sql,$group_name,$user_id);
|
||||
}
|
||||
if($m=="get_user_list_of_contest"){
|
||||
$contest_id=$_POST['contest_id'];
|
||||
$sql= "select distinct user_id from privilege where rightstr=? ";
|
||||
$users=pdo_query($sql,"c".$contest_id);
|
||||
foreach($users as $user){
|
||||
echo $user['user_id']."\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
113
web/admin/backup.php
Normal file
113
web/admin/backup.php
Normal file
@@ -0,0 +1,113 @@
|
||||
<?php
|
||||
require_once("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
if(isset($_POST['do'])){
|
||||
|
||||
require_once(dirname(__FILE__)."/../include/backup.php");
|
||||
$target=$OJ_DATA."/0/".$DB_NAME."_".(date('Y-m-d H:i:s')).".sql";
|
||||
$db_file=basename($target);
|
||||
$dirpath=dirname($target);
|
||||
if (!file_exists($dirpath)) {
|
||||
mkdir($dirpath);
|
||||
}
|
||||
$config = array(
|
||||
'host' => $DB_HOST,
|
||||
'port' => 3306,
|
||||
'user' => $DB_USER,
|
||||
'password' => $DB_PASS,
|
||||
'database' => $DB_NAME,
|
||||
'charset' => 'utf-8',
|
||||
'target' => $target
|
||||
);
|
||||
$bak = new DatabaseTool($config);
|
||||
$bak->backup();
|
||||
|
||||
function addDirToZip($path, $zip) {
|
||||
global $OJ_DATA;
|
||||
if ($path=="data/0") return;
|
||||
$handler = opendir($path); //打开当前文件夹由$path指定。
|
||||
/*
|
||||
循环的读取文件夹下的所有文件和文件夹
|
||||
其中$filename = readdir($handler)是每次循环的时候将读取的文件名赋值给$filename,
|
||||
为了不陷于死循环,所以还要让$filename !== false。
|
||||
一定要用!==,因为如果某个文件名如果叫'0',或者某些被系统认为是代表false,用!=就会停止循环
|
||||
*/
|
||||
while (($filename = readdir($handler)) !== false) {
|
||||
if ($filename != "." && $filename != "..") {//文件夹文件名字为'.'和‘..’,不要对他们进行操作
|
||||
if (is_dir($path . "/" . $filename)) {// 如果读取的某个对象是文件夹,则递归
|
||||
addDirToZip($path . "/" . $filename, $zip);
|
||||
} else { //将文件加入zip对象
|
||||
$zip->addFile($path . "/" . $filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
@closedir($path);
|
||||
}
|
||||
|
||||
$zip = new ZipArchive();
|
||||
$ztar=dirname($target)."/backup_".(date('Y-m-d H:i:s')).".zip";;
|
||||
//echo $ztar;
|
||||
if ($zip->open($ztar, ZipArchive::CREATE) === TRUE) {
|
||||
chdir( dirname($OJ_DATA) );
|
||||
if(is_dir("data"))
|
||||
addDirToZip("data", $zip); //测试数据
|
||||
chdir(realpath(dirname(dirname(__FILE__))));
|
||||
if($OJ_SaaS_ENABLE && $DOMAIN!=$domain){
|
||||
if(is_dir("upload/$domain"))
|
||||
addDirToZip("upload/$domain", $zip); //子域题目图片
|
||||
}else{
|
||||
if(is_dir("upload/"))
|
||||
addDirToZip("upload", $zip); //题目图片
|
||||
}
|
||||
chdir($OJ_DATA."/0");
|
||||
if(file_exists($db_file)){
|
||||
$zip->addFile($db_file);
|
||||
}
|
||||
$zip->close(); //关闭处理的zip文件
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
||||
<?php
|
||||
}else{
|
||||
?>
|
||||
<br>
|
||||
<br>
|
||||
<form method="post" action="backup.php">
|
||||
<input type="submit" name="do" value="Backup">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
<button onclick="phpfm(0)" >查看备份文件</button>
|
||||
<script src='../template/bs3/jquery.min.js' ></script>
|
||||
|
||||
<script>
|
||||
function phpfm(pid){
|
||||
//alert(pid);
|
||||
$.post("phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){
|
||||
if(status=="success"){
|
||||
document.location.href="phpfm.php?frame=3&pid="+pid;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
73
web/admin/changepass.php
Normal file
73
web/admin/changepass.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php require_once("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'password_setter']) )){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Set Password</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_USER."-".$MSG_SETPASSWORD?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
|
||||
$user_id = $_POST['user_id'];
|
||||
$passwd = $_POST['passwd'];
|
||||
|
||||
if(false){
|
||||
$user_id = stripslashes($user_id);
|
||||
$passwd = stripslashes($passwd);
|
||||
}
|
||||
|
||||
$passwd = pwGen($passwd);
|
||||
$sql = "update `users` set `password`=? where `user_id`=? and user_id not in( select user_id from privilege where rightstr='administrator')";
|
||||
|
||||
if(pdo_query($sql,$passwd,$user_id) == 1)
|
||||
echo "<center><h4 class='text-danger'>User ".htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8')."'s Password Changed!</h4></center>";
|
||||
else
|
||||
echo "<center><h4 class='text-danger'>There is No such User ".htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8')."! or User ".htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8')." is administrator!</h4></center>";
|
||||
}
|
||||
?>
|
||||
|
||||
<form action=changepass.php method=post class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID?></label>
|
||||
<?php if(isset($_GET['uid'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else if(isset($_POST['user_id'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PASSWORD?></label>
|
||||
<div class="col-sm-3"><input name="passwd" class="form-control" placeholder="<?php echo $MSG_PASSWORD."*"?>" type="password" autocomplete="off" required ></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<button name="do" type="hidden" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button name="submit" type="button" onclick='$("input[name=passwd]").attr("type","text");' class="btn btn-default btn-block">Show</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
37
web/admin/check.php
Normal file
37
web/admin/check.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php require_once("admin-header.php");
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>OJ Administration</title>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel=stylesheet href='admin.css' type='text/css'>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<?php require_once("admin-bar.php"); ?>
|
||||
<div class="row-fluid top-space">
|
||||
<div class="span2" >
|
||||
<div class="menu-group" >
|
||||
<?php require_once("menu.php") ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span10">
|
||||
<div class="">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
310
web/admin/contest_add.php
Normal file
310
web/admin/contest_add.php
Normal file
@@ -0,0 +1,310 @@
|
||||
<?php
|
||||
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
require_once("../include/const.inc.php");
|
||||
require_once("admin-header.php");
|
||||
header("Cache-control:private");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
echo "<center><h3>".$MSG_CONTEST."-".$MSG_ADD."</h3></center>";
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
|
||||
<body leftmargin="30" >
|
||||
<?php
|
||||
$description = "";
|
||||
if(isset($_POST['startdate'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
$starttime = $_POST['startdate']." ".intval($_POST['shour']).":".intval($_POST['sminute']).":00";
|
||||
$endtime = $_POST['enddate']." ".intval($_POST['ehour']).":".intval($_POST['eminute']).":00";
|
||||
//echo $starttime;
|
||||
//echo $endtime;
|
||||
|
||||
$title = $_POST['title'];
|
||||
$private = $_POST['private'];
|
||||
$password = $_POST['password'];
|
||||
$description = $_POST['description'];
|
||||
|
||||
if(false){
|
||||
$title = stripslashes($title);
|
||||
$private = stripslashes($private);
|
||||
$password = stripslashes($password);
|
||||
$description = stripslashes($description);
|
||||
}
|
||||
|
||||
$lang = $_POST['lang'];
|
||||
$langmask = 0;
|
||||
foreach($lang as $t){
|
||||
$langmask += 1<<$t;
|
||||
}
|
||||
|
||||
$langmask = ((1<<count($language_ext))-1)&(~$langmask);
|
||||
//echo $langmask;
|
||||
|
||||
$sql = "INSERT INTO `contest`(`title`,`start_time`,`end_time`,`private`,`langmask`,`description`,`password`,`user_id`)
|
||||
VALUES(?,?,?,?,?,?,?,?)";
|
||||
|
||||
$description = str_replace("<p>", "", $description);
|
||||
$description = str_replace("</p>", "<br />", $description);
|
||||
$description = str_replace(",", ", ", $description);
|
||||
$user_id=$_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
echo $sql.$title.$starttime.$endtime.$private.$langmask.$description.$password,$user_id;
|
||||
$cid = pdo_query($sql,$title,$starttime,$endtime,$private,$langmask,$description,$password,$user_id) ;
|
||||
echo "Add Contest ".$cid;
|
||||
|
||||
$sql = "DELETE FROM `contest_problem` WHERE `contest_id`=$cid";
|
||||
$plist = trim($_POST['cproblem']);
|
||||
$pieces = explode(",",$plist );
|
||||
$pieces = array_unique($pieces);
|
||||
if(count($pieces)>0 && intval($pieces[0])>0){
|
||||
|
||||
|
||||
$sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)";
|
||||
$plist="";
|
||||
$pid=0;
|
||||
for($i=0; $i<count($pieces); $i++){
|
||||
$sql="select problem_id from problem where problem_id=?";
|
||||
$has=pdo_query($sql,$pieces[$i]);
|
||||
if(count($has) > 0) {
|
||||
if($plist) $plist.=",";
|
||||
$plist.=intval($pieces[$i]);
|
||||
pdo_query($sql_1,$cid,$pieces[$i],$pid);
|
||||
$pid++;
|
||||
}else{
|
||||
print("Problem not exists:".$pieces[$i]."<br>\n");
|
||||
}
|
||||
}
|
||||
//echo $sql_1;
|
||||
$sql = "UPDATE `problem` SET defunct='N' WHERE `problem_id` IN ($plist)";
|
||||
pdo_query($sql) ;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `privilege` WHERE `rightstr`=?";
|
||||
pdo_query($sql,"c$cid");
|
||||
|
||||
$sql = "INSERT INTO `privilege` (`user_id`,`rightstr`) VALUES(?,?)";
|
||||
pdo_query($sql,$_SESSION[$OJ_NAME.'_'.'user_id'],"m$cid");
|
||||
|
||||
$_SESSION[$OJ_NAME.'_'."m$cid"] = true;
|
||||
$pieces = explode("\n", trim($_POST['ulist']));
|
||||
|
||||
if(count($pieces)>0 && strlen($pieces[0])>0){
|
||||
$sql_1 = "INSERT INTO `privilege`(`user_id`,`rightstr`) VALUES (?,?)";
|
||||
for($i=0; $i<count($pieces); $i++){
|
||||
pdo_query($sql_1,trim($pieces[$i]),"c$cid") ;
|
||||
}
|
||||
}
|
||||
echo "<script>window.location.href=\"contest_list.php\";</script>";
|
||||
}
|
||||
else{
|
||||
if(isset($_GET['cid'])){
|
||||
$cid = intval($_GET['cid']);
|
||||
$sql = "SELECT * FROM contest WHERE `contest_id`=?";
|
||||
$result = pdo_query($sql,$cid);
|
||||
$row = $result[0];
|
||||
$title = $row['title']."-Copy";
|
||||
|
||||
$private = $row['private'];
|
||||
$langmask = $row['langmask'];
|
||||
$description = $row['description'];
|
||||
|
||||
$plist = "";
|
||||
$sql = "SELECT `problem_id` FROM `contest_problem` WHERE `contest_id`=? ORDER BY `num`";
|
||||
$result = pdo_query($sql,$cid);
|
||||
foreach($result as $row){
|
||||
if($plist) $plist = $plist.',';
|
||||
$plist = $plist.$row[0];
|
||||
}
|
||||
|
||||
$ulist = "";
|
||||
$sql = "SELECT `user_id` FROM `privilege` WHERE `rightstr`=? order by user_id";
|
||||
$result = pdo_query($sql,"c$cid");
|
||||
|
||||
foreach($result as $row){
|
||||
if($ulist) $ulist .= "\n";
|
||||
$ulist .= $row[0];
|
||||
}
|
||||
}
|
||||
else if(isset($_POST['problem2contest'])){
|
||||
$plist = "";
|
||||
|
||||
sort($_POST['pid']);
|
||||
foreach($_POST['pid'] as $i){
|
||||
if($plist)
|
||||
$plist.=','.intval($i);
|
||||
else
|
||||
$plist=$i;
|
||||
}
|
||||
$plist = trim($_POST['hlist']);
|
||||
$pieces = explode(",",$plist );
|
||||
$pieces = array_unique($pieces);
|
||||
if($pieces[0]=="") unset($pieces[0]);
|
||||
$plist=implode(",",$pieces);
|
||||
|
||||
}else if(isset($_GET['spid'])){
|
||||
//require_once("../include/check_get_key.php");
|
||||
$spid = intval($_GET['spid']);
|
||||
|
||||
$plist = "";
|
||||
$sql = "SELECT `problem_id` FROM `problem` WHERE `problem_id`>=? ";
|
||||
$result = pdo_query($sql,$spid);
|
||||
foreach($result as $row){
|
||||
if($plist) $plist.=',';
|
||||
$plist.=$row[0];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Contest Add</title>
|
||||
</head>
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<form method=POST>
|
||||
<p align=left>
|
||||
<?php echo "<h3>".$MSG_CONTEST."-".$MSG_TITLE."</h3>"?>
|
||||
<input class="input input-xxlarge" style="width:100%;" type=text name=title value="<?php echo isset($title)?$title:""?>"><br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST.$MSG_Start?>:
|
||||
<input class=input-large type=date name='startdate' value='<?php echo date('Y').'-'. date('m').'-'.date('d')?>' size=4 >
|
||||
Hour: <input class=input-mini type=text name=shour size=2 value=<?php echo date('H')?>>
|
||||
Minute: <input class=input-mini type=text name=sminute value=00 size=2 >
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST.$MSG_End?>:
|
||||
<input class=input-large type=date name='enddate' value='<?php echo date('Y').'-'. date('m').'-'.date('d')?>' size=4 >
|
||||
Hour: <input class=input-mini type=text name=ehour size=2 value=<?php echo (date('H')+4)%24?>>
|
||||
Minute: <input class=input-mini type=text name=eminute value=00 size=2 >
|
||||
</p>
|
||||
<br>
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_PROBLEM_ID?>
|
||||
<?php echo "( Add problemIDs with coma , )"?><br>
|
||||
<input id="plist" onchange="showTitles()" class=input-xxlarge placeholder="Example:1000,1001,1002" type=text style="width:100%" name=cproblem value="<?php echo isset($plist)?$plist:""?>">
|
||||
<div id="ptitles"></div>
|
||||
</p>
|
||||
<br>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_CONTEST."-".$MSG_Description."</h4>"?>
|
||||
<textarea class=kindeditor rows=13 name=description cols=80><?php echo isset($description)?$description:""?></textarea>
|
||||
<br>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td rowspan=2>
|
||||
<p aligh=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_LANG?>
|
||||
<?php echo "( Add PLs with Ctrl+click )"?><br>
|
||||
<?php echo $MSG_PLS_ADD?><br>
|
||||
<select name="lang[]" multiple="multiple" style="height:220px">
|
||||
<?php
|
||||
$lang_count = count($language_ext);
|
||||
$lang = (~((int)$langmask))&((1<<$lang_count)-1);
|
||||
|
||||
if(isset($_COOKIE['lastlang'])) $lastlang=$_COOKIE['lastlang'];
|
||||
else $lastlang = 0;
|
||||
|
||||
for($i=0; $i<$lang_count; $i++){
|
||||
if( (1<<$i) & $OJ_LANGMASK ) continue;
|
||||
echo "<option value=$i ".( $lang&(1<<$i)?"selected":"").">".$language_name[$i]."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
</td>
|
||||
<td height="10px">
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_Public?>:
|
||||
<select name=private style="width:150px;">
|
||||
<option value=0 <?php echo $private=='0'?'selected=selected':''?>><?php echo $MSG_Public?></option>
|
||||
<option value=1 <?php echo $private=='1'?'selected=selected':''?>><?php echo $MSG_Private?></option>
|
||||
</select>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_PASSWORD?>:
|
||||
<input type=text name=password style="width:150px;" value="">
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="*">
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_USER?>
|
||||
<?php echo "( Add private contest's userIDs with newline \n )"?>
|
||||
<select id="copy_from" onchange="copy_user_from_contest($(this).val());" >
|
||||
<option value=0 ><?php echo $MSG_COPY_USER_LIST_FROM_CONTEST ?></option>
|
||||
<?php
|
||||
$contests="0";
|
||||
foreach($_SESSION as $right=>$value){
|
||||
if(strpos($right,$OJ_NAME.'_m')===0){
|
||||
// echo "<option>".substr($right,strlen($OJ_NAME."_m"))."[".strpos($right,$OJ_NAME.'_m')."]</option>";
|
||||
$contests.=",".substr($right,strlen($OJ_NAME."_m"));
|
||||
}
|
||||
}
|
||||
$contests=pdo_query("select contest_id,title from contest where contest_id in ($contests) order by contest_id desc limit 20 ");
|
||||
if(!empty($contests)){
|
||||
|
||||
foreach( $contests as $contest ){
|
||||
echo "<option value='".$contest['contest_id']."'>".$contest['title']."</option>";
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
|
||||
<br>
|
||||
<textarea id="ulist" name='ulist' rows='10' style='width:100%;' placeholder='user1<?php echo "\n"?>user2<?php echo "\n"?>user3<?php echo "\n"?>
|
||||
<?php echo $MSG_PRIVATE_USERS_ADD?><?php echo "\n"?>'><?php if(isset($ulist)){ echo $ulist;}?></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value='<?php echo $MSG_SAVE?>' name=submit>
|
||||
</div>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function copy_user_from_contest(cid){
|
||||
$("#ulist").val($.ajax({url:"ajax.php",method:"post",data:{"contest_id":cid,"m":"get_user_list_of_contest"},async:false}).responseText);
|
||||
}
|
||||
|
||||
function showTitles(){
|
||||
let ts=$("#ptitles");
|
||||
let pids=$("#plist").val().split(",");
|
||||
let html="";
|
||||
pids.forEach(function(v,i,a){
|
||||
let title=$.ajax({url:"ajax.php",method:"post",data:{"pid":v,"m":"problem_get_title"},async:false}).responseText;
|
||||
html+=(v)+":<a href='../problem.php?id="+v+"' target='_blank'>"+title+"</a><br>\n";
|
||||
console.log(v);
|
||||
});
|
||||
ts.html(html);
|
||||
|
||||
}
|
||||
$(document).ready(function(){
|
||||
showTitles();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php }
|
||||
require_once("../oj-footer.php");
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
28
web/admin/contest_df_change.php
Normal file
28
web/admin/contest_df_change.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php require_once("admin-header.php");
|
||||
require_once("../include/check_get_key.php");
|
||||
$cid=intval($_GET['cid']);
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'."m$cid"]) || isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) exit();
|
||||
$sql="select `defunct` FROM `contest` WHERE `contest_id`=?";
|
||||
$result=pdo_query($sql,$cid);
|
||||
$num=count($result);
|
||||
if ($num<1){
|
||||
|
||||
echo "No Such Contest!";
|
||||
require_once("../oj-footer.php");
|
||||
exit(0);
|
||||
}
|
||||
$row=$result[0];
|
||||
if ($row[0]=='N'){
|
||||
$sql="UPDATE `contest` SET `defunct`='Y' WHERE `contest_id`=?";
|
||||
}else{
|
||||
$sql="UPDATE `contest` SET `defunct`='N' WHERE `contest_id`=?";
|
||||
}
|
||||
pdo_query($sql,$cid);
|
||||
|
||||
|
||||
|
||||
?>
|
||||
<script language=javascript>
|
||||
history.go(-1);
|
||||
</script>
|
||||
|
||||
267
web/admin/contest_edit.php
Normal file
267
web/admin/contest_edit.php
Normal file
@@ -0,0 +1,267 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Edit Contest</title>
|
||||
</head>
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
require_once("../include/const.inc.php");
|
||||
|
||||
require_once("admin-header.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
echo "<center><h3>"."Edit-".$MSG_CONTEST."</h3></center>";
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
|
||||
<body leftmargin="30" >
|
||||
<?php
|
||||
if(isset($_POST['startdate'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
$starttime = $_POST['startdate']." ".intval($_POST['shour']).":".intval($_POST['sminute']).":00";
|
||||
$endtime = $_POST['enddate']." ".intval($_POST['ehour']).":".intval($_POST['eminute']).":00";
|
||||
//echo $starttime;
|
||||
//echo $endtime;
|
||||
|
||||
$title = $_POST['title'];
|
||||
$private = $_POST['private'];
|
||||
$password = $_POST['password'];
|
||||
$description = $_POST['description'];
|
||||
|
||||
if(false){
|
||||
$title = stripslashes($title);
|
||||
$private = stripslashes($private);
|
||||
$password = stripslashes($password);
|
||||
$description = stripslashes($description);
|
||||
}
|
||||
|
||||
$lang = $_POST['lang'];
|
||||
$langmask=0;
|
||||
foreach($lang as $t){
|
||||
$langmask += 1<<$t;
|
||||
}
|
||||
|
||||
$langmask = ((1<<count($language_ext))-1)&(~$langmask);
|
||||
//echo $langmask;
|
||||
|
||||
$cid=intval($_POST['cid']);
|
||||
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'."m$cid"])||isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) exit();
|
||||
|
||||
$description = str_replace("<p>", "", $description);
|
||||
$description = str_replace("</p>", "<br />", $description);
|
||||
$description = str_replace(",", ",", $description);
|
||||
|
||||
|
||||
$sql = "UPDATE `contest` SET `title`=?,`description`=?,`start_time`=?,`end_time`=?,`private`=?,`langmask`=?,`password`=? WHERE `contest_id`=?";
|
||||
//echo $sql;
|
||||
pdo_query($sql,$title,$description,$starttime,$endtime,$private,$langmask,$password,$cid);
|
||||
|
||||
$sql = "DELETE FROM `contest_problem` WHERE `contest_id`=?";
|
||||
pdo_query($sql,$cid);
|
||||
$plist=trim($_POST['cproblem']);
|
||||
$pieces = explode(',', $plist);
|
||||
|
||||
if(count($pieces)>0 && strlen($pieces[0])>0){
|
||||
$sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)";
|
||||
|
||||
$plist="";
|
||||
pdo_query("update solution set num=-1 where contest_id=?",$cid);
|
||||
$num=0;
|
||||
for($i=0; $i<count($pieces); $i++){
|
||||
$sql="select problem_id from problem where problem_id=?";
|
||||
$pid=intval($pieces[$i]);
|
||||
$has=pdo_query($sql,$pid);
|
||||
if(count($has) > 0) {
|
||||
if($plist) $plist.=",";
|
||||
$plist.=intval($pieces[$i]);
|
||||
pdo_query($sql_1,$cid,$pieces[$i],$num);
|
||||
$sql="UPDATE `contest_problem` SET `c_accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=? AND `result`=4) WHERE `problem_id`=? and contest_id=?";
|
||||
pdo_query($sql,$pid,$cid,$pid,$cid);
|
||||
$sql="UPDATE `contest_problem` SET `c_submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=?) WHERE `problem_id`=? and contest_id=?";
|
||||
pdo_query($sql,$pid,$cid,$pid,$cid);
|
||||
$sql_2 = "update solution set num=? where contest_id=? and problem_id=?;";
|
||||
pdo_query($sql_2,$num,$cid,$pid);
|
||||
$num++;
|
||||
}else{
|
||||
print("Problem not exists:".$pieces[$i]."<br>\n");
|
||||
}
|
||||
}
|
||||
|
||||
$sql = "update `problem` set defunct='N' where `problem_id` in ($plist)";
|
||||
pdo_query($sql) ;
|
||||
}
|
||||
|
||||
$sql = "DELETE FROM `privilege` WHERE `rightstr`=?";
|
||||
pdo_query($sql,"c$cid");
|
||||
$pieces = explode("\n", trim($_POST['ulist']));
|
||||
$pieces = array_unique($pieces);
|
||||
if(count($pieces)>0 && strlen($pieces[0])>0){
|
||||
$sql_1 = "INSERT INTO `privilege`(`user_id`,`rightstr`) VALUES (?,?)";
|
||||
for($i=0; $i<count($pieces); $i++){
|
||||
pdo_query($sql_1,trim($pieces[$i]),"c$cid") ;
|
||||
}
|
||||
}
|
||||
|
||||
echo "<script>window.location.href=\"contest_list.php\";</script>";
|
||||
exit();
|
||||
}else{
|
||||
$cid = intval($_GET['cid']);
|
||||
$sql = "SELECT * FROM `contest` WHERE `contest_id`=?";
|
||||
$result = pdo_query($sql,$cid);
|
||||
|
||||
if(count($result)!=1){
|
||||
echo "No such Contest!";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$row = $result[0];
|
||||
$starttime = $row['start_time'];
|
||||
$endtime = $row['end_time'];
|
||||
$private = $row['private'];
|
||||
$password = $row['password'];
|
||||
$langmask = $row['langmask'];
|
||||
$description = $row['description'];
|
||||
$title = htmlentities($row['title'],ENT_QUOTES,"UTF-8");
|
||||
|
||||
$plist = "";
|
||||
$sql = "SELECT `problem_id` FROM `contest_problem` WHERE `contest_id`=? ORDER BY `num`";
|
||||
$result=pdo_query($sql,$cid);
|
||||
|
||||
foreach($result as $row){
|
||||
if($plist) $plist .= ",";
|
||||
$plist.=$row[0];
|
||||
}
|
||||
|
||||
$ulist = "";
|
||||
$sql = "SELECT `user_id` FROM `privilege` WHERE `rightstr`=? order by user_id";
|
||||
$result = pdo_query($sql,"c$cid");
|
||||
|
||||
foreach($result as $row){
|
||||
if($ulist) $ulist .= "\n";
|
||||
$ulist .= $row[0];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<form method=POST>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=hidden name='cid' value=<?php echo $cid?>>
|
||||
<p align=left>
|
||||
<?php echo "<h3>".$MSG_CONTEST."-".$MSG_TITLE."</h3>"?>
|
||||
<input class="input input-xxlarge" style="width:100%;" type=text name=title value="<?php echo $title?>"><br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST.$MSG_Start?>:
|
||||
<input class=input-large type=date name='startdate' value='<?php echo substr($starttime,0,10)?>' size=4 >
|
||||
Hour: <input class=input-mini type=text name=shour size=2 value='<?php echo substr($starttime,11,2)?>'>
|
||||
Minute: <input class=input-mini type=text name=sminute value='<?php echo substr($starttime,14,2)?>' size=2 >
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST.$MSG_End?>:
|
||||
<input class=input-large type=date name='enddate' value='<?php echo substr($endtime,0,10)?>' size=4 >
|
||||
Hour: <input class=input-mini type=text name=ehour size=2 value='<?php echo substr($endtime,11,2)?>'>
|
||||
Minute: <input class=input-mini type=text name=eminute value='<?php echo substr($endtime,14,2)?>' size=2 >
|
||||
</p>
|
||||
<br>
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_PROBLEM_ID?>
|
||||
<?php echo "( Add problemIDs with coma , )"?><br>
|
||||
<input id="plist" onchange="showTitles()" class=input-xxlarge type=text style="width:100%" name=cproblem value='<?php echo $plist?>'>
|
||||
<div id="ptitles"></div>
|
||||
</p>
|
||||
<br>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_CONTEST."-".$MSG_Description."</h4>"?>
|
||||
<textarea class=kindeditor rows=13 name=description cols=80>
|
||||
<?php echo htmlentities($description,ENT_QUOTES,'UTF-8')?>
|
||||
</textarea>
|
||||
<br>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td rowspan=2>
|
||||
<p aligh=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_LANG?>
|
||||
<?php echo "( Add PLs with Ctrl+click )"?><br>
|
||||
<?php echo $MSG_PLS_ADD?><br>
|
||||
<select name="lang[]" multiple="multiple" style="height:220px">
|
||||
<?php
|
||||
$lang_count = count($language_ext);
|
||||
$lang = (~((int)$langmask))&((1<<$lang_count)-1);
|
||||
|
||||
if(isset($_COOKIE['lastlang'])) $lastlang=$_COOKIE['lastlang'];
|
||||
else $lastlang = 0;
|
||||
|
||||
for($i=0; $i<$lang_count; $i++){
|
||||
if( (1<<$i) & $OJ_LANGMASK ) continue;
|
||||
echo "<option value=$i ".( $lang&(1<<$i)?"selected":"").">".$language_name[$i]."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
</td>
|
||||
|
||||
<td height="10px">
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_Public?>:
|
||||
<select name=private style="width:150px;">
|
||||
<option value=0 <?php echo $private=='0'?'selected=selected':''?>><?php echo $MSG_Public?></option>
|
||||
<option value=1 <?php echo $private=='1'?'selected=selected':''?>><?php echo $MSG_Private?></option>
|
||||
</select>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_PASSWORD?>:
|
||||
<input type=text name=password style="width:150px;" value='<?php echo htmlentities($password,ENT_QUOTES,'utf-8')?>'>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td height="*">
|
||||
<p align=left>
|
||||
<?php echo $MSG_CONTEST."-".$MSG_USER?>
|
||||
<?php echo "( Add private contest's userIDs with newline /n )"?>
|
||||
<br>
|
||||
<textarea name='ulist' rows='10' style='width:100%;' placeholder='user1<?php echo "\n"?>user2<?php echo "\n"?>user3<?php echo "\n"?>
|
||||
<?php echo $MSG_PRIVATE_USERS_ADD?><?php echo "\n"?>'><?php if(isset($ulist)){ echo $ulist;}?></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value='<?php echo $MSG_SAVE?>' name=submit> <input type=reset value=Reset name=reset>
|
||||
</div>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
<script>
|
||||
function showTitles(){
|
||||
let ts=$("#ptitles");
|
||||
let pids=$("#plist").val().split(",");
|
||||
let html="";
|
||||
pids.forEach(function(v,i,a){
|
||||
let title=$.ajax({url:"ajax.php",method:"post",data:{"pid":v,"m":"problem_get_title"},async:false}).responseText;
|
||||
html+=(v)+":<a href='../problem.php?id="+v+"' target='_blank'>"+title+"</a><br>\n";
|
||||
console.log(v);
|
||||
});
|
||||
ts.html(html);
|
||||
|
||||
}
|
||||
$(document).ready(function(){
|
||||
showTitles();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
124
web/admin/contest_list.php
Normal file
124
web/admin/contest_list.php
Normal file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
require_once("../include/set_get_key.php");
|
||||
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Contest List</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_CONTEST."-".$MSG_LIST?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
$sql = "SELECT COUNT('contest_id') AS ids FROM `contest`";
|
||||
$result = pdo_query($sql);
|
||||
$row = $result[0];
|
||||
|
||||
$ids = intval($row['ids']);
|
||||
|
||||
$idsperpage = 25;
|
||||
$pages = intval(ceil($ids/$idsperpage));
|
||||
|
||||
if(isset($_GET['page'])){ $page = intval($_GET['page']);}
|
||||
else{ $page = 1;}
|
||||
|
||||
$pagesperframe = 5;
|
||||
$frame = intval(ceil($page/$pagesperframe));
|
||||
|
||||
$spage = ($frame-1)*$pagesperframe+1;
|
||||
$epage = min($spage+$pagesperframe-1, $pages);
|
||||
|
||||
$sid = ($page-1)*$idsperpage;
|
||||
|
||||
$sql = "";
|
||||
if(isset($_GET['keyword']) && $_GET['keyword']!=""){
|
||||
$keyword = $_GET['keyword'];
|
||||
$keyword = "%$keyword%";
|
||||
$sql = "SELECT `contest_id`,`title`,`start_time`,`end_time`,`private`,`defunct` FROM `contest` WHERE (title LIKE ?) OR (description LIKE ?) ORDER BY `contest_id` DESC";
|
||||
$result = pdo_query($sql,$keyword,$keyword);
|
||||
}else{
|
||||
$sql = "SELECT `contest_id`,`title`,`start_time`,`end_time`,`private`,`defunct` FROM `contest` ORDER BY `contest_id` DESC LIMIT $sid, $idsperpage";
|
||||
$result = pdo_query($sql);
|
||||
}
|
||||
?>
|
||||
|
||||
<center>
|
||||
<form action=contest_list.php class="form-search form-inline">
|
||||
<input type="text" name=keyword class="form-control search-query" placeholder="<?php echo $MSG_CONTEST_NAME.', '.$MSG_EXPLANATION?>">
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
<table width=100% border=1 style="text-align:center;">
|
||||
<tr>
|
||||
<td><?php echo $MSG_CONTEST_ID?></td>
|
||||
<td><?php echo $MSG_CONTEST_NAME?></td>
|
||||
<td><?php echo $MSG_START_TIME?></td>
|
||||
<td><?php echo $MSG_END_TIME?></td>
|
||||
<td><?php echo $MSG_CONTEST_OPEN?></td>
|
||||
<td><?php echo $MSG_STATUS?></td>
|
||||
<td><?php echo $MSG_EDIT ?></td>
|
||||
<td><?php echo $MSG_COPY?></td>
|
||||
<td><?php echo $MSG_EXPORT ?></td>
|
||||
<td><?php echo $MSG_LOG?></td>
|
||||
<td><?php echo $MSG_SUSPECT?></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($result as $row){
|
||||
echo "<tr>";
|
||||
echo "<td>".$row['contest_id']."</td>";
|
||||
echo "<td><a href='../contest.php?cid=".$row['contest_id']."'>".$row['title']."</a></td>";
|
||||
echo "<td>".$row['start_time']."</td>";
|
||||
echo "<td>".$row['end_time']."</td>";
|
||||
$cid = $row['contest_id'];
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."m$cid"])){
|
||||
echo "<td><a href=contest_pr_change.php?cid=".$row['contest_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">".($row['private']=="0"?"<span class=green>$MSG_Public</span>":"<span class=red>$MSG_Private<span>")."</a></td>";
|
||||
echo "<td><a href=contest_df_change.php?cid=".$row['contest_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">".($row['defunct']=="N"?"<span class=green>$MSG_AVAILABLE </span>":"<span class=red>$MSG_RESERVED </span>")."</a></td>";
|
||||
echo "<td><a href=contest_edit.php?cid=".$row['contest_id'].">$MSG_EDIT</a></td>";
|
||||
echo "<td><a href=contest_add.php?cid=".$row['contest_id'].">$MSG_COPY</a></td>";
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])){
|
||||
echo "<td><a href=\"problem_export_xml.php?cid=".$row['contest_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey']."\">$MSG_EXPORT</a></td>";
|
||||
}else{
|
||||
echo "<td></td>";
|
||||
}
|
||||
echo "<td> <a href=\"../export_contest_code.php?cid=".$row['contest_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey']."\">$MSG_LOG</a></td>";
|
||||
}else{
|
||||
echo "<td colspan=5 align=right><a href=contest_add.php?cid=".$row['contest_id'].">$MSG_COPY</a><td>";
|
||||
}
|
||||
echo "<td><a href='suspect_list.php?cid=".$row['contest_id']."'>$MSG_SUSPECT</a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
if(!(isset($_GET['keyword']) && $_GET['keyword']!=""))
|
||||
{
|
||||
echo "<div style='display:inline;'>";
|
||||
echo "<nav class='center'>";
|
||||
echo "<ul class='pagination pagination-sm'>";
|
||||
echo "<li class='page-item'><a href='contest_list.php?page=".(strval(1))."'><<</a></li>";
|
||||
echo "<li class='page-item'><a href='contest_list.php?page=".($page==1?strval(1):strval($page-1))."'><</a></li>";
|
||||
for($i=$spage; $i<=$epage; $i++){
|
||||
echo "<li class='".($page==$i?"active ":"")."page-item'><a title='go to page' href='contest_list.php?page=".$i."'>".$i."</a></li>";
|
||||
}
|
||||
echo "<li class='page-item'><a href='contest_list.php?page=".($page==$pages?strval($page):strval($page+1))."'>></a></li>";
|
||||
echo "<li class='page-item'><a href='contest_list.php?page=".(strval($pages))."'>>></a></li>";
|
||||
echo "</ul>";
|
||||
echo "</nav>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
22
web/admin/contest_pr_change.php
Normal file
22
web/admin/contest_pr_change.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php require_once("admin-header.php");
|
||||
require_once("../include/check_get_key.php");
|
||||
$cid=intval($_GET['cid']);
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'."m$cid"]) || isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) exit();
|
||||
$sql="select `private` FROM `contest` WHERE `contest_id`=?";
|
||||
$result=pdo_query($sql,$cid);
|
||||
$num=count($result);
|
||||
if ($num<1){
|
||||
echo "No Such Problem!";
|
||||
|
||||
exit(0);
|
||||
}
|
||||
$row=$result[0];
|
||||
if (intval($row[0])==0) $sql="UPDATE `contest` SET `private`='1' WHERE `contest_id`=?";
|
||||
else $sql="UPDATE `contest` SET `private`='0' WHERE `contest_id`=?";
|
||||
|
||||
pdo_query($sql,$cid);
|
||||
?>
|
||||
<script language=javascript>
|
||||
history.go(-1);
|
||||
</script>
|
||||
|
||||
207
web/admin/help.php
Normal file
207
web/admin/help.php
Normal file
@@ -0,0 +1,207 @@
|
||||
<?php require_once("admin-header.php");
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
$sql="select avg(usedtime) delay from (select judgetime-in_date usedtime from solution where result >=4 order by solution_id desc limit 10 ) c";
|
||||
$delay=pdo_query($sql);
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $MSG_ADMIN?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<center>
|
||||
<a class='btn btn-info btn-sm' href='#' onclick='toggleWatch()'>System Status</a>
|
||||
</center>
|
||||
</td>
|
||||
<td id="watch" style="display:none;">
|
||||
<iframe src="watch.php?notext" width="100%" height="200"></iframe>
|
||||
Delay:<?php echo $delay[0][0] ?>s/judge
|
||||
CPU:<?php echo sys_getloadavg()[0];?>tasks/1min
|
||||
<?php if(function_exists('system')){ ?>
|
||||
FreeMem:<?php system(" free -h|grep Mem|awk '{print $7\"/\"$2 }'");?>
|
||||
FreeDisk:<?php system("df -h|grep '/dev/'|grep -v 'shm'|awk '{print $4 \"/\" $2}'");?>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td>
|
||||
<div id="serverInfo" style="display:block;">
|
||||
Delay:<?php echo $delay[0][0] ?>s/judge
|
||||
CPU:<?php echo sys_getloadavg()[0];?>tasks/1min
|
||||
<?php if(function_exists('system')){ ?>
|
||||
FreeMem:<?php system(" free -h|grep Mem|awk '{print $7\"/\"$2 }'");?>
|
||||
FreeDisk:<?php system("df -h|grep '/dev/'|grep -v 'shm'|awk '{print $4 \"/\" $2}'");?>
|
||||
<?php } ?>
|
||||
<?php echo $MSG_PROBLEM. pdo_query("select count(*) from problem ")[0][0];?>
|
||||
<?php echo $MSG_USER. pdo_query("select count(*) from users ")[0][0];?>
|
||||
<?php echo $MSG_SUBMIT. pdo_query("select count(*) from solution ")[0][0];?>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
<script>
|
||||
function toggleWatch() {
|
||||
var watch = document.getElementById("watch");
|
||||
var serverInfo = document.getElementById("serverInfo");
|
||||
if (watch.style.display === "none") {
|
||||
watch.style.display = "block";
|
||||
serverInfo.style.display = "none";
|
||||
} else {
|
||||
watch.style.display = "none";
|
||||
serverInfo.style.display = "block";
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a class='btn btn-block btn-sm' href="../status.php" target="_top"><b><?php echo $MSG_SEEOJ?></b></a></td>
|
||||
<td><p><?php echo $MSG_HELP_SEEOJ?></p></td>
|
||||
</tr>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-info btn-sm' href="setmsg.php" target="main"><b><?php echo $MSG_NEWS."-".$MSG_SETMESSAGE?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_SETMESSAGE?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-info btn-sm' href="news_list.php" target="main"><b><?php echo $MSG_NEWS."-".$MSG_LIST?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_NEWS_LIST?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-info btn-sm' href="news_add_page.php" target="main"><b><?php echo $MSG_NEWS."-".$MSG_ADD?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_ADD_NEWS?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'] )){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-primary btn-sm' href="user_list.php" target="main"><b><?php echo $MSG_USER."-".$MSG_LIST?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_USER_LIST?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-primary btn-sm' href="user_add.php" target="main"><b><?php echo $MSG_USER."-".$MSG_ADD?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_USER_ADD?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'] )){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-primary btn-sm' href="changepass.php" target="main"><b><?php echo $MSG_USER."-".$MSG_SETPASSWORD?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_SETPASSWORD?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-primary btn-sm' href="privilege_list.php" target="main"><b><?php echo $MSG_USER."-".$MSG_PRIVILEGE."-".$MSG_LIST?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_PRIVILEGE_LIST?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-primary btn-sm' href="privilege_add.php" target="main"><b><?php echo $MSG_USER."-".$MSG_PRIVILEGE."-".$MSG_ADD?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_ADD_PRIVILEGE?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-success btn-sm' href="problem_list.php" target="main"><b><?php echo $MSG_PROBLEM."-".$MSG_LIST?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_PROBLEM_LIST?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-success btn-sm' href="problem_add_page.php" target="main"><b><?php echo $MSG_PROBLEM."-".$MSG_ADD?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_ADD_PROBLEM?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-success btn-sm' href="problem_import.php" target="main"><b><?php echo $MSG_PROBLEM."-".$MSG_IMPORT?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_IMPORT_PROBLEM?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-success btn-sm' href="problem_export.php" target="main"><b><?php echo $MSG_PROBLEM."-".$MSG_EXPORT?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_EXPORT_PROBLEM?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-warning btn-sm' href="contest_list.php" target="main"><b><?php echo $MSG_CONTEST."-".$MSG_LIST?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_CONTEST_LIST?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-warning btn-sm' href="contest_add.php" target="main"><b><?php echo $MSG_CONTEST."-".$MSG_ADD?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_ADD_CONTEST?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-warning btn-sm' href="user_set_ip.php" target="main"><b><?php echo $MSG_CONTEST."-".$MSG_SET_LOGIN_IP?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_SET_LOGIN_IP?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-warning btn-sm' href="team_generate.php" target="main"><b><?php echo $MSG_CONTEST."-".$MSG_TEAMGENERATOR?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_TEAMGENERATOR?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-warning btn-sm' href="team_generate2.php" target="main"><b><?php echo $MSG_CONTEST."-".$MSG_TEAMGENERATOR?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_TEAMGENERATOR?></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-danger btn-sm' href="rejudge.php" target="main"><b><?php echo $MSG_SYSTEM."-".$MSG_REJUDGE?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_REJUDGE?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-danger btn-sm' href="source_give.php" target="main"><b><?php echo $MSG_SYSTEM."-".$MSG_GIVESOURCE?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_GIVESOURCE?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-danger btn-sm' href="../online.php" target="main"><b><?php echo $MSG_SYSTEM."-".$MSG_HELP_ONLINE?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_ONLINE?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-danger btn-sm' href="update_db.php" target="main"><b><?php echo $MSG_SYSTEM."-".$MSG_UPDATE_DATABASE?></b></a></center></td>
|
||||
<td><p><?php echo $MSG_HELP_UPDATE_DATABASE?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a class='btn btn-block btn-sm' href="https://github.com/zhblue/hustoj/" target="_blank"><b>HUSTOJ</b></a></td>
|
||||
<td><p>HUSTOJ</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><center><a class='btn btn-sm' target='_blank' href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md" target="main"><?php echo $MSG_ADMIN." ".$MSG_FAQ?></a></center></td>
|
||||
<td><p><?php echo $MSG_ADMIN." ".$MSG_FAQ?></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a class='btn btn-block btn-sm' href="https://github.com/zhblue/freeproblemset/" target="_blank"><b>FreeProblemSet</b></a></td>
|
||||
<td><p>FreeProblemSet</p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a class='btn btn-block btn-sm' href="http://tk.hustoj.com" target="_blank"><b>自助题库</b></a></td>
|
||||
<td><p></p></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><a class='btn btn-block btn-sm' href="http://shang.qq.com/wpa/qunwpa?idkey=d52c3b12ddaffb43420d308d39118fafe5313e271769277a5ac49a6fae63cf7a" target="_blank">手机QQ加官方群23361372</a></td>
|
||||
<td><p></p></td>
|
||||
</tr>
|
||||
<?php }?>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])&&!$OJ_SAE){?>
|
||||
<a href="problem_copy.php" target="main" title="Create your own data"><font color="eeeeee">CopyProblem</font></a> <br>
|
||||
<a href="problem_changeid.php" target="main" title="Danger,Use it on your own risk"><font color="eeeeee">ReOrderProblem</font></a>
|
||||
|
||||
<?php }?>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
13
web/admin/index.php
Normal file
13
web/admin/index.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
?><html>
|
||||
<head>
|
||||
<title><?php echo $OJ_NAME.$MSG_ADMIN?></title>
|
||||
</head>
|
||||
<frameset cols="14%,*">
|
||||
<frame name="menu" src="menu2.php">
|
||||
<frame name="main" src="help.php">
|
||||
<noframes>
|
||||
</noframes>
|
||||
</frameset>
|
||||
</html>
|
||||
48
web/admin/kindeditor.php
Normal file
48
web/admin/kindeditor.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<meta charset="utf-8" />
|
||||
<link rel="stylesheet" href="../kindeditor/themes/default/default.css" />
|
||||
<link rel="stylesheet" href="../kindeditor/plugins/code/prettify.css" />
|
||||
<script charset="utf-8" src="../kindeditor/kindeditor.js"></script>
|
||||
<script charset="utf-8" src="../kindeditor/lang/zh_CN.js"></script>
|
||||
<script charset="utf-8" src="../kindeditor/plugins/code/prettify.js"></script>
|
||||
<script>
|
||||
$(document).ready(window.setTimeout(function (){
|
||||
KindEditor.ready(function(K) {
|
||||
let editor1 = K.create('textarea[class="kindeditor"]', {
|
||||
width : '100%',
|
||||
cssPath : '../kindeditor/plugins/code/prettify.css',
|
||||
uploadJson : '../kindeditor/php/upload_json.php',
|
||||
fileManagerJson : '../kindeditor/php/file_manager_json.php',
|
||||
allowFileManager : false,
|
||||
filterMode:false,
|
||||
cssData: 'body { font-family:"Consolas";font-size: 18px;line-height:150% } ',
|
||||
<?php if(isset($OJ_MARKDOWN)&&$OJ_MARKDOWN)
|
||||
echo "designMode:false,";
|
||||
?>
|
||||
|
||||
afterCreate : function() {
|
||||
var self = this;
|
||||
K.ctrl(document, 13, function() {
|
||||
self.sync();
|
||||
});
|
||||
K.ctrl(self.edit.doc, 13, function() {
|
||||
self.sync();
|
||||
});
|
||||
}
|
||||
,
|
||||
afterBlur: function() {
|
||||
var self = this;
|
||||
self.sync();
|
||||
}
|
||||
|
||||
,
|
||||
afterChange: function() {
|
||||
var self = this;
|
||||
self.sync();
|
||||
if( typeof sync === "function") sync();
|
||||
}
|
||||
});
|
||||
prettyPrint();
|
||||
});
|
||||
}),100);
|
||||
</script>
|
||||
|
||||
79
web/admin/menu.php
Normal file
79
web/admin/menu.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?php require_once("admin-header.php");
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $MSG_ADMIN?></title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<hr>
|
||||
<h4>
|
||||
<ol>
|
||||
|
||||
<li><a class='btn btn-danger' href="../status.php" target="_top" title="<?php echo $MSG_HELP_SEEOJ?>"><b><?php echo $MSG_SEEOJ?></b></a>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<li><a class='btn btn-primary' href="setmsg.php" target="main" title="<?php echo $MSG_HELP_SETMESSAGE?>"><b><?php echo $MSG_SETMESSAGE?></b></a>
|
||||
<li><a class='btn btn-primary' href="news_list.php" target="main" title="<?php echo $MSG_HELP_NEWS_LIST?>"><b><?php echo $MSG_NEWS.$MSG_LIST?></b></a>
|
||||
<li><a class='btn btn-primary' href="news_add_page.php" target="main" title="<?php echo $MSG_HELP_ADD_NEWS?>"><b><?php echo $MSG_ADD.$MSG_NEWS?></b></a>
|
||||
<li><a class='btn btn-primary' href="user_list.php" target="main" title="<?php echo $MSG_HELP_USER_LIST?>"><b><?php echo $MSG_USER.$MSG_LIST?></b></a>
|
||||
<li><a class='btn btn-primary' href="user_set_ip.php" target="main" title="<?php echo $MSG_SET_LOGIN_IP?>"><b><?php echo $MSG_SET_LOGIN_IP?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'] )){?>
|
||||
<li><a class='btn btn-primary' href="changepass.php" target="main" title="<?php echo $MSG_HELP_SETPASSWORD?>"><b><?php echo $MSG_SETPASSWORD?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<li><a class='btn btn-primary' href="source_give.php" target="main" title="<?php echo $MSG_HELP_GIVESOURCE?>"><b><?php echo $MSG_GIVESOURCE?></b></a>
|
||||
<li><a class='btn btn-primary' href="privilege_list.php" target="main" title="<?php echo $MSG_HELP_PRIVILEGE_LIST?>"><b><?php echo $MSG_PRIVILEGE.$MSG_LIST?></b></a>
|
||||
<li><a class='btn btn-primary' href="privilege_add.php" target="main" title="<?php echo $MSG_HELP_ADD_PRIVILEGE?>"><b><?php echo $MSG_ADD.$MSG_PRIVILEGE?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])){?>
|
||||
<li><a class='btn btn-success' href="problem_list.php" target="main" title="<?php echo $MSG_HELP_PROBLEM_LIST?>"><b><?php echo $MSG_PROBLEM.$MSG_LIST?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])){?>
|
||||
<li><a class='btn btn-success' href="problem_add_page.php" target="main" title="<?php echo html_entity_decode($MSG_HELP_ADD_PROBLEM)?>"><b><?php echo $MSG_ADD.$MSG_PROBLEM?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<li><a class='btn btn-success' href="problem_import.php" target="main" title="<?php echo $MSG_HELP_IMPORT_PROBLEM?>"><b><?php echo $MSG_IMPORT.$MSG_PROBLEM?></b></a>
|
||||
<li><a class='btn btn-success' href="problem_export.php" target="main" title="<?php echo $MSG_HELP_EXPORT_PROBLEM?>"><b><?php echo $MSG_EXPORT.$MSG_PROBLEM?></b></a>
|
||||
<?php }?>
|
||||
<li><a class='btn btn-success' href="https://github.com/zhblue/freeproblemset/" target="_blank"><b>FreeProblemSet</b></a>
|
||||
<?php
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])){?>
|
||||
<li><a class='btn btn-warning' href="contest_list.php" target="main" title="<?php echo $MSG_HELP_CONTEST_LIST?>"><b><?php echo $MSG_CONTEST.$MSG_LIST?></b></a>
|
||||
<li><a class='btn btn-warning' href="contest_add.php" target="main" title="<?php echo $MSG_HELP_ADD_CONTEST?>"><b><?php echo $MSG_ADD.$MSG_CONTEST?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<li><a class='btn btn-warning' href="team_generate.php" target="main" title="<?php echo $MSG_HELP_TEAMGENERATOR?>"><b><?php echo $MSG_TEAMGENERATOR?></b></a>
|
||||
<li><a class='btn btn-warning' href="team_generate2.php" target="main" title="<?php echo $MSG_HELP_TEAMGENERATOR?>"><b><?php echo $MSG_TEAMGENERATOR?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<li><a class='btn btn-primary' href="rejudge.php" target="main" title="<?php echo $MSG_HELP_REJUDGE?>"><b><?php echo $MSG_REJUDGE?></b></a>
|
||||
<?php }?>
|
||||
<li><a class='btn btn-primary' href="https://github.com/zhblue/hustoj/" target="_blank"><b>HUSTOJ</b></a>
|
||||
<?php
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<li><a class='btn btn-primary' href="update_db.php" target="main" title="<?php echo $MSG_HELP_UPDATE_DATABASE?>"><b><?php echo $MSG_UPDATE_DATABASE?></b></a>
|
||||
<?php }
|
||||
if (isset($OJ_ONLINE)&&$OJ_ONLINE){?>
|
||||
<li><a class='btn btn-primary' href="../online.php" target="main"><b><?php echo $MSG_ONLINE?></b></a>
|
||||
<?php }?>
|
||||
<li><a class='btn btn-primary' href="http://tk.hustoj.com" target="_blank"><b>自助题库</b></a>
|
||||
<li><a class='btn btn-primary' href="http://shang.qq.com/wpa/qunwpa?idkey=d52c3b12ddaffb43420d308d39118fafe5313e271769277a5ac49a6fae63cf7a" target="_blank">手机QQ加官方群23361372</a>
|
||||
|
||||
</ol>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])&&!$OJ_SAE){
|
||||
?>
|
||||
<a href="problem_copy.php" target="main" title="Create your own data"><font color="eeeeee">CopyProblem</font></a> <br>
|
||||
<a href="problem_changeid.php" target="main" title="Danger,Use it on your own risk"><font color="eeeeee">ReOrderProblem</font></a>
|
||||
|
||||
<?php }
|
||||
?>
|
||||
<h4>
|
||||
</body>
|
||||
</html>
|
||||
141
web/admin/menu2.php
Normal file
141
web/admin/menu2.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?php require_once("admin-header.php");
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
$path_fix="../";
|
||||
$OJ_TP=$OJ_TEMPLATE;
|
||||
$OJ_TEMPLATE="bs3";
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<title><?php echo $MSG_ADMIN?></title>
|
||||
<link rel="stylesheet" href="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>bootstrap-theme.min.css">
|
||||
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>jquery.min.js"></script>
|
||||
|
||||
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
|
||||
<script src="<?php echo $OJ_CDN_URL.$path_fix."template/$OJ_TEMPLATE/"?>bootstrap.min.js"></script>
|
||||
|
||||
</head>
|
||||
|
||||
<body style="text-align:center;min-width:100px" >
|
||||
<hr>
|
||||
<a class='btn btn-sm' href="help.php" target="main" title="<?php echo $MSG_ADMIN?>"><b><?php echo $MSG_ADMIN?></b></a>
|
||||
<hr>
|
||||
|
||||
<a class='btn btn-sm' href="../status.php" target="_top" title="<?php echo $MSG_HELP_SEEOJ?>"><b><?php echo $MSG_SEEOJ?></b></a><br>
|
||||
|
||||
<div>
|
||||
<div class="btn-group-vertical" role="menu">
|
||||
|
||||
<div class="btn-group" role="menu">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<?php echo $MSG_NEWS."-".$MSG_ADMIN ?> <span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<?php if ($OJ_TP=="bs3"){?>
|
||||
<a class="dropdown-item btn-sm" href="setmsg.php" target="main" title="<?php echo $MSG_HELP_SETMESSAGE?>"><b><?php echo $MSG_NEWS."-".$MSG_SETMESSAGE?></b></a>
|
||||
<?php }?>
|
||||
<a class="dropdown-item btn-sm" href="news_list.php" target="main" title="<?php echo $MSG_HELP_NEWS_LIST?>"><b><?php echo $MSG_NEWS."-".$MSG_LIST?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="news_add_page.php" target="main" title="<?php echo $MSG_HELP_ADD_NEWS?>"><b><?php echo $MSG_NEWS."-".$MSG_ADD?></b></a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="btn-group" role="menu">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<?php echo $MSG_USER."-".$MSG_ADMIN ?> <span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'])){?>
|
||||
<a class="dropdown-item btn-sm" href="user_list.php" target="main" title="<?php echo $MSG_HELP_USER_LIST?>"><b><?php echo $MSG_USER."-".$MSG_LIST?></b></a>
|
||||
<?php }?>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'user_adder'])){?>
|
||||
<a class="dropdown-item btn-sm" href="user_add.php" target="main" title="<?php echo $MSG_HELP_USER_ADD?>"><b><?php echo $MSG_USER."-".$MSG_ADD?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="user_import.php" target="main" title="<?php echo $MSG_HELP_USER_IMPORT ?>"><b><?php echo $MSG_USER."-".$MSG_IMPORT?></b></a>
|
||||
|
||||
<?php }?>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset( $_SESSION[$OJ_NAME.'_'.'password_setter'])){?>
|
||||
<a class="dropdown-item btn-sm" href="changepass.php" target="main" title="<?php echo $MSG_HELP_SETPASSWORD?>"><b><?php echo $MSG_USER."-".$MSG_SETPASSWORD?></b></a>
|
||||
<?php }?>
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<a class="dropdown-item btn-sm" href="privilege_list.php" target="main" title="<?php echo $MSG_HELP_PRIVILEGE_LIST?>"><b><?php echo $MSG_USER."-".$MSG_PRIVILEGE."-".$MSG_LIST?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="privilege_add.php" target="main" title="<?php echo $MSG_HELP_ADD_PRIVILEGE?>"><b><?php echo $MSG_USER."-".$MSG_PRIVILEGE."-".$MSG_ADD?></b></a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="btn-group" role="menu">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<?php echo $MSG_PROBLEM."-".$MSG_ADMIN ?> <span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])) {?>
|
||||
<a class="dropdown-item btn-sm" href="problem_list.php" target="main" title="<?php echo $MSG_HELP_PROBLEM_LIST?>"><b><?php echo $MSG_PROBLEM."-".$MSG_LIST?></b></a>
|
||||
<?php }
|
||||
if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])) {?>
|
||||
<a class="dropdown-item btn-sm" href="problem_add_page.php" target="main" title="<?php echo html_entity_decode($MSG_HELP_ADD_PROBLEM)?>"><b><?php echo $MSG_PROBLEM."-".$MSG_ADD?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="problem_import.php" target="main" title="<?php echo $MSG_HELP_IMPORT_PROBLEM?>"><b><?php echo $MSG_PROBLEM."-".$MSG_IMPORT?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="problem_export.php" target="main" title="<?php echo $MSG_HELP_EXPORT_PROBLEM?>"><b><?php echo $MSG_PROBLEM."-".$MSG_EXPORT?></b></a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="btn-group" role="menu">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<?php echo $MSG_CONTEST."-".$MSG_ADMIN ?> <span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])){?>
|
||||
<a class="dropdown-item btn-sm" href="contest_list.php" target="main" title="<?php echo $MSG_HELP_CONTEST_LIST?>"><b><?php echo $MSG_CONTEST."-".$MSG_LIST?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="contest_add.php" target="main" title="<?php echo $MSG_HELP_ADD_CONTEST?>"><b><?php echo $MSG_CONTEST."-".$MSG_ADD?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="user_set_ip.php" target="main" title="<?php echo $MSG_HELP_SET_LOGIN_IP?>"><b><?php echo $MSG_CONTEST."-".$MSG_SET_LOGIN_IP?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="team_generate.php" target="main" title="<?php echo $MSG_HELP_TEAMGENERATOR?>"><b><?php echo $MSG_CONTEST."-".$MSG_TEAMGENERATOR?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="team_generate2.php" target="main" title="<?php echo $MSG_HELP_TEAMGENERATOR?>"><b><?php echo $MSG_CONTEST."-".$MSG_TEAMGENERATOR?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="offline_import.php" target="main" title="<?php echo $MSG_IMPORT.$MSG_CONTEST ?>"><b><?php echo $MSG_CONTEST."-".$MSG_IMPORT ?></b></a>
|
||||
<?php }?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<div class="btn-group" role="menu">
|
||||
<button type="button" class="btn btn-secondary dropdown-toggle btn-sm" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||
<?php echo $MSG_SYSTEM."-".$MSG_ADMIN ?> <span class="caret"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item btn-sm" href="rejudge.php" target="main" title="<?php echo $MSG_HELP_REJUDGE?>"><b><?php echo $MSG_SYSTEM."-".$MSG_REJUDGE?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="source_give.php" target="main" title="<?php echo $MSG_HELP_GIVESOURCE?>"><b><?php echo $MSG_SYSTEM."-".$MSG_GIVESOURCE?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="../online.php" target="main"><b><?php echo $MSG_SYSTEM."-".$MSG_HELP_ONLINE?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="update_db.php" target="main" title="<?php echo $MSG_HELP_UPDATE_DATABASE?>"><b><?php echo $MSG_SYSTEM."-".$MSG_UPDATE_DATABASE?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="backup.php" target="main" title="<?php echo $MSG_HELP_BACKUP_DATABASE?>"><b><?php echo $MSG_SYSTEM."-".$MSG_BACKUP_DATABASE?></b></a>
|
||||
<a class="dropdown-item btn-sm" href="ranklist_export.php" target="main" title="<?php echo $MSG_EXPORT.$MSG_RANKLIST ?>"><b><?php echo $MSG_EXPORT.$MSG_RANKLIST ?></b></a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<?php }?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])){?>
|
||||
<br><a class='btn btn-sm' href="https://github.com/zhblue/hustoj/" target="_blank"><b>HUSTOJ</b></a>
|
||||
<br><a class='btn btn-sm' href="https://yuanqi.tencent.com/agent/jADpOEWqLvTv" target="_blank"><b>小张老师(AI-help)</b></a>
|
||||
<br><div><a class="btn btn-sm" target='main' href="http://hustoj.com"><?php echo $MSG_ADMIN." ".$MSG_FAQ?></a></div>
|
||||
<br><a class='btn btn-sm' href="https://github.com/zhblue/freeproblemset/" target="_blank"><b>FreeProblemSet</b></a>
|
||||
<br><a class='btn btn-sm' href="http://tk.hustoj.com" target="_blank"><b>自助题库</b></a>
|
||||
<?php if(isset($OJ_REMOTE_JUDGE)&&$OJ_REMOTE_JUDGE){ ?>
|
||||
<br><a class='btn btn-sm' href="https://www.ssoier.cn/api/" target="_blank"><b>一本通远程账户管理</b></a>
|
||||
<?php } ?>
|
||||
<br><a class='btn btn-sm' href="https://mp.weixin.qq.com/s?__biz=MzI1MTAwMTI2NA==&mid=2656403287&idx=1&sn=2b1b9a5cd0b271aa4a050c349981e715" target="_blank"><b>二次开发教程</b></a>
|
||||
<br>
|
||||
<?php }?>
|
||||
|
||||
<?php if (isset($_SESSION[$OJ_NAME.'_'.'administrator'])&&!$OJ_SAE){?>
|
||||
<a href="solution_statistics.php" target="main" title="Create your own data"><font color="eeeeee">SS Report</font></a> <br>
|
||||
<a href="problem_copy.php" target="main" title="Create your own data"><font color="eeeeee">CopyProblem</font></a> <br>
|
||||
<a href="problem_changeid.php" target="main" title="Danger,Use it on your own risk"><font color="eeeeee">ReOrderProblem</font></a>
|
||||
<?php }?>
|
||||
</body>
|
||||
</html>
|
||||
3
web/admin/msg.txt
Normal file
3
web/admin/msg.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
<center>
|
||||
<span>欢迎关注微信公众号</span><img src="http://hustoj.com/wx.jpg" width="96px" />onlinejudge
|
||||
</center>
|
||||
34
web/admin/news_add.php
Normal file
34
web/admin/news_add.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
require_once("../include/check_post_key.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
|
||||
//contest_id
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['content'];
|
||||
$showInMenu = $_POST['showInMenu'];
|
||||
$menu = $showInMenu == "on" ? 1 : 0;
|
||||
|
||||
$user_id = $_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
|
||||
|
||||
|
||||
$content = str_replace("<p>", "", $content);
|
||||
$content = str_replace("</p>", "<br />", $content);
|
||||
//$content = str_replace(",", ",", $content);
|
||||
|
||||
|
||||
|
||||
$sql = "INSERT INTO news(`user_id`,`title`,`content`,`time`,`menu`) VALUES(?,?,?,now(),?)";
|
||||
pdo_query($sql,$user_id,$title,$content,$menu);
|
||||
$sessionDataKey = $OJ_NAME.'_'."_MENU_NEWS_CACHE";
|
||||
unset($_SESSION[$sessionDataKey]);
|
||||
|
||||
echo "<script>window.location.href=\"news_list.php\";</script>";
|
||||
?>
|
||||
67
web/admin/news_add_page.php
Normal file
67
web/admin/news_add_page.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
require_once("admin-header.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "<hr>";
|
||||
echo "<center><h3>".$MSG_NEWS."-".$MSG_ADD."</h3></center>";
|
||||
|
||||
include_once("kindeditor.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
if(isset($_GET['cid'])){
|
||||
$cid = intval($_GET['cid']);
|
||||
$sql = "SELECT * FROM news WHERE `news_id`=?";
|
||||
$result = pdo_query($sql,$cid);
|
||||
$row = $result[0];
|
||||
$title = $row['title'];
|
||||
$content = $row['content'];
|
||||
$defunct = $row['defunct'];
|
||||
}
|
||||
$plist = "";
|
||||
if(isset($_POST['pid'])){
|
||||
sort($_POST['pid']);
|
||||
foreach($_POST['pid'] as $i){
|
||||
if($plist)
|
||||
$plist.=','.intval($i);
|
||||
else
|
||||
$plist = $i;
|
||||
}
|
||||
|
||||
$plist = trim($_POST['hlist']);
|
||||
$pieces = explode(",",$plist );
|
||||
$pieces = array_unique($pieces);
|
||||
if($pieces[0]=="") unset($pieces[0]);
|
||||
$plist=implode(",",$pieces);
|
||||
|
||||
$content="[plist=".$plist."]".htmlentities($_POST['keyword'],ENT_QUOTES,"utf-8")."[/plist]";
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<form method=POST action=news_add.php>
|
||||
<p align=left>
|
||||
<label class="col control-label"><?php echo $MSG_TITLE?></label>
|
||||
<input type=text name=title size=71 value='<?php echo isset($title)?$title."-Copy":""?>'>
|
||||
</p>
|
||||
<p align=left>
|
||||
<label class="col control-label"><?php echo $MSG_NEWS_MENU?>
|
||||
<input style="display: inline-block;" type="checkbox" name=showInMenu />
|
||||
</label>
|
||||
</p>
|
||||
<p align=left>
|
||||
<textarea class=kindeditor name=content rows=41 >
|
||||
<?php echo isset($content)?$content:""?>
|
||||
</textarea>
|
||||
</p>
|
||||
<p>
|
||||
<center>
|
||||
<input type=submit value='<?php echo $MSG_SAVE?>' name=submit>
|
||||
</center>
|
||||
</p>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
</div>
|
||||
21
web/admin/news_df_change.php
Normal file
21
web/admin/news_df_change.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php require_once("admin-header.php");
|
||||
require_once("../include/check_get_key.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php $id=intval($_GET['id']);
|
||||
$sql="SELECT `defunct` FROM `news` WHERE `news_id`=?";
|
||||
$result=pdo_query($sql,$id);
|
||||
$row=$result[0];
|
||||
$defunct=$row[0];
|
||||
echo $defunct;
|
||||
|
||||
if ($defunct=='Y') $sql="update `news` set `defunct`='N' where `news_id`=?";
|
||||
else $sql="update `news` set `defunct`='Y' where `news_id`=?";
|
||||
pdo_query($sql,$id) ;
|
||||
?>
|
||||
<script language=javascript>
|
||||
history.go(-1);
|
||||
</script>
|
||||
80
web/admin/news_edit.php
Normal file
80
web/admin/news_edit.php
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
require_once("admin-header.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
|
||||
echo "<hr>";
|
||||
echo "<center><h3>".$MSG_NEWS."-"."Edit"."</h3></center>";
|
||||
|
||||
include_once("kindeditor.php");
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<?php
|
||||
if(isset($_POST['news_id'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
$title = $_POST['title'];
|
||||
$content = $_POST['content'];
|
||||
$showInMenu = $_POST['showInMenu'];
|
||||
$menu = $showInMenu == "on" ? 1 : 0;
|
||||
|
||||
$content = str_replace("<p>", "", $content);
|
||||
$content = str_replace("</p>", "<br />", $content);
|
||||
// $content = str_replace(",", ",", $content);
|
||||
|
||||
$user_id = $_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
$news_id = intval($_POST['news_id']);
|
||||
|
||||
$sql = "UPDATE `news` SET `title`=?,`time`=now(),`content`=?,user_id=?,`menu`=? WHERE `news_id`=?";
|
||||
//echo $sql;
|
||||
pdo_query($sql,$title,$content,$user_id,$menu,$news_id);
|
||||
$sessionDataKey = $OJ_NAME.'_'."_MENU_NEWS_CACHE";
|
||||
unset($_SESSION[$sessionDataKey]);
|
||||
header("location:news_list.php");
|
||||
exit();
|
||||
}else{
|
||||
$news_id = intval($_GET['id']);
|
||||
$sql = "SELECT * FROM `news` WHERE `news_id`=?";
|
||||
$result = pdo_query($sql,$news_id);
|
||||
if(count($result)!=1){
|
||||
echo "No such News!";
|
||||
exit(0);
|
||||
}
|
||||
|
||||
$row = $result[0];
|
||||
|
||||
$title = htmlentities($row['title'],ENT_QUOTES,"UTF-8");
|
||||
$content = $row['content'];
|
||||
$showInMenu = $row['menu'] == 1;
|
||||
}
|
||||
?>
|
||||
|
||||
<form method=POST action=news_edit.php>
|
||||
<input type=hidden name='news_id' value=<?php echo $news_id?>>
|
||||
<p align=left>
|
||||
<label class="col control-label"><?php echo $MSG_TITLE?></label>
|
||||
<input type=text name=title size=71 value='<?php echo $title?>'>
|
||||
</p>
|
||||
<p align=left>
|
||||
<label class="col control-label"><?php echo $MSG_NEWS_MENU?>
|
||||
<input style="display: inline-block;" type="checkbox" name=showInMenu <?php if($showInMenu) { echo "checked"; } ?> />
|
||||
</label>
|
||||
</p>
|
||||
<p align=left>
|
||||
<textarea class=kindeditor name=content rows=41 ><?php echo htmlentities($content,ENT_QUOTES,"UTF-8")?>
|
||||
</textarea>
|
||||
</p>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<p>
|
||||
<center>
|
||||
<input type=submit value='<?php echo $MSG_SAVE?>' name=submit>
|
||||
</center>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
106
web/admin/news_list.php
Normal file
106
web/admin/news_list.php
Normal file
@@ -0,0 +1,106 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
require_once("../include/set_get_key.php");
|
||||
|
||||
if(!isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>News List</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_NEWS."-".$MSG_LIST?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
$sql = "SELECT COUNT('news_id') AS ids FROM `news`";
|
||||
$result = pdo_query($sql);
|
||||
$row = $result[0];
|
||||
|
||||
$ids = intval($row['ids']);
|
||||
|
||||
$idsperpage = 25;
|
||||
$pages = intval(ceil($ids/$idsperpage));
|
||||
|
||||
if(isset($_GET['page'])){ $page = intval($_GET['page']);}
|
||||
else{ $page = 1;}
|
||||
|
||||
$pagesperframe = 5;
|
||||
$frame = intval(ceil($page/$pagesperframe));
|
||||
|
||||
$spage = ($frame-1)*$pagesperframe+1;
|
||||
$epage = min($spage+$pagesperframe-1, $pages);
|
||||
|
||||
$sid = ($page-1)*$idsperpage;
|
||||
|
||||
$sql = "";
|
||||
if(isset($_GET['keyword']) && $_GET['keyword']!=""){
|
||||
$keyword = $_GET['keyword'];
|
||||
$keyword = "%$keyword%";
|
||||
$sql = "SELECT `news_id`,`user_id`,`title`,`time`,`defunct`,`menu` FROM `news` WHERE (title LIKE ?) OR (content LIKE ?) ORDER BY `news_id` DESC";
|
||||
$result = pdo_query($sql,$keyword,$keyword);
|
||||
}else{
|
||||
$sql = "SELECT `news_id`,`user_id`,`title`,`time`,`defunct`,`menu` FROM `news` ORDER BY `news_id` DESC LIMIT $sid, $idsperpage";
|
||||
$result = pdo_query($sql);
|
||||
}
|
||||
?>
|
||||
|
||||
<center>
|
||||
<form action=news_list.php class="form-search form-inline">
|
||||
<input type="text" name=keyword class="form-control search-query" placeholder="<?php echo $MSG_TITLE.', '.$MSG_CONTENTS?>">
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
<table width=100% border=1 style="text-align:center;">
|
||||
<tr style='height:22px;'>
|
||||
<td>ID</td>
|
||||
<td>TITLE</td>
|
||||
<td>UPDATE</td>
|
||||
<td>NOW</td>
|
||||
<td>COPY</td>
|
||||
<td>MENU</td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($result as $row){
|
||||
echo "<tr style='height:22px;'>";
|
||||
echo "<td>".$row['news_id']."</td>";
|
||||
echo "<td><a href='news_edit.php?id=".$row['news_id']."'>".($row['title']==""?"Empty":$row['title'])."</a>"."</td>";
|
||||
echo "<td>".$row['time']."</td>";
|
||||
echo "<td><a href=news_df_change.php?id=".$row['news_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">".($row['defunct']=="N"?"<span class=green>On</span>":"<span class=red>Off</span>")."</a>"."</td>";
|
||||
echo "<td><a href=news_add_page.php?cid=".$row['news_id'].">Copy</a></td>";
|
||||
echo "<td>" . ($row['menu'] == 1 ? "YES" : "NO") . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</center>
|
||||
- <?php echo $MSG_HELP_ADD_FAQS?>
|
||||
|
||||
<?php
|
||||
if(!(isset($_GET['keyword']) && $_GET['keyword']!=""))
|
||||
{
|
||||
echo "<div style='display:inline;'>";
|
||||
echo "<nav class='center'>";
|
||||
echo "<ul class='pagination pagination-sm'>";
|
||||
echo "<li class='page-item'><a href='news_list.php?page=".(strval(1))."'><<</a></li>";
|
||||
echo "<li class='page-item'><a href='news_list.php?page=".($page==1?strval(1):strval($page-1))."'><</a></li>";
|
||||
for($i=$spage; $i<=$epage; $i++){
|
||||
echo "<li class='".($page==$i?"active ":"")."page-item'><a title='go to page' href='news_list.php?page=".$i."'>".$i."</a></li>";
|
||||
}
|
||||
echo "<li class='page-item'><a href='news_list.php?page=".($page==$pages?strval($page):strval($page+1))."'>></a></li>";
|
||||
echo "<li class='page-item'><a href='news_list.php?page=".(strval($pages))."'>>></a></li>";
|
||||
echo "</ul>";
|
||||
echo "</nav>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
296
web/admin/offline_import.php
Normal file
296
web/admin/offline_import.php
Normal file
@@ -0,0 +1,296 @@
|
||||
<?php
|
||||
ini_set("display_errors", "Off"); //set this to "On" for debugging ,especially when no reason blank shows up.
|
||||
error_reporting(E_ALL);
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_editor']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Offline ... <br>
|
||||
<b><?php echo $MSG_CONTEST."-".$MSG_IMPORT ?></b>
|
||||
<?php
|
||||
function startsWith( $haystack, $needle ) {
|
||||
$length = strlen( $needle );
|
||||
return substr( $haystack, 0, $length ) === $needle;
|
||||
}
|
||||
function endsWith( $haystack, $needle ) {
|
||||
$length = strlen( $needle );
|
||||
if( !$length ) {
|
||||
return true;
|
||||
}
|
||||
return substr( $haystack, -$length ) === $needle;
|
||||
}
|
||||
function strip($Node, $TagName) {
|
||||
$len=mb_strlen($TagName);
|
||||
$i=mb_strpos($Node,"<".$TagName.">");
|
||||
$j=mb_strpos($Node,"</".$TagName.">");
|
||||
|
||||
return mb_substr($Node,$i+$len+2,$j-($i+$len+2));
|
||||
}
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$sql = "SELECT problem_id FROM problem WHERE title=?";
|
||||
$result = pdo_query($sql, $title);
|
||||
$ret=0;
|
||||
if (isset($result[0])&&isset($result[0][0])) $ret=$result[0][0];
|
||||
//echo "row->$rows_cnt";
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function import_dir($json) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN;
|
||||
$qduoj_problem=json_decode($json);
|
||||
echo( $qduoj_problem->{'problem'}->{'title'})."<br>";
|
||||
|
||||
$title = $qduoj_problem->{'problem'}->{'title'};
|
||||
|
||||
$time_limit = floatval($qduoj_problem->{'problem'}->{'timeLimit'});
|
||||
$unit = "ms";
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = floatval($qduoj_problem->{'problem'}->{'memoryLimit'});
|
||||
$unit = "M";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = $qduoj_problem->{'problem'}->{'description'};
|
||||
$input = $qduoj_problem->{'problem'}->{'input'};
|
||||
$output = $qduoj_problem->{'problem'}->{'output'};
|
||||
$sample_input = strip($qduoj_problem->{'problem'}->{'examples'},"input");
|
||||
$sample_output = strip($qduoj_problem->{'problem'}->{'examples'},"output");
|
||||
// echo $sample_input."<br>";
|
||||
// echo $sample_output;
|
||||
$hint = $qduoj_problem->{'problem'}->{'hint'};
|
||||
$source = $qduoj_problem->{'problem'}->{'source'};
|
||||
$spj=0;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
return $pid;
|
||||
}
|
||||
|
||||
|
||||
if (!isset($_FILES ["offline"])||$_FILES ["offline"] ["error"] > 0) {
|
||||
echo " - Error: File size is too big, change in PHP.ini<br />";
|
||||
|
||||
echo $MSG_OFFLINE_ZIP_IMPORT;
|
||||
?>
|
||||
|
||||
<pre>
|
||||
<?php echo "$MSG_OFFLINE $MSG_CONTEST". date("Ymd")?>.zip
|
||||
+ data
|
||||
| + problem1
|
||||
| | + 1.in
|
||||
| | + 1.out
|
||||
| | + 2.in
|
||||
| | + 2.out
|
||||
| |
|
||||
| + problem2
|
||||
| |
|
||||
| ......
|
||||
+ source
|
||||
+ student1
|
||||
| + problem1
|
||||
| + problem1.cpp
|
||||
| + problem2
|
||||
| + problem2.cpp
|
||||
|
|
||||
+ student2
|
||||
| + problem1
|
||||
| + problem1.cpp
|
||||
| + problem2
|
||||
| + problem2.cpp
|
||||
|
|
||||
......
|
||||
</pre>
|
||||
<form method="post" action="offline_import.php" enctype="multipart/form-data">
|
||||
<input type=file name="offline" >
|
||||
<input type=submit >
|
||||
|
||||
</form>
|
||||
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_offline".time();
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["offline"] ["tmp_name"];
|
||||
$titles=array();
|
||||
$problems=array();
|
||||
$nums=array();
|
||||
$cid=0;
|
||||
$nextNum=0;
|
||||
if (get_extension( $_FILES ["offline"] ["name"])=="zip") {
|
||||
$resource = zip_open($tempfile);
|
||||
$save_path="";
|
||||
$num = 0;
|
||||
$pid=$title=$description=$input=$output=$sample_input=$sample_output=$hint=$source=$spj="";
|
||||
$type="normal";
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(startsWith($file_name,"data")){
|
||||
if(dirname($file_name)=="data"){
|
||||
$title=basename($file_name);
|
||||
if($title!="data"){
|
||||
$pid = addproblem($title,1,128, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
mkdir($OJ_DATA."/$pid/");
|
||||
$problems[$title]=$pid;
|
||||
$titles[$num]=$title;
|
||||
$nums[$title]=$num++;
|
||||
}
|
||||
}else{
|
||||
|
||||
if(endsWith($file_name,".in")||endsWith($file_name,".out")||endsWith($file_name,".name")){
|
||||
file_put_contents($OJ_DATA."/$pid/".basename($file_name),$file_content );
|
||||
}else if(endsWith($file_name,".ans")){
|
||||
file_put_contents($OJ_DATA."/$pid/".basename($file_name,".ans").".out",$file_content );
|
||||
}
|
||||
|
||||
}
|
||||
}else if (startsWith($file_name,"source")){
|
||||
$answer=basename($file_name);
|
||||
if($answer==="source"){
|
||||
$title= basename($_FILES ["offline"] ["name"],".zip");
|
||||
$sql = "INSERT INTO `contest`(`title`,`start_time`,`end_time`,`private`,`langmask`,`description`,`password`,`user_id`)
|
||||
VALUES(?,?,?,?,?,?,?,?)";
|
||||
$user_id=$_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
$starttime=date("Y-m-d H:i");
|
||||
$endtime=date("Y-m-d H:i",time()+3600);
|
||||
$description = "Offline contest imported by ".$user_id;
|
||||
$cid = pdo_query($sql,$title,$starttime,$endtime,0,0,$description,"",$user_id) ;
|
||||
echo " $MSG_OFFLINE $MSG_CONTEST - $MSG_IMPORT $title:".$cid."<br>";
|
||||
$plist="";
|
||||
$i=0;
|
||||
$sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)";
|
||||
for(; $i<count($problems); $i++){
|
||||
if($plist) $plist.=",";
|
||||
$plist.=intval($problems[$titles[$i]]);
|
||||
pdo_query($sql_1,$cid,$problems[$titles[$i]],$i);
|
||||
}
|
||||
$nextNum=$i;
|
||||
//echo $sql_1;
|
||||
$sql = "UPDATE `problem` SET defunct='N' WHERE `problem_id` IN ($plist)";
|
||||
pdo_query($sql) ;
|
||||
|
||||
}else if(endsWith($answer,".cpp")){
|
||||
$student=dirname($file_name);
|
||||
$pdname=basename($student);
|
||||
if(dirname($student)!="source") {
|
||||
$student=dirname($student);
|
||||
}
|
||||
$student=basename($student);
|
||||
$problem=basename($answer,".cpp");
|
||||
if( endsWith($problem,".cpp") && !$OJ_OFFLINE_ZIP_CCF_DIRNAME ) $problem=basename($problem,".cpp");
|
||||
if(!isset($problems[$problem])){
|
||||
$pid=hasProblem($problem);
|
||||
if($pid>0){
|
||||
$problems[$problem]=$pid;
|
||||
$sql_1 = "INSERT INTO `contest_problem`(`contest_id`,`problem_id`,`num`) VALUES (?,?,?)";
|
||||
pdo_query($sql_1,$cid,$pid,$nextNum);
|
||||
$nextNum++;
|
||||
}
|
||||
}
|
||||
if(isset($nums[$problem])&&isset($problems[$problem])){
|
||||
$num=$nums[$problem];
|
||||
$pid=$problems[$problem];
|
||||
if( $OJ_OFFLINE_ZIP_CCF_DIRNAME && $pdname!=$student && $pdname!=$problem){
|
||||
$file_content.="\nThe dirname of this file is NOT qualified. Will be rated as 0 point!";
|
||||
}
|
||||
$len=strlen($file_content);
|
||||
$sql = "INSERT INTO solution(problem_id,user_id,contest_id,num,nick,in_date,language,ip,code_length,result)
|
||||
VALUES(?,?,?,?,?,NOW(),?,'127.0.0.1',?,14)";
|
||||
$insert_id = pdo_query($sql, $pid,$student,$cid,$num,$student, 1 , $len);
|
||||
// echo "submiting$language.....$insert_id";
|
||||
$sql = "INSERT INTO `source_code`(`solution_id`,`source`) VALUES(?,?)";
|
||||
pdo_query($sql ,$insert_id, $file_content);
|
||||
$sql = "INSERT INTO `source_code_user`(`solution_id`,`source`) VALUES(?,?)";
|
||||
$ret=pdo_query($sql, $insert_id, $file_content);
|
||||
if($ret<0){
|
||||
echo "<h3> $student - $problem</h3> - 非法字符,提交失败<br> ";
|
||||
echo " - 尝试转码 <br> ";
|
||||
$file_content=mb_convert_encoding($file_content, "utf8", "gbk");
|
||||
$sql = "INSERT INTO `source_code`(`solution_id`,`source`) VALUES(?,?)";
|
||||
pdo_query($sql ,$insert_id, $file_content);
|
||||
$sql = "INSERT INTO `source_code_user`(`solution_id`,`source`) VALUES(?,?)";
|
||||
$ret=pdo_query($sql, $insert_id, $file_content);
|
||||
if($ret<0){
|
||||
pdo_query("delete from solution where solution_id=?",$insert_id);
|
||||
echo " - 转码失败,提交无效 <br> ";
|
||||
}else{
|
||||
echo " - 转码成功 <br> ";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
pdo_query("UPDATE solution SET result=1 WHERE solution_id=?", $insert_id);
|
||||
pdo_query("UPDATE problem SET submit=submit+1 WHERE problem_id=?", $pid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (isset($OJ_UDP) && $OJ_UDP) {
|
||||
trigger_judge();
|
||||
}
|
||||
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
|
||||
unlink ( $_FILES ["offline"] ["tmp_name"] );
|
||||
system ("rmdir $tempdir");
|
||||
|
||||
}else{
|
||||
echo " zip file Only <hr> \n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
5597
web/admin/phpfm.php
Normal file
5597
web/admin/phpfm.php
Normal file
File diff suppressed because it is too large
Load Diff
176
web/admin/privilege_add.php
Normal file
176
web/admin/privilege_add.php
Normal file
@@ -0,0 +1,176 @@
|
||||
<?php require_once("admin-header.php");
|
||||
require_once("../include/email.class.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Privilege Add</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_USER."-".$MSG_PRIVILEGE."-".$MSG_ADD?></h3></center>
|
||||
|
||||
<div class="container">
|
||||
|
||||
<?php
|
||||
if (isset($_POST['do'])) {
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
$user_id = trim($_POST['user_id']);
|
||||
$rightstr = trim($_POST['rightstr']);
|
||||
$valuestr = "true";
|
||||
if(isset($_POST['valuestr']))
|
||||
$valuestr = $_POST['valuestr'];
|
||||
|
||||
if (isset($_POST['contest']))
|
||||
$rightstr = "c$rightstr";
|
||||
|
||||
if (isset($_POST['psv']))
|
||||
$rightstr = "s$rightstr";
|
||||
|
||||
$sql = "insert into `privilege`(user_id,rightstr,valuestr,defunct) values(?,?,?,'N')";
|
||||
$link= 'http://'.$_SERVER['HTTP_HOST'].dirname($_SERVER['REQUEST_URI']);
|
||||
$msg = $_SESSION[$OJ_NAME.'_user_id']." $MSG_ADD $rightstr [$valuestr] $MSG_PRIVILEGE -> $user_id @ ".date('Y-m-d h:i:s a', time());
|
||||
$msg .="\n\nmessage from site: $link";
|
||||
if(!empty($user_id)) $rows = pdo_query($sql,$user_id,$rightstr,$valuestr);
|
||||
if ($OJ_ADMIN=="root@localhost"){
|
||||
$sql="select email from users where user_id=? ";
|
||||
$OJ_ADMIN=pdo_query($sql,$_SESSION[$OJ_NAME.'_user_id'])[0][0];
|
||||
//email($OJ_ADMIN,"Privilege Add Warning!",$msg);
|
||||
}else{
|
||||
email($OJ_ADMIN,"Privilege Add Warning!",$msg);
|
||||
}
|
||||
echo "<center><h4 class='text-danger'>User ".htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8')."'s Privilege Added!</h4></center>";
|
||||
}
|
||||
?>
|
||||
|
||||
<div>
|
||||
<form method="post" class="form-horizontal">
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<center><label class="text-info"><?php echo $MSG_HELP_ADD_PRIVILEGE?></label></center>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID?></label>
|
||||
<?php if(isset($_GET['uid'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else if(isset($_POST['user_id'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PRIVILEGE_TYPE?></label>
|
||||
<select class="col-sm-3" name="rightstr" onchange="show_value_input(this.value)" >
|
||||
<?php
|
||||
$rightarray = array("administrator","problem_editor","problem_importer","problem_verifiter","source_browser","contest_creator","user_adder","http_judge","password_setter","printer","balloon","vip",'problem_start','problem_end');
|
||||
while ($val=current($rightarray)) {
|
||||
$key=key($rightarray);
|
||||
if (isset($rightstr) && ($rightstr == $val)) {
|
||||
echo '<option value="'.$val.'" selected>'.$val.'</option>';
|
||||
} else {
|
||||
echo '<option value="'.$val.'">'.$val.'</option>';
|
||||
}
|
||||
next($rightarray);
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="col-sm-offset-9"><input id='value_input' type="text" class="form-control" name="valuestr" value="true"></div>
|
||||
</div>
|
||||
<script>
|
||||
function show_value_input(new_value){
|
||||
if(new_value=='problem_start'||new_value=='problem_end') {
|
||||
$("#value_input").val("1000");
|
||||
$("#value_input").show();
|
||||
}else{
|
||||
$("#value_input").val("true");
|
||||
$("#value_input").hide();
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
$("#value_input").hide();
|
||||
});
|
||||
</script>
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<button type="submit" name="do" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button type="reset" class="btn btn-default btn-block"><?php echo $MSG_RESET?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<form method="post" class="form-horizontal">
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<center><label class="text-info"><?php echo $MSG_HELP_ADD_CONTEST_USER?></label></center>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID?></label>
|
||||
<?php if(isset($_GET['uid'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else if(isset($_POST['user_id'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_CONTEST_ID?></label>
|
||||
<div class="col-sm-3"><input name="rightstr" class="form-control" placeholder="<?php echo $MSG_CONTEST_ID."*"?>" type="text"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<button type="submit" name="contest" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button>
|
||||
<input type=hidden name="postkey" value="<?php echo $_SESSION[$OJ_NAME.'_'.'postkey']?>">
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button type="reset" class="btn btn-default btn-block"><?php echo $MSG_RESET?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
|
||||
<div>
|
||||
<form method="post" class="form-horizontal">
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<center><label class="text-info"><?php echo $MSG_HELP_ADD_SOLUTION_VIEW?></label></center>
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID?></label>
|
||||
<?php if(isset($_GET['uid'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else if(isset($_POST['user_id'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_PROBLEM_ID?></label>
|
||||
<div class="col-sm-3"><input name="rightstr" class="form-control" placeholder="<?php echo $MSG_PROBLEM_ID."*"?>" type="text"></div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<button type="submit" name="psv" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button>
|
||||
<input type=hidden name="postkey" value="<?php echo $_SESSION[$OJ_NAME.'_'.'postkey']?>">
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button type="reset" class="btn btn-default btn-block"><?php echo $MSG_RESET?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
18
web/admin/privilege_delete.php
Normal file
18
web/admin/privilege_delete.php
Normal file
@@ -0,0 +1,18 @@
|
||||
<?php require_once("admin-header.php");?>
|
||||
<?php require_once("../include/check_get_key.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
if(isset($_GET['uid'])){
|
||||
$user_id=$_GET['uid'];
|
||||
$rightstr =$_GET['rightstr'];
|
||||
$sql="delete from `privilege` where user_id=? and rightstr=?";
|
||||
$rows=pdo_query($sql,$user_id,$rightstr);
|
||||
echo "$user_id $rightstr deleted!";
|
||||
}
|
||||
?>
|
||||
|
||||
<script language=javascript>
|
||||
window.setTimeOut(1000,"history.go(-1)");
|
||||
</script>
|
||||
101
web/admin/privilege_list.php
Normal file
101
web/admin/privilege_list.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
require_once("../include/set_get_key.php");
|
||||
|
||||
if(!isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Privilege List</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_USER."-".$MSG_PRIVILEGE."-".$MSG_LIST?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
$sql = "SELECT COUNT(*) AS ids FROM privilege WHERE rightstr IN ('administrator','source_browser','contest_creator','http_judge','problem_editor','problem_importer','problem_verifiter','password_setter','printer','balloon','vip','problem_start','problem_end') ORDER BY user_id, rightstr";
|
||||
$result = pdo_query($sql);
|
||||
$row = $result[0];
|
||||
|
||||
$ids = intval($row['ids']);
|
||||
|
||||
$idsperpage = 25;
|
||||
$pages = intval(ceil($ids/$idsperpage));
|
||||
|
||||
if(isset($_GET['page'])){ $page = intval($_GET['page']);}
|
||||
else{ $page = 1;}
|
||||
|
||||
$pagesperframe = 5;
|
||||
$frame = intval(ceil($page/$pagesperframe));
|
||||
|
||||
$spage = ($frame-1)*$pagesperframe+1;
|
||||
$epage = min($spage+$pagesperframe-1, $pages);
|
||||
|
||||
$sid = ($page-1)*$idsperpage;
|
||||
|
||||
$sql = "";
|
||||
if(isset($_GET['keyword']) && $_GET['keyword']!=""){
|
||||
$keyword = $_GET['keyword'];
|
||||
$keyword = "%$keyword%";
|
||||
$sql = "SELECT * FROM privilege WHERE (user_id LIKE ?) OR (rightstr LIKE ?) ORDER BY user_id, rightstr";
|
||||
$result = pdo_query($sql,$keyword,$keyword);
|
||||
}else{
|
||||
$sql = "SELECT * FROM privilege WHERE rightstr IN ('administrator','source_browser','contest_creator','http_judge','problem_editor','problem_importer','password_setter','printer','balloon','vip','problem_start','problem_end') ORDER BY user_id, rightstr LIMIT $sid, $idsperpage";
|
||||
$result = pdo_query($sql);
|
||||
}
|
||||
?>
|
||||
|
||||
<center>
|
||||
<form action=privilege_list.php class="form-search form-inline">
|
||||
<input type="text" name=keyword class="form-control search-query" placeholder="<?php echo $MSG_USER_ID.', '.$MSG_PRIVILEGE?>">
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
<table width=100% border=1 style="text-align:center;">
|
||||
<tr>
|
||||
<td>ID</td>
|
||||
<td>PRIVILEGE</td>
|
||||
<td>REMOVE</td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($result as $row){
|
||||
echo "<tr>";
|
||||
echo "<td>".$row['user_id']."</td>";
|
||||
echo "<td>".$row['rightstr'];
|
||||
if($row['valuestr']!="true") echo ":".$row['valuestr'];
|
||||
echo "</td>";
|
||||
echo "<td><a href='privilege_delete.php?uid=".htmlentities($row['user_id'],ENT_QUOTES,"UTF-8")."&rightstr={$row['rightstr']}&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey']."'>Delete</a></td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
if(!(isset($_GET['keyword']) && $_GET['keyword']!=""))
|
||||
{
|
||||
echo "<div style='display:inline;'>";
|
||||
echo "<nav class='center'>";
|
||||
echo "<ul class='pagination pagination-sm'>";
|
||||
echo "<li class='page-item'><a href='privilege_list.php?page=".(strval(1))."'><<</a></li>";
|
||||
echo "<li class='page-item'><a href='privilege_list.php?page=".($page==1?strval(1):strval($page-1))."'><</a></li>";
|
||||
for($i=$spage; $i<=$epage; $i++){
|
||||
echo "<li class='".($page==$i?"active ":"")."page-item'><a title='go to page' href='privilege_list.php?page=".$i."'>".$i."</a></li>";
|
||||
}
|
||||
echo "<li class='page-item'><a href='privilege_list.php?page=".($page==$pages?strval($page):strval($page+1))."'>></a></li>";
|
||||
echo "<li class='page-item'><a href='privilege_list.php?page=".(strval($pages))."'>>></a></li>";
|
||||
echo "</ul>";
|
||||
echo "</nav>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
131
web/admin/problem_add.php
Normal file
131
web/admin/problem_add.php
Normal file
@@ -0,0 +1,131 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
require_once("../include/check_post_key.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
require_once ("../include/db_info.inc.php");
|
||||
require_once ("../include/my_func.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
|
||||
// contest_id
|
||||
$title = $_POST['title'];
|
||||
$title = str_replace(",", ",", $title);
|
||||
$time_limit = $_POST['time_limit'];
|
||||
$memory_limit = $_POST['memory_limit'];
|
||||
|
||||
$description = $_POST['description'];
|
||||
//$description = str_replace("<p>", "", $description);
|
||||
//$description = str_replace("</p>", "<br />", $description);
|
||||
$description = str_replace(",", ",", $description);
|
||||
|
||||
$input = $_POST['input'];
|
||||
//$input = str_replace("<p>", "", $input);
|
||||
//$input = str_replace("</p>", "<br />", $input);
|
||||
$input = str_replace(",", ",", $input);
|
||||
|
||||
$output = $_POST['output'];
|
||||
//$output = str_replace("<p>", "", $output);
|
||||
//$output = str_replace("</p>", "<br />", $output);
|
||||
$output = str_replace(",", ",", $output);
|
||||
|
||||
$sample_input = $_POST['sample_input'];
|
||||
$sample_output = $_POST['sample_output'];
|
||||
$test_input = $_POST['test_input'];
|
||||
$test_output = $_POST['test_output'];
|
||||
/* don't do this , we will left them empty for not generating invalid test data files
|
||||
if ($sample_input=="") $sample_input="\n";
|
||||
if ($sample_output=="") $sample_output="\n";
|
||||
if ($test_input=="") $test_input="\n";
|
||||
if ($test_output=="") $test_output="\n";
|
||||
*/
|
||||
$hint = $_POST['hint'];
|
||||
//$hint = str_replace("<p>", "", $hint);
|
||||
//$hint = str_replace("</p>", "<br />", $hint);
|
||||
$hint = str_replace(",", ",", $hint);
|
||||
|
||||
$source = $_POST['source'];
|
||||
|
||||
$spj = $_POST['spj'];
|
||||
|
||||
|
||||
if (false) {
|
||||
$title = stripslashes($title);
|
||||
$time_limit = stripslashes($time_limit);
|
||||
$memory_limit = stripslashes($memory_limit);
|
||||
$description = stripslashes($description);
|
||||
$input = stripslashes($input);
|
||||
$output = stripslashes($output);
|
||||
$sample_input = stripslashes($sample_input);
|
||||
$sample_output = stripslashes($sample_output);
|
||||
$test_input = stripslashes($test_input);
|
||||
$test_output = stripslashes($test_output);
|
||||
$hint = stripslashes($hint);
|
||||
$source = stripslashes($source);
|
||||
$spj = stripslashes($spj);
|
||||
$source = stripslashes($source);
|
||||
}
|
||||
|
||||
$title = ($title);
|
||||
$description = ($description);
|
||||
$input = ($input);
|
||||
$output = ($output);
|
||||
$hint = ($hint);
|
||||
//echo "->".$OJ_DATA."<-";
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
mkdir($basedir);
|
||||
if(strlen($sample_output) && !strlen($sample_input)) $sample_input = "0";
|
||||
if(strlen($sample_input)) mkdata($pid, "sample.in", $sample_input, $OJ_DATA);
|
||||
if(strlen($sample_output)) mkdata($pid, "sample.out", $sample_output, $OJ_DATA);
|
||||
if(strlen($test_output) && !strlen($test_input)) $test_input = "0";
|
||||
if(strlen($test_input)) mkdata($pid,"test.in", $test_input, $OJ_DATA);
|
||||
if(strlen($test_output)) mkdata($pid,"test.out", $test_output, $OJ_DATA);
|
||||
if(isset($_POST['remote_oj'])){
|
||||
$remote_oj=$_POST['remote_oj'];
|
||||
$remote_id=intval($_POST['remote_id']);
|
||||
$sql="update problem set remote_oj=?,remote_id=? where problem_id=?";
|
||||
pdo_query($sql,$remote_oj,$remote_id,$pid);
|
||||
?>
|
||||
<form method=POST action=problem_add_page_<?php echo $remote_oj?>.php>
|
||||
<?php
|
||||
if($remote_oj=="luogu"){
|
||||
$pre=mb_strpos($source,"P");
|
||||
$pre=mb_substr($source,0,$pre+1);
|
||||
$remote_id=intval(mb_substr($_POST['remote_id'],1));
|
||||
echo "remote id :$remote_id";
|
||||
|
||||
}else{
|
||||
$pre=mb_strpos($source,"=");
|
||||
$pre=mb_substr($source,0,$pre+1);
|
||||
}
|
||||
?>
|
||||
<input name=url type=text size=100 class="input input-xxlarge" value="<?php echo $pre.(++$remote_id) ?>">
|
||||
<input type=submit>
|
||||
</form>
|
||||
<script>// $("form").submit();</script>
|
||||
|
||||
<?php
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO `privilege` (`user_id`,`rightstr`) VALUES(?,?)";
|
||||
pdo_query($sql, $_SESSION[$OJ_NAME.'_'.'user_id'], "p$pid");
|
||||
$_SESSION[$OJ_NAME.'_'."p$pid"] = true;
|
||||
|
||||
echo " - <a href='javascript:phpfm($pid);'>Add more TestData now!</a>";
|
||||
/* */
|
||||
?>
|
||||
|
||||
<script src='../template/bs3/jquery.min.js' ></script>
|
||||
<script>
|
||||
function phpfm(pid){
|
||||
//alert(pid);
|
||||
$.post("phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){
|
||||
if(status=="success"){
|
||||
document.location.href="phpfm.php?frame=3&pid="+pid;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
92
web/admin/problem_add_loj.php
Normal file
92
web/admin/problem_add_loj.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php require_once ("admin-header.php");
|
||||
require_once("../include/check_post_key.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php require_once ("../include/db_info.inc.php");
|
||||
?>
|
||||
<?php require_once ("../include/problem.php");
|
||||
?>
|
||||
<?php // contest_id
|
||||
|
||||
|
||||
$title = $_POST ['title'];
|
||||
$time_limit = $_POST ['time_limit'];
|
||||
$memory_limit = $_POST ['memory_limit'];
|
||||
$description = $_POST ['description'];
|
||||
$input = $_POST ['input'];
|
||||
$output = $_POST ['output'];
|
||||
$sample_input = $_POST ['sample_input'];
|
||||
$sample_output = $_POST ['sample_output'];
|
||||
$test_input = $_POST ['test_input'];
|
||||
$test_output = $_POST ['test_output'];
|
||||
$hint = $_POST ['hint'];
|
||||
$source = $_POST ['source'];
|
||||
$spj = $_POST ['spj'];
|
||||
if (false) {
|
||||
$title = stripslashes ( $title);
|
||||
$time_limit = stripslashes ( $time_limit);
|
||||
$memory_limit = stripslashes ( $memory_limit);
|
||||
$description = stripslashes ( $description);
|
||||
$input = stripslashes ( $input);
|
||||
$output = stripslashes ( $output);
|
||||
$sample_input = stripslashes ( $sample_input);
|
||||
$sample_output = stripslashes ( $sample_output);
|
||||
$test_input = stripslashes ( $test_input);
|
||||
$test_output = stripslashes ( $test_output);
|
||||
$hint = stripslashes ( $hint);
|
||||
$source = stripslashes ( $source);
|
||||
$spj = stripslashes ( $spj);
|
||||
$source = stripslashes ( $source );
|
||||
}
|
||||
$description ='<link href="https://dn-menci.qbox.me/libreoj/libs/KaTeX/katex.min.css" rel="stylesheet">'. $description ;
|
||||
//echo "->".$OJ_DATA."<-";
|
||||
$pid=addproblem ( $title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA );
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
mkdir ( $basedir );
|
||||
if(strlen($sample_output)&&!strlen($sample_input)) $sample_input="0";
|
||||
if(strlen($sample_input)) mkdata($pid,"sample.in",$sample_input,$OJ_DATA);
|
||||
if(strlen($sample_output))mkdata($pid,"sample.out",$sample_output,$OJ_DATA);
|
||||
if(strlen($test_output)&&!strlen($test_input)) $test_input="0";
|
||||
if(strlen($test_input))mkdata($pid,"test.in",$test_input,$OJ_DATA);
|
||||
if(strlen($test_output))mkdata($pid,"test.out",$test_output,$OJ_DATA);
|
||||
|
||||
$sql="insert into `privilege` (`user_id`,`rightstr`) values(?,?)";
|
||||
pdo_query($sql,$_SESSION[$OJ_NAME.'_'.'user_id'],"p$pid");
|
||||
$_SESSION[$OJ_NAME.'_'."p$pid"]=true;
|
||||
$loj_id=intval($_POST['loj_id']);
|
||||
//print_r($_POST);
|
||||
echo "<br>".$loj_id."<br>";
|
||||
echo htmlentities("wget https://loj.ac/problem/".$loj_id."/testdata/download -O $OJ_DATA/$pid/data.zip");
|
||||
echo system("wget https://loj.ac/problem/".$loj_id."/testdata/download -O $OJ_DATA/$pid/data.zip");
|
||||
echo system("/home/judge/src/install/ans2out $OJ_DATA/$pid/");
|
||||
echo "<br>";
|
||||
echo htmlentities("unzip $OJ_DATA/$pid/data.zip -d $OJ_DATA/$pid");
|
||||
echo system("unzip $OJ_DATA/$pid/data.zip -d $OJ_DATA/$pid");
|
||||
echo system("/usr/bin/loj.ac $OJ_DATA/$pid");
|
||||
echo "<br>";
|
||||
|
||||
echo "<a href='javascript:phpfm($pid);'>Add more TestData now !</a>";
|
||||
/* */
|
||||
?>
|
||||
<script src='../template/bs3/jquery.min.js' ></script>
|
||||
<script>
|
||||
function phpfm(pid){
|
||||
//alert(pid);
|
||||
$.post("phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){
|
||||
if(status=="success"){
|
||||
document.location.href="phpfm.php?frame=3&pid="+pid;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Copy from https://loj.ac/problem/
|
||||
<form method=POST action=problem_add_page_loj.php>
|
||||
<input name=url type=text size=100 value="https://loj.ac/problem/<?php echo $loj_id+1?>">
|
||||
<input type=submit>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
219
web/admin/problem_add_page.php
Normal file
219
web/admin/problem_add_page.php
Normal file
@@ -0,0 +1,219 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Problem Add</title>
|
||||
</head>
|
||||
<?php
|
||||
echo "<center><h3>".$MSG_PROBLEM."-".$MSG_ADD."</h3></center>";
|
||||
include_once("kindeditor.php") ;
|
||||
$source=pdo_query("select source from problem order by problem_id desc limit 1"); //默认续用最后一次的分类标签
|
||||
if(!empty($source)&&isset($source[0]))$source=$source[0][0];else $source="";
|
||||
?>
|
||||
|
||||
<hr>
|
||||
<body leftmargin="30" >
|
||||
<div id="main" class="container">
|
||||
<form method=POST action=problem_add.php>
|
||||
<input type=hidden name=problem_id value="New Problem">
|
||||
<p align=left>
|
||||
<div class="ui toggle checkbox">
|
||||
<input type="checkbox" id="preview-toggle" checked>
|
||||
<label for="preview-toggle">题目预览</label>
|
||||
</div>
|
||||
<?php echo "<h3>".$MSG_TITLE."</h3>"?>
|
||||
<input class="input input-large" style="width:100%;" type=text name='title' > <input type=submit value='<?php echo $MSG_SAVE?>' name=submit>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo $MSG_Time_Limit?>
|
||||
<input class="input input-mini" type=number min="0.001" max="300" step="0.001" name=time_limit size=20 value=1> sec
|
||||
<?php echo $MSG_Memory_Limit?>
|
||||
<input class="input input-mini" type=number min="1" max="2048" step="1" name=memory_limit size=20 value=128> MiB<br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Description."(<64kB)</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><span class='md auto_select'>
|
||||
</span></textarea><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Input."(<64kB)</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><span class='md'>
|
||||
</span></textarea><br></textarea><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Output."(<64kB)</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><span class='md'>
|
||||
</span></textarea><br></textarea><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Sample_Input."(<64kB)</h4>"?>
|
||||
<textarea class="input input-large" style="width:100%;" rows=13 name=sample_input></textarea><br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Sample_Output."(<64kB)</h4>"?>
|
||||
<textarea class="input input-large" style="width:100%;" rows=13 name=sample_output></textarea><br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Test_Input."</h4>"?>
|
||||
<?php echo "(".$MSG_HELP_MORE_TESTDATA_LATER.")"?><br>
|
||||
<textarea class="input input-large" style="width:100%;" rows=13 name=test_input></textarea><br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Test_Output."</h4>"?>
|
||||
<?php echo "(".$MSG_HELP_MORE_TESTDATA_LATER.")"?><br>
|
||||
<textarea class="input input-large" style="width:100%;" rows=13 name=test_output></textarea><br><br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_HINT."(<64kB)</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=hint cols=80><span class='md'>
|
||||
</span></textarea><br></textarea><br>
|
||||
</p>
|
||||
<p>
|
||||
<?php echo "<h4>".$MSG_SPJ."</h4>"?>
|
||||
<input type=radio name=spj value='0' checked ><?php echo $MSG_NJ?> 更多测试数据,在题目添加后补充。<br>
|
||||
<input type=radio name=spj value='1' ><?php echo $MSG_SPJ?> <?php echo "(".$MSG_HELP_SPJ.")"?><br>
|
||||
<input type=radio name=spj value='2' ><?php echo $MSG_RTJ?>(用于选择判断填空题,用法见<a target='_blank' href='http://hustoj.com'>hustoj.com</a>)<br>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_SOURCE."</h4>"?>
|
||||
<textarea name=source style="width:100%;" rows=1><?php echo htmlentities($source,ENT_QUOTES,'UTF-8') ?></textarea><br><br>
|
||||
</p>
|
||||
<p align=left><?php echo "<h4>".$MSG_CONTEST."</h4>"?>
|
||||
<select name=contest_id>
|
||||
<?php
|
||||
$sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0) {
|
||||
}
|
||||
else {
|
||||
foreach ($result as $row) {
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
}?>
|
||||
</select>
|
||||
</p>
|
||||
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value='<?php echo $MSG_SAVE?>' name=submit>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
<script src="<?php echo $OJ_CDN_URL."/template/bs3/"?>marked.min.js"></script>
|
||||
<script>
|
||||
function transform(){
|
||||
let height=document.body.clientHeight;
|
||||
let width=parseInt(document.body.clientWidth*0.6);
|
||||
let width2=parseInt(document.body.clientWidth*0.4);
|
||||
if(width<500) width2=300;
|
||||
let submitURL="../problem.php?id=1000";
|
||||
console.log(width);
|
||||
let main=$("#main");
|
||||
let problem=main.html();
|
||||
main.removeClass("container");
|
||||
main.css("width",width2);
|
||||
main.css("margin-left","10px");
|
||||
main.parent().append("<div id='preview' class='container' style='opacity:0.95;position:fixed;z-index:1000;top:49px;right:-"+width2+"px'></div>");
|
||||
$("#preview").html("<iframe id='previewFrame' src='"+submitURL+"&spa' width='"+width+"px' height='"+height+"px' ></iframe>");
|
||||
$("#submit").remove();
|
||||
setTimeout('hide()',1500);
|
||||
$("input").keyup(sync);
|
||||
$("textarea").keyup(sync);
|
||||
}
|
||||
function hide(){
|
||||
let preview=$("#previewFrame").contents();
|
||||
preview.find(".ui.buttons").hide();
|
||||
preview.find("span.ui.label").eq(2).hide();
|
||||
preview.find("span.ui.label").eq(3).hide();
|
||||
preview.find("span.ui.label").eq(4).hide();
|
||||
preview.find("span.ui.label").eq(5).hide();
|
||||
preview.find("#show_tag_div").parent().hide();
|
||||
sync();
|
||||
// preview.find("h1:first").parent().parent().hide();
|
||||
}
|
||||
function sync(){
|
||||
console.log("sync...");
|
||||
let preview=$("#previewFrame").contents();
|
||||
let title=$("input[name=title]").val();
|
||||
preview.find("h1:first").html(title);
|
||||
let time=$("input[name=time_limit]").val();
|
||||
preview.find("span.ui.label").eq(0).html("<?php echo $MSG_Time_Limit ?>:"+time);
|
||||
let memory=$("input[name=memory_limit]").val();
|
||||
preview.find("span.ui.label").eq(1).html("<?php echo $MSG_Memory_Limit ?>:"+memory);
|
||||
|
||||
let description=$("textarea").eq(1).val();
|
||||
preview.find("#description").html(description);
|
||||
preview.find("#description .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
|
||||
let input=$("textarea").eq(3).val();
|
||||
preview.find("#input").html(input);
|
||||
preview.find("#input .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
let output=$("textarea").eq(5).val();
|
||||
preview.find("#output").html(output);
|
||||
preview.find("#output .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
|
||||
let sinput=$("textarea").eq(6).val();
|
||||
preview.find("#sinput").html(sinput);
|
||||
let soutput=$("textarea").eq(7).val();
|
||||
preview.find("#soutput").html(soutput);
|
||||
let hint=$("textarea").eq(11).val();
|
||||
preview.find("#hint").html(hint);
|
||||
preview.find("#hint .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
if($("#previewFrame")[0] != undefined) $("#previewFrame")[0].contentWindow.MathJax.typeset();
|
||||
}
|
||||
|
||||
$(document).ready(function(){
|
||||
// 默认开启预览功能
|
||||
<?php if (!(isset($OJ_OLD_FASHINED) && $OJ_OLD_FASHINED )) echo " transform();" ?>
|
||||
|
||||
// 监听checkbox的点击事件
|
||||
$('#preview-toggle').change(function() {
|
||||
if(this.checked) {
|
||||
transform();
|
||||
} else {
|
||||
// 假设这里是关闭预览的函数
|
||||
untransform();
|
||||
}
|
||||
});
|
||||
});
|
||||
function untransform() {
|
||||
console.log("预览关闭");
|
||||
// 恢复原始的 #main 元素样式
|
||||
let main = $("#main");
|
||||
main.addClass("container");
|
||||
main.css("width", "");
|
||||
main.css("margin-left", "");
|
||||
|
||||
// 移除预览的 iframe
|
||||
$("#preview").remove();
|
||||
|
||||
|
||||
// 移除同步事件
|
||||
$("input").off('keyup', sync);
|
||||
$("textarea").off('keyup', sync);
|
||||
}
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
122
web/admin/problem_add_page_bas.php
Normal file
122
web/admin/problem_add_page_bas.php
Normal file
@@ -0,0 +1,122 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
function getPartByMark($html,$mark1,$mark2){
|
||||
$i=mb_strpos($html,$mark1);
|
||||
$j=mb_strpos($html,$mark2,$i+mb_strlen($mark1)+1);
|
||||
$descriptionHTML=mb_substr($html,$i+ mb_strlen($mark1),$j-($i+ mb_strlen($mark1)));
|
||||
$descriptionHTML=str_replace("\\n","<br>",$descriptionHTML);
|
||||
$descriptionHTML=str_replace('\\\\','\\',$descriptionHTML);
|
||||
$descriptionHTML=str_replace('\\"','"',$descriptionHTML);
|
||||
return ($descriptionHTML);
|
||||
}
|
||||
$url=$_POST ['url'];
|
||||
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://ybt.ssoier.cn:8088/problem_show.php?pid=1000 ";
|
||||
exit(1);
|
||||
}
|
||||
$remote_id=mb_substr($url,mb_strpos($url,"=")+1);
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
// echo $baseurl;
|
||||
$html = file_get_html($url, false,null,0, -1,true,true, DEFAULT_TARGET_CHARSET,false);
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
$element=$html->find('h3',0);
|
||||
$title=$element->plaintext;
|
||||
$title=mb_substr($title,mb_strlen($remote_id.":"));
|
||||
$i=1;
|
||||
$sample_output=$sample_input=$descriptionHTML="";
|
||||
|
||||
$html=$html->innertext;
|
||||
$html=mb_ereg_replace("\<script\>pshow\(\"","",$html);
|
||||
$html=mb_ereg_replace("\"\);\<\/script\>","",$html);
|
||||
// echo $i."-".strlen($html);
|
||||
if(strpos($html,"<center><table width=1000px>")>0){
|
||||
$descriptionHTML=getPartByMark($html,"<center><table width=1000px><td class=\"pcontent\"><center>","<p align=center> <a href=submit.php?pid=$remote_id class=\"bottom_link\">");
|
||||
}else{
|
||||
$descriptionHTML=getPartByMark($html,"【题目描述】","<p align=center> <a href=submit.php?pid=".$remote_id);
|
||||
}
|
||||
// echo $i."-".strlen($descriptionHTML);
|
||||
$time_limit=getPartByMark( $descriptionHTML,"时间限制: ","ms");
|
||||
$time_limit=intval($time_limit)/1000.0;
|
||||
$memory_limit=getPartByMark( $descriptionHTML,"内存限制: ","KB");
|
||||
$memory_limit=intval($memory_limit)/1024.0;
|
||||
$inputHTML=getPartByMark($descriptionHTML,"<h3>【输入】</h3>","<h3>【输出】</h3>");
|
||||
$inputHTML=mb_ereg_replace("\\\\n","\n<br>",$inputHTML);
|
||||
$outputHTML=getPartByMark($descriptionHTML,"<h3>【输出】</h3>","<h3>【输入样例】</h3>");
|
||||
$outputHTML=mb_ereg_replace("\\\\n","\n<br>",$outputHTML);
|
||||
$sample_input=getPartByMark($descriptionHTML,"【输入样例】</h3>\n<font size=3><pre>","</pre></font>");
|
||||
$sample_output=getPartByMark($descriptionHTML,"【输出样例】</h3>\n<font size=3><pre>","</pre></font>");
|
||||
$descriptionHTML=getPartByMark($descriptionHTML,"【题目描述】</h3>","<h3>【输入】</h3>");
|
||||
$descriptionHTML=mb_ereg_replace("\\\\n","\n<br>",$descriptionHTML);
|
||||
?>
|
||||
<form method=POST action=problem_add.php >
|
||||
<input type=hidden name=problem_id value=New Problem>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>"></p>
|
||||
<p align=left>Time Limit:<input type=text name=time_limit size=20 value="<?php echo $time_limit?>">S
|
||||
Memory Limit:<input type=text name=memory_limit size=20 value="<?php echo $memory_limit?>">MByte</p>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Input:
|
||||
<textarea rows=5 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
Output:<!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea rows=5 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
<br>
|
||||
Sample Input:<textarea rows=1 name=sample_input cols=80><?php echo $sample_input?></textarea>
|
||||
Sample Output:<textarea rows=1 name=sample_output cols=80><?php echo $sample_output?></textarea>
|
||||
<br>
|
||||
Test Input:<textarea rows=1 name=test_input cols=80></textarea>
|
||||
Test Output:<textarea rows=1 name=test_output cols=80></textarea>
|
||||
<br>
|
||||
Hint:
|
||||
<textarea rows=1 name=hint cols=80></textarea>
|
||||
<p>SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<textarea class='input input-xxlarge' name=source rows=1 cols=170><?php echo htmlentities($url,ENT_QUOTES,'UTF-8')?></textarea></p>
|
||||
<p align=left>contest:
|
||||
<select name=contest_id>
|
||||
<?php $sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0){
|
||||
}else{
|
||||
foreach($result as $row)
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=hidden name=remote_oj value="bas" >
|
||||
<input type=text name=remote_id value="<?php echo $remote_id?>" >
|
||||
<input type=submit value=Submit name=submit>
|
||||
</div></form>
|
||||
<p>
|
||||
<?php if(intval($remote_id)<3483){ ?>
|
||||
<script> window.setTimeout("$('input[type=submit]').click();",2000);</script>
|
||||
<?php } ?>
|
||||
</body></html>
|
||||
|
||||
99
web/admin/problem_add_page_hdu.php
Normal file
99
web/admin/problem_add_page_hdu.php
Normal file
@@ -0,0 +1,99 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
$url=$_POST ['url'];
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://acm.hdu.edu.cn/showproblem.php?pid=1000";
|
||||
exit(1);
|
||||
}
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$remote_id=mb_substr($url,mb_strpos($url,"=")+1);
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
//echo $baseurl;
|
||||
$html = file_get_html($url, false,null,0, -1,true,true, DEFAULT_TARGET_CHARSET,false);//file_get_html($url,'GB2312');
|
||||
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
|
||||
$element=$html->find('h1',0);
|
||||
$title=$element->plaintext;
|
||||
|
||||
$element=$html->find('span',0);
|
||||
$tlimit=$element->plaintext;
|
||||
$tlimit=substr($tlimit,12);
|
||||
$tlimit=substr($tlimit,strpos($tlimit, '/')+1,strpos($tlimit, ' MS') - strpos($tlimit, '/'));
|
||||
$mlimit=$element->plaintext;
|
||||
$mlimit=substr($mlimit, strpos($mlimit, "Memory"));
|
||||
$mlimit=substr($mlimit, strpos($mlimit, '/')+1,strpos($mlimit, ' K') - strpos($mlimit, '/'));
|
||||
//echo $mlimit;
|
||||
$tlimit/=1000;
|
||||
$mlimit/=1000;
|
||||
|
||||
$element=$html->find('div[class=panel_content]',0);
|
||||
$descriptionHTML=$element->outertext;
|
||||
$element=$html->find('div[class=panel_content]',1);
|
||||
$inputHTML=$element->outertext;
|
||||
$element=$html->find('div[class=panel_content]',2);
|
||||
$outputHTML=$element->outertext;
|
||||
|
||||
$element=$html->find('pre',0);
|
||||
$element=$element->find('div',0);
|
||||
$sample_input=$element->innertext;
|
||||
$element=$html->find('pre',1);
|
||||
$element=$element->find('div',0);
|
||||
$sample_output=$element->innertext;
|
||||
?>
|
||||
<form method=POST action=problem_add.php>
|
||||
<input type=hidden name=problem_id value=New Problem>
|
||||
<p align=left>Problem Id: New Problem from acm.hdu.edu.cn</p>
|
||||
HDU<input type=text name=remote_id value="<?php echo $remote_id?>" >
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>">
|
||||
Time Limit:<input type=text name=time_limit class='input input-mini' size=2 value="<?php echo $tlimit?>">S
|
||||
Memory Limit:<input type=text name=memory_limit class='input input-mini' size=2 value="<?php echo $mlimit?>">MByte
|
||||
<input type=submit value=Submit name=submit></p>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Input:<br>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
</p>
|
||||
</p>
|
||||
<p align=left>Output:<br><!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<textarea rows=3 name=sample_input cols=80><?php echo $sample_input?></textarea>
|
||||
Sample Output:<textarea rows=3 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<textarea rows=3 name=test_input cols=80></textarea>
|
||||
Test Output:<textarea rows=3 name=test_output cols=80></textarea></p>
|
||||
<p align=left>Hint:<br>
|
||||
<textarea rows=3 name=hint cols=30></textarea>
|
||||
SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<textarea name=source rows=1 cols=70 ><?php echo htmlentities($url)?></textarea></p>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=hidden name=remote_oj value="hdu" >
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
119
web/admin/problem_add_page_hustoj.php
Normal file
119
web/admin/problem_add_page_hustoj.php
Normal file
@@ -0,0 +1,119 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse" width="100%" height="50">
|
||||
<tr>
|
||||
<td width="100"></td>
|
||||
<td>
|
||||
<p align="center"><font color="#333399" size="4">Welcome To Administrator's Page of Judge Online of ACM ICPC,<?php echo $OJ_NAME?>.</font></td>
|
||||
<td width="100"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
<h1>Add New problem</h1>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
function getPartByMark($html,$mark1,$mark2){
|
||||
$i=mb_strpos($html,$mark1);
|
||||
$j=mb_strpos($html,$mark2,$i+mb_strlen($mark1)+1);
|
||||
$descriptionHTML=mb_substr($html,$i+ mb_strlen($mark1),$j-($i+ mb_strlen($mark1)));
|
||||
|
||||
return $descriptionHTML;
|
||||
}
|
||||
|
||||
$url=$_POST ['url'];
|
||||
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://hustoj.com/oj/problem.php?id=1000";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
// echo $baseurl;
|
||||
$html = file_get_html($url);
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
$element=$html->find('h2',0);
|
||||
$title=$element->plaintext;
|
||||
$i=1;
|
||||
$sample_output=$sample_input=$descriptionHTML="";
|
||||
|
||||
$html=$html->innertext;
|
||||
// echo $i."-".strlen($html);
|
||||
if(strpos($html,"<h2>Description</h2>")>0){
|
||||
$descriptionHTML=getPartByMark($html,"<h2>Description</h2>","<h2>Source</h2>");
|
||||
}else{
|
||||
$descriptionHTML=getPartByMark($html,"<h2>题目描述</h2>","<h2>来源</h2>");
|
||||
}
|
||||
// echo $i."-".strlen($descriptionHTML);
|
||||
|
||||
?>
|
||||
<form method=POST action=problem_add.php>
|
||||
<p align=center><font size=4 color=#333399>Add a Problem</font></p>
|
||||
<input type=hidden name=problem_id value=New Problem>
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>"></p>
|
||||
<p align=left>Time Limit:<input type=text name=time_limit size=20 value=1>S</p>
|
||||
<p align=left>Memory Limit:<input type=text name=memory_limit size=20 value=128>MByte</p>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Input:<br>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
</p>
|
||||
</p>
|
||||
<p align=left>Output:<br><!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<br><textarea rows=13 name=sample_input cols=80><?php echo $sample_input?></textarea></p>
|
||||
<p align=left>Sample Output:<br><textarea rows=13 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<br><textarea rows=13 name=test_input cols=80></textarea></p>
|
||||
<p align=left>Test Output:<br><textarea rows=13 name=test_output cols=80></textarea></p>
|
||||
<p align=left>Hint:<br>
|
||||
<textarea class="kindeditor" rows=13 name=hint cols=80></textarea>
|
||||
</p>
|
||||
<p>SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<br><textarea name=source rows=1 cols=70></textarea></p>
|
||||
<p align=left>contest:
|
||||
<select name=contest_id>
|
||||
<?php $sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0){
|
||||
}else{
|
||||
foreach($result as $row)
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value=Submit name=submit>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
|
||||
125
web/admin/problem_add_page_loj.php
Normal file
125
web/admin/problem_add_page_loj.php
Normal file
@@ -0,0 +1,125 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
$url=$_POST ['url'];
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like https://loj.ac/problem/1";
|
||||
exit(1);
|
||||
}
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$loj_id=intval(substr($url,23));
|
||||
echo $loj_id;
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
//echo $baseurl;
|
||||
$html = file_get_html($url);
|
||||
// foreach($html->find('img') as $element)
|
||||
// $element->src=$baseurl.$element->src;
|
||||
|
||||
$element=$html->find('h1',0);
|
||||
$title=trim($element->plaintext);
|
||||
|
||||
$element=$html->find('span',0);
|
||||
$mlimit=$element->plaintext;
|
||||
$mlimit=substr($mlimit, strpos($mlimit, ":")+3);
|
||||
$mlimit=substr($mlimit,0,strpos($mlimit, 'MiB')-1);
|
||||
$element=$html->find('span',1);
|
||||
$tlimit=$element->plaintext;
|
||||
$tlimit=substr($tlimit, strpos($tlimit, ":")+3);
|
||||
$tlimit=substr($tlimit,0,strpos($mlimit, ' ms')-3);
|
||||
$tlimit/=1000;
|
||||
//$mlimit/=1000;
|
||||
//echo "mlimit:$mlimit<br>";
|
||||
//echo "tlimit:".$tlimit;
|
||||
function mjpage($raw){
|
||||
|
||||
$ret=str_replace('<span class="mjpage">','\(',$raw);
|
||||
$ret=str_replace('</span>','\)',$ret);
|
||||
return $ret;
|
||||
}
|
||||
|
||||
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',0);
|
||||
$descriptionHTML=mjpage($element->outertext);
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',1);
|
||||
$inputHTML=mjpage($element->outertext);
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',2);
|
||||
$outputHTML=mjpage($element->outertext);
|
||||
|
||||
$element=$html->find('code[class=lang-plain]',0);
|
||||
$sample_input=$element->innertext;
|
||||
$element=$html->find('code[class=lang-plain]',1);
|
||||
$sample_output=$element->innertext;
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',4);
|
||||
$hintHTML=mjpage($element->outertext);
|
||||
$element=$html->find('div[class=ui bottom attached segment]',1);
|
||||
$sourceHTML=$element->outertext;
|
||||
?>
|
||||
<form method=POST action="problem_add_loj.php">
|
||||
<input type=submit value=Submit name=submit>
|
||||
<p align=center><font size=4 color=#333399>Add a Problem</font></p>
|
||||
<input type="hidden" name=problem_id value="New Problem">
|
||||
<input type="text" name="loj_id" value="<?php echo $loj_id?>">
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>"></p>
|
||||
<p align=left>Time Limit:<input type=text name=time_limit size=20 value="<?php echo $tlimit?>">S</p>
|
||||
<p align=left>Memory Limit:<input type=text name=memory_limit size=20 value="<?php echo $mlimit?>">MByte</p>
|
||||
<p align=left>Description:<br><!--<textarea rows=13 name=description cols=80></textarea>-->
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Input:<br>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
</p>
|
||||
</p>
|
||||
<p align=left>Output:<br><!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<br><textarea rows=13 name=sample_input cols=80><?php echo $sample_input?></textarea></p>
|
||||
<p align=left>Sample Output:<br><textarea rows=13 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<br><textarea rows=13 name=test_input cols=80></textarea></p>
|
||||
<p align=left>Test Output:<br><textarea rows=13 name=test_output cols=80></textarea></p>
|
||||
<p align=left>Hint:<br>
|
||||
<textarea class="kindeditor" rows=13 name=hint cols=80><?php echo $hintHTML?></textarea>
|
||||
</p>
|
||||
<p>SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<br><textarea name=source rows=1 cols=70>LibreOJ<?php echo $sourceHTML?></textarea></p>
|
||||
<p align=left>contest:
|
||||
<select name=contest_id>
|
||||
<?php $sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0){
|
||||
}else{
|
||||
foreach($result as $row)
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
90
web/admin/problem_add_page_luogu.php
Normal file
90
web/admin/problem_add_page_luogu.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
function getPartByMark($html,$mark1,$mark2){
|
||||
$i=mb_strpos($html,$mark1);
|
||||
$start=$i+mb_strlen($mark1)+1;
|
||||
if($i>=0&&$start<=mb_strlen($html)) $j=mb_strpos($html,$mark2,$start);
|
||||
else return $html;
|
||||
$descriptionHTML=mb_substr($html,$i+ mb_strlen($mark1),$j-($i+ mb_strlen($mark1)));
|
||||
echo "[$star-$j]";
|
||||
return $descriptionHTML;
|
||||
}
|
||||
$url=$_POST ['url'];
|
||||
$remote_id=basename($url);
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like https://www.luogu.com.cn/problem/P1000";
|
||||
exit(1);
|
||||
}
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
// echo $baseurl;
|
||||
//$html = file_get_html($url);
|
||||
$html = file_get_html($url, false,null,0, -1,true,true, DEFAULT_TARGET_CHARSET,false);
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
|
||||
$element=$html->find('article',0);
|
||||
$tlimit=1;
|
||||
$mlimit=128;
|
||||
$html=$element->innertext;
|
||||
// $html=getPartByMark($html,"<h1>","</h1>");
|
||||
$title=getPartByMark($html,"<h1>","</h1>");
|
||||
$descriptionHTML="<div class='md'>".getPartByMark($html,"<h2>题目背景</h2>","<h3>输入格式</h3>")."</div>";
|
||||
|
||||
$inputHTML=getPartByMark($html,"<h3>输入格式</h3>","<h3>输出格式</h3>");
|
||||
$outputHTML=getPartByMark($html,"<h3>输出格式</h3>","<h2>输入输出样例</h2>");
|
||||
$hint=getPartByMark($html,"<h2>输入输出样例</h2>","<div>**广告**");
|
||||
|
||||
?>
|
||||
<form method=POST action=problem_add.php>
|
||||
<input type=hidden name=problem_id value="New Problem">
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>">
|
||||
Time Limit:<input type=text class='input input-mini' name=time_limit size=20 value="<?php echo $tlimit?>">S
|
||||
Memory Limit:<input type=text class='input input-mini' name=memory_limit size=20 value="<?php echo $mlimit?>">MB
|
||||
<br>LUOGU<input type=text name=remote_id value="<?php echo $remote_id?>" >
|
||||
<input type=submit value=Submit name=submit>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=5 name=description cols=30><?php echo $descriptionHTML;?></textarea>
|
||||
<p align=left>Input:
|
||||
<textarea rows=5 name=input cols=30 ><?php echo $inputHTML;?></textarea>
|
||||
Output:
|
||||
<textarea rows=5 name=output cols=30><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<textarea rows=2 name=sample_input cols=80><?php echo $sample_input?></textarea>
|
||||
Sample Output:<textarea rows=2 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<textarea rows=2 name=test_input cols=80></textarea>
|
||||
Test Output:<textarea rows=2 name=test_output cols=80></textarea>
|
||||
<br>
|
||||
Hint:<textarea rows=3 name=hint cols=2 ><?php echo $hint ?></textarea>
|
||||
SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'>
|
||||
Source:<textarea name=source rows=1 cols=3><?php echo $url ?></textarea>
|
||||
<input type=hidden name=contest_id></input>
|
||||
<input type=hidden name=remote_oj value="luogu" >
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
94
web/admin/problem_add_page_pku.php
Normal file
94
web/admin/problem_add_page_pku.php
Normal file
@@ -0,0 +1,94 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
$url=$_POST ['url'];
|
||||
$remote_id=mb_substr($url,mb_strpos($url,"=")+1);
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://poj.org/problem?id=1000";
|
||||
exit(1);
|
||||
}
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
// echo $baseurl;
|
||||
//$html = file_get_html($url);
|
||||
$html = file_get_html($url, false,null,0, -1,true,true, DEFAULT_TARGET_CHARSET,false);
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
|
||||
$element=$html->find('div[class=ptt]',0);
|
||||
$title=$element->plaintext;
|
||||
|
||||
$element=$html->find('div[class=plm]',0);
|
||||
$tlimit=$element->find('td',0);//->next_sibling();
|
||||
$tlimit=substr($tlimit->plaintext,11);
|
||||
$tlimit=substr($tlimit,0,strlen($tlimit)-2);
|
||||
$mlimit=$element->find('td',2);//->nextSibling();
|
||||
$mlimit=substr($mlimit->plaintext,13);
|
||||
$mlimit=substr($mlimit,0,strlen($mlimit)-1);
|
||||
$tlimit/=1000;
|
||||
$mlimit/=1000;
|
||||
|
||||
$element=$html->find('div[class=ptx]',0);
|
||||
$descriptionHTML=$element->outertext;
|
||||
$element=$html->find('div[class=ptx]',1);
|
||||
$inputHTML=$element->outertext;
|
||||
$element=$html->find('div[class=ptx]',2);
|
||||
$outputHTML=$element->outertext;
|
||||
$element=$html->find('pre[class=sio]',0);
|
||||
$sample_input=$element->innertext;
|
||||
$element=$html->find('pre[class=sio]',1);
|
||||
$sample_output=$element->innertext;
|
||||
$element=$html->find('div[class=ptx]',3);
|
||||
$hint=htmlentities($element->outertext);
|
||||
?>
|
||||
<form method=POST action=problem_add.php>
|
||||
<input type=hidden name=problem_id value=New Problem>
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>">
|
||||
Time Limit:<input type=text class='input input-mini' name=time_limit size=20 value="<?php echo $tlimit?>">S
|
||||
Memory Limit:<input type=text class='input input-mini' name=memory_limit size=20 value="<?php echo $mlimit?>">MB
|
||||
<br>POJ<input type=text name=remote_id value="<?php echo $remote_id?>" >
|
||||
<input type=submit value=Submit name=submit>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=5 name=description cols=30><?php echo $descriptionHTML;?></textarea>
|
||||
<p align=left>Input:
|
||||
<textarea rows=5 name=input cols=30 ><?php echo $inputHTML;?></textarea>
|
||||
Output:
|
||||
<textarea rows=5 name=output cols=30><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<textarea rows=2 name=sample_input cols=80><?php echo $sample_input?></textarea>
|
||||
Sample Output:<textarea rows=2 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<textarea rows=2 name=test_input cols=80></textarea>
|
||||
Test Output:<textarea rows=2 name=test_output cols=80></textarea>
|
||||
<br>
|
||||
Hint:<textarea rows=3 name=hint cols=2 ><?php echo $hint ?></textarea>
|
||||
SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'>
|
||||
Source:<textarea name=source rows=1 cols=3><?php echo $url ?></textarea>
|
||||
<input type=hidden name=contest_id></input>
|
||||
<input type=hidden name=remote_oj value="pku" >
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
137
web/admin/problem_add_page_uoj.php
Normal file
137
web/admin/problem_add_page_uoj.php
Normal file
@@ -0,0 +1,137 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
function pregReplaceImg2($content,$prefix)
|
||||
{
|
||||
$contentAlter = preg_replace_callback('/(<[img|IMG].*?src=[\'\"])([\s\S]*?)([\'\"])[\s\S]*?/i', function($match)use($prefix){
|
||||
if(strstr($match[2], 'http://') == false && strstr($match[1], 'https://') == false)
|
||||
return $match[1].$prefix.$match[2].$match[3];
|
||||
else
|
||||
return $match[1].$match[2].$match[3];
|
||||
} , $content);
|
||||
return $contentAlter;
|
||||
}
|
||||
|
||||
|
||||
$url=$_POST ['url'];
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://uoj.ac/problem/1";
|
||||
exit(1);
|
||||
}
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$loj_id=intval(substr($url,strrpos($url,"/")+1));
|
||||
//echo strrpos($url,"/");
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
//echo $baseurl;
|
||||
$html = file_get_html($url);
|
||||
// foreach($html->find('img') as $element)
|
||||
// $element->src=$baseurl.$element->src;
|
||||
|
||||
$element=$html->find('h1',2);
|
||||
$title=trim($element->plaintext);
|
||||
|
||||
$element=$html->find('article',0);
|
||||
$mlimit=$element->plaintext;
|
||||
$mlimit=mb_substr($mlimit, mb_strpos($mlimit, "空间限制")+6);
|
||||
$mlimit=mb_substr($mlimit,0,mb_strpos($mlimit, 'MB')-8);
|
||||
$mlimit=intval($mlimit);
|
||||
if($mlimit==0)$mlimit=256;
|
||||
$tlimit=$element->plaintext;
|
||||
$tlimit=mb_substr($tlimit, mb_strpos($tlimit, "时间限制")+6);
|
||||
$tlimit=mb_substr($tlimit,0,mb_strpos($tlimit, 's')-8);
|
||||
$tlimit=intval($tlimit);
|
||||
if($tlimit==0)$tlimit=1;
|
||||
//$mlimit/=1000;
|
||||
//echo "mlimit:$mlimit<br>";
|
||||
//echo "tlimit:".$tlimit;
|
||||
|
||||
$element=$html->find('article',0);
|
||||
$descriptionHTML=$element->outertext;
|
||||
$descriptionHTML=pregReplaceImg2($descriptionHTML,"https://darkbzoj.tk/");
|
||||
|
||||
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',1);
|
||||
$inputHTML=$element->outertext;
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',2);
|
||||
$outputHTML=$element->outertext;
|
||||
|
||||
$element=$html->find('code[class=lang-plain]',0);
|
||||
$sample_input=$element->innertext;
|
||||
$element=$html->find('code[class=lang-plain]',1);
|
||||
$sample_output=$element->innertext;
|
||||
$element=$html->find('div[class=ui bottom attached segment font-content]',4);
|
||||
$hintHTML=$element->outertext;
|
||||
$element=$html->find('div[class=ui bottom attached segment]',1);
|
||||
$sourceHTML=$element->outertext;
|
||||
?>
|
||||
<form method=POST action="problem_add_uoj.php">
|
||||
<input type=submit value=Submit name=submit>
|
||||
<p align=center><font size=4 color=#333399>Add a Problem</font></p>
|
||||
<input type="hidden" name=problem_id value="New Problem">
|
||||
<input type="hidden" name="url" value="<?php echo htmlentities($url)?>">
|
||||
<input type="hidden" name="loj_id" value="<?php echo $loj_id?>">
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>"></p>
|
||||
<p align=left>Time Limit:<input type=text name=time_limit size=20 value="<?php echo $tlimit?>">S</p>
|
||||
<p align=left>Memory Limit:<input type=text name=memory_limit size=20 value="<?php echo $mlimit?>">MByte</p>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<span style="display:none">
|
||||
<p align=left>Input:<br>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
</p>
|
||||
</p>
|
||||
<p align=left>Output:<br><!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<br><textarea rows=13 name=sample_input cols=80><?php echo $sample_input?></textarea></p>
|
||||
<p align=left>Sample Output:<br><textarea rows=13 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<br><textarea rows=13 name=test_input cols=80></textarea></p>
|
||||
<p align=left>Test Output:<br><textarea rows=13 name=test_output cols=80></textarea></p>
|
||||
<p align=left>Hint:<br>
|
||||
<textarea class="kindeditor" rows=13 name=hint cols=80><?php echo $hintHTML?></textarea>
|
||||
</p>
|
||||
<p>SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<br><textarea name=source rows=1 cols=70><?php echo $url?></textarea></p>
|
||||
<p align=left>contest:
|
||||
<select name=contest_id>
|
||||
<?php $sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0){
|
||||
}else{
|
||||
foreach($result as $row)
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
</span>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
120
web/admin/problem_add_page_waterloo.php
Normal file
120
web/admin/problem_add_page_waterloo.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
|
||||
<table border="0" cellpadding="0" cellspacing="0" style="border-collapse:collapse" width="100%" height="50">
|
||||
<tr>
|
||||
<td width="100"></td>
|
||||
<td>
|
||||
<p align="center"><font color="#333399" size="4">Welcome To Administrator's Page of Judge Online of ACM ICPC,<?php echo $OJ_NAME?>.</font></td>
|
||||
<td width="100"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
<hr>
|
||||
<h1>Add New problem</h1>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
$url=$_POST ['url'];
|
||||
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://acm.student.cs.uwaterloo.ca/~acm00";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
// echo $baseurl;
|
||||
$html = file_get_html($url);
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
$element=$html->find('h2',0);
|
||||
$title=$element->plaintext;
|
||||
$i=1;
|
||||
$outputHTML=$inputHTML=$sample_output=$sample_input=$descriptionHTML="";
|
||||
|
||||
$html=$html->innertext;
|
||||
$i=strpos($html,"<h3>");
|
||||
// echo $i."-".strlen($html);
|
||||
$descriptionHTML=substr($html,0,$i-1);
|
||||
// echo $i."-".strlen($descriptionHTML);
|
||||
$i=strpos($html,"</h3>",$i+1);
|
||||
$j=strpos($html,"<h3>",$i);
|
||||
$inputHTML=substr($html,$i+5,$j-$i-1);
|
||||
$i=strpos($html,"<pre>",$i);
|
||||
$j=strpos($html,"</pre>",$i);
|
||||
$sample_input=substr($html,$i+5,$j-$i-5);
|
||||
$i=strpos($html,"</h3>",$i+1);
|
||||
$j=strpos($html,"<h3>",$i);
|
||||
$outputHTML=substr($html,$i+5,$j-$i-1);
|
||||
$i=strpos($html,"<pre>",$j);
|
||||
$j=strpos($html,"</pre>",$i);
|
||||
$sample_output=substr($html,$i+5,$j-$i-5);
|
||||
|
||||
?>
|
||||
<form method=POST action=problem_add.php>
|
||||
<p align=center><font size=4 color=#333399>Add a Problem</font></p>
|
||||
<input type=hidden name=problem_id value=New Problem>
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>"></p>
|
||||
<p align=left>Time Limit:<input type=text name=time_limit size=20 value=1>S</p>
|
||||
<p align=left>Memory Limit:<input type=text name=memory_limit size=20 value=128>MByte</p>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Input:<br>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
</p>
|
||||
</p>
|
||||
<p align=left>Output:<br><!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<br><textarea rows=13 name=sample_input cols=80><?php echo $sample_input?></textarea></p>
|
||||
<p align=left>Sample Output:<br><textarea rows=13 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<br><textarea rows=13 name=test_input cols=80></textarea></p>
|
||||
<p align=left>Test Output:<br><textarea rows=13 name=test_output cols=80></textarea></p>
|
||||
<p align=left>Hint:<br>
|
||||
<textarea class="kindeditor" rows=13 name=hint cols=80></textarea>
|
||||
</p>
|
||||
<p>SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<br><textarea name=source rows=1 cols=70>Waterloo </textarea></p>
|
||||
<p align=left>contest:
|
||||
<select name=contest_id>
|
||||
<?php $sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0){
|
||||
}else{
|
||||
foreach($result as $row)
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value=Submit name=submit>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
|
||||
110
web/admin/problem_add_page_zju.php
Normal file
110
web/admin/problem_add_page_zju.php
Normal file
@@ -0,0 +1,110 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>New Problem</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<center>
|
||||
<?php require_once("../include/db_info.inc.php");?>
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
<?php require_once("../include/simple_html_dom.php");
|
||||
$url=$_POST ['url'];
|
||||
if (!$url) $url=$_GET['url'];
|
||||
if (strpos($url, "http") === false){
|
||||
echo "Please Input like http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1001";
|
||||
exit(1);
|
||||
}
|
||||
if (false) {
|
||||
$url = stripslashes ( $url);
|
||||
}
|
||||
$baseurl=substr($url,0,strrpos($url,"/")+1);
|
||||
$html = file_get_html($url);
|
||||
foreach($html->find('img') as $element)
|
||||
$element->src=$baseurl.$element->src;
|
||||
|
||||
$element=$html->find('span[class=bigProblemTitle]',0);
|
||||
$title=$element->plaintext;
|
||||
|
||||
$element=$html->find('center',1);
|
||||
$tlimit=substr($element->plaintext,strpos($element->plaintext,": ")+2,3);
|
||||
$mlimit=substr($element->plaintext,strrpos($element->plaintext,": ")+2,7);
|
||||
$mlimit/=1024;
|
||||
|
||||
$element=$html->find('div[id=content_body]',0);
|
||||
$descriptionHTML=$element->innertext;
|
||||
|
||||
//$tlimit=substr($html,'Time Limit: </font> ([\\s\\S]*?) Second');
|
||||
//$mlimit=substr($html,'Memory Limit: </font> ([\\s\\S]*?) KB');
|
||||
//$descriptionHTML=$html->find('KB[\\s\\S]*?</center>[\\s\\S]*?<hr>([\\s\\S]*?)>[\\s]*Input',0);
|
||||
//$inputHTML=$html->pre_grep(">[\\s]*Input([\\s\\S]*?)>[\\s]*Out?put",$html->outertext);
|
||||
//$outputHTML=$html->find('>[\\s]*Out?put([\\s\\S]*?)>[\\s]*Sample Input',0);
|
||||
//$sample_input=pre_grep(">[\\s]*Sample Input([\\s\\S]*?)>[\\s]*Sample Out?put",$html->outertext);
|
||||
//$sample_output=$html->find(">[\\s]*Sample Out?put([\\s\\S]*?)<hr",0);
|
||||
|
||||
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ޣ<EFBFBD><DEA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD><EFBFBD>ɹ<EFBFBD><C9B9>ܺ<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ģ<EFBFBD>ʵ<EFBFBD>ֲ<EFBFBD><D6B2>ˣ<EFBFBD><CBA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ȥ<EFBFBD>ĸĽ<C4B8><C4BD>ɣ<EFBFBD>
|
||||
|
||||
?>
|
||||
<form method=POST action=problem_add.php>
|
||||
<p align=center><font size=4 color=#333399>Add a Problem</font></p>
|
||||
<input type=hidden name=problem_id value=New Problem>
|
||||
<p align=left>Problem Id: New Problem</p>
|
||||
<p align=left>Title:<input type=text name=title size=71 value="<?php echo $title?>"></p>
|
||||
<p align=left>Time Limit:<input type=text name=time_limit size=20 value="<?php echo $tlimit?>">S</p>
|
||||
<p align=left>Memory Limit:<input type=text name=memory_limit size=20 value="<?php echo $mlimit?>">MByte</p>
|
||||
<p align=left>Description:<br>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo $descriptionHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Input:<br>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo $inputHTML;?></textarea>
|
||||
</p>
|
||||
</p>
|
||||
<p align=left>Output:<br><!--<textarea rows=13 name=output cols=80></textarea>-->
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo $outputHTML;?></textarea>
|
||||
</p>
|
||||
<p align=left>Sample Input:<br><textarea rows=13 name=sample_input cols=80><?php echo $sample_input?></textarea></p>
|
||||
<p align=left>Sample Output:<br><textarea rows=13 name=sample_output cols=80><?php echo $sample_output?></textarea></p>
|
||||
<p align=left>Test Input:<br><textarea rows=13 name=test_input cols=80></textarea></p>
|
||||
<p align=left>Test Output:<br><textarea rows=13 name=test_output cols=80></textarea></p>
|
||||
<p align=left>Hint:<br>
|
||||
<?php
|
||||
$output = new FCKeditor('hint') ;
|
||||
$output->BasePath = '../fckeditor/' ;
|
||||
$output->Height = 300 ;
|
||||
$output->Width=600;
|
||||
$output->Value = '<p></p>' ;
|
||||
$output->Create() ;
|
||||
?>
|
||||
</p>
|
||||
<p>SpecialJudge: N<input type=radio name=spj value='0' checked>Y<input type=radio name=spj value='1'></p>
|
||||
<p align=left>Source:<br><textarea name=source rows=1 cols=70></textarea></p>
|
||||
<p align=left>contest:
|
||||
<select name=contest_id>
|
||||
<?php $sql="SELECT `contest_id`,`title` FROM `contest` WHERE `start_time`>NOW() order by `contest_id`";
|
||||
$result=pdo_query($sql);
|
||||
echo "<option value=''>none</option>";
|
||||
if (count($result)==0){
|
||||
}else{
|
||||
foreach($result as $row)
|
||||
echo "<option value='{$row['contest_id']}'>{$row['contest_id']} {$row['title']}</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
</p>
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value=Submit name=submit>
|
||||
</div></form>
|
||||
<p>
|
||||
|
||||
</body></html>
|
||||
118
web/admin/problem_add_uoj.php
Normal file
118
web/admin/problem_add_uoj.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php require_once ("admin-header.php");
|
||||
require_once("../include/check_post_key.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<?php require_once ("../include/db_info.inc.php");
|
||||
?>
|
||||
<?php require_once ("../include/problem.php");
|
||||
?>
|
||||
<?php // contest_id
|
||||
|
||||
$url=$_POST ['url'];
|
||||
|
||||
$title = $_POST ['title'];
|
||||
$time_limit = $_POST ['time_limit'];
|
||||
$memory_limit = $_POST ['memory_limit'];
|
||||
$description = $_POST ['description'];
|
||||
$input = $_POST ['input'];
|
||||
$output = $_POST ['output'];
|
||||
$sample_input = $_POST ['sample_input'];
|
||||
$sample_output = $_POST ['sample_output'];
|
||||
$test_input = $_POST ['test_input'];
|
||||
$test_output = $_POST ['test_output'];
|
||||
$hint = $_POST ['hint'];
|
||||
$source = $_POST ['source'];
|
||||
$spj = $_POST ['spj'];
|
||||
if (false) {
|
||||
$title = stripslashes ( $title);
|
||||
$time_limit = stripslashes ( $time_limit);
|
||||
$memory_limit = stripslashes ( $memory_limit);
|
||||
$description = stripslashes ( $description);
|
||||
$input = stripslashes ( $input);
|
||||
$output = stripslashes ( $output);
|
||||
$sample_input = stripslashes ( $sample_input);
|
||||
$sample_output = stripslashes ( $sample_output);
|
||||
$test_input = stripslashes ( $test_input);
|
||||
$test_output = stripslashes ( $test_output);
|
||||
$hint = stripslashes ( $hint);
|
||||
$source = stripslashes ( $source);
|
||||
$spj = stripslashes ( $spj);
|
||||
$source = stripslashes ( $source );
|
||||
}
|
||||
//echo "->".$OJ_DATA."<-";
|
||||
$pid=addproblem ( $title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA );
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
mkdir ( $basedir );
|
||||
chdir($basedir);
|
||||
$loj_id=intval($_POST['loj_id']);
|
||||
if(strstr($url,"uoj")){
|
||||
$fileCon = file_get_contents("https://uoj.ac/download.php?type=problem&id=$loj_id");
|
||||
file_put_contents($basedir."/data.zip",$fileCon);
|
||||
$tempfile=$basedir."/data.zip";
|
||||
echo "unzip files ... <br>";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
$tempfile = tempnam("/tmp", "fps");
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = zip_entry_name($dir_resource);
|
||||
echo "<br>".$file_name;
|
||||
if(pathinfo($file_name)['extension']=="ans") {
|
||||
$file_name=pathinfo($file_name)['filename'].".out";
|
||||
echo "->".$file_name;
|
||||
}
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if($file_name)
|
||||
file_put_contents($basedir."/".$file_name,$file_content);
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ($basedir."/data.zip");
|
||||
}else{
|
||||
$fileCon = file_get_contents("https://darkbzoj.tk/data/$loj_id.zip");
|
||||
file_put_contents($basedir."/data.zip",$fileCon);
|
||||
}
|
||||
//var_dump($fileCon);
|
||||
if(strlen($sample_output)&&!strlen($sample_input)) $sample_input="0";
|
||||
if(strlen($sample_input)) mkdata($pid,"sample.in",$sample_input,$OJ_DATA);
|
||||
if(strlen($sample_output))mkdata($pid,"sample.out",$sample_output,$OJ_DATA);
|
||||
if(strlen($test_output)&&!strlen($test_input)) $test_input="0";
|
||||
if(strlen($test_input))mkdata($pid,"test.in",$test_input,$OJ_DATA);
|
||||
if(strlen($test_output))mkdata($pid,"test.out",$test_output,$OJ_DATA);
|
||||
|
||||
$sql="insert into `privilege` (`user_id`,`rightstr`) values(?,?)";
|
||||
pdo_query($sql,$_SESSION[$OJ_NAME.'_'.'user_id'],"p$pid");
|
||||
$_SESSION[$OJ_NAME.'_'."p$pid"]=true;
|
||||
//print_r($_POST);
|
||||
echo "<br>".$loj_id."<br>";
|
||||
echo "<a href='javascript:phpfm($pid);'>Add more TestData now !</a>";
|
||||
/* */
|
||||
?>
|
||||
<script src='../template/bs3/jquery.min.js' ></script>
|
||||
<script>
|
||||
function phpfm(pid){
|
||||
//alert(pid);
|
||||
$.post("phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){
|
||||
if(status=="success"){
|
||||
document.location.href="phpfm.php?frame=3&pid="+pid;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Copy Next
|
||||
<form method=POST action=problem_add_page_uoj.php>
|
||||
<input name=url type=text size=100 value="<?php echo pathinfo($url)['dirname']."/".($loj_id+1)?>">
|
||||
<input type=submit>
|
||||
</form>
|
||||
|
||||
|
||||
|
||||
82
web/admin/problem_changeid.php
Normal file
82
web/admin/problem_changeid.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php require("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
function writable($path){
|
||||
$ret=false;
|
||||
$fp=fopen($path."/testifwritable.tst","w");
|
||||
$ret=!($fp===false);
|
||||
fclose($fp);
|
||||
unlink($path."/testifwritable.tst");
|
||||
return $ret;
|
||||
}
|
||||
?>
|
||||
<?php if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
if (isset($_POST['from'])){
|
||||
$from=intval($_POST['from']);
|
||||
$to=intval($_POST['to']);
|
||||
$row=0;
|
||||
if($result=pdo_query("select 1 from problem where problem_id=?",$to)){
|
||||
$row=count($result);
|
||||
|
||||
}
|
||||
|
||||
if($row==0&&rename("$OJ_DATA/$from","$OJ_DATA/$to")){
|
||||
$sql="UPDATE `problem` SET `problem_id`=? WHERE `problem_id`=?";
|
||||
if(pdo_query($sql,$to,$from)==0){
|
||||
rename("$OJ_DATA/$to","$OJ_DATA/$from");
|
||||
echo "fail...";
|
||||
exit(1);
|
||||
}
|
||||
$sql="UPDATE `solution` SET `problem_id`=? WHERE `problem_id`=?";
|
||||
pdo_query($sql,$to,$from);
|
||||
$sql="UPDATE `contest_problem` SET `problem_id`=? WHERE `problem_id`=?";
|
||||
pdo_query($sql,$to,$from);
|
||||
$sql="UPDATE `topic` SET `pid`=? WHERE `pid`=?";
|
||||
pdo_query($sql,$to,$from);
|
||||
|
||||
$sql="select max(problem_id) from problem";
|
||||
if($result=pdo_query($sql)){
|
||||
$f=$result[0];
|
||||
$nextid=$f[0]+1;
|
||||
$sql="ALTER TABLE problem AUTO_INCREMENT = $nextid";
|
||||
pdo_query($sql);
|
||||
}
|
||||
|
||||
echo "done!";
|
||||
}else{
|
||||
|
||||
echo "fail...";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$show_form=true;
|
||||
if(!isset($OJ_SAE)||!$OJ_SAE){
|
||||
if(!writable($OJ_DATA)){
|
||||
echo " You need to add $OJ_DATA into your open_basedir setting of php.ini,<br>
|
||||
or you need to execute:<br>
|
||||
<b>chmod 775 -R $OJ_DATA && chgrp -R www-data $OJ_DATA</b><br>
|
||||
you can't use import function at this time.<br>";
|
||||
$show_form=false;
|
||||
}
|
||||
}
|
||||
if($show_form){
|
||||
?>
|
||||
<b>Change ProblemID</b>
|
||||
<ol>
|
||||
<li>Problem
|
||||
<form action='problem_changeid.php' method=post>
|
||||
Move<input type=input name='from'>->
|
||||
<input type=input name='to'>
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<input type=submit value=submit>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
|
||||
<?php }
|
||||
?>
|
||||
75
web/admin/problem_copy.php
Normal file
75
web/admin/problem_copy.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php require_once ("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<ol>
|
||||
<li>
|
||||
Copy from http://uoj.ac
|
||||
<form method=POST action=problem_add_page_uoj.php>
|
||||
<input name=url type=text size="100" class="input input-xxlarge" value="http://uoj.ac/problem/1">
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
<!-- <li>
|
||||
Copy from http://ybt.ssoier.cn:8088/......
|
||||
<form method=POST action=problem_add_page_ybt.php>
|
||||
<input name=url type=text size=100 class="input input-xxlarge" value="http://ybt.ssoier.cn:8088/problem_show.php?pid=1000">
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
-->
|
||||
<li>
|
||||
Copy from http://hustoj......
|
||||
<form method=POST action=problem_add_page_hustoj.php>
|
||||
<input name=url type=text size=100 value="http://hustoj.com/oj/problem.php?id=1000">
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
<li>
|
||||
Copy from https://www.luogu.com.cn/problem/P1000
|
||||
<form method=POST action="problem_add_page_luogu.php" >
|
||||
<input name=url type=text size=100 class="input input-xxlarge" value="https://www.luogu.com.cn/problem/P1000">
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
<li>
|
||||
Copy from https://loj.ac/problem/
|
||||
<form method=POST action=problem_add_page_loj.php>
|
||||
<input name=url type=text size=100 >
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
<li>
|
||||
Copy from http://acm.student.cs.uwaterloo.ca/~acm00
|
||||
<form method=POST action=problem_add_page_waterloo.php>
|
||||
<input name=url type=text size=100>
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
<li>
|
||||
Copy from acm.pku.edu.cn
|
||||
<form method=POST action=problem_add_page_pku.php>
|
||||
<input name=url class='input input-xxlarge' type=text size=100 value='http://poj.org/problem?id=1000' >
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Copy from acm.hdu.edu.cn
|
||||
<form method=POST action=problem_add_page_hdu.php>
|
||||
<input name=url class="input input-xxlarge" value="https://acm.hdu.edu.cn/showproblem.php?pid=1172" type=text size=100>
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
Copy from acm.zju.edu.cn
|
||||
<form method=POST action=problem_add_page_zju.php>
|
||||
<input name=url type=text size=100>
|
||||
<input type=submit>
|
||||
</form>
|
||||
</li>
|
||||
|
||||
</ol>
|
||||
71
web/admin/problem_del.php
Normal file
71
web/admin/problem_del.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
require_once("admin-header.php");
|
||||
ini_set("display_errors","On");
|
||||
require_once("../include/check_get_key.php");
|
||||
$pid=intval($_GET['id']);
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$pid]) )){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
function recursiveDelete($dir) {
|
||||
if (is_dir($dir)) {
|
||||
$files = scandir($dir);
|
||||
foreach ($files as $file) {
|
||||
if ($file != "." && $file != "..") {
|
||||
$path = $dir . DIRECTORY_SEPARATOR . $file;
|
||||
if (is_dir($path)) {
|
||||
recursiveDelete($path);
|
||||
} else {
|
||||
unlink($path);
|
||||
}
|
||||
}
|
||||
}
|
||||
rmdir($dir);
|
||||
}
|
||||
}
|
||||
|
||||
// 使用示例
|
||||
$id=intval($_GET['id']);
|
||||
if($id>0&&strlen($OJ_DATA)>8){
|
||||
$basedir = "$OJ_DATA/$id";
|
||||
if(strlen($basedir)>16&&$id>0){
|
||||
//system("rm -rf $basedir");
|
||||
recursiveDelete($basedir);
|
||||
}
|
||||
$sql="delete FROM `problem` WHERE `problem_id`=?";
|
||||
pdo_query($sql,$id) ;
|
||||
$sql = "delete from `privilege` where `rightstr`=? ";
|
||||
pdo_query($sql, "p$id");
|
||||
$sql = "update solution set problem_id=0 where `problem_id`=? ";
|
||||
pdo_query($sql, $id);
|
||||
|
||||
$sql="select max(problem_id) FROM `problem`" ;
|
||||
$result=pdo_query($sql);
|
||||
$row=$result[0];
|
||||
$max_id=$row[0];
|
||||
$max_id++;
|
||||
if($max_id<1000)$max_id=1000;
|
||||
|
||||
$sql="ALTER TABLE problem AUTO_INCREMENT = $max_id";
|
||||
pdo_query($sql);
|
||||
?>
|
||||
<script language=javascript>
|
||||
history.go(-1);
|
||||
</script>
|
||||
<?php
|
||||
}else{
|
||||
|
||||
|
||||
?>
|
||||
<script language=javascript>
|
||||
alert("Nees enable system() in php.ini");
|
||||
history.go(-1);
|
||||
</script>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
58
web/admin/problem_df_change.php
Normal file
58
web/admin/problem_df_change.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
require_once("admin-header.php");
|
||||
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if($_SERVER['REQUEST_METHOD']=="POST"){
|
||||
//require_once("../include/check_post_key.php");
|
||||
}else{
|
||||
require_once("../include/check_get_key.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
$plist = "";
|
||||
if(isset($_POST['pid'])&&!empty($_POST['pid'])) {
|
||||
sort($_POST['pid']);
|
||||
foreach($_POST['pid'] as $i){
|
||||
if($plist)
|
||||
$plist.=','.intval($i);
|
||||
else
|
||||
$plist = $i;
|
||||
}
|
||||
}
|
||||
|
||||
//echo "===".$plist;
|
||||
$plist = trim($_POST['hlist']);
|
||||
$pieces = explode(",",$plist );
|
||||
$pieces = array_unique($pieces);
|
||||
if($pieces[0]=="")unset($pieces[0]);
|
||||
$plist=implode(",",$pieces);
|
||||
|
||||
if(isset($_POST['enable'])&&$plist){
|
||||
$sql = "UPDATE `problem` SET defunct='N' WHERE `problem_id` IN ($plist)";
|
||||
pdo_query($sql);
|
||||
}else if(isset($_POST['disable'])&&$plist){
|
||||
$sql = "UPDATE `problem` SET defunct='Y' WHERE `problem_id` IN ($plist)";
|
||||
pdo_query($sql);
|
||||
}else{
|
||||
$id = intval($_GET['id']);
|
||||
$sql = "SELECT `defunct` FROM `problem` WHERE `problem_id`=?";
|
||||
$result = pdo_query($sql,$id);
|
||||
|
||||
$row = $result[0];
|
||||
$defunct = $row[0];
|
||||
echo $defunct;
|
||||
|
||||
if($defunct=='Y') $sql = "UPDATE `problem` SET `defunct`='N' WHERE `problem_id`=?";
|
||||
else $sql = "UPDATE `problem` SET `defunct`='Y' WHERE `problem_id`=?";
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$id]) ){
|
||||
pdo_query($sql,$id) ;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<script language=javascript>history.go(-1);</script>
|
||||
282
web/admin/problem_edit.php
Normal file
282
web/admin/problem_edit.php
Normal file
@@ -0,0 +1,282 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("admin-header.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Edit Problem</title>
|
||||
</head>
|
||||
<hr>
|
||||
|
||||
<?php
|
||||
echo "<center><h3>"."Edit-".$MSG_PROBLEM."</h3></center>";
|
||||
include_once("kindeditor.php") ;
|
||||
?>
|
||||
|
||||
|
||||
<body leftmargin="30" >
|
||||
<div id="main" class="container">
|
||||
<?php
|
||||
if (isset($_GET['id'])) {
|
||||
;//require_once("../include/check_get_key.php");
|
||||
$pid=intval($_GET['id']);
|
||||
if(! (isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$pid])) ){
|
||||
echo "No Privilege.";
|
||||
exit(0);
|
||||
}
|
||||
?>
|
||||
|
||||
<form method=POST action=problem_edit.php>
|
||||
<?php
|
||||
$sql = "SELECT * FROM `problem` WHERE `problem_id`=?";
|
||||
$result = pdo_query($sql,intval($_GET['id']));
|
||||
$row = $result[0];
|
||||
?>
|
||||
|
||||
<input type=hidden name=problem_id value='<?php echo $row['problem_id']?>'>
|
||||
<p align=left>
|
||||
<center>
|
||||
<h3>
|
||||
<?php echo $row['problem_id']?>: <input class="input input-xxlarge" style='width:90%' type=text name=title value='<?php echo htmlentities($row['title'],ENT_QUOTES,"UTF-8")?>'>
|
||||
</h3>
|
||||
</center>
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo $MSG_Time_Limit?>
|
||||
<input class="input input-mini" type=number min="0.001" max="300" step="0.001" name=time_limit size=20 value="<?php echo $row['time_limit']?>"> sec
|
||||
<?php echo $MSG_Memory_Limit?>
|
||||
<input class="input input-mini" type=number min="1" max="1024" step="1" name=memory_limit size=20 value="<?php echo $row['memory_limit']?>"> MiB
|
||||
</p>
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Description."</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=description cols=80><?php echo htmlentities($row['description'],ENT_QUOTES,"UTF-8")?></textarea><br>
|
||||
</p>
|
||||
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Input."</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=input cols=80><?php echo htmlentities($row['input'],ENT_QUOTES,"UTF-8")?></textarea><br>
|
||||
</p>
|
||||
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Output."</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=output cols=80><?php echo htmlentities($row['output'],ENT_QUOTES,"UTF-8")?></textarea><br>
|
||||
</p>
|
||||
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Sample_Input."</h4>"?>
|
||||
<textarea class="input input-large" style="width:100%;" rows=13 name=sample_input><?php echo htmlentities($row['sample_input'],ENT_QUOTES,"UTF-8")?></textarea><br><br>
|
||||
</p>
|
||||
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_Sample_Output."</h4>"?>
|
||||
<textarea class="input input-large" style="width:100%;" rows=13 name=sample_output><?php echo htmlentities($row['sample_output'],ENT_QUOTES,"UTF-8")?></textarea><br><br>
|
||||
</p>
|
||||
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_HINT."</h4>"?>
|
||||
<textarea class="kindeditor" rows=13 name=hint cols=80><?php echo htmlentities($row['hint'],ENT_QUOTES,"UTF-8")?></textarea><br>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<?php echo "<h4>".$MSG_SPJ."</h4>"?>
|
||||
<?php echo "(".$MSG_HELP_SPJ.")"?><br>
|
||||
<input type=radio name=spj value='0' <?php echo $row['spj']=="0"?"checked":""?> title='Normal Judger'><?php echo $MSG_NJ?><br>
|
||||
<input type=radio name=spj value='1' <?php echo $row['spj']=="1"?"checked":""?> title='Special Judger'><?php echo $MSG_SPJ?><br>
|
||||
<input type=radio name=spj value='2' <?php echo $row['spj']=="2"?"checked":""?> title='Raw Text Judger' ><?php echo $MSG_RTJ?><br>
|
||||
</p>
|
||||
|
||||
<p align=left>
|
||||
<?php echo "<h4>".$MSG_SOURCE."</h4>"?>
|
||||
<textarea name=source style="width:100%;" rows=1><?php echo htmlentities($row['source'],ENT_QUOTES,"UTF-8")?></textarea><br>
|
||||
|
||||
<?php echo "<h4>".$MSG_REMOTE_OJ."</h4>"?>
|
||||
<input name=remote_oj value='<?php echo htmlentities($row['remote_oj'],ENT_QUOTES,"UTF-8")?>' placeholder='<?php echo $MSG_HELP_LOCAL_EMPTY ?>' >
|
||||
<input name=remote_id value='<?php echo htmlentities($row['remote_id'],ENT_QUOTES,"UTF-8")?>' placeholder='<?php echo $MSG_HELP_LOCAL_EMPTY ?>' ><br>
|
||||
</p>
|
||||
|
||||
<div align=center>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value='<?php echo $MSG_SAVE?>' name=submit>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<script src="<?php echo $OJ_CDN_URL."/template/bs3/"?>marked.min.js"></script>
|
||||
<script>
|
||||
function transform(){
|
||||
let height=document.body.clientHeight;
|
||||
let width=parseInt(document.body.clientWidth*0.6);
|
||||
let width2=parseInt(document.body.clientWidth*0.4);
|
||||
if(width<500) width2=300;
|
||||
let submitURL="../problem.php?id=<?php echo $pid ?>";
|
||||
console.log(width);
|
||||
let main=$("#main");
|
||||
let problem=main.html();
|
||||
main.removeClass("container");
|
||||
main.css("width",width2);
|
||||
main.css("margin-left","10px");
|
||||
main.parent().append("<div id='preview' class='container' style='opacity:0.95;position:fixed;z-index:1000;top:49px;right:-"+width2+"px'></div>");
|
||||
$("#preview").html("<iframe id='previewFrame' src='"+submitURL+"&spa' width='"+width+"px' height='"+height+"px' ></iframe>");
|
||||
$("#submit").remove();
|
||||
setTimeout('hide()',1500);
|
||||
$("input").keyup(sync);
|
||||
$("textarea").keyup(sync);
|
||||
}
|
||||
function hide(){
|
||||
let preview=$("#previewFrame").contents();
|
||||
preview.find(".ui.buttons").hide();
|
||||
preview.find("span.ui.label").eq(2).hide();
|
||||
preview.find("span.ui.label").eq(3).hide();
|
||||
preview.find("span.ui.label").eq(4).hide();
|
||||
preview.find("span.ui.label").eq(5).hide();
|
||||
preview.find("#show_tag_div").parent().hide();
|
||||
sync();
|
||||
// preview.find("h1:first").parent().parent().hide();
|
||||
}
|
||||
function sync(){
|
||||
console.log("sync...");
|
||||
let preview=$("#previewFrame").contents();
|
||||
let title=$("input[name=title]").val();
|
||||
preview.find("h1:first").html(title);
|
||||
let time=$("input[name=time_limit]").val();
|
||||
preview.find("span.ui.label").eq(0).html("<?php echo $MSG_Time_Limit ?>:"+time);
|
||||
let memory=$("input[name=memory_limit]").val();
|
||||
preview.find("span.ui.label").eq(1).html("<?php echo $MSG_Memory_Limit ?>:"+memory);
|
||||
|
||||
let description=$("textarea").eq(1).val();
|
||||
preview.find("#description").html(description);
|
||||
preview.find("#description .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
|
||||
let input=$("textarea").eq(3).val();
|
||||
preview.find("#input").html(input);
|
||||
preview.find("#input .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
let output=$("textarea").eq(5).val();
|
||||
preview.find("#output").html(output);
|
||||
preview.find("#output .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
|
||||
let sinput=$("textarea").eq(6).val();
|
||||
preview.find("#sinput").html(sinput);
|
||||
let soutput=$("textarea").eq(7).val();
|
||||
preview.find("#soutput").html(soutput);
|
||||
let hint=$("textarea").eq(9).val();
|
||||
preview.find("#hint").html(hint);
|
||||
preview.find("#hint .md").each(function(){
|
||||
$(this).html(marked.parse($(this).html()));
|
||||
});
|
||||
if($("#previewFrame")[0] != undefined) $("#previewFrame")[0].contentWindow.MathJax.typeset();
|
||||
}
|
||||
$(document).ready(function(){
|
||||
<?php if (!(isset($OJ_OLD_FASHINED) && $OJ_OLD_FASHINED ) ) echo " transform();" ?>
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
require_once("../include/check_post_key.php");
|
||||
$id = intval($_POST['problem_id']);
|
||||
if(! (isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$id])) ){
|
||||
echo "No Privilege.";
|
||||
exit(0) ;
|
||||
}
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'."p$id"]) || isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor']) )) exit();
|
||||
|
||||
$title = $_POST['title'];
|
||||
$title = str_replace(",", ",", $title);
|
||||
|
||||
$time_limit = $_POST['time_limit'];
|
||||
|
||||
$memory_limit = $_POST['memory_limit'];
|
||||
|
||||
$description = $_POST['description'];
|
||||
// $description = str_replace("<p>", "", $description);
|
||||
// $description = str_replace("</p>", "<br />", $description);
|
||||
$description = str_replace(",", ",", $description);
|
||||
|
||||
$input = $_POST['input'];
|
||||
// $input = str_replace("<p>", "", $input);
|
||||
// $input = str_replace("</p>", "<br />", $input);
|
||||
$input = str_replace(",", ",", $input);
|
||||
|
||||
$output = $_POST['output'];
|
||||
// $output = str_replace("<p>", "", $output);
|
||||
// $output = str_replace("</p>", "<br />", $output);
|
||||
$output = str_replace(",", ",", $output);
|
||||
|
||||
$sample_input = $_POST['sample_input'];
|
||||
$sample_output = $_POST['sample_output'];
|
||||
//if ($sample_input=="") $sample_input="\n";
|
||||
//if ($sample_output=="") $sample_output="\n";
|
||||
|
||||
$hint = $_POST['hint'];
|
||||
// $hint = str_replace("<p>", "", $hint);
|
||||
// $hint = str_replace("</p>", "<br />", $hint);
|
||||
$hint = str_replace(",", ",", $hint);
|
||||
|
||||
$source = $_POST['source'];
|
||||
$remote_oj= $_POST['remote_oj'];
|
||||
$remote_id = $_POST['remote_id'];
|
||||
$spj = $_POST['spj'];
|
||||
|
||||
if (false) {
|
||||
$title = stripslashes($title);
|
||||
$time_limit = stripslashes($time_limit);
|
||||
$memory_limit = stripslashes($memory_limit);
|
||||
$description = stripslashes($description);
|
||||
$input = stripslashes($input);
|
||||
$output = stripslashes($output);
|
||||
$sample_input = stripslashes($sample_input);
|
||||
$sample_output = stripslashes($sample_output);
|
||||
//$test_input = stripslashes($test_input);
|
||||
//$test_output = stripslashes($test_output);
|
||||
$hint = stripslashes($hint);
|
||||
$source = stripslashes($source);
|
||||
$spj = stripslashes($spj);
|
||||
}
|
||||
|
||||
$title = ($title);
|
||||
$description = ($description);
|
||||
$input = ($input);
|
||||
$output = ($output);
|
||||
$hint = ($hint);
|
||||
$basedir = $OJ_DATA."/$id";
|
||||
|
||||
echo "Problem Updated!<br>";
|
||||
|
||||
if ($sample_input && file_exists($basedir."/sample.in")) {
|
||||
//mkdir($basedir);
|
||||
$fp = fopen($basedir."/sample.in","w");
|
||||
fputs($fp,preg_replace("(\r\n)","\n",$sample_input));
|
||||
fclose($fp);
|
||||
|
||||
$fp = fopen($basedir."/sample.out","w");
|
||||
fputs($fp,preg_replace("(\r\n)","\n",$sample_output));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
$spj = intval($spj);
|
||||
|
||||
$sql = "UPDATE `problem` SET `title`=?,`time_limit`=?,`memory_limit`=?, `description`=?,`input`=?,`output`=?,`sample_input`=?,`sample_output`=?,`hint`=?,`source`=?,`spj`=?,remote_oj=?,remote_id=?,`in_date`=NOW() WHERE `problem_id`=?";
|
||||
|
||||
@pdo_query($sql,$title,$time_limit,$memory_limit,$description,$input,$output,$sample_input,$sample_output,$hint,$source,$spj,$remote_oj,$remote_id,$id);
|
||||
|
||||
echo "Edit OK!<br>";
|
||||
echo "<a href='../problem.php?id=$id'>See The Problem!</a>";
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
65
web/admin/problem_export.php
Normal file
65
web/admin/problem_export.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "<center><h3>".$MSG_PROBLEM."-".$MSG_EXPORT."</h3></center>";
|
||||
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Problem Export</title>
|
||||
</head>
|
||||
<hr>
|
||||
|
||||
<body leftmargin="30" >
|
||||
<div class="container">
|
||||
<br><br>
|
||||
- Export Problem XML<br><br>
|
||||
<form class="form-inline" action="problem_export_xml.php" method=post>
|
||||
<div class="form-group">
|
||||
<label>1) Continuous Problem IDs:</label>
|
||||
<input class="form-control" name="start" type="text" placeholder="1001">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label> ~ </label>
|
||||
<input class="form-control" name="end" type="text" placeholder="1009">
|
||||
</div>
|
||||
<br><br>
|
||||
<div class="form-group">
|
||||
<label>2) Separate Problem IDs:</label>
|
||||
<input class="form-control" name="in" type="text" placeholder="1001,1003,1005, ... ">
|
||||
</div>
|
||||
<br><br>
|
||||
|
||||
<center>
|
||||
<div class='form-group'>
|
||||
<input type="hidden" name="do" value="do">
|
||||
<!-- <input type="submit" name="submit" value="Export to XML Script"> -->
|
||||
<button class='btn btn-default btn-sm' type=submit>Download to XML File</button>
|
||||
</div>
|
||||
</center>
|
||||
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
|
||||
<br><br>
|
||||
<!--
|
||||
* from-to will working if empty IN <br>
|
||||
* if using IN,from-to will not working.<br>
|
||||
* IN can go with "," seperated problem_ids like [1000,1020]
|
||||
-->
|
||||
- Continuous Problem IDs fields will be applied when Seperate Problem IDs fields was empty.<br>
|
||||
- Seperate Problem IDs fields will be applied when Continuous Problem IDs fields was empty.
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
363
web/admin/problem_export_xml.php
Normal file
363
web/admin/problem_export_xml.php
Normal file
@@ -0,0 +1,363 @@
|
||||
<?php
|
||||
@session_start ();
|
||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
|
||||
require_once ("../include/db_info.inc.php");
|
||||
|
||||
if (!isset($OJ_LANG)) {
|
||||
$OJ_LANG = "en";
|
||||
}
|
||||
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
require_once("../include/const.inc.php");
|
||||
|
||||
function fixcdata($content) {
|
||||
$content = str_replace("\x1a","",$content); // remove some strange \x1a [SUB] char from datafile
|
||||
return str_replace("]]>","]]]]><![CDATA[>",$content);
|
||||
}
|
||||
|
||||
function getTestFileIn($pid, $testfile,$OJ_DATA) {
|
||||
if ($testfile != "")
|
||||
return file_get_contents("$OJ_DATA/$pid/".$testfile.".in");
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function getTestFileOut($pid, $testfile,$OJ_DATA) {
|
||||
if ($testfile != "")
|
||||
return file_get_contents();
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
function printTestCases($pid,$OJ_DATA) {
|
||||
if (strstr($OJ_DATA,"saestor:")) {
|
||||
// echo "<debug>$pid</debug>";
|
||||
$store = new SaeStorage();
|
||||
$ret = $store->getList("data", "$pid",100,0 );
|
||||
|
||||
foreach ($ret as $file) {
|
||||
//echo "<debug>$file</debug>";
|
||||
|
||||
if (!strstr($file,"sae-dir-tag")) {
|
||||
$pinfo = pathinfo($file);
|
||||
|
||||
if (isset($pinfo['extension']) &&$pinfo['extension']=="in" && $pinfo['basename']!="sample.in") {
|
||||
$f = basename($pinfo['basename'],".".$pinfo ['extension']);
|
||||
|
||||
$outfile = "$pid/".$f.".out";
|
||||
$infile = "$pid/".$f.".in";
|
||||
|
||||
if ($store->fileExists("data",$infile)) {
|
||||
echo "<test_input><![CDATA[".fixcdata($store->read("data",$infile))."]]></test_input>\n";
|
||||
}
|
||||
|
||||
if ($store->fileExists("data",$outfile)) {
|
||||
echo "<test_output><![CDATA[".fixcdata($store->read("data",$outfile))."]]></test_output>\n";
|
||||
}
|
||||
//break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$ret = "";
|
||||
if(!is_dir("$OJ_DATA/$pid/")) return "";
|
||||
//$pdir = opendir("$OJ_DATA/$pid/");
|
||||
$files = scandir("$OJ_DATA/$pid/"); //sorting file names by ascending order with default scandir function
|
||||
|
||||
//while ($file=readdir($pdir)) {
|
||||
foreach ($files as $file) {
|
||||
$pinfo = pathinfo($file);
|
||||
|
||||
if (isset($pinfo['extension']) && $pinfo['extension']=="in" && $pinfo['basename']!="sample.in") {
|
||||
$ret = basename($pinfo['basename'], ".".$pinfo['extension']);
|
||||
|
||||
$outfile = "$OJ_DATA/$pid/".$ret.".out";
|
||||
$infile = "$OJ_DATA/$pid/".$ret.".in";
|
||||
|
||||
if (file_exists($infile)) {
|
||||
echo "<test_input name=\"".$ret."\"><![CDATA[".fixcdata(file_get_contents($infile))."]]></test_input>\n";
|
||||
}
|
||||
|
||||
if (file_exists($outfile)) {
|
||||
echo "<test_output name=\"".$ret."\"><![CDATA[".fixcdata(file_get_contents($outfile))."]]></test_output>\n";
|
||||
}
|
||||
//break;
|
||||
}
|
||||
}
|
||||
|
||||
//closedir($pdir);
|
||||
return $ret;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class Solution {
|
||||
var $language = "";
|
||||
var $source_code = "";
|
||||
}
|
||||
|
||||
function getSolution($pid,$lang) {
|
||||
$ret = new Solution();
|
||||
|
||||
$language_name = $GLOBALS['language_name'];
|
||||
|
||||
$sql = "SELECT `solution_id`,`language` FROM solution WHERE problem_id=? AND result=4 AND language=? LIMIT 1";
|
||||
//echo $sql;
|
||||
|
||||
$result = pdo_query($sql,$pid,$lang);
|
||||
|
||||
if ($result && $row=$result[0]) {
|
||||
$solution_id = $row[0];
|
||||
$ret->language = $language_name[$row[1]];
|
||||
$sql = "SELECT source FROM source_code WHERE solution_id=?";
|
||||
$result = pdo_query( $sql,$solution_id ) ;
|
||||
|
||||
if ($row = $result[0]){
|
||||
$ret->source_code = $row['source'];
|
||||
}
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function fixurl($img_url) {
|
||||
if(substr($img_url,0,4)=="data") return $img_url;
|
||||
$img_url = html_entity_decode($img_url,ENT_QUOTES,"UTF-8");
|
||||
|
||||
if (substr($img_url,0,4)!="http") {
|
||||
if (substr($img_url,0,1)=="/") {
|
||||
$ret = 'http://'.$_SERVER['HTTP_HOST'].':'.$_SERVER["SERVER_PORT"].$img_url;
|
||||
}
|
||||
else {
|
||||
$path = dirname($_SERVER['PHP_SELF']);
|
||||
$ret = 'http://'.$_SERVER['HTTP_HOST'].':'.$_SERVER["SERVER_PORT"].$path."/../".$img_url;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
$ret = $img_url;
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function image_base64_encode($img_url) {
|
||||
$img_url = fixurl($img_url);
|
||||
echo $img_url;
|
||||
if (substr($img_url,0,4)!="http")
|
||||
return false;
|
||||
$context = stream_context_create(array('http' => array('timeout' => 5))); // prevent stuck on export image failed
|
||||
$handle = @fopen($img_url, "rb",false,$context);
|
||||
if ($handle) {
|
||||
$contents = stream_get_contents($handle);
|
||||
$encoded_img = base64_encode($contents);
|
||||
fclose($handle);
|
||||
return $encoded_img;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
function getImages($content) {
|
||||
preg_match_all("<[iI][mM][gG][^<>]+[sS][rR][cC]=\"?([^ \"\>]+)/?>",$content,$images);
|
||||
|
||||
$pattern = '/!\[img\]\(([^\)]+)\)/i';
|
||||
preg_match_all($pattern, $content, $mdImages);
|
||||
|
||||
return array_merge($images[1],$mdImages[1]);
|
||||
}
|
||||
|
||||
function fixImageURL(&$html,&$did) {
|
||||
$images = getImages($html);
|
||||
$imgs = array_unique($images);
|
||||
|
||||
foreach ($imgs as $img) {
|
||||
if(substr($img,0,4)=="data") continue; // skip image from paste clips
|
||||
$html = str_replace($img,fixurl($img),$html);
|
||||
// print_r($did);
|
||||
|
||||
if (!in_array($img,$did)) {
|
||||
$base64 = image_base64_encode($img);
|
||||
if ($base64) {
|
||||
echo "<img><src><![CDATA[";
|
||||
echo fixurl($img);
|
||||
echo "]]></src><base64><![CDATA[";
|
||||
echo $base64;
|
||||
echo "]]></base64></img>";
|
||||
}
|
||||
array_push($did,$img);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) {
|
||||
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">";
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit ( 1 );
|
||||
}
|
||||
|
||||
|
||||
if (isset($_POST['do']) || isset($_GET['cid'])) {
|
||||
if (isset($_POST['in']) && strlen($_POST['in'])>0) {
|
||||
require_once("../include/check_post_key.php");
|
||||
$in = $_POST['in'];
|
||||
$ins = explode(",",$in);
|
||||
$in = "";
|
||||
|
||||
foreach ($ins as $pid) {
|
||||
$pid = intval($pid);
|
||||
|
||||
if ($in)
|
||||
$in .= ",";
|
||||
|
||||
$in .= $pid;
|
||||
}
|
||||
|
||||
$sql = "SELECT * FROM problem WHERE problem_id IN($in)";
|
||||
$result = pdo_query($sql);
|
||||
|
||||
$filename = "-$in";
|
||||
}
|
||||
else if (isset($_GET['cid'])) {
|
||||
require_once("../include/check_get_key.php");
|
||||
|
||||
$cid = intval($_GET['cid']);
|
||||
$sql = "SELECT title FROM contest WHERE contest_id=?";
|
||||
$result = pdo_query($sql,$cid);
|
||||
|
||||
$row = $result[0];
|
||||
$filename = '-'.$row['title'];
|
||||
|
||||
$sql = "SELECT * FROM problem p inner join (select problem_id id,num from contest_problem where contest_id=?) cp on p.problem_id=cp.id order by cp.num ";
|
||||
$result = pdo_query($sql,$cid);
|
||||
}
|
||||
else {
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
$start = intval($_POST['start']);
|
||||
$end = intval($_POST['end']);
|
||||
|
||||
$sql = "SELECT * FROM problem WHERE problem_id>=? AND problem_id<=? ORDER BY problem_id ";
|
||||
$result = pdo_query($sql,$start,$end);
|
||||
|
||||
$filename = "-$start-$end";
|
||||
}
|
||||
|
||||
//echo $sql;
|
||||
|
||||
if (isset($_POST['submit']) && $_POST['submit']== "Export")
|
||||
header('Content-Type:text/xml');
|
||||
else {
|
||||
header("content-type:application/file");
|
||||
header("content-disposition:attachment;filename=\"fps-".$_SESSION[$OJ_NAME.'_'.'user_id'].$filename.".xml\"");
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE fps PUBLIC
|
||||
"-//freeproblemset//An opensource XML standard for Algorithm Contest Problem Set//EN"
|
||||
"http://hustoj.com/fps.current.dtd" >
|
||||
|
||||
<fps version="1.5" url="https://github.com/zhblue/freeproblemset/">
|
||||
<generator name="HUSTOJ" url="https://github.com/zhblue/hustoj/" />
|
||||
<?php
|
||||
foreach ($result as $row) {
|
||||
?>
|
||||
|
||||
<item>
|
||||
<title><![CDATA[<?php echo $row['title']?>]]></title>
|
||||
<url><![CDATA[<?php echo 'http://'.$_SERVER['HTTP_HOST'].dirname(dirname($_SERVER['REQUEST_URI']))."problem.php?id=".$row['problem_id']?>]]></url>
|
||||
<time_limit unit="s"><![CDATA[<?php // 兼容老版本和QDUOJ之类的其他OJ
|
||||
$time=$row['time_limit'];
|
||||
if (intval($time)==$time)
|
||||
echo intval($time);
|
||||
else
|
||||
echo $time;
|
||||
?>]]></time_limit>
|
||||
|
||||
<memory_limit unit="mb"><![CDATA[<?php echo $row['memory_limit']?>]]></memory_limit>
|
||||
|
||||
<?php
|
||||
$did = array();
|
||||
fixImageURL($row['description'],$did);
|
||||
fixImageURL($row['input'],$did);
|
||||
fixImageURL($row['output'],$did);
|
||||
fixImageURL($row['hint'],$did);
|
||||
?>
|
||||
|
||||
<description><![CDATA[<?php echo $row['description']?>]]></description>
|
||||
<input><![CDATA[<?php echo $row['input']?>]]></input>
|
||||
<output><![CDATA[<?php echo $row['output']?>]]></output>
|
||||
<sample_input><![CDATA[<?php echo $row['sample_input']?>]]></sample_input>
|
||||
<sample_output><![CDATA[<?php echo $row['sample_output']?>]]></sample_output>
|
||||
<?php printTestCases($row['problem_id'],$OJ_DATA)?>
|
||||
<hint><![CDATA[<?php echo $row['hint']?>]]></hint>
|
||||
<source><![CDATA[<?php echo fixcdata($row['source'])?>]]></source>
|
||||
<remote_oj><![CDATA[<?php echo fixcdata($row['remote_oj'])?>]]></remote_oj>
|
||||
<remote_id><![CDATA[<?php echo fixcdata($row['remote_id'])?>]]></remote_id>
|
||||
|
||||
<?php
|
||||
$pid = $row['problem_id'];
|
||||
for ($lang=0; $lang<count($language_ext); $lang++) {
|
||||
$solution = getSolution($pid,$lang);
|
||||
|
||||
if ($solution->language)
|
||||
{?>
|
||||
<solution language="<?php echo $solution->language?>"><![CDATA[<?php echo fixcdata($solution->source_code)?>]]></solution>
|
||||
<?php
|
||||
}
|
||||
|
||||
$pta = array("prepend","template","append");
|
||||
|
||||
foreach ($pta as $pta_file) {
|
||||
$append_file = "$OJ_DATA/$pid/$pta_file.".$language_ext[$lang];
|
||||
//echo "<filename value=\"$lang $append_file $language_ext[$lang]\"/>";
|
||||
|
||||
if (file_exists($append_file)) { ?>
|
||||
<<?php echo $pta_file?> language="<?php echo $language_name[$lang]?>"><![CDATA[<?php echo fixcdata(file_get_contents($append_file))?>]]></<?php echo $pta_file?>>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
if ($row['spj'] == 1) {
|
||||
$filec = "$OJ_DATA/".$row['problem_id']."/spj.c";
|
||||
$filecc = "$OJ_DATA/".$row['problem_id']."/spj.cc";
|
||||
|
||||
if (file_exists($filec)) {
|
||||
echo "<spj language=\"C\"><![CDATA[";
|
||||
echo fixcdata(file_get_contents($filec));
|
||||
echo "]]></spj>";
|
||||
}
|
||||
else if (file_exists($filecc)) {
|
||||
echo "<spj language=\"C++\"><![CDATA[";
|
||||
echo fixcdata(file_get_contents ($filecc ));
|
||||
echo "]]></spj>";
|
||||
}
|
||||
$filec = "$OJ_DATA/".$row['problem_id']."/tpj.c";
|
||||
$filecc = "$OJ_DATA/".$row['problem_id']."/tpj.cc";
|
||||
|
||||
if (file_exists($filec)) {
|
||||
echo "<tpj language=\"C\"><![CDATA[";
|
||||
echo fixcdata(file_get_contents($filec));
|
||||
echo "]]></tpj>";
|
||||
}
|
||||
else if (file_exists($filecc)) {
|
||||
echo "<tpj language=\"C++\"><![CDATA[";
|
||||
echo fixcdata(file_get_contents ($filecc ));
|
||||
echo "]]></tpj>";
|
||||
}
|
||||
}else if ($row['spj'] == 2){
|
||||
echo "<spj language=\"Text\">text judge</spj>";
|
||||
}
|
||||
?>
|
||||
</item>
|
||||
|
||||
<?php }
|
||||
echo "</fps>";
|
||||
}
|
||||
?>
|
||||
153
web/admin/problem_import.php
Normal file
153
web/admin/problem_import.php
Normal file
@@ -0,0 +1,153 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']) || isset($_SESSION[$OJ_NAME.'_problem_importer']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
function writable($path) {
|
||||
$ret = false;
|
||||
$fp = fopen($path."/testifwritable.tst","w");
|
||||
$ret = !($fp===false);
|
||||
|
||||
if($fp!=false) {
|
||||
fclose($fp);
|
||||
unlink($path."/testifwritable.tst");
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
|
||||
$maxfile = min(ini_get("upload_max_filesize"), ini_get("post_max_size"));
|
||||
|
||||
echo "<center><h3>".$MSG_PROBLEM."-".$MSG_IMPORT."</h3></center>";
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Pragma" content="no-cache">
|
||||
<meta http-equiv="Cache-Control" content="no-cache">
|
||||
<meta http-equiv="Content-Language" content="zh-cn">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<title>Problem Import</title>
|
||||
</head>
|
||||
<body leftmargin="30">
|
||||
<div class="container">
|
||||
<?php
|
||||
$show_form = true;
|
||||
|
||||
if (!isset($OJ_SAE) || !$OJ_SAE) {
|
||||
if (!writable($OJ_DATA)) {
|
||||
echo "- You need to add $OJ_DATA into your open_basedir setting of php.ini,<br>
|
||||
or you need to execute:<br>
|
||||
<b>chmod 775 -R $OJ_DATA && chgrp -R ".get_current_user()." $OJ_DATA</b><br>
|
||||
you can't use import function at this time.<br>";
|
||||
|
||||
if($OJ_LANG == "cn")
|
||||
echo "权限异常,请先去执行sudo chmod 775 -R $OJ_DATA <br> 和 sudo chgrp -R ".get_current_user()." $OJ_DATA <br>";
|
||||
|
||||
$show_form = false;
|
||||
if(get_current_user()=="www")
|
||||
echo "如果你是宝塔用户,请关闭宝塔的跨站防护功能,如果你是lnmp或者centos用户,请禁用open_basedir。如果坚持使用,请将/home/jduge/data目录加进去。";
|
||||
}
|
||||
|
||||
|
||||
if (!file_exists("../upload"))
|
||||
mkdir("../upload");
|
||||
|
||||
if (!writable("../upload")) {
|
||||
echo "../upload is not writable, <b>chmod 770</b> to it.<br>";
|
||||
$show_form = false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($show_form) { ?>
|
||||
- Import Problem <b>FPS(.xml)/ZIP(.xml inside) 导入xml或zip压缩的xml文件,支持一个或多个,不支持子目录。</b> <br><br>
|
||||
<form class='form-inline' action='problem_import_xml.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-success btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
<hr>
|
||||
- QDUOJ - json - zip<br>应该是真的QDUOJ,未严格测试,感谢[温十六中]吴晓阳提供例子文件<br>
|
||||
<form class='form-inline' action='problem_import_qduoj.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-info btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form> <hr>
|
||||
- unkownOJ - json - zip<br>曾经以为是QDUOJ,但似乎不是,谁知道请告诉我<br>
|
||||
<form class='form-inline' action='problem_import_unkownoj.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-primary btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form> <hr>
|
||||
- SYZOJ - zip<br><br>
|
||||
<form class='form-inline' action='problem_import_syzoj.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-warning btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form> <hr>
|
||||
- HydroOJ - zip<br><br>
|
||||
<form class='form-inline' action='problem_import_hydro.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-danger btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form> <hr>
|
||||
- HOJ - zip<br><br>
|
||||
<form class='form-inline' action='problem_import_hoj.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-info btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
- TYVJ - zip<br><br>
|
||||
<form class='form-inline' action='problem_import_tyvj.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-primary btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
- Markdown - zip<br>zip压缩的.md文件,首行为标题<br>
|
||||
<form class='form-inline' action='problem_import_md.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name=fps>
|
||||
<button class='btn btn-warning btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<br><br>
|
||||
|
||||
<?php if ($OJ_LANG == "cn") { ?>
|
||||
免费题目<a href="https://github.com/zhblue/freeproblemset/tree/master/fps-examples" target="_blank">下载</a><br>
|
||||
更多题目请到 <a href="http://tk.hustoj.com/problemset.php?search=free" target="_blank">TK 题库免费专区</a>。
|
||||
<?php } ?>
|
||||
|
||||
<br><br>
|
||||
|
||||
- Import FPS data, please make sure you file is smaller than [<?php echo $maxfile?>] or set upload_max_filesize and post_max_size in <span style='color:blue'>php.ini</span><br>
|
||||
- If you fail on import big files[10M+],try enlarge your [memory_limit] setting in <span style='color:blue'>php.ini</span><br>
|
||||
- To find the php configuration file, use <span style='color:blue'> find /etc -name php.ini </span>
|
||||
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
189
web/admin/problem_import_hoj.php
Normal file
189
web/admin/problem_import_hoj.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
function strip($Node, $TagName) {
|
||||
$len=mb_strlen($TagName);
|
||||
$i=mb_strpos($Node,"<".$TagName.">");
|
||||
$j=mb_strpos($Node,"</".$TagName.">");
|
||||
|
||||
return mb_substr($Node,$i+$len+2,$j-($i+$len+2));
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function import_json($json) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN;
|
||||
$qduoj_problem=json_decode($json)->{'problem'};
|
||||
echo( "<br> ".$qduoj_problem->{'problemId'});
|
||||
echo( $qduoj_problem->{'title'})."<br>";
|
||||
|
||||
$title = $qduoj_problem->{'title'};
|
||||
|
||||
$time_limit = floatval($qduoj_problem->{'timeLimit'});
|
||||
$unit = "ms";
|
||||
//echo $unit;
|
||||
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = floatval($qduoj_problem->{'memoryLimit'});
|
||||
$unit = "M";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = "[md]\n".$qduoj_problem->{'description'}."\n[/md]";
|
||||
$input = "[md]\n".$qduoj_problem->{'input'}."\n[/md]";
|
||||
$output = "[md]\n".$qduoj_problem->{'output'}."\n[/md]";
|
||||
$examples=$qduoj_problem->{'examples'};
|
||||
$sample_input = strip($examples,"input");
|
||||
$sample_output = strip($examples,"output");;
|
||||
echo "sin:".$sample_input."<br>";
|
||||
echo "sout:".$sample_output."<br>";
|
||||
$hint = "[md]\n".$qduoj_problem->{'hint'}."\n[/md]";
|
||||
$source ="";
|
||||
echo json_decode($json)->{'tags'}->{'value'};
|
||||
$spj=0;
|
||||
|
||||
echo "($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj )";
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
return $pid;
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_hoj".time();
|
||||
echo $tempdir ;
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only HOJ exported file is supported";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
//echo "$file_name"."<br>";
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
// import_json($file_content);
|
||||
}else{
|
||||
//echo "$file_name"."<br>";
|
||||
mkdir($tempdir."/".dirname($file_name));
|
||||
file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
$resource = zip_open($tempfile);
|
||||
$cmds=array();
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
$pid=import_json($file_content);
|
||||
// $dir=$tempdir."/".basename($file_name,".json");
|
||||
mkdir("$OJ_DATA/$pid");
|
||||
$data_dir=basename($file_name,".json");
|
||||
array_push ($cmds,"mv $tempdir/$data_dir/* $OJ_DATA/$pid/");
|
||||
array_push ($cmds,"rmdir $tempdir/$data_dir/");
|
||||
$i++;
|
||||
}else{
|
||||
//echo "$file_name"."<br>";
|
||||
mkdir($tempdir."/".dirname($file_name),0755,true);
|
||||
file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
foreach($cmds as $cmd){
|
||||
// echo $cmd."<br>";
|
||||
system($cmd);
|
||||
|
||||
}
|
||||
rmdir ($tempdir);
|
||||
}
|
||||
else {
|
||||
echo ($tempfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
330
web/admin/problem_import_hydro.php
Normal file
330
web/admin/problem_import_hydro.php
Normal file
@@ -0,0 +1,330 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
function replaceLT($string) {
|
||||
// 正则表达式匹配两个美元符号包裹的内容
|
||||
$pattern = '/(\$.*?)(<)(.*?\$)/';
|
||||
// 替换小于号为\lt
|
||||
$replacement = '$1 \\lt $3';
|
||||
|
||||
// 使用preg_replace进行替换
|
||||
$ret= preg_replace($pattern, $replacement, $string);
|
||||
if (strlen($string)==strlen($ret))
|
||||
return $ret;
|
||||
else
|
||||
return preg_replace($pattern, $replacement, $ret); //递归到不再发生变化
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
function startsWith( $haystack, $needle ) {
|
||||
$length = strlen( $needle );
|
||||
return substr( $haystack, 0, $length ) === $needle;
|
||||
}
|
||||
function endsWith( $haystack, $needle ) {
|
||||
$length = strlen( $needle );
|
||||
if( !$length ) {
|
||||
return true;
|
||||
}
|
||||
return substr( $haystack, -$length ) === $needle;
|
||||
}
|
||||
function strip($Node, $TagName) {
|
||||
$len=mb_strlen($TagName);
|
||||
$i=mb_strpos($Node,"<".$TagName.">");
|
||||
$j=mb_strpos($Node,"</".$TagName.">");
|
||||
|
||||
return mb_substr($Node,$i+$len+2,$j-($i+$len+2));
|
||||
}
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function import_dir($json) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN;
|
||||
$qduoj_problem=json_decode($json);
|
||||
echo( $qduoj_problem->{'problem'}->{'title'})."<br>";
|
||||
|
||||
$title = $qduoj_problem->{'problem'}->{'title'};
|
||||
|
||||
$time_limit = floatval($qduoj_problem->{'problem'}->{'timeLimit'});
|
||||
$unit = "ms";
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = floatval($qduoj_problem->{'problem'}->{'memoryLimit'});
|
||||
$unit = "M";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = $qduoj_problem->{'problem'}->{'description'};
|
||||
$input = $qduoj_problem->{'problem'}->{'input'};
|
||||
$output = $qduoj_problem->{'problem'}->{'output'};
|
||||
$sample_input = strip($qduoj_problem->{'problem'}->{'examples'},"input");
|
||||
$sample_output = strip($qduoj_problem->{'problem'}->{'examples'},"output");
|
||||
// echo $sample_input."<br>";
|
||||
// echo $sample_output;
|
||||
$hint = $qduoj_problem->{'problem'}->{'hint'};
|
||||
$source = $qduoj_problem->{'problem'}->{'source'};
|
||||
$spj=0;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
return $pid;
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_hydro".time();
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only HydroOJ exported file is supported<hr>\n";
|
||||
$resource = zip_open($tempfile);
|
||||
$save_path="";
|
||||
$i = 1;
|
||||
$pid=$title=$description=$input=$output=$sample_input=$sample_output=$hint=$source=$spj="";
|
||||
$type="normal";
|
||||
$inserted=array();
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$ymd ="/upload/".$domain."/". date("Ymd");
|
||||
$save_path = $ymd ;
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(basename($file_name)=="problem.yaml"){
|
||||
$hydrop=yaml_parse($file_content);
|
||||
$title=$hydrop['title'];
|
||||
$source=implode(" ",$hydrop['tag']);
|
||||
echo "<hr>".htmlentities($file_name." $title $source");
|
||||
if(!in_array($title,$inserted)){
|
||||
$pid = addproblem($title,1,128, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
mkdir($OJ_DATA."/$pid/");
|
||||
array_push($inserted,$title);
|
||||
}
|
||||
}else if(basename($file_name)=="problem_zh.md"||basename($file_name)=="problem.md"){
|
||||
|
||||
$regex = '/<(?!div)/';
|
||||
// $file_content = preg_replace($regex, '<',$file_content);
|
||||
$regex = '/(?<!div)>\s?/';
|
||||
// $file_content = preg_replace($regex, '>', $file_content);
|
||||
$file_content = replaceLT( $file_content);
|
||||
|
||||
if($type=="normal")$description="<span class=\"md\">".$file_content."</span>";
|
||||
else $description="<span class=\"md auto_select\">".$file_content."</span>";
|
||||
$description=preg_replace('/{{ select\(\d+\) }}/', "", $description);
|
||||
if($save_path){
|
||||
$description=str_replace("file://",$save_path."/",$description);
|
||||
|
||||
// echo htmlentities($description);
|
||||
}
|
||||
|
||||
$spj=0;
|
||||
if($title!="" && (!in_array($title,$inserted)) && !hasProblem($title)){
|
||||
$pid = addproblem($title,1,128, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
echo htmlentities("$description");
|
||||
mkdir($OJ_DATA."/$pid/");
|
||||
array_push($inserted,$title);
|
||||
}else{
|
||||
$sql="update problem set description=? where problem_id=?";
|
||||
pdo_query($sql,$description,$pid);
|
||||
echo "skiped $title";
|
||||
//$pid=0;
|
||||
}
|
||||
echo "PID:<a href='../problem.php?id=$pid' >".htmlentities($title,ENT_QUOTES,"UTF-8")."</a>";
|
||||
}else if(basename($file_name)=="config.yaml"){
|
||||
$hydrop=yaml_parse($file_content);
|
||||
if($hydrop['type']=="objective"){
|
||||
$type="objective";
|
||||
echo $type.":dump answers";
|
||||
$ansi=1;
|
||||
$out="";
|
||||
while($hydrop['answers'][$ansi]!=""){
|
||||
$out.= $ansi." [".$hydrop['answers'][$ansi][1]."] ";
|
||||
$out.= $hydrop['answers'][$ansi][0]."\n";
|
||||
$ansi++;
|
||||
}
|
||||
//echo htmlentities($out);
|
||||
if($pid>0){
|
||||
file_put_contents($OJ_DATA."/$pid/data.out",$out);
|
||||
file_put_contents($OJ_DATA."/$pid/data.in",($ansi-1)."\n");
|
||||
}
|
||||
$template="";
|
||||
for($i=1;$i<$ansi;$i++){
|
||||
$template.=$i."\n";
|
||||
}
|
||||
file_put_contents($OJ_DATA."/$pid/template.c",$template);
|
||||
pdo_query("update problem set spj=2 ,description=replace(description,'<span class=\"md\">','<span class=\"md auto_select\">') where problem_id=?",$pid);
|
||||
|
||||
}else{
|
||||
if(endsWith($hydrop['time'],"ms")){
|
||||
$hydrop['time']=substr($hydrop['time'],0,-2);
|
||||
$hydrop['time']=floatval($hydrop['time'])/1000;
|
||||
}else if(endsWith($hydrop['time'],"s")){
|
||||
$hydrop['time']=substr($hydrop['time'],0,-1);
|
||||
$hydrop['time']=floatval($hydrop['time']);
|
||||
}
|
||||
$time=floatval($hydrop['time']);
|
||||
$memory=floatval($hydrop['memory']);
|
||||
$iofile=$hydrop['filename'];
|
||||
if($pid!=""&&$iofile!=""){
|
||||
file_put_contents($OJ_DATA."/$pid/input.name",$iofile.".in\n");
|
||||
file_put_contents($OJ_DATA."/$pid/output.name",$iofile.".out\n");
|
||||
|
||||
}
|
||||
if($time>0) pdo_query("update problem set time_limit=?,memory_limit=? where problem_id=?",$time,$memory,$pid);
|
||||
}
|
||||
//echo $time."s-".${memory}."m";
|
||||
}else if($pid!="" && strpos($file_path,"testdata") !== false && basename($file_name) != "testdata" ){
|
||||
echo ".";
|
||||
$dataname=basename($file_name);
|
||||
if(endsWith($dataname,".txt")){
|
||||
$pattern = '/input([0-9]*).txt/i';
|
||||
$dataname=preg_replace($pattern, '\\1.in', $dataname);
|
||||
$pattern = '/output([0-9]*).txt/i';
|
||||
$dataname=preg_replace($pattern, '\\1.out', $dataname);
|
||||
}else if(endsWith($dataname,"put")){
|
||||
$dataname=substr($dataname,0,-3);
|
||||
}else if(endsWith($dataname,".ans")){
|
||||
$dataname=substr($dataname,0,-3)."out";
|
||||
}else if(endsWith($dataname,".in")){
|
||||
$dataname=substr($dataname,0,-2)."in";
|
||||
}else if(endsWith($dataname,".out")){
|
||||
$dataname=substr($dataname,0,-3)."out";
|
||||
}
|
||||
file_put_contents($OJ_DATA."/$pid/".$dataname,$file_content);
|
||||
}else if(strpos($file_path,"additional_file") !== false && basename($file_name) != "additional_file" ){
|
||||
|
||||
// echo $file_name."[$pid]<br>";
|
||||
$ext = strtolower(get_extension($file_name));
|
||||
|
||||
if (!stristr(",jpeg,jpg,svg,png,gif,bmp,xlsx,xls,doc,docx",$ext)) {
|
||||
$ext = "bad";
|
||||
continue;
|
||||
}else{
|
||||
|
||||
//新文件名
|
||||
$new_file_name = basename($file_name);
|
||||
$newpath = $save_path."/".$new_file_name;
|
||||
if ($OJ_SAE)
|
||||
$newpath = "saestor://web".$newpath;
|
||||
else
|
||||
$newpath="..".$newpath;
|
||||
}
|
||||
if(!file_exists(dirname($newpath))){
|
||||
mkdir(dirname($newpath),0750,true);
|
||||
}
|
||||
file_put_contents($newpath,$file_content);
|
||||
// echo ($newpath)."<br>";
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}else{
|
||||
|
||||
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
|
||||
/*
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
$pid=import_json($file_content);
|
||||
$dir=$tempdir."/".basename($file_name,".json");
|
||||
mkdir("$OJ_DATA/$pid");
|
||||
system ("mv $dir/* $OJ_DATA/$pid/");
|
||||
system ("rmdir $dir");
|
||||
}else{
|
||||
// echo "$file_name"."<br>";
|
||||
// mkdir($tempdir."/".dirname($file_name));
|
||||
// file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
*/
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
rmdir ($tempdir);
|
||||
}
|
||||
else {
|
||||
echo ($tempfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
191
web/admin/problem_import_md.php
Normal file
191
web/admin/problem_import_md.php
Normal file
@@ -0,0 +1,191 @@
|
||||
<?php
|
||||
ini_set("display_errors", "On"); //set this to "On" for debugging ,especially when no reason blank shows up.
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
function startsWith( $haystack, $needle ) {
|
||||
$length = strlen( $needle );
|
||||
return substr( $haystack, 0, $length ) === $needle;
|
||||
}
|
||||
function endsWith( $haystack, $needle ) {
|
||||
$length = strlen( $needle );
|
||||
if( !$length ) {
|
||||
return true;
|
||||
}
|
||||
return substr( $haystack, -$length ) === $needle;
|
||||
}
|
||||
function strip($Node, $TagName) {
|
||||
$len=mb_strlen($TagName);
|
||||
$i=mb_strpos($Node,"<".$TagName.">");
|
||||
$j=mb_strpos($Node,"</".$TagName.">");
|
||||
|
||||
return mb_substr($Node,$i+$len+2,$j-($i+$len+2));
|
||||
}
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function import_dir($json) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN;
|
||||
$qduoj_problem=json_decode($json);
|
||||
echo( $qduoj_problem->{'problem'}->{'title'})."<br>";
|
||||
|
||||
$title = $qduoj_problem->{'problem'}->{'title'};
|
||||
|
||||
$time_limit = floatval($qduoj_problem->{'problem'}->{'timeLimit'});
|
||||
$unit = "ms";
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = floatval($qduoj_problem->{'problem'}->{'memoryLimit'});
|
||||
$unit = "M";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = $qduoj_problem->{'problem'}->{'description'};
|
||||
$input = $qduoj_problem->{'problem'}->{'input'};
|
||||
$output = $qduoj_problem->{'problem'}->{'output'};
|
||||
$sample_input = strip($qduoj_problem->{'problem'}->{'examples'},"input");
|
||||
$sample_output = strip($qduoj_problem->{'problem'}->{'examples'},"output");
|
||||
// echo $sample_input."<br>";
|
||||
// echo $sample_output;
|
||||
$hint = $qduoj_problem->{'problem'}->{'hint'};
|
||||
$source = $qduoj_problem->{'problem'}->{'source'};
|
||||
$spj=0;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
return $pid;
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_markdown".time();
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only Markdown .md file is supported<hr>\n";
|
||||
$resource = zip_open($tempfile);
|
||||
$save_path="";
|
||||
$i = 1;
|
||||
$pid=$title=$description=$input=$output=$sample_input=$sample_output=$hint=$source=$spj="";
|
||||
$type="normal";
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $save_path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$ymd ="/upload/".$domain."/". date("Ymd");
|
||||
$save_path = $ymd ;
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(endsWith(basename($file_name),".md")){
|
||||
$hydrop=explode("\n",$file_content);
|
||||
$title=str_replace("#","",$hydrop[0]);
|
||||
$title=str_replace("\r","",$title);
|
||||
$source="";
|
||||
echo "<hr>".htmlentities($file_name." $title $source");
|
||||
$regex = '/<(?!div)/';
|
||||
// $file_content = preg_replace($regex, '<',$file_content);
|
||||
$regex = '/(?<!div)>\s?/';
|
||||
// $file_content = preg_replace($regex, '>', $file_content);
|
||||
//$file_content = str_replace("&", '&', $file_content);
|
||||
// if(strpos($file_content,"##")===false)
|
||||
// $description=$file_content;
|
||||
// else
|
||||
if($type=="normal")$description="<span class=\"md\">".$file_content."</span>";
|
||||
else $description="<span class=\"md auto_select\">".$file_content."</span>";
|
||||
$description=preg_replace('/{{ select\(\d+\) }}/', "", $description);
|
||||
if($save_path){
|
||||
$description=str_replace("file://",$save_path."/",$description);
|
||||
|
||||
// echo htmlentities($description);
|
||||
}
|
||||
|
||||
//echo htmlentities("$description");
|
||||
$tail=0;
|
||||
$ptitle = $title;
|
||||
while (hasProblem($ptitle)) {
|
||||
$tail++;
|
||||
$ptitle = $title."_".$tail;
|
||||
}
|
||||
$title=$ptitle;
|
||||
$pid = addproblem($title,1,128, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
mkdir($OJ_DATA."/$pid/");
|
||||
|
||||
echo "PID:<a href='../problem.php?id=$pid' >".htmlentities($title,ENT_QUOTES,"UTF-8")."</a>";
|
||||
}
|
||||
}
|
||||
}else{
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
rmdir ($tempdir);
|
||||
}
|
||||
else {
|
||||
echo ($tempfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
186
web/admin/problem_import_qduoj.php
Normal file
186
web/admin/problem_import_qduoj.php
Normal file
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
function strip($Node, $TagName) {
|
||||
$len=mb_strlen($TagName);
|
||||
$i=mb_strpos($Node,"<".$TagName.">");
|
||||
$j=mb_strpos($Node,"</".$TagName.">");
|
||||
|
||||
return mb_substr($Node,$i+$len+2,$j-($i+$len+2));
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function import_json($json) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN;
|
||||
$qduoj_problem=json_decode($json);
|
||||
echo( $qduoj_problem->{'title'})."<br>";
|
||||
echo( $qduoj_problem->{'title'})."<br>";
|
||||
|
||||
$title = $qduoj_problem->{'title'};
|
||||
|
||||
$time_limit = floatval($qduoj_problem->{'time_limit'});
|
||||
$unit = "ms";
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = floatval($qduoj_problem->{'memory_limit'});
|
||||
$unit = "M";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = $qduoj_problem->{'description'}->{'value'};
|
||||
$input = $qduoj_problem->{'input_description'}->{'value'};
|
||||
$output = $qduoj_problem->{'output_description'}->{'value'};
|
||||
// var_dump($qduoj_problem->{'samples'});
|
||||
$sample_input = $qduoj_problem->{'samples'}[0]->{"input"};
|
||||
$sample_output = $qduoj_problem->{'samples'}[0]->{"output"};
|
||||
// echo $sample_input."<br>";
|
||||
// echo $sample_output;
|
||||
$hint = $qduoj_problem->{'hint'}->{'value'};
|
||||
$source = $qduoj_problem->{'problem'}->{'source'};
|
||||
$spj=0;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
return $pid;
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_qduoj".time();
|
||||
echo $tempdir ;
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only QDUOJ exported file is supported";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
// import_json($file_content);
|
||||
}else{
|
||||
//echo "$file_name"."<br>";
|
||||
mkdir($tempdir."/".dirname($file_name));
|
||||
file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
$resource = zip_open($tempfile);
|
||||
$cmds=array();
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
$pid=import_json($file_content);
|
||||
// $dir=$tempdir."/".basename($file_name,".json");
|
||||
mkdir("$OJ_DATA/$pid");
|
||||
array_push ($cmds,"mv $tempdir/$i/testcase/* $OJ_DATA/$pid/");
|
||||
array_push ($cmds,"rmdir $tempdir/$i/testcase");
|
||||
$i++;
|
||||
}else{
|
||||
//echo "$file_name"."<br>";
|
||||
mkdir($tempdir."/".dirname($file_name),0755,true);
|
||||
file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
foreach($cmds as $cmd){
|
||||
// echo $cmd."<br>";
|
||||
system($cmd);
|
||||
|
||||
}
|
||||
//system ("rmdir $tempdir");
|
||||
}
|
||||
else {
|
||||
echo ($tempfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
101
web/admin/problem_import_syzoj.php
Normal file
101
web/admin/problem_import_syzoj.php
Normal file
@@ -0,0 +1,101 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/curl.php");
|
||||
require_once ("../include/problem.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_syzoj".time();
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only SYZOJ exported file is supported<hr>\n";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
$pid=$title=$description=$input=$output=$sample_input=$sample_output=$hint=$source=$spj="";
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(basename($file_name)=="statement.md"){
|
||||
$description="<div class='md'>\n".$file_content."\n</div>";
|
||||
$title=explode("\n",$file_content)[0];
|
||||
$title=mb_substr($title,2);
|
||||
$time=getPartByMark($file_content,"时间限制:","ms");
|
||||
$time=intval($time)/1000;
|
||||
$memory=getPartByMark($file_content,"空间限制:","MiB");
|
||||
echo "<hr>".htmlentities(" $title $source");
|
||||
$pid = addproblem($title,$time,$memory, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
echo "PID:$pid";
|
||||
mkdir($OJ_DATA."/$pid");
|
||||
echo ("mv $tempdir/data/* $OJ_DATA/$pid/");
|
||||
system ("mv $tempdir/data/* $OJ_DATA/$pid/");
|
||||
}else if(strpos($file_path,"data") !== false && basename($file_name) != "data" ){
|
||||
echo ".";
|
||||
mkdir($tempdir."/data/");
|
||||
$name=basename($file_name);
|
||||
if(get_extension($name)=="ans"){
|
||||
$name=basename($file_name,".ans").".out";
|
||||
}
|
||||
echo "[$pid]";
|
||||
if($pid>0)
|
||||
file_put_contents("$OJ_DATA/$pid/".$name,$file_content);
|
||||
else
|
||||
file_put_contents($tempdir."/data/".$name,$file_content);
|
||||
}else{
|
||||
echo $file_name.":$pid<br>";
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
system ("rmdir $tempdir");
|
||||
}
|
||||
else {
|
||||
echo ($tempfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
418
web/admin/problem_import_tyvj.php
Normal file
418
web/admin/problem_import_tyvj.php
Normal file
@@ -0,0 +1,418 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
function image_save_file($filepath ,$base64_encoded_img) {
|
||||
$dirpath=dirname($filepath);
|
||||
if (!file_exists($dirpath)) {
|
||||
mkdir($dirpath,0755,true);
|
||||
}
|
||||
$fp = fopen($filepath ,"wb");
|
||||
fwrite($fp,base64_decode($base64_encoded_img));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
require_once ("../include/problem.php");
|
||||
require_once ("../include/db_info.inc.php");
|
||||
|
||||
function getLang($language) {
|
||||
$language_name = $GLOBALS['language_name'];
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
|
||||
for ($i=0; $i<count($language_name); $i++) {
|
||||
//echo "$language=$language_name[$i]=".($language==$language_name[$i]);
|
||||
// compatibility with other onlinejudge FPS implementation might using extension name as language
|
||||
|
||||
if ($language==$language_ext[$i]) {
|
||||
return $i;
|
||||
}
|
||||
|
||||
// HUSTOJ classic using language_name
|
||||
if ($language==$language_name[$i]) {
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
return $i;
|
||||
}
|
||||
|
||||
function submitSolution($pid,$solution,$language) {
|
||||
global $OJ_NAME,$_SESSION;
|
||||
$language = getLang($language);
|
||||
$len = mb_strlen($solution,'utf-8');
|
||||
$user_id=$_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
$sql = "SELECT nick FROM users WHERE user_id=?";
|
||||
$nick = pdo_query($sql, $user_id);
|
||||
if ($nick) {
|
||||
$nick = $nick[0][0];
|
||||
}
|
||||
else {
|
||||
$nick = "Guest";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO solution(problem_id,user_id,nick,in_date,language,ip,code_length,result) VALUES(?,?,?,NOW(),?,'127.0.0.1',?,14)";
|
||||
$insert_id = pdo_query($sql, $pid,$_SESSION[$OJ_NAME.'_'.'user_id'],$nick, $language, $len);
|
||||
// echo "submiting$language.....$insert_id";
|
||||
|
||||
$sql = "INSERT INTO `source_code`(`solution_id`,`source`) VALUES(?,?)";
|
||||
pdo_query($sql ,$insert_id, $solution);
|
||||
|
||||
$sql = "INSERT INTO `source_code_user`(`solution_id`,`source`) VALUES(?,?)";
|
||||
pdo_query($sql, $insert_id, $solution);
|
||||
pdo_query("UPDATE solution SET result=1 WHERE solution_id=?", $insert_id);
|
||||
pdo_query("UPDATE problem SET submit=submit+1 WHERE problem_id=?", $pid);
|
||||
}
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br>
|
||||
<a href="problem_list.php" > Return to Problem List </a>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
function getValue($Node, $TagName) {
|
||||
// $value=mb_ereg_replace("<div[a-z -=\"]*>","",$Node->$TagName);
|
||||
// $value=mb_ereg_replace("</div>","",$value);
|
||||
return $Node->$TagName->Chinese;
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasRemoteProblem($remote_oj,$remote_id) {
|
||||
if($remote_oj=="" || $remote_id=="")return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE remote_oj=? and remote_id=?";
|
||||
$result = pdo_query($sql,$remote_oj,$remote_id);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function import_fps($tempfile,$tempData) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN,$OJ_NAME;
|
||||
$xmlDoc = simplexml_load_file($tempfile, 'SimpleXMLElement', LIBXML_PARSEHUGE);
|
||||
$searchNodes = $xmlDoc->xpath("/DocumentElement");
|
||||
$spid = 0;
|
||||
|
||||
foreach ($searchNodes as $searchNode) {
|
||||
//echo $searchNode->title,"\n";
|
||||
set_time_limit(60);
|
||||
$title = $searchNode->Background->Chinese;
|
||||
|
||||
$time_limit = "1";
|
||||
$unit = "s";
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = getAttribute($searchNode,"Datas",'MemoryLimit');
|
||||
$unit = "kb";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = $searchNode->Description->Chinese;
|
||||
$input = getValue($searchNode,'InputFormat');
|
||||
$output = getValue($searchNode,'OutputFormat');
|
||||
$sample_input = $searchNode->SampleInput->Sample1;
|
||||
$sample_output = $searchNode->SampleOutput->Sample1;
|
||||
//$test_input = getValue($searchNode,'test_input');
|
||||
//$test_output = getValue($searchNode,'test_output');
|
||||
$hint = getValue ($searchNode,'Hint');
|
||||
$source = getValue ($searchNode,'Source');
|
||||
$spj= 0;
|
||||
$remote_oj= getValue ($searchNode,'remote_oj');
|
||||
$remote_id= getValue ($searchNode,'remote_id');
|
||||
|
||||
if(hasRemoteProblem($remote_oj,$remote_id)){
|
||||
$sql="update problem set title=?,time_limit=?,memory_limit=?,description=?,input=?,output=?,sample_input=?,sample_output=?,hint=?,source=?,spj=? where remote_oj=? and remote_id=?";
|
||||
pdo_query($sql,$title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj,$remote_oj,$remote_id);
|
||||
}else{
|
||||
$tail=0;
|
||||
$ptitle = $title;
|
||||
while (hasProblem($ptitle)) {
|
||||
$tail++;
|
||||
$ptitle = $title."_".$tail;
|
||||
}
|
||||
$title=$ptitle;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
if($remote_oj!=""){
|
||||
$sql="update problem set remote_oj=?,remote_id=? where problem_id=?";
|
||||
pdo_query($sql,$remote_oj,$remote_id,$pid);
|
||||
}
|
||||
if ($spid==0)
|
||||
$spid = $pid;
|
||||
$sql = "INSERT INTO `privilege` (`user_id`,`rightstr`) VALUES(?,?)";
|
||||
pdo_query($sql, $_SESSION[$OJ_NAME.'_'.'user_id'], "p$pid");
|
||||
$_SESSION[$OJ_NAME.'_'."p$pid"] = true;
|
||||
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
mkdir($basedir);
|
||||
|
||||
if (strlen($sample_input)) mkdata($pid,"sample.in",$sample_input,$OJ_DATA);
|
||||
if (strlen($sample_output)) mkdata($pid,"sample.out",$sample_output,$OJ_DATA);
|
||||
|
||||
//if(!isset($OJ_SAE)||!$OJ_SAE){
|
||||
$testinputs = $searchNode->Datas->Data;
|
||||
$testno = 0;
|
||||
|
||||
foreach ($testinputs as $testNode) {
|
||||
//if($testNode->nodeValue)
|
||||
$output=$testNode['OutputFile'];
|
||||
$input=$testNode['InputFile'];
|
||||
$score=intval($testNode['Score']);
|
||||
if($score<=0) $score=20;
|
||||
//echo "$input-$output<br>";
|
||||
rename($tempData."/$input",$basedir."/".$testno."[".$score."].in");
|
||||
rename($tempData."/$output",$basedir."/".$testno."[".$score."].out");
|
||||
$testno++;
|
||||
}
|
||||
|
||||
unset($testinputs);
|
||||
// }
|
||||
|
||||
$images = ($searchNode->children()->img);
|
||||
$did = array();
|
||||
$testno = 0;
|
||||
|
||||
foreach ($images as $img) {
|
||||
//
|
||||
$src = getValue($img,"src");
|
||||
|
||||
if (!in_array($src,$did)) {
|
||||
$base64 = getValue($img,"base64");
|
||||
$ext = pathinfo($src);
|
||||
$ext = strtolower($ext['extension']);
|
||||
|
||||
if (!stristr(",jpeg,jpg,svg,png,gif,bmp",$ext)) {
|
||||
$ext = "bad";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$testno++;
|
||||
$ymd =$domain."/". date("Ymd");
|
||||
$save_path = $ymd . "/";
|
||||
//新文件名
|
||||
$new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $ext;
|
||||
$newpath = $save_path."/$pid"."_".$testno."_".$new_file_name;
|
||||
if ($OJ_SAE)
|
||||
$newpath = "saestor://web/upload/".$newpath;
|
||||
else
|
||||
$newpath="../upload/".$newpath;
|
||||
|
||||
image_save_file($newpath,$base64);
|
||||
$sql = "UPDATE problem SET description=replace(description,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
|
||||
$sql = "UPDATE problem SET input=replace(input,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
|
||||
$sql = "UPDATE problem SET output=replace(output,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
|
||||
$sql = "UPDATE problem SET hint=replace(hint,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
array_push($did,$src);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($OJ_SAE) || !$OJ_SAE) {
|
||||
if ($spj==1) {
|
||||
if($spjcode){
|
||||
if($spjlang=="C++"){
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$fp = fopen("$basedir/spj.cc","w");
|
||||
fputs($fp, $spjcode);
|
||||
fclose($fp);
|
||||
//////system( " g++ -o $basedir/spj $basedir/spj.cc ");
|
||||
}else{
|
||||
$fp = fopen("$basedir/spj.c","w");
|
||||
fputs($fp, $spjcode);
|
||||
fclose($fp);
|
||||
//////system( " gcc -o $basedir/spj $basedir/spj.c ");
|
||||
|
||||
}
|
||||
if (!file_exists("$basedir/spj")) {
|
||||
echo "you need to compile $basedir/spj.cc for spj[ g++ -o $basedir/spj $basedir/spj.cc ]<br> and rejudge $pid";
|
||||
}
|
||||
else {
|
||||
//unlink("$basedir/spj.cc");
|
||||
}
|
||||
|
||||
}
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
if($tpjcode){
|
||||
if($tpjlang=="C++"){
|
||||
$fp = fopen("$basedir/tpj.cc","w");
|
||||
fputs($fp, $tpjcode);
|
||||
fclose($fp);
|
||||
//////system( " g++ -o $basedir/spj $basedir/spj.cc ");
|
||||
}else{
|
||||
$fp = fopen("$basedir/tpj.c","w");
|
||||
fputs($fp, $spjcode);
|
||||
fclose($fp);
|
||||
//////system( " gcc -o $basedir/spj $basedir/spj.c ");
|
||||
}
|
||||
if (!file_exists("$basedir/tpj")) {
|
||||
echo "you need to compile $basedir/tpj.cc for tpj[ g++ -o $basedir/tpj $basedir/tpj.cc ]<br> and rejudge $pid";
|
||||
}
|
||||
else {
|
||||
//unlink("$basedir/spj.cc");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solutions = $searchNode->children()->solution;
|
||||
|
||||
foreach ($solutions as $solution) {
|
||||
$language = $solution->attributes()->language;
|
||||
submitSolution($pid,$solution,$language);
|
||||
}
|
||||
unset($solutions);
|
||||
|
||||
$prepends = $searchNode->children()->prepend;
|
||||
mkpta($pid,$prepends,"prepend");
|
||||
|
||||
$prepends = $searchNode->children()->template;
|
||||
mkpta($pid,$prepends,"template");
|
||||
|
||||
$prepends = $searchNode->children()->append;
|
||||
mkpta($pid,$prepends,"append");
|
||||
}
|
||||
}
|
||||
|
||||
unlink($tempfile);
|
||||
|
||||
if (isset($OJ_REDIS) && $OJ_REDIS) {
|
||||
$redis = new Redis();
|
||||
$redis->connect($OJ_REDISSERVER, $OJ_REDISPORT);
|
||||
$sql = "SELECT solution_id FROM solution WHERE result=0 AND problem_id>0";
|
||||
$result = pdo_query($sql);
|
||||
|
||||
foreach ($result as $row) {
|
||||
echo $row['solution_id']."\n";
|
||||
$redis->lpush($OJ_REDISQNAME,$row['solution_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($spid>0) {
|
||||
require_once("../include/set_get_key.php");
|
||||
//echo "<br><a class=blue href=contest_add.php?spid=$spid&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">Use these problems to create a contest.</a>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only fps/xml files in root dir are supported";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
$tempfile = tempnam("/tmp", "tyvj");
|
||||
$tempData = tempnam("/tmp","tyvjData");
|
||||
unlink($tempData);
|
||||
mkdir($tempData);
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension(basename($file_name))=="xml"){
|
||||
file_put_contents($tempfile,$file_content);
|
||||
import_fps($tempfile,$tempData);
|
||||
}else{
|
||||
file_put_contents($tempData."/".basename($file_name),$file_content);
|
||||
//echo basename($file_name)."<br>";
|
||||
}
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
}
|
||||
else {
|
||||
echo "zip only";
|
||||
}
|
||||
// echo "Upload: " . $_FILES ["fps"] ["name"] . "<br />";
|
||||
// echo "Type: " . $_FILES ["fps"] ["type"] . "<br />";
|
||||
// echo "Size: " . ($_FILES ["fps"] ["size"] / 1024) . " Kb<br />";
|
||||
// echo "Stored in: " . $tempfile;
|
||||
|
||||
//$xmlDoc = new DOMDocument ();
|
||||
//$xmlDoc->load ( $tempfile );
|
||||
//$xmlcontent=file_get_contents($tempfile );
|
||||
}
|
||||
if (isset($OJ_UDP) && $OJ_UDP) {
|
||||
$JUDGE_SERVERS = explode(",",$OJ_UDPSERVER);
|
||||
$JUDGE_TOTAL = count($JUDGE_SERVERS);
|
||||
|
||||
$select = $insert_id%$JUDGE_TOTAL;
|
||||
$JUDGE_HOST = $JUDGE_SERVERS[$select];
|
||||
|
||||
if (strstr($JUDGE_HOST,":")!==false) {
|
||||
$JUDGE_SERVERS = explode(":",$JUDGE_HOST);
|
||||
$JUDGE_HOST = $JUDGE_SERVERS[0];
|
||||
$OJ_UDPPORT = $JUDGE_SERVERS[1];
|
||||
}
|
||||
if(isset($OJ_JUDGE_HUB_PATH))
|
||||
send_udp_message($JUDGE_HOST, $OJ_UDPPORT, $OJ_JUDGE_HUB_PATH);
|
||||
else
|
||||
send_udp_message($JUDGE_HOST, $OJ_UDPPORT, 0);
|
||||
}
|
||||
|
||||
?>
|
||||
177
web/admin/problem_import_unkownoj.php
Normal file
177
web/admin/problem_import_unkownoj.php
Normal file
@@ -0,0 +1,177 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
//require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']) )) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/problem.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
function strip($Node, $TagName) {
|
||||
$len=mb_strlen($TagName);
|
||||
$i=mb_strpos($Node,"<".$TagName.">");
|
||||
$j=mb_strpos($Node,"</".$TagName.">");
|
||||
|
||||
return mb_substr($Node,$i+$len+2,$j-($i+$len+2));
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function import_json($json) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN;
|
||||
$qduoj_problem=json_decode($json);
|
||||
echo( $qduoj_problem->{'problem'}->{'title'})."<br>";
|
||||
|
||||
$title = $qduoj_problem->{'problem'}->{'title'};
|
||||
|
||||
$time_limit = floatval($qduoj_problem->{'problem'}->{'timeLimit'});
|
||||
$unit = "ms";
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = floatval($qduoj_problem->{'problem'}->{'memoryLimit'});
|
||||
$unit = "M";
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = $qduoj_problem->{'problem'}->{'description'};
|
||||
$input = $qduoj_problem->{'problem'}->{'input'};
|
||||
$output = $qduoj_problem->{'problem'}->{'output'};
|
||||
$sample_input = strip($qduoj_problem->{'problem'}->{'examples'},"input");
|
||||
$sample_output = strip($qduoj_problem->{'problem'}->{'examples'},"output");
|
||||
// echo $sample_input."<br>";
|
||||
// echo $sample_output;
|
||||
$hint = $qduoj_problem->{'problem'}->{'hint'};
|
||||
$source = $qduoj_problem->{'problem'}->{'source'};
|
||||
$spj=0;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
return $pid;
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempdir = sys_get_temp_dir()."/import_qduoj";
|
||||
mkdir($tempdir);
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only QDUOJ exported file is supported";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
// import_json($file_content);
|
||||
}else{
|
||||
//echo "$file_name"."<br>";
|
||||
mkdir($tempdir."/".dirname($file_name));
|
||||
file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
if(get_extension($file_name)=="json")
|
||||
{
|
||||
$pid=import_json($file_content);
|
||||
$dir=$tempdir."/".basename($file_name,".json");
|
||||
mkdir("$OJ_DATA/$pid");
|
||||
system ("mv $dir/* $OJ_DATA/$pid/");
|
||||
system ("rmdir $dir");
|
||||
}else{
|
||||
// echo "$file_name"."<br>";
|
||||
// mkdir($tempdir."/".dirname($file_name));
|
||||
// file_put_contents($tempdir."/".$file_name,$file_content);
|
||||
}
|
||||
}else{
|
||||
echo $file_name;
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
system ("rmdir $tempdir");
|
||||
}
|
||||
else {
|
||||
echo ($tempfile);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
432
web/admin/problem_import_xml.php
Normal file
432
web/admin/problem_import_xml.php
Normal file
@@ -0,0 +1,432 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_problem_importer']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
|
||||
require_once ("../include/const.inc.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
|
||||
function image_save_file($filepath ,$base64_encoded_img) {
|
||||
$dirpath=dirname($filepath);
|
||||
if (!file_exists($dirpath)) {
|
||||
mkdir($dirpath,0755,true);
|
||||
}
|
||||
$fp = fopen($filepath ,"wb");
|
||||
fwrite($fp,base64_decode($base64_encoded_img));
|
||||
fclose($fp);
|
||||
}
|
||||
|
||||
require_once ("../include/problem.php");
|
||||
require_once ("../include/db_info.inc.php");
|
||||
|
||||
function getLang($language) {
|
||||
$language_name = $GLOBALS['language_name'];
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
|
||||
for ($i=0; $i<count($language_name); $i++) {
|
||||
//echo "$language=$language_name[$i]=".($language==$language_name[$i]);
|
||||
// compatibility with other onlinejudge FPS implementation might using extension name as language
|
||||
|
||||
if ($language==$language_ext[$i]) {
|
||||
return $i;
|
||||
}
|
||||
|
||||
// HUSTOJ classic using language_name
|
||||
if ($language==$language_name[$i]) {
|
||||
return $i;
|
||||
}
|
||||
}
|
||||
return $i;
|
||||
}
|
||||
|
||||
function submitSolution($pid,$solution,$language) {
|
||||
global $OJ_NAME,$_SESSION;
|
||||
$language = getLang($language);
|
||||
$len = mb_strlen($solution,'utf-8');
|
||||
$user_id=$_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
$sql = "SELECT nick FROM users WHERE user_id=?";
|
||||
$nick = pdo_query($sql, $user_id);
|
||||
if ($nick) {
|
||||
$nick = $nick[0][0];
|
||||
}
|
||||
else {
|
||||
$nick = "Guest";
|
||||
}
|
||||
|
||||
$sql = "INSERT INTO solution(problem_id,user_id,nick,in_date,language,ip,code_length,result) VALUES(?,?,?,NOW(),?,'127.0.0.1',?,14)";
|
||||
$insert_id = pdo_query($sql, $pid,$_SESSION[$OJ_NAME.'_'.'user_id'],$nick, $language, $len);
|
||||
// echo "submiting$language.....$insert_id";
|
||||
|
||||
$sql = "INSERT INTO `source_code`(`solution_id`,`source`) VALUES(?,?)";
|
||||
pdo_query($sql ,$insert_id, $solution);
|
||||
|
||||
$sql = "INSERT INTO `source_code_user`(`solution_id`,`source`) VALUES(?,?)";
|
||||
pdo_query($sql, $insert_id, $solution);
|
||||
pdo_query("UPDATE solution SET result=1 WHERE solution_id=?", $insert_id);
|
||||
pdo_query("UPDATE problem SET submit=submit+1 WHERE problem_id=?", $pid);
|
||||
}
|
||||
?>
|
||||
|
||||
<hr>
|
||||
- Import Problem ... <br>
|
||||
- 如果导入失败,请参考 <a href="https://github.com/zhblue/hustoj/blob/master/wiki/FAQ.md#%E5%90%8E%E5%8F%B0%E5%AF%BC%E5%85%A5%E9%97%AE%E9%A2%98%E5%A4%B1%E8%B4%A5" target="_blank">FAQ</a>。
|
||||
<br>
|
||||
<a href="problem_list.php" > Return to Problem List </a>
|
||||
<br>
|
||||
|
||||
<?php
|
||||
function getValue($Node, $TagName) {
|
||||
// $value=mb_ereg_replace("<div[a-z -=\"]*>","",$Node->$TagName);
|
||||
// $value=mb_ereg_replace("</div>","",$value);
|
||||
return $Node->$TagName;
|
||||
}
|
||||
|
||||
function getAttribute($Node, $TagName,$attribute) {
|
||||
return $Node->children()->$TagName->attributes()->$attribute;
|
||||
}
|
||||
|
||||
function hasRemoteProblem($remote_oj,$remote_id) {
|
||||
if($remote_oj=="" || $remote_id=="")return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE remote_oj=? and remote_id=?";
|
||||
$result = pdo_query($sql,$remote_oj,$remote_id);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
function hasProblem($title) {
|
||||
//return false;
|
||||
$md5 = md5($title);
|
||||
$sql = "SELECT 1 FROM problem WHERE md5(title)=?";
|
||||
$result = pdo_query($sql, $md5);
|
||||
$rows_cnt = count($result);
|
||||
//echo "row->$rows_cnt";
|
||||
return ($rows_cnt>0);
|
||||
}
|
||||
|
||||
function mkpta($pid,$prepends,$node) {
|
||||
$language_ext = $GLOBALS['language_ext'];
|
||||
$OJ_DATA = $GLOBALS['OJ_DATA'];
|
||||
|
||||
foreach ($prepends as $prepend) {
|
||||
$language = $prepend->attributes()->language;
|
||||
$lang = getLang($language);
|
||||
$file_ext = $language_ext[$lang];
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$file_name = "$basedir/$node.$file_ext";
|
||||
file_put_contents($file_name,$prepend);
|
||||
}
|
||||
}
|
||||
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
|
||||
function import_fps($tempfile) {
|
||||
global $OJ_DATA,$OJ_SAE,$OJ_REDIS,$OJ_REDISSERVER,$OJ_REDISPORT,$OJ_REDISQNAME,$domain,$DOMAIN,$OJ_NAME;
|
||||
$xmlDoc = simplexml_load_file($tempfile, 'SimpleXMLElement', LIBXML_PARSEHUGE);
|
||||
$searchNodes = $xmlDoc->xpath("/fps/item");
|
||||
$spid = 0;
|
||||
|
||||
foreach ($searchNodes as $searchNode) {
|
||||
//echo $searchNode->title,"\n";
|
||||
//set_time_limit(60);
|
||||
$title = $searchNode->title;
|
||||
|
||||
$time_limit = $searchNode->time_limit;
|
||||
$unit = getAttribute($searchNode,'time_limit','unit');
|
||||
//echo $unit;
|
||||
|
||||
if ($unit=='ms')
|
||||
$time_limit /= 1000;
|
||||
|
||||
$memory_limit = getValue($searchNode,'memory_limit');
|
||||
$unit = getAttribute($searchNode,'memory_limit','unit');
|
||||
|
||||
if ($unit=='kb')
|
||||
$memory_limit /= 1024;
|
||||
|
||||
$description = getValue($searchNode,'description');
|
||||
$input = getValue($searchNode,'input');
|
||||
$output = getValue($searchNode,'output');
|
||||
$sample_input = getValue($searchNode,'sample_input');
|
||||
$sample_output = getValue($searchNode,'sample_output');
|
||||
//$test_input = getValue($searchNode,'test_input');
|
||||
//$test_output = getValue($searchNode,'test_output');
|
||||
$hint = getValue ($searchNode,'hint');
|
||||
$source = getValue ($searchNode,'source');
|
||||
$spjcode = getValue ($searchNode,'spj');
|
||||
$remote_oj= getValue ($searchNode,'remote_oj');
|
||||
$remote_id= getValue ($searchNode,'remote_id');
|
||||
|
||||
if($spjcode) $spjlang=getAttribute($searchNode,'spj','language');
|
||||
$tpjcode = getValue ($searchNode,'tpj');
|
||||
if($tpjcode) $tpjlang=getAttribute($searchNode,'tpj','language');
|
||||
$spj = trim($spjcode.$tpjcode)?1:0;
|
||||
if($spjlang=="Text") $spj=2;
|
||||
if(hasRemoteProblem($remote_oj,$remote_id)){
|
||||
$sql="update problem set title=?,time_limit=?,memory_limit=?,description=?,input=?,output=?,sample_input=?,sample_output=?,hint=?,source=?,spj=? where remote_oj=? and remote_id=?";
|
||||
pdo_query($sql,$title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj,$remote_oj,$remote_id);
|
||||
}else{
|
||||
$tail=0;
|
||||
$ptitle = $title;
|
||||
while (hasProblem($ptitle)) {
|
||||
$tail++;
|
||||
$ptitle = $title."_".$tail;
|
||||
}
|
||||
$title=$ptitle;
|
||||
|
||||
$pid = addproblem($title, $time_limit, $memory_limit, $description, $input, $output, $sample_input, $sample_output, $hint, $source, $spj, $OJ_DATA);
|
||||
if($remote_oj!=""){
|
||||
$sql="update problem set remote_oj=?,remote_id=? where problem_id=?";
|
||||
pdo_query($sql,$remote_oj,$remote_id,$pid);
|
||||
}
|
||||
if ($spid==0)
|
||||
$spid = $pid;
|
||||
$sql = "INSERT INTO `privilege` (`user_id`,`rightstr`) VALUES(?,?)";
|
||||
pdo_query($sql, $_SESSION[$OJ_NAME.'_'.'user_id'], "p$pid");
|
||||
$_SESSION[$OJ_NAME.'_'."p$pid"] = true;
|
||||
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
mkdir($basedir);
|
||||
|
||||
if (strlen($sample_input)) mkdata($pid,"sample.in",$sample_input,$OJ_DATA);
|
||||
if (strlen($sample_output)) mkdata($pid,"sample.out",$sample_output,$OJ_DATA);
|
||||
|
||||
//if(!isset($OJ_SAE)||!$OJ_SAE){
|
||||
$testinputs = $searchNode->children()->test_input;
|
||||
$testno = 0;
|
||||
|
||||
foreach ($testinputs as $testNode) {
|
||||
//if($testNode->nodeValue)
|
||||
$name=$testNode['name'];
|
||||
if($name != ""){
|
||||
mkdata($pid,$name.".in",$testNode,$OJ_DATA);
|
||||
|
||||
}else{
|
||||
mkdata($pid,"test".$testno.".in",$testNode,$OJ_DATA);
|
||||
}
|
||||
$testno++;
|
||||
}
|
||||
|
||||
unset($testinputs);
|
||||
$testinputs = $searchNode->children()->test_output;
|
||||
$testno = 0;
|
||||
|
||||
foreach ($testinputs as $testNode) {
|
||||
//if($testNode->nodeValue)
|
||||
$name=$testNode['name'];
|
||||
if($name != ""){
|
||||
mkdata($pid,$name.".out",$testNode,$OJ_DATA);
|
||||
|
||||
}else{
|
||||
mkdata($pid,"test".$testno.".out",$testNode,$OJ_DATA);
|
||||
}
|
||||
$testno++;
|
||||
}
|
||||
|
||||
unset($testinputs);
|
||||
// }
|
||||
|
||||
$images = ($searchNode->children()->img);
|
||||
$did = array();
|
||||
$testno = 0;
|
||||
|
||||
foreach ($images as $img) {
|
||||
//
|
||||
$src = getValue($img,"src");
|
||||
|
||||
if (!in_array($src,$did)) {
|
||||
$base64 = getValue($img,"base64");
|
||||
$ext = pathinfo($src);
|
||||
$ext = strtolower($ext['extension']);
|
||||
|
||||
if (!stristr(",jpeg,jpg,svg,png,gif,bmp",$ext)) {
|
||||
$ext = "bad";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$testno++;
|
||||
$ymd =$domain."/". date("Ymd");
|
||||
$save_path = $ymd . "/";
|
||||
//新文件名
|
||||
$new_file_name = date("YmdHis") . '_' . rand(10000, 99999) . '.' . $ext;
|
||||
$newpath = $save_path."/$pid"."_".$testno."_".$new_file_name;
|
||||
if ($OJ_SAE)
|
||||
$newpath = "saestor://web/upload/".$newpath;
|
||||
else
|
||||
$newpath="../upload/".$newpath;
|
||||
|
||||
image_save_file($newpath,$base64);
|
||||
$sql = "UPDATE problem SET description=replace(description,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
|
||||
$sql = "UPDATE problem SET input=replace(input,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
|
||||
$sql = "UPDATE problem SET output=replace(output,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
|
||||
$sql = "UPDATE problem SET hint=replace(hint,?,?) WHERE problem_id=?";
|
||||
pdo_query($sql,$src,$newpath,$pid);
|
||||
array_push($did,$src);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($OJ_SAE) || !$OJ_SAE) {
|
||||
if ($spj==1) {
|
||||
if($spjcode){
|
||||
if($spjlang=="C++"){
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
$fp = fopen("$basedir/spj.cc","w");
|
||||
fputs($fp, $spjcode);
|
||||
fclose($fp);
|
||||
//////system( " g++ -o $basedir/spj $basedir/spj.cc ");
|
||||
}else{
|
||||
$fp = fopen("$basedir/spj.c","w");
|
||||
fputs($fp, $spjcode);
|
||||
fclose($fp);
|
||||
//////system( " gcc -o $basedir/spj $basedir/spj.c ");
|
||||
|
||||
}
|
||||
if (!file_exists("$basedir/spj")) {
|
||||
echo "you need to compile $basedir/spj.cc for spj[ g++ -o $basedir/spj $basedir/spj.cc ]<br> and rejudge $pid";
|
||||
}
|
||||
else {
|
||||
//unlink("$basedir/spj.cc");
|
||||
}
|
||||
|
||||
}
|
||||
$basedir = "$OJ_DATA/$pid";
|
||||
if($tpjcode){
|
||||
if($tpjlang=="C++"){
|
||||
$fp = fopen("$basedir/tpj.cc","w");
|
||||
fputs($fp, $tpjcode);
|
||||
fclose($fp);
|
||||
//////system( " g++ -o $basedir/spj $basedir/spj.cc ");
|
||||
}else{
|
||||
$fp = fopen("$basedir/tpj.c","w");
|
||||
fputs($fp, $spjcode);
|
||||
fclose($fp);
|
||||
//////system( " gcc -o $basedir/spj $basedir/spj.c ");
|
||||
}
|
||||
if (!file_exists("$basedir/tpj")) {
|
||||
echo "you need to compile $basedir/tpj.cc for tpj[ g++ -o $basedir/tpj $basedir/tpj.cc ]<br> and rejudge $pid";
|
||||
}
|
||||
else {
|
||||
//unlink("$basedir/spj.cc");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$solutions = $searchNode->children()->solution;
|
||||
|
||||
foreach ($solutions as $solution) {
|
||||
$language = $solution->attributes()->language;
|
||||
submitSolution($pid,$solution,$language);
|
||||
}
|
||||
unset($solutions);
|
||||
|
||||
$prepends = $searchNode->children()->prepend;
|
||||
mkpta($pid,$prepends,"prepend");
|
||||
|
||||
$prepends = $searchNode->children()->template;
|
||||
mkpta($pid,$prepends,"template");
|
||||
|
||||
$prepends = $searchNode->children()->append;
|
||||
mkpta($pid,$prepends,"append");
|
||||
}
|
||||
}
|
||||
|
||||
unlink($tempfile);
|
||||
|
||||
if (isset($OJ_REDIS) && $OJ_REDIS) {
|
||||
$redis = new Redis();
|
||||
$redis->connect($OJ_REDISSERVER, $OJ_REDISPORT);
|
||||
$sql = "SELECT solution_id FROM solution WHERE result=0 AND problem_id>0";
|
||||
$result = pdo_query($sql);
|
||||
|
||||
foreach ($result as $row) {
|
||||
echo $row['solution_id']."\n";
|
||||
$redis->lpush($OJ_REDISQNAME,$row['solution_id']);
|
||||
}
|
||||
}
|
||||
|
||||
if ($spid>0) {
|
||||
require_once("../include/set_get_key.php");
|
||||
//echo "<br><a class=blue href=contest_add.php?spid=$spid&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">Use these problems to create a contest.</a>";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ($_FILES ["fps"] ["error"] > 0) {
|
||||
echo " - Error: ".$_FILES ["fps"] ["error"]."File size is too big, change in PHP.ini<br />";
|
||||
}
|
||||
else {
|
||||
$tempfile = $_FILES ["fps"] ["tmp_name"];
|
||||
if (get_extension( $_FILES ["fps"] ["name"])=="zip") {
|
||||
echo " - zip file, only fps/xml files in root dir are supported";
|
||||
$resource = zip_open($tempfile);
|
||||
|
||||
$i = 1;
|
||||
$tempfile = tempnam("/tmp", "fps");
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource,$dir_resource)) {
|
||||
$file_name = $path.zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name,0,strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource,$file_size);
|
||||
file_put_contents($tempfile,$file_content);
|
||||
import_fps($tempfile);
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink ( $_FILES ["fps"] ["tmp_name"] );
|
||||
}
|
||||
else {
|
||||
import_fps($tempfile);
|
||||
}
|
||||
// echo "Upload: " . $_FILES ["fps"] ["name"] . "<br />";
|
||||
// echo "Type: " . $_FILES ["fps"] ["type"] . "<br />";
|
||||
// echo "Size: " . ($_FILES ["fps"] ["size"] / 1024) . " Kb<br />";
|
||||
// echo "Stored in: " . $tempfile;
|
||||
|
||||
//$xmlDoc = new DOMDocument ();
|
||||
//$xmlDoc->load ( $tempfile );
|
||||
//$xmlcontent=file_get_contents($tempfile );
|
||||
}
|
||||
if (isset($OJ_UDP) && $OJ_UDP) {
|
||||
$JUDGE_SERVERS = explode(",",$OJ_UDPSERVER);
|
||||
$JUDGE_TOTAL = count($JUDGE_SERVERS);
|
||||
|
||||
$select = $insert_id%$JUDGE_TOTAL;
|
||||
$JUDGE_HOST = $JUDGE_SERVERS[$select];
|
||||
|
||||
if (strstr($JUDGE_HOST,":")!==false) {
|
||||
$JUDGE_SERVERS = explode(":",$JUDGE_HOST);
|
||||
$JUDGE_HOST = $JUDGE_SERVERS[0];
|
||||
$OJ_UDPPORT = $JUDGE_SERVERS[1];
|
||||
}
|
||||
if(isset($OJ_JUDGE_HUB_PATH))
|
||||
send_udp_message($JUDGE_HOST, $OJ_UDPPORT, $OJ_JUDGE_HUB_PATH);
|
||||
else
|
||||
send_udp_message($JUDGE_HOST, $OJ_UDPPORT, 0);
|
||||
}
|
||||
|
||||
?>
|
||||
279
web/admin/problem_judge.php
Normal file
279
web/admin/problem_judge.php
Normal file
@@ -0,0 +1,279 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'http_judge']))){
|
||||
echo "0";
|
||||
exit(1);
|
||||
}
|
||||
header('Content-Type: text/plain');
|
||||
|
||||
if(isset($_POST['manual'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$result=intval($_POST['result']);
|
||||
if($result>=0){
|
||||
if($result==4)
|
||||
$sql="UPDATE solution SET result=?,pass_rate=1.0 WHERE solution_id=? LIMIT 1";
|
||||
else
|
||||
$sql="UPDATE solution SET result=?,pass_rate=0 WHERE solution_id=? LIMIT 1";
|
||||
pdo_query($sql,$result,$sid);
|
||||
}
|
||||
if(isset($_POST['explain'])){
|
||||
$sql="DELETE FROM runtimeinfo WHERE solution_id=? ";
|
||||
pdo_query($sql,$sid);
|
||||
$reinfo=$_POST['explain'];
|
||||
if (false) {
|
||||
$reinfo= stripslashes ( $reinfo);
|
||||
}
|
||||
$sql="INSERT INTO runtimeinfo VALUES(?,?)";
|
||||
pdo_query($sql,$sid,$reinfo);
|
||||
}
|
||||
if (isset($OJ_UDP) && $OJ_UDP) {
|
||||
trigger_judge($sid);
|
||||
}
|
||||
echo "<script>history.go(-1);</script>";
|
||||
}
|
||||
|
||||
if(isset($_POST['update_solution'])){
|
||||
//require_once("../include/check_post_key.php");
|
||||
$sid=intval($_POST['sid']);
|
||||
$result=intval($_POST['result']);
|
||||
$time=intval($_POST['time']);
|
||||
$memory=intval($_POST['memory']);
|
||||
$sim=intval($_POST['sim']);
|
||||
$simid=intval($_POST['simid']);
|
||||
$pass_rate=floatval($_POST['pass_rate']);
|
||||
$judger=$_SESSION[$OJ_NAME.'_'.'user_id'];
|
||||
$sql="UPDATE solution SET result=?,time=?,memory=?,judgetime=NOW(),pass_rate=?,judger=? WHERE solution_id=? LIMIT 1";
|
||||
//echo $sql;
|
||||
pdo_query($sql,$result,$time,$memory,$pass_rate,$judger,$sid);
|
||||
|
||||
if ($sim) {
|
||||
$sql="insert into sim(s_id,sim_s_id,sim) values(?,?,?) on duplicate key update sim_s_id=?,sim=?";
|
||||
pdo_query($sql,$sid,$simid,$sim,$simid,$sim);
|
||||
}
|
||||
|
||||
}else if(isset($_POST['checkout'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$result=intval($_POST['result']);
|
||||
$sql="update solution SET result=?,time=0,memory=0,judgetime=NOW() WHERE solution_id=? and (result<2 or (result<4 and NOW()-judgetime>60)) LIMIT 1";
|
||||
$rows=pdo_query($sql,$result,$sid);
|
||||
if($rows>0)
|
||||
echo "1";
|
||||
else
|
||||
echo "0";
|
||||
}else if(isset($_POST['getpending'])){
|
||||
$max_running=intval($_POST['max_running']);
|
||||
if($OJ_REDIS && !isset($_SESSION[$OJ_NAME.'_'.'problem_start'])){
|
||||
$redis = new Redis();
|
||||
$redis->connect($OJ_REDISSERVER, $OJ_REDISPORT);
|
||||
if(isset($OJ_REDISAUTH)) $redis->auth($OJ_REDISAUTH);
|
||||
|
||||
for(;$max_running>0;$max_running--){
|
||||
$sid=$redis->rpop($OJ_REDISQNAME);
|
||||
if($sid>0){
|
||||
echo $sid."\n";
|
||||
}else{
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
$redis->close();
|
||||
}else{
|
||||
|
||||
$oj_lang_set=$_POST['oj_lang_set'];
|
||||
$langs=explode(",",$oj_lang_set);
|
||||
$oj_lang_set="";
|
||||
foreach($langs as $lang){
|
||||
$lang=intval($lang);
|
||||
if($oj_lang_set!="") $oj_lang_set.=",";
|
||||
$oj_lang_set.=$lang;
|
||||
}
|
||||
|
||||
$sql="SELECT solution_id FROM solution WHERE language in ($oj_lang_set)
|
||||
and (result<2 or (result<4 and NOW()-judgetime>60)) ";
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'problem_start'])){
|
||||
$start=intval($_SESSION[$OJ_NAME.'_'.'problem_start']);
|
||||
$sql.="and problem_id>=$start ";
|
||||
}
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'problem_end'])){
|
||||
$end=intval($_SESSION[$OJ_NAME.'_'.'problem_end']);
|
||||
$sql.="and problem_id<=$end ";
|
||||
}
|
||||
|
||||
$sql.=" ORDER BY result ASC,solution_id ASC limit $max_running";
|
||||
$result=pdo_query($sql);
|
||||
foreach($result as $row){
|
||||
echo $row['solution_id']."\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}else if(isset($_POST['getsolutioninfo'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$sql="select problem_id, user_id, language,contest_id from solution WHERE solution_id=?";
|
||||
$result=pdo_query($sql,$sid);
|
||||
if ( $row=$result[0]){
|
||||
echo $row['problem_id']."\n";
|
||||
echo $row['user_id']."\n";
|
||||
echo $row['language']."\n";
|
||||
echo intval($row['contest_id'])."\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else if(isset($_POST['getsolution'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$sql="SELECT source FROM source_code WHERE solution_id=? ";
|
||||
$result=pdo_query($sql,$sid);
|
||||
if ( $row=$result[0]){
|
||||
echo $row['source']."\n";
|
||||
}
|
||||
|
||||
|
||||
}else if(isset($_POST['getcustominput'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$sql="SELECT input_text FROM custominput WHERE solution_id=? ";
|
||||
$result=pdo_query($sql,$sid);
|
||||
if ( $row=$result[0]){
|
||||
echo $row['input_text']."\n";
|
||||
}
|
||||
|
||||
|
||||
}else if(isset($_POST['getprobleminfo'])){
|
||||
|
||||
$pid=intval($_POST['pid']);
|
||||
$sql="SELECT time_limit,memory_limit,spj FROM problem where problem_id=?";
|
||||
$result=pdo_query($sql,$pid );
|
||||
if ( $row=$result[0]){
|
||||
echo $row['time_limit']."\n";
|
||||
echo $row['memory_limit']."\n";
|
||||
echo $row['spj']."\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
}else if(isset($_POST['addceinfo'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$sql="DELETE FROM compileinfo WHERE solution_id=? ";
|
||||
pdo_query($sql,$sid);
|
||||
$ceinfo=$_POST['ceinfo'];
|
||||
$sql="INSERT INTO compileinfo VALUES(?,?)";
|
||||
pdo_query($sql,$sid,$ceinfo);
|
||||
|
||||
}else if(isset($_POST['addreinfo'])){
|
||||
|
||||
$sid=intval($_POST['sid']);
|
||||
$sql="DELETE FROM runtimeinfo WHERE solution_id=? ";
|
||||
pdo_query($sql,$sid);
|
||||
$reinfo=$_POST['reinfo'];
|
||||
$sql="INSERT INTO runtimeinfo VALUES(?,?)";
|
||||
pdo_query($sql,$sid,$reinfo);
|
||||
|
||||
}else if(isset($_POST['updateuser'])){
|
||||
|
||||
$user_id=$_POST['user_id'];
|
||||
$sql="UPDATE `users` SET `solved`=(SELECT count(DISTINCT `problem_id`) FROM `solution` WHERE `user_id`=? AND `result`=4) WHERE `user_id`=?";
|
||||
pdo_query($sql,$user_id,$user_id);
|
||||
// echo $sql;
|
||||
|
||||
$sql="UPDATE `users` SET `submit`=(SELECT count(*) FROM `solution` WHERE `user_id`=? and problem_id>0) WHERE `user_id`=?";
|
||||
pdo_query($sql,$user_id,$user_id);
|
||||
// echo $sql;
|
||||
|
||||
}else if(isset($_POST['updateproblem'])){
|
||||
$cid=intval($_POST['cid']);
|
||||
$pid=intval($_POST['pid']);
|
||||
if($cid>0){
|
||||
$sql="UPDATE `contest_problem` SET `c_accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=? AND `result`=4) WHERE `problem_id`=? and contest_id=?";
|
||||
pdo_query($sql,$pid,$cid,$pid,$cid);
|
||||
// $sql="UPDATE `contest_problem` SET `c_submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? and contest_id=?) WHERE `problem_id`=? and contest_id=?";
|
||||
// pdo_query($sql,$pid,$cid,$pid,$cid);
|
||||
}else{
|
||||
// $sql="UPDATE `problem` SET `submit`=(SELECT count(1) FROM `solution` WHERE `problem_id`=?) WHERE `problem_id`=?";
|
||||
//echo $sql;
|
||||
// pdo_query($sql,$pid,$pid);
|
||||
$sql="UPDATE `problem` SET `accepted`=(SELECT count(1) FROM `solution` WHERE `problem_id`=? AND `result`=4) WHERE `problem_id`=?";
|
||||
//echo $sql;
|
||||
pdo_query($sql,$pid,$pid);
|
||||
}
|
||||
|
||||
|
||||
}else if(isset($_POST['checklogin'])){
|
||||
echo "1";
|
||||
}else if(isset($_POST['gettestdatalist'])){
|
||||
|
||||
|
||||
$pid=intval($_POST['pid']);
|
||||
|
||||
if($OJ_SAE){
|
||||
//echo $OJ_DATA."$pid";
|
||||
|
||||
$store = new SaeStorage();
|
||||
$ret = $store->getList("data", "$pid" ,100,0);
|
||||
foreach($ret as $file) {
|
||||
if(!strstr($file,"sae-dir-tag")){
|
||||
$file=pathinfo($file);
|
||||
$file=$file['basename'];
|
||||
echo $file."\n";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
} else{
|
||||
|
||||
$dir=opendir($OJ_DATA."/$pid");
|
||||
while (($file = readdir($dir)) != ""){
|
||||
if(!is_dir($file)&&$file!="ac"){
|
||||
if(isset($_POST['time'])){
|
||||
echo filemtime($OJ_DATA."/$pid/".$file)."\n";
|
||||
}
|
||||
|
||||
$file=pathinfo($file);
|
||||
$file=$file['basename'];
|
||||
echo "$file\n";
|
||||
}
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
|
||||
}else if(isset($_POST['gettestdata'])){
|
||||
$file=$_POST['filename'];
|
||||
if($OJ_SAE){
|
||||
$store = new SaeStorage();
|
||||
if($store->fileExists("data",$file)){
|
||||
|
||||
echo $store->read("data",$file);
|
||||
}
|
||||
|
||||
}else{
|
||||
echo file_get_contents($OJ_DATA.'/'.$file);
|
||||
}
|
||||
|
||||
}else{
|
||||
?>
|
||||
|
||||
<form action='problem_judge.php' method=post>
|
||||
<b>HTTP Judge:</b><br />
|
||||
sid:<input type=text size=10 name="sid" value=1244><br />
|
||||
pid:<input type=text size=10 name="pid" value=1000><br />
|
||||
result:<input type=text size=10 name="result" value=4><br />
|
||||
time:<input type=text size=10 name="time" value=500><br />
|
||||
memory:<input type=text size=10 name="memory" value=1024><br />
|
||||
sim:<input type=text size=10 name="sim" value=100><br />
|
||||
simid:<input type=text size=10 name="simid" value=0><br />
|
||||
gettestdata:<input type=text size=10 name="filename" value="1000/test.in"><br />
|
||||
|
||||
<input type='hidden' name='gettestdatalist' value='do'>
|
||||
<input type=submit value='Judge'>
|
||||
</form>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
299
web/admin/problem_list.php
Normal file
299
web/admin/problem_list.php
Normal file
@@ -0,0 +1,299 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
require_once("../include/set_get_key.php");
|
||||
require_once('../include/const.inc.php');
|
||||
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])
|
||||
|| isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])
|
||||
|| isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])
|
||||
)){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Problem List</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_PROBLEM."-".$MSG_LIST?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
$sql = "SELECT COUNT('problem_id') AS ids FROM `problem`";
|
||||
$result = pdo_query($sql);
|
||||
$row = $result[0];
|
||||
|
||||
$ids = intval($row['ids']);
|
||||
|
||||
$idsperpage = 50;
|
||||
$pages = intval(ceil($ids/$idsperpage));
|
||||
|
||||
if(isset($_GET['page'])){ $page = intval($_GET['page']);}
|
||||
else{ $page = 1;}
|
||||
|
||||
$pagesperframe = 5;
|
||||
$frame = intval(ceil($page/$pagesperframe));
|
||||
|
||||
$spage = ($frame-1)*$pagesperframe+1;
|
||||
$epage = min($spage+$pagesperframe-1, $pages);
|
||||
|
||||
$sid = ($page-1)*$idsperpage;
|
||||
|
||||
$sql = "";
|
||||
if(isset($_GET['keyword']) && $_GET['keyword']!=""){
|
||||
$keyword = $_GET['keyword'];
|
||||
$keyword = "%$keyword%";
|
||||
$sql = "SELECT `problem_id`,`title`,`accepted`,`in_date`,`defunct`,`source`,`remote_oj`,`remote_id` FROM `problem` WHERE (problem_id LIKE ?) OR (title LIKE ?) OR (description LIKE ?) OR (source LIKE ?) OR (hint LIKE ?) ORDER BY `problem_id` ASC";
|
||||
$result = pdo_query($sql,$keyword,$keyword,$keyword,$keyword,$keyword);
|
||||
}else{
|
||||
$sql = "SELECT `problem_id`,`title`,`accepted`,`in_date`,`defunct`,`source`,`remote_oj`,`remote_id` FROM `problem` ORDER BY `problem_id` DESC LIMIT $sid, $idsperpage";
|
||||
$result = pdo_query($sql);
|
||||
}
|
||||
?>
|
||||
|
||||
<center>
|
||||
<form action=problem_list.php class="form-search form-inline">
|
||||
<input type="text" name=keyword value="<?php if(isset($_GET['keyword']))echo htmlentities($_GET['keyword'],ENT_QUOTES,"utf-8")?>" class="form-control search-query" placeholder="<?php echo $MSG_PROBLEM_ID.', '.$MSG_TITLE.', '.$MSG_Description.', '.$MSG_SOURCE?>">
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
/*
|
||||
echo "<select class='input-mini' onchange=\"location.href='problem_list.php?page='+this.value;\">";
|
||||
for ($i=1;$i<=$cnt;$i++){
|
||||
if ($i>1) echo ' ';
|
||||
if ($i==$page) echo "<option value='$i' selected>";
|
||||
else echo "<option value='$i'>";
|
||||
echo $i+9;
|
||||
echo "**</option>";
|
||||
}
|
||||
echo "</select>";
|
||||
*/
|
||||
?>
|
||||
|
||||
<center>
|
||||
<table width=100% border=1 style="text-align:center;">
|
||||
<form id='pform' method=post action=contest_add.php >
|
||||
<input type="hidden" name=keyword value="<?php if(isset($_GET['keyword']))echo htmlentities($_GET['keyword'],ENT_QUOTES,"utf-8")?>">
|
||||
<input type="hidden" name=hlist value="" >
|
||||
<tr>
|
||||
<td width=60px><?php echo $MSG_PROBLEM_ID?><input type=checkbox style='vertical-align:2px;' onchange='$("input[type=checkbox]").prop("checked", this.checked)'></td>
|
||||
<td><?php echo $MSG_TITLE?></td>
|
||||
<td><?php echo $MSG_AC?></td>
|
||||
<td><?php echo $MSG_SAVED_DATE?></td>
|
||||
<td><?php echo $MSG_SOURCE ?></td><!--分类-->
|
||||
<?php
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) ||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])){
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) ||isset($_SESSION[$OJ_NAME.'_'.'problem_editor']))
|
||||
echo "<td>$MSG_PROBLEM_STATUS</td><td>$MSG_DELETE</td>";
|
||||
echo "<td>$MSG_EDIT</td><td>$MSG_TESTDATA</td>";
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=2 style="height:40px;"><?php echo "$MSG_CHECK_TO"?></td>
|
||||
<td colspan=6>
|
||||
<input type=submit name='problem2contest' value='<?php echo $MSG_NEW_CONTEST?>'>
|
||||
<input type=submit name='enable' value='<?php echo $MSG_AVAILABLE ?>' onclick='$("form").attr("action","problem_df_change.php")'>
|
||||
<input type=submit name='disable' value='<?php echo $MSG_RESERVED ?>' onclick='$("form").attr("action","problem_df_change.php")'>
|
||||
<input type=submit name='plist' value='<?php echo $MSG_NEW_PROBLEM_LIST?>' onclick='$("form").attr("action","news_add_page.php")'>
|
||||
</td>
|
||||
</tr>
|
||||
<?php
|
||||
|
||||
foreach($result as $row){
|
||||
$view = "";
|
||||
echo "<tr>";
|
||||
echo "<td>".$row['problem_id']." <input type=checkbox style='vertical-align:2px;' name='pid[]' value='".$row['problem_id']."'></td>";
|
||||
echo "<td><a href='../problem.php?id=".$row['problem_id']."'>".$row['title']."</a>";
|
||||
if(!empty($row['remote_oj']))echo " <a href='".$row['source']."' target=_blank> ".$row['remote_oj'].$row['remote_id']."</a>";
|
||||
echo "</td>";
|
||||
echo "<td>".$row['accepted']."</td>";
|
||||
echo "<td>".$row['in_date']."</td>";
|
||||
echo "<td>";//分类
|
||||
|
||||
$category = array();
|
||||
$cate = explode(" ",$row['source']);
|
||||
foreach($cate as $cat){
|
||||
$cat=trim($cat);
|
||||
if(mb_ereg("^http",$cat)){
|
||||
echo "<a class='label' style='display: inline-block;' href=\"".htmlentities($cat,ENT_QUOTES,'utf-8').'" target="_blank">Remote</a>' ;
|
||||
}
|
||||
else array_push($category,trim($cat));
|
||||
}
|
||||
foreach ($category as $cat) {
|
||||
if(trim($cat)==""||trim($cat)==" ")
|
||||
continue;
|
||||
|
||||
$hash_num = hexdec(substr(md5($cat),0,7));
|
||||
$label_theme = $color_theme[$hash_num%count($color_theme)];
|
||||
|
||||
if ($label_theme=="") $label_theme = "default";
|
||||
$view .= "<a title='".htmlentities($cat,ENT_QUOTES,'UTF-8')."' class='label label-$label_theme' style='display: inline-block;' href='problem_list.php?keyword=".htmlentities(urlencode($cat),ENT_QUOTES,'UTF-8')."'>".mb_substr($cat,0,10,'utf8')."</a> ";
|
||||
}
|
||||
echo "<div class=\"show_tag_controled\" style=\"float: right; \">";
|
||||
echo $view;
|
||||
echo "</div></td>";
|
||||
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])){
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])){
|
||||
echo "<td><a href=problem_df_change.php?id=".$row['problem_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">".($row['defunct']=="N"?"<span titlc='click to reserve it' class=green>$MSG_AVAILABLE</span>":"<span class=red title='click to be available'>$MSG_RESERVED</span>")."</a><td>";
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$row['problem_id']]) ){
|
||||
?>
|
||||
<a href=# onclick='javascript:if(confirm("<?php echo $MSG_DELETE."[".htmlentities($row['title'],ENT_QUOTES,"UTF-8")?>] ? "))
|
||||
location.href="problem_del.php?id=<?php echo $row['problem_id']?>&getkey=<?php echo $_SESSION[$OJ_NAME.'_'.'getkey']?>"'>
|
||||
<?php echo $MSG_DELETE ?>
|
||||
</a>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'."p".$row['problem_id']]) ){
|
||||
echo "<td><a href=problem_edit.php?id=".$row['problem_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">$MSG_EDIT</a>";
|
||||
echo "<td><a href='javascript:phpfm(".$row['problem_id'].");'>$MSG_TEST_DATA</a>";
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td colspan=2 style="height:40px;"><?php echo "$MSG_CHECK_TO"?></td>
|
||||
<td colspan=6>
|
||||
<input type=submit name='problem2contest' value='<?php echo $MSG_NEW_CONTEST?>'>
|
||||
<input type=submit name='enable' value='<?php echo $MSG_AVAILABLE ?>' onclick='$("form").attr("action","problem_df_change.php")'>
|
||||
<input type=submit name='disable' value='<?php echo $MSG_RESERVED ?>' onclick='$("form").attr("action","problem_df_change.php")'>
|
||||
<input type=submit name='plist' value='<?php echo $MSG_NEW_PROBLEM_LIST?>' onclick='$("form").attr("action","news_add_page.php")'>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
</form>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<script src='../template/bs3/jquery.min.js' ></script>
|
||||
|
||||
<script>
|
||||
function phpfm(pid){
|
||||
//alert(pid);
|
||||
$.post("phpfm.php",{'frame':3,'pid':pid,'pass':''},function(data,status){
|
||||
if(status=="success"){
|
||||
document.location.href="phpfm.php?frame=3&pid="+pid;
|
||||
}
|
||||
});
|
||||
}
|
||||
function delPid(pid){
|
||||
|
||||
let plist=sessionStorage.getItem('plist');
|
||||
if(typeof(plist)=='undefined'||plist==null) plist="";
|
||||
let oldArray=plist.split(',');
|
||||
oldArray=oldArray.filter(onlyUnique);
|
||||
let index=oldArray.indexOf(pid);
|
||||
// console.log("remove:"+pid+" index:"+index);
|
||||
if(index>-1){
|
||||
oldArray.splice(index,1);
|
||||
}
|
||||
plist=oldArray.join();
|
||||
if(!!sessionStorage){
|
||||
sessionStorage.setItem('plist',plist);
|
||||
$("input[name=hlist]").attr("value",plist);
|
||||
// console.log(plist);
|
||||
}
|
||||
}
|
||||
function onlyUnique(value, index, array) {
|
||||
return array.indexOf(value) === index;
|
||||
}
|
||||
function addPid(pid){
|
||||
|
||||
let plist=sessionStorage.getItem('plist');
|
||||
if(typeof(plist)=='undefined'||plist==null) plist="";
|
||||
let oldArray=plist.split(',');
|
||||
//oldArray=oldArray.filter(onlyUnique);
|
||||
let index=oldArray.indexOf(pid);
|
||||
// console.log("add:"+pid);
|
||||
plist=oldArray.join();
|
||||
if(index<0){
|
||||
plist+=","+pid;
|
||||
}
|
||||
if(!!sessionStorage){
|
||||
sessionStorage.setItem('plist',plist);
|
||||
$("input[name=hlist]").attr("value",plist);
|
||||
|
||||
// console.log(plist);
|
||||
}
|
||||
}
|
||||
$(document).ready(function(){
|
||||
let plist=sessionStorage.getItem('plist');
|
||||
if(typeof(plist)=="undefined" || plist == null) plist="";
|
||||
let oldArray=plist.split(',');
|
||||
oldArray=oldArray.filter(onlyUnique);
|
||||
for(let i=0;i<oldArray.length;i++){
|
||||
if(oldArray[i]!="")
|
||||
$('input[value='+oldArray[i]+']').prop("checked",true);
|
||||
}
|
||||
$("input[name=hlist]").val(plist);
|
||||
|
||||
$('input[type=checkbox]').change(function(){
|
||||
|
||||
let plist=sessionStorage.getItem('plist');
|
||||
if(typeof(plist)=='undefined'||plist==null) plist="";
|
||||
let oldArray=plist.split(',');
|
||||
oldArray=oldArray.filter(onlyUnique);
|
||||
let pid=$(this).attr('value');
|
||||
let index=oldArray.indexOf(pid);
|
||||
// console.log("pid:"+pid);
|
||||
// console.log("before:"+plist);
|
||||
if(typeof(pid)=='undefiend'||pid==null ){
|
||||
// console.log("all");
|
||||
$('input[type=checkbox]').each(function(){
|
||||
let pid=parseInt($(this).val());
|
||||
if(pid>0){
|
||||
if($(this).prop('checked')){
|
||||
addPid(""+pid);
|
||||
}else{
|
||||
delPid(""+pid);
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}else{
|
||||
if($(this).prop('checked')){
|
||||
addPid(""+pid);
|
||||
}else{
|
||||
delPid(""+pid);
|
||||
}
|
||||
}
|
||||
// console.log("after:"+plist);
|
||||
// console.log(plist);
|
||||
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
if(!(isset($_GET['keyword']) && $_GET['keyword']!=""))
|
||||
{
|
||||
echo "<div style='display:inline;'>";
|
||||
echo "<nav class='center'>";
|
||||
echo "<ul class='pagination pagination-sm'>";
|
||||
echo "<li class='page-item'><a href='problem_list.php?page=".(strval(1))."'><<</a></li>";
|
||||
echo "<li class='page-item'><a href='problem_list.php?page=".($page==1?strval(1):strval($page-1))."'><</a></li>";
|
||||
for($i=$spage; $i<=$epage; $i++){
|
||||
echo "<li class='".($page==$i?"active ":"")."page-item'><a title='go to page' href='problem_list.php?page=".$i."'>".$i."</a></li>";
|
||||
}
|
||||
echo "<li class='page-item'><a href='problem_list.php?page=".($page==$pages?strval($page):strval($page+1))."'>></a></li>";
|
||||
echo "<li class='page-item'><a href='problem_list.php?page=".(strval($pages))."'>>></a></li>";
|
||||
echo "</ul>";
|
||||
echo "</nav>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
189
web/admin/ranklist_export.php
Normal file
189
web/admin/ranklist_export.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
$OJ_CACHE_SHARE=false;
|
||||
$cache_time=30;
|
||||
require_once('../include/cache_start.php');
|
||||
require_once('../include/db_info.inc.php');
|
||||
require_once("../include/my_func.inc.php");
|
||||
require_once('../include/setlang.php');
|
||||
require_once('../include/memcache.php');
|
||||
|
||||
if(!isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
$now = date('Y-m-d H:i', time());
|
||||
if(isset($OJ_NOIP_KEYWORD)&&$OJ_NOIP_KEYWORD){
|
||||
|
||||
$sql="select count(contest_id) from contest where start_time<'$now' and end_time>'$now' and title like '%$OJ_NOIP_KEYWORD%'";
|
||||
$row=pdo_query($sql);
|
||||
$cols=$row[0];
|
||||
//echo $sql;
|
||||
//echo $cols[0];
|
||||
if($cols[0]>0) {
|
||||
|
||||
$view_errors = "<h2> $MSG_NOIP_WARNING </h2>";
|
||||
require("../template/".$OJ_TEMPLATE."/error.php");
|
||||
exit(0);
|
||||
|
||||
}
|
||||
}
|
||||
$view_title= $MSG_RANKLIST;
|
||||
if(!isset($OJ_RANK_HIDDEN)) $OJ_RANK_HIDDEN="'admin','zhblue'";
|
||||
|
||||
$scope="";
|
||||
if(isset($_GET['scope']))
|
||||
$scope=$_GET['scope'];
|
||||
if($scope!=""&&$scope!='d'&&$scope!='w'&&$scope!='m')
|
||||
$scope='y';
|
||||
$where="";
|
||||
|
||||
if(isset($_GET['prefix'])){
|
||||
$prefix=$_GET['prefix'];
|
||||
$where="where user_id like ?";
|
||||
}else{
|
||||
$where="where user_id not in (".$OJ_RANK_HIDDEN.") and defunct='N' ";
|
||||
}
|
||||
$rank = 0;
|
||||
if(isset( $_GET ['start'] ))
|
||||
$rank = intval ( $_GET ['start'] );
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
$page_size=5000;
|
||||
//$rank = intval ( $_GET ['start'] );
|
||||
if ($rank < 0)
|
||||
$rank = 0;
|
||||
|
||||
$sql = "SELECT `user_id`,`nick`,`solved`,`submit` FROM `users` $where ORDER BY `solved` DESC,submit,reg_time LIMIT " . strval ( $rank ) . ",$page_size";
|
||||
|
||||
if($scope){
|
||||
$s="";
|
||||
switch ($scope){
|
||||
case 'd':
|
||||
$s=date('Y').'-'.date('m').'-'.date('d');
|
||||
break;
|
||||
case 'w':
|
||||
$monday=mktime(0, 0, 0, date("m"),date("d")-(date("w")+7)%8+1, date("Y")) ;
|
||||
//$monday->subDays(date('w'));
|
||||
$s= date('Y-m-d H:i', $monday);
|
||||
break;
|
||||
case 'm':
|
||||
$s=date('Y').'-'.date('m').'-01';
|
||||
;break;
|
||||
default :
|
||||
$s=date('Y').'-01-01';
|
||||
}
|
||||
//echo $s."<-------------------------";
|
||||
$sql="SELECT users.`user_id`,`nick`,s.`solved`,t.`submit` FROM `users`
|
||||
inner join
|
||||
(select count(distinct problem_id) solved ,user_id from solution
|
||||
where in_date>str_to_date('$s','%Y-%m-%d') and result=4
|
||||
group by user_id order by solved desc limit " . strval ( $rank ) . ",$page_size) s
|
||||
on users.user_id=s.user_id
|
||||
inner join
|
||||
(select count( problem_id) submit ,user_id from solution
|
||||
where in_date>str_to_date('$s','%Y-%m-%d')
|
||||
group by user_id order by submit desc ) t
|
||||
on users.user_id=t.user_id
|
||||
ORDER BY s.`solved` DESC,t.submit,reg_time LIMIT 0,50
|
||||
";
|
||||
// echo $sql;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['prefix'])){
|
||||
if(is_valid_user_name($_GET['prefix'])){
|
||||
$result = pdo_query($sql,$_GET['prefix']."%");
|
||||
}else{
|
||||
$view_errors = "<h2>invalid user name prefix</h2>";
|
||||
require("../template/".$OJ_TEMPLATE."/error.php");
|
||||
exit(0);
|
||||
}
|
||||
}else{
|
||||
$result = mysql_query_cache($sql) ;
|
||||
}
|
||||
if($result) $rows_cnt=count($result);
|
||||
else $rows_cnt=0;
|
||||
$view_rank=Array();
|
||||
$i=0;
|
||||
|
||||
|
||||
for ( $i=0;$i<$rows_cnt;$i++ ) {
|
||||
|
||||
$row=$result[$i];
|
||||
|
||||
$rank ++;
|
||||
|
||||
$view_rank[$i][0]= $rank;
|
||||
$view_rank[$i][1]= $row['user_id'];
|
||||
$view_rank[$i][2]= htmlentities ( $row['nick'] ,ENT_QUOTES,"UTF-8");
|
||||
$view_rank[$i][3]= $row['solved'];
|
||||
$view_rank[$i][4]= $row['submit'];
|
||||
|
||||
if ($row['submit'] == 0)
|
||||
$view_rank[$i][5]= "0.00%";
|
||||
else
|
||||
$view_rank[$i][5]= sprintf ( "%.02lf%%", 100 * $row['solved'] / $row['submit'] );
|
||||
|
||||
// $i++;
|
||||
}
|
||||
$exl_title = array($MSG_Number,$MSG_USER,$MSG_NICK,$MSG_SOVLED,$MSG_SUBMIT,$MSG_RATIO);
|
||||
$exl_value =[];
|
||||
//循环数据生成二维数组
|
||||
$exl_value=$view_rank;
|
||||
//foreach ($list as $k => $y){
|
||||
// $exl_value[] = array($rank,$row['user_id'], htmlentities ( $row['nick'] ,ENT_QUOTES,"UTF-8"),$row['solved'],$row['submit'],$row['submit'] );
|
||||
// }
|
||||
$file_name = $MSG_Number.'_'.time().'.csv';
|
||||
$excel = new export_class();
|
||||
$excel-> exportToExcel($file_name,$exl_title,$exl_value);
|
||||
$sql = "SELECT count(1) as `mycount` FROM `users`";
|
||||
// $result = mysql_query ( $sql );
|
||||
// require("../include/memcache.php");
|
||||
$result = mysql_query_cache($sql);
|
||||
$row=$result[0];
|
||||
$view_total=$row['mycount'];
|
||||
|
||||
class export_class
|
||||
{
|
||||
|
||||
/**
|
||||
* 导出excel csv格式
|
||||
* @param string $filename 文件名
|
||||
* @param array $tileArray 表头标题列表 格式一维数组 [标题1,标题2,标题3,标题n]
|
||||
* @param array $dataArray 数据列表数组 格式二维数组 [[1,2,3,n],[1,2,3,n]]
|
||||
*/
|
||||
public function exportToExcel($filename='file', $tileArray=[], $dataArray=[]){
|
||||
ini_set('memory_limit','512M');
|
||||
ini_set('max_execution_time',0);
|
||||
ob_end_clean();
|
||||
ob_start();
|
||||
header("Content-Type: text/csv");
|
||||
header("Content-Disposition:filename=".$filename);
|
||||
$fp=fopen('php://output','w');
|
||||
fwrite($fp, chr(0xEF).chr(0xBB).chr(0xBF));//转码 防止乱码(比如微信昵称(乱七八糟的))
|
||||
fputcsv($fp,$tileArray);
|
||||
$index = 0;
|
||||
foreach ($dataArray as $item) {
|
||||
if($index==1000){
|
||||
$index=0;
|
||||
ob_flush();
|
||||
flush();
|
||||
}
|
||||
$index++;
|
||||
fputcsv($fp,$item);
|
||||
}
|
||||
|
||||
ob_flush();
|
||||
flush();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
||||
146
web/admin/rejudge.php
Normal file
146
web/admin/rejudge.php
Normal file
@@ -0,0 +1,146 @@
|
||||
<?php require("admin-header.php");
|
||||
require_once("../include/const.inc.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
if (isset($_POST['rjpid'])){
|
||||
$rjpid=intval($_POST['rjpid']);
|
||||
if($rjpid == 0) {
|
||||
echo "Rejudge Problem ID should not equal to 0";
|
||||
exit(1);
|
||||
}
|
||||
$sql="UPDATE `solution` SET `result`=1,pass_rate=0 WHERE `problem_id`=? and problem_id>0";
|
||||
pdo_query($sql,$rjpid) ;
|
||||
$sql="UPDATE `problem` SET `accepted`=0 WHERE `problem_id`=? and problem_id>0";
|
||||
pdo_query($sql,$rjpid) ;
|
||||
$sql="delete from `sim` WHERE `s_id` in (select solution_id from solution where `problem_id`=?)";
|
||||
pdo_query($sql,$rjpid) ;
|
||||
$url="../status.php?problem_id=".$rjpid;
|
||||
echo "Rejudged Problem ".$rjpid;
|
||||
echo "<script>location.href='$url';</script>";
|
||||
}else if (isset($_POST['rjsid'])){
|
||||
$rjsid=intval($_POST['rjsid']);
|
||||
$sql="delete from `sim` WHERE `s_id`=?";
|
||||
pdo_query($sql,$rjsid) ;
|
||||
$sql="UPDATE `solution` SET `result`=1,pass_rate=0 WHERE `solution_id`=? and problem_id>0" ;
|
||||
pdo_query($sql,$rjsid) ;
|
||||
$sql="select contest_id from `solution` WHERE `solution_id`=? " ;
|
||||
$data=pdo_query($sql,$rjsid);
|
||||
$row=$data[0];
|
||||
$cid=intval($row[0]);
|
||||
if ($cid>0)
|
||||
$url="../status.php?cid=".$cid."&top=".($rjsid+1);
|
||||
else
|
||||
$url="../status.php?top=".($rjsid+1);
|
||||
echo "Rejudged Runid ".$rjsid;
|
||||
echo "<script>location.href='$url';</script>";
|
||||
}else if (isset($_POST['result'])){
|
||||
$result=intval($_POST['result']);
|
||||
$to=intval($_POST['to']);
|
||||
$sql="UPDATE `solution` SET `result`=$to,pass_rate=0 WHERE `result`=? and problem_id>0" ;
|
||||
pdo_query($sql,$result) ;
|
||||
$url="../status.php?jresult=$to";
|
||||
echo "<script>location.href='$url';</script>";
|
||||
}else if (isset($_POST['rjcid'])){
|
||||
$rjcid=intval($_POST['rjcid']);
|
||||
if( $rjcid>0 ){
|
||||
if(isset($_POST['pid'])){
|
||||
$pid=intval($_POST['pid']);
|
||||
$sql="UPDATE `solution` SET `result`=1,pass_rate=0 WHERE `contest_id`=? and num=?";
|
||||
pdo_query($sql,$rjcid,$pid) ;
|
||||
}else{
|
||||
$sql="UPDATE `solution` SET `result`=1,pass_rate=0 WHERE `contest_id`=? and problem_id>0";
|
||||
pdo_query($sql,$rjcid) ;
|
||||
}
|
||||
$url="../status.php?cid=".($rjcid);
|
||||
echo "Rejudged Contest id :".$rjcid;
|
||||
echo "<script>location.href='$url';</script>";
|
||||
}else{
|
||||
echo "<script>location.href='rejudge.php';</script>";
|
||||
}
|
||||
}
|
||||
echo str_repeat(" ",4096);
|
||||
flush();
|
||||
if($OJ_REDIS){
|
||||
$redis = new Redis();
|
||||
$redis->connect($OJ_REDISSERVER, $OJ_REDISPORT);
|
||||
if(isset($OJ_REDISAUTH)) $redis->auth($OJ_REDISAUTH);
|
||||
$sql="select solution_id from solution where result=1,pass_rate=0 and problem_id>0";
|
||||
$result=pdo_query($sql);
|
||||
foreach($result as $row){
|
||||
echo $row['solution_id']."\n";
|
||||
$redis->lpush($OJ_REDISQNAME,$row['solution_id']);
|
||||
}
|
||||
$redis->close();
|
||||
}
|
||||
if (isset($OJ_UDP) && $OJ_UDP) {
|
||||
trigger_judge();
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<b>Rejudge</b>
|
||||
<ol>
|
||||
<li><?php echo $MSG_PROBLEM?>
|
||||
<form action='rejudge.php' method=post>
|
||||
<input type=input name='rjpid' placeholder="1001"> <input type='hidden' name='do' value='do'>
|
||||
<input type=submit value=submit>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
<li><?php echo $MSG_SUBMIT?>
|
||||
<form action='rejudge.php' method=post>
|
||||
<input type=input name='rjsid' placeholder="1002"> <input type='hidden' name='do' value='do'>
|
||||
<input type=hidden name="postkey" value="<?php echo $_SESSION[$OJ_NAME.'_'.'postkey']?>">
|
||||
<input type=submit value=submit>
|
||||
</form>
|
||||
<li><?php echo "$MSG_Manual"?>
|
||||
<form action='rejudge.php' method=post>
|
||||
<select name='result'>
|
||||
<?php
|
||||
for($i=0;$i<4;$i++){
|
||||
echo "<option value='$i' ".($i==3?"selected":"").">".$jresult[$i]."</option>\n";
|
||||
}
|
||||
for($i=16;$i<17;$i++){
|
||||
echo "<option value='$i' >".$jresult[$i]."</option>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
<input type='hidden' name='do' value='do'> - >
|
||||
<select name='to'>
|
||||
<?php
|
||||
$i=1;
|
||||
echo "<option value='$i'>".$jresult[$i]."</option>\n";
|
||||
for($i=4;$i<18;$i++){
|
||||
echo "<option value='$i' ".($i==6?"selected":"").">".$jresult[$i]."</option>\n";
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
<input type=hidden name="postkey" value="<?php echo $_SESSION[$OJ_NAME.'_'.'postkey']?>">
|
||||
<input type=submit value=submit>
|
||||
</form>
|
||||
<li><?php echo $MSG_CONTEST?>
|
||||
<form action='rejudge.php' method=post>
|
||||
<input type=input name='rjcid' placeholder="1003" value='1003' > <input type='hidden' name='do' value='do'>
|
||||
<input type=hidden name="postkey" value="<?php echo $_SESSION[$OJ_NAME.'_'.'postkey']?>">
|
||||
<input type=submit value=submit>
|
||||
</form>
|
||||
<form action='rejudge.php' method=post>
|
||||
<input type=input name='rjcid' placeholder="1004">
|
||||
<select name=pid >
|
||||
<?php
|
||||
foreach($PID as $i=>$id){
|
||||
echo "<option value='$i'>$id</option>";
|
||||
}
|
||||
|
||||
?>
|
||||
</select>
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<input type=hidden name="postkey" value="<?php echo $_SESSION[$OJ_NAME.'_'.'postkey']?>">
|
||||
<input type=submit value=submit>
|
||||
</form>
|
||||
</div>
|
||||
49
web/admin/setmsg.php
Normal file
49
web/admin/setmsg.php
Normal file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
require_once("admin-header.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "<hr>";
|
||||
echo "<center><h3>".$MSG_NEWS."-".$MSG_SETMESSAGE."</h3></center>";
|
||||
$msgfile=$OJ_SAE?"saestor://web/msg.txt":"msg/$domain.txt";
|
||||
if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
mkdir("msg");
|
||||
$fp = fopen($msgfile,"w");
|
||||
$msg = $_POST['msg'];
|
||||
|
||||
$msg = str_replace("<p>", "", $msg);
|
||||
$msg = str_replace("</p>", "<br />", $msg);
|
||||
$msg = str_replace(",", ",", $msg);
|
||||
|
||||
if(false){
|
||||
$title = stripslashes($title);
|
||||
}
|
||||
|
||||
$msg = RemoveXSS($msg);
|
||||
fputs($fp,$msg);
|
||||
fclose($fp);
|
||||
echo "<center><h4 class='text-danger'>Message Updated At ".date('Y-m-d h:i:s')."</h4></center>";
|
||||
}
|
||||
if(file_exists($msgfile))
|
||||
$msg = file_get_contents($msgfile);
|
||||
|
||||
include("kindeditor.php");
|
||||
?>
|
||||
|
||||
<div class="container">
|
||||
<form action='setmsg.php' method='post'>
|
||||
<textarea name='msg' class="kindeditor" ><?php echo $msg?></textarea><br>
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<center><input type='submit' value='<?php echo $MSG_SAVE?>'></center>
|
||||
<!-- <br>
|
||||
如果升级无法修改公告,发送“修改公告”到微信公众号onlinejudge看解决方案。<br>
|
||||
if this does not work, try run "sudo chown -R www-data /home/judge/src/web " in terminal.
|
||||
-->
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php require_once('../oj-footer.php'); ?>
|
||||
150
web/admin/solution_statistics.php
Normal file
150
web/admin/solution_statistics.php
Normal file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
require_once("../include/set_get_key.php");
|
||||
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Solution Statistics</title>
|
||||
<hr>
|
||||
<center><h3><?php echo "Report:"?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
$cid=intval($_GET['cid']);
|
||||
if(isset($_POST['pids'])||$cid>0){
|
||||
|
||||
$user_ida = explode("\n", trim($_POST['ulist']));
|
||||
$user_ida = array_unique($user_ida);
|
||||
$user_ids="";
|
||||
if(count($user_ida)>0 && strlen($user_ida[0])>0){
|
||||
$len=count($user_ida);
|
||||
for($i=0; $i<$len; $i++){
|
||||
if($user_ids) $user_ids.=",";
|
||||
$user_ids.="?";
|
||||
$user_ida[$i]=trim($user_ida[$i]);
|
||||
}
|
||||
}
|
||||
//echo implode(",",$user_ida),"<br>";
|
||||
|
||||
$sql="select user_id,nick ";
|
||||
|
||||
if($cid>0){
|
||||
$pida=array();
|
||||
$result=pdo_query("select problem_id from contest_problem where contest_id=? order by num",$cid);
|
||||
foreach($result as $row){
|
||||
array_push($pida,$row['problem_id']);
|
||||
}
|
||||
|
||||
}else{
|
||||
$pida=array_unique(explode(',',$_POST['pids']));
|
||||
$len=count($pida);
|
||||
for($i=0;$i<$len;$i++){
|
||||
$pida[$i]=intval($pida[$i]);
|
||||
}
|
||||
}
|
||||
|
||||
$pida=array_unique($pida);
|
||||
|
||||
foreach($pida as $pid){
|
||||
$sql.=" ,min(case problem_id when $pid then result else 15 end) P$pid";
|
||||
}
|
||||
//$user_ids=implode("','",$user_ida);
|
||||
if(isset($_GET['cid'])){
|
||||
$sql.=" from solution where contest_id=? group by user_id,nick order by user_id";
|
||||
$result = pdo_query($sql,$cid);
|
||||
|
||||
}else{
|
||||
$sql.=" from solution where user_id in ($user_ids) group by user_id,nick ";
|
||||
$result = pdo_query($sql,$user_ida);
|
||||
}
|
||||
// echo $sql;
|
||||
?>
|
||||
|
||||
|
||||
<center>
|
||||
<table width=100% border=1 style="text-align:center;">
|
||||
<tr>
|
||||
<?php
|
||||
echo "<td>USER_ID</td>";
|
||||
echo "<td>NICK</td>";
|
||||
foreach($pida as $pid){
|
||||
echo "<td class='pid' value='$pid'>P".$pid;
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
// var_dump($result);
|
||||
foreach($result as $row){
|
||||
echo "<tr>";
|
||||
echo "<td>".$row['user_id']."</td>";
|
||||
echo "<td>".$row['nick']."</td>";
|
||||
foreach($pida as $pid){
|
||||
echo "<td>";
|
||||
if($row["P$pid"]==4) echo "<span class='label label-success label-sm' >AC</span>";
|
||||
else if($row["P$pid"]==15) echo " ";
|
||||
else echo "<span class='label label-danger label-sm' >WA</span>";
|
||||
echo "</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<a href="javascript:history.go(-1);" >Back</a>
|
||||
</center>
|
||||
<script>
|
||||
function showTitles(){
|
||||
$('.pid').each(function(){
|
||||
let v=$(this).attr('value');
|
||||
let title=$.ajax({url:"ajax.php",method:"post",data:{"pid":v,"m":"problem_get_title"},async:false}).responseText;
|
||||
let html=(v)+"<br><a href='../problem.php?id="+v+"' target='_blank'>"+title+"</a>\n";
|
||||
$(this).html(html);
|
||||
$(this).mouseover=null;
|
||||
});
|
||||
|
||||
}
|
||||
$(document).ready(function(){
|
||||
showTitles();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
<?php
|
||||
}else{
|
||||
|
||||
?>
|
||||
|
||||
<center>
|
||||
<form action=solution_statistics.php method='post' class="form-search form-inline">
|
||||
<input type="text" name=pids class="form-control" placeholder="1000,1001" size=128 >
|
||||
|
||||
<textarea name='ulist' rows='10' style='width:100%;' placeholder='user1<?php echo "\n"?>user2<?php echo "\n"?>user3<?php echo "\n"?>
|
||||
'> </textarea>
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
</form>
|
||||
</center>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<form action=solution_statistics.php method='get' class="form-search form-inline">
|
||||
<select name="cid" >
|
||||
<?php
|
||||
$sql="select * from contest order by contest_id desc limit 50 ";
|
||||
$result=pdo_query($sql);
|
||||
foreach($result as $row){
|
||||
echo "<option value='".$row['contest_id']."'";
|
||||
if($row['contest_id']==$cid) echo " selected ";
|
||||
echo ">".$row['title']."</option>";
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
</form>
|
||||
30
web/admin/source_give.php
Normal file
30
web/admin/source_give.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php require_once("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
$from=$_POST['from'];
|
||||
$to=$_POST['to'];
|
||||
$start=intval($_POST['start']);
|
||||
$end=intval($_POST['end']);
|
||||
$sql="update `solution` set `user_id`=? where `user_id`=? and problem_id>=? and problem_id<=? and result=4";
|
||||
//echo $sql;
|
||||
echo pdo_query($sql,$to,$from,$start,$end)." source file given!";
|
||||
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<form action='source_give.php' method=post>
|
||||
<b>Give source:</b><br />
|
||||
From:<input type=text size=10 name="from" value="zhblue"><br />
|
||||
To:<input type=text size=10 name="to" value="standard"><br />
|
||||
start pid:<input type=text size=10 name="start"><br />
|
||||
end pid:<input type=text size=10 name="end"><br />
|
||||
<input type='hidden' name='do' value='do'>
|
||||
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value='GiveMySourceToHim'>
|
||||
</form>
|
||||
</div>
|
||||
103
web/admin/suspect_list.php
Normal file
103
web/admin/suspect_list.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
|
||||
//if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])|| isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) {
|
||||
// echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
// exit(1);
|
||||
//}
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Suspect List</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_IP_VERIFICATION?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
require_once("../include/set_get_key.php");
|
||||
|
||||
$contest_id = intval($_GET['cid']);
|
||||
|
||||
$sql = "select * from (select count(distinct user_id) c,ip from solution where contest_id=? group by ip) suspect inner join (select distinct ip, user_id, in_date from solution where contest_id=? ) u on suspect.ip=u.ip and suspect.c>1 order by c desc, u.ip, in_date, user_id";
|
||||
|
||||
$result = pdo_query($sql,$contest_id,$contest_id);
|
||||
?>
|
||||
|
||||
<div>
|
||||
<center>
|
||||
<?php echo $MSG_CONTEST_SUSPECT1?>
|
||||
<table width=90% border=1 style="text-align:center;">
|
||||
<tr>
|
||||
<td>IP address</td>
|
||||
<td colspan=2>Used ID</td>
|
||||
<td>Time</td>
|
||||
<td>IP address count</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
foreach ($result as $row) {
|
||||
echo "<tr>";
|
||||
echo "<td>".$row['ip']."</td>";
|
||||
echo "<td>".$row['user_id']."</td>";
|
||||
echo "<td>";
|
||||
echo "<a href='../userinfo.php?user=".$row['user_id']."'><sub>".$MSG_USERINFO."</sub></a> <sub>/</sub> ";
|
||||
echo "<a href='../status.php?cid=$contest_id&user_id=".$row['user_id']."'><sub>".$MSG_CONTEST." ".$MSG_SUBMIT."</sub></a>";
|
||||
echo "</td>";
|
||||
echo "<td>".$row['in_date'];
|
||||
echo "<td>".$row['c']."</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
|
||||
</table>
|
||||
</center>
|
||||
</div>
|
||||
|
||||
<br><br>
|
||||
|
||||
<?php
|
||||
$start = pdo_query("select start_time from contest where contest_id=?",$contest_id)[0][0];
|
||||
$end = pdo_query("select end_time from contest where contest_id=?",$contest_id)[0][0];
|
||||
$sql = "select * from (select count(distinct ip) c,user_id from loginlog where time>=? and time<=? group by user_id) suspect inner join (select distinct user_id from solution where contest_id=? ) u on suspect.user_id=u.user_id and suspect.c>1 inner join (select distinct ip, user_id, time from loginlog where time>=? and time<=? ) ips on ips.user_id=u.user_id order by c desc, u.user_id, ips.time, ip";
|
||||
$result = pdo_query($sql,$start,$end,$contest_id,$start,$end);
|
||||
?>
|
||||
|
||||
<div>
|
||||
<center>
|
||||
<?php echo $MSG_CONTEST_SUSPECT2?>
|
||||
<table width=90% border=1 style="text-align:center;">
|
||||
<tr>
|
||||
<td colspan=2>User ID</td>
|
||||
<td>Used IP address</td>
|
||||
<td>Time</td>
|
||||
<td>IP address count</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
foreach ($result as $row) {
|
||||
echo "<tr>";
|
||||
echo "<td>".$row['user_id']."</td>";
|
||||
echo "<td>";
|
||||
echo "<a href='../userinfo.php?user=".$row['user_id']."'><sub>".$MSG_USERINFO."</sub></a> <sub>/</sub> ";
|
||||
echo "<a href='../status.php?cid=$contest_id&user_id=".$row['user_id']."'><sub>".$MSG_CONTEST." ".$MSG_SUBMIT."</sub></a>";
|
||||
echo "</td>";
|
||||
echo "<td>".$row['ip'];
|
||||
echo "<td>".$row['time'];
|
||||
echo "<td>".$row['c'];
|
||||
echo "</tr>";
|
||||
}
|
||||
?>
|
||||
|
||||
</table>
|
||||
</center>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require("../oj-footer.php");
|
||||
?>
|
||||
77
web/admin/team_generate.php
Normal file
77
web/admin/team_generate.php
Normal file
@@ -0,0 +1,77 @@
|
||||
<?php require("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php if(isset($_POST['prefix'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
$prefix=$_POST['prefix'];
|
||||
require_once("../include/my_func.inc.php");
|
||||
if (!is_valid_user_name($prefix)){
|
||||
echo "Prefix is not valid.";
|
||||
exit(0);
|
||||
}
|
||||
$teamnumber=intval($_POST['teamnumber']);
|
||||
$pieces = explode("\n", trim($_POST['ulist']));
|
||||
|
||||
if ($teamnumber>0){
|
||||
echo "<table border=1>";
|
||||
echo "<tr><td colspan=3>Copy these accounts to distribute</td></tr>";
|
||||
echo "<tr><td>team_name<td>login_id</td><td>password</td></tr>";
|
||||
$max_length=20;
|
||||
for($i=1;$i<=$teamnumber;$i++){
|
||||
|
||||
$user_id=$prefix.($i<10?('0'.$i):$i);
|
||||
$password=strtoupper(substr(MD5($user_id.rand(0,9999999)),0,10));
|
||||
if(isset($pieces[$i-1]))
|
||||
$nick=$pieces[$i-1];
|
||||
else
|
||||
$nick="your_own_nick";
|
||||
if($teamnumber==1) $user_id=$prefix;
|
||||
|
||||
echo "<tr><td>$nick<td>$user_id</td><td>$password</td></tr>";
|
||||
|
||||
$password=pwGen($password);
|
||||
$email="your_own_email@internet";
|
||||
|
||||
$school="your_own_school";
|
||||
$ip = ($_SERVER['REMOTE_ADDR']);
|
||||
if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ){
|
||||
$REMOTE_ADDR = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
$tmp_ip=explode(',',$REMOTE_ADDR);
|
||||
$ip =(htmlentities($tmp_ip[0],ENT_QUOTES,"UTF-8"));
|
||||
}
|
||||
|
||||
if(mb_strlen($nick,'utf-8')>20){
|
||||
$new_len=mb_strlen($nick,'utf-8');
|
||||
if($new_len>$max_length){
|
||||
$max_length=$new_len;
|
||||
$longer="ALTER TABLE `users` MODIFY COLUMN `nick` varchar($max_length) NULL DEFAULT '' ";
|
||||
pdo_query($longer);
|
||||
}
|
||||
}
|
||||
if( $user_id == "admin" ) continue;
|
||||
$sql="INSERT INTO `users`("."`user_id`,`email`,`ip`,`accesstime`,`password`,`reg_time`,`nick`,`school`)".
|
||||
"VALUES(?,?,?,NOW(),?,NOW(),?,?)on DUPLICATE KEY UPDATE `email`=?,`ip`=?,`accesstime`=NOW(),`password`=?,`reg_time`=now(),nick=?,`school`=?";
|
||||
pdo_query($sql,$user_id,$email,$ip,$password,$nick,$school,$email,$ip,$password,$nick,$school) ;
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<b>TeamGenerator:</b>
|
||||
|
||||
<form action='team_generate.php' method=post>
|
||||
Prefix:<input type='test' name='prefix' value='team' placeholder="Team"><br>
|
||||
Generate<input class="input-mini" type=input name='teamnumber' value=5 size=3 >Teams.<br>
|
||||
Users:<textarea name="ulist" rows="12" cols="40" placeholder="Preset nicknames of the teams. One name per line."></textarea>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value=Generate><br>
|
||||
</form>
|
||||
<span style="color:red;font-weight:bold">以相同的前缀生成账号,将覆盖昵称和密码,请谨慎操作!</span>
|
||||
|
||||
</div>
|
||||
121
web/admin/team_generate2.php
Normal file
121
web/admin/team_generate2.php
Normal file
@@ -0,0 +1,121 @@
|
||||
<?php require("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'contest_creator']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php
|
||||
|
||||
if(isset($_POST['idlist']) && isset($_POST['pwdlist']) && isset($_POST['nicklist']))
|
||||
{
|
||||
require_once("../include/check_post_key.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
|
||||
$idPieces = explode("\n", trim($_POST['idlist']));
|
||||
$pwdPieces = explode("\n", trim($_POST['pwdlist']));
|
||||
$nickPieces = explode("\n", trim($_POST['nicklist']));
|
||||
|
||||
$teamnumber=count($idPieces);
|
||||
|
||||
if($teamnumber==count($pwdPieces) && $teamnumber==count($nickPieces))
|
||||
{
|
||||
$ok=true;
|
||||
for($i=0;$i<$teamnumber;$i++)
|
||||
{
|
||||
$idPieces[$i]=trim($idPieces[$i]);
|
||||
$pwdPieces[$i]=trim($pwdPieces[$i]);
|
||||
$nickPieces[$i]=trim($nickPieces[$i]);
|
||||
|
||||
if(strlen($idPieces[$i])==0)
|
||||
{
|
||||
echo "<h3>one empty line existed in user id field. all of the users is not inserted.</h3>";
|
||||
$ok=false;
|
||||
}
|
||||
if(strlen($pwdPieces[$i])==0)
|
||||
{
|
||||
echo "<h3>one empty line existed in password field. all of the users is not inserted.</h3>";
|
||||
$ok=false;
|
||||
}
|
||||
if(strlen($nickPieces[$i])==0)
|
||||
{
|
||||
echo "<h3>one empty line existed in nickname field. all of the users is not inserted.</h3>";
|
||||
$ok=false;
|
||||
}
|
||||
if (!is_valid_user_name($idPieces[$i])){
|
||||
echo "<h3>user id \"".$idPieces[$i]."\" is not valid. all of the users is not inserted.</h3>";
|
||||
$ok=false;
|
||||
}
|
||||
}
|
||||
|
||||
if($ok)
|
||||
{
|
||||
echo "<table border=1>";
|
||||
echo "<tr><td colspan=3>Copy these accounts to distribute</td></tr>";
|
||||
echo "<tr><td>team_name<td>login_id</td><td>password</td></tr>";
|
||||
|
||||
$max_length=20;
|
||||
|
||||
for($i=0;$i<$teamnumber;$i++){
|
||||
$user_id=$idPieces[$i];
|
||||
$nick=$nickPieces[$i];
|
||||
|
||||
echo "<tr><td>$nick<td>$user_id</td><td>$pwdPieces[$i]</td></tr>";
|
||||
|
||||
$password=pwGen($pwdPieces[$i]);
|
||||
|
||||
$email="your_own_email@internet";
|
||||
$school="your_own_school";
|
||||
|
||||
$ip = ($_SERVER['REMOTE_ADDR']);
|
||||
if( !empty( $_SERVER['HTTP_X_FORWARDED_FOR'] ) ){
|
||||
$REMOTE_ADDR = $_SERVER['HTTP_X_FORWARDED_FOR'];
|
||||
$tmp_ip=explode(',',$REMOTE_ADDR);
|
||||
$ip =(htmlentities($tmp_ip[0],ENT_QUOTES,"UTF-8"));
|
||||
}
|
||||
if(mb_strlen($nick,'utf-8')>20){
|
||||
$new_len=mb_strlen($nick,'utf-8');
|
||||
if($new_len>$max_length){
|
||||
$max_length=$new_len;
|
||||
$longer="ALTER TABLE `users` MODIFY COLUMN `nick` varchar($max_length) NULL DEFAULT '' ";
|
||||
pdo_query($longer);
|
||||
}
|
||||
}
|
||||
if( $user_id == "admin" ) continue;
|
||||
$sql="INSERT INTO `users`("."`user_id`,`email`,`ip`,`accesstime`,`password`,`reg_time`,`nick`,`school`)".
|
||||
"VALUES(?,?,?,NOW(),?,NOW(),?,?)on DUPLICATE KEY UPDATE `email`=?,`ip`=?,`accesstime`=NOW(),`password`=?,`reg_time`=now(),nick=?,`school`=?";
|
||||
pdo_query($sql,$user_id,$email,$ip,$password,$nick,$school,$email,$ip,$password,$nick,$school) ;
|
||||
}
|
||||
}
|
||||
|
||||
echo "</table><br/>";
|
||||
|
||||
}else{
|
||||
echo "<h3>sorry,the sum of user id is not equal to the sum of Password or Nickname</h3>";
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
<div class="container">
|
||||
<b>TeamGenerator2:</b>
|
||||
<p>the account will be replaced if Login ID exists.</p>
|
||||
<form action='team_generate2.php' method=post>
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
Login ID:<textarea name="idlist" rows="12" cols="40" placeholder="Preset ID of the teams. One ID per line."></textarea>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
Password:<textarea name="pwdlist" rows="12" cols="40" placeholder="Preset password of the teams. One password per line."></textarea>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
Nickname:<textarea name="nicklist" rows="12" cols="40" placeholder="Preset nicknames of the teams. One name per line."></textarea>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<br/>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type=submit value=Generate><br>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
253
web/admin/update_db.php
Normal file
253
web/admin/update_db.php
Normal file
@@ -0,0 +1,253 @@
|
||||
<?php require("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}?>
|
||||
<?php $tsql=Array();
|
||||
$csql=Array();
|
||||
$tsql[0]="use ".$DB_NAME.";";
|
||||
$csql[0]="
|
||||
CREATE TABLE $DB_NAME.`topic` (
|
||||
`tid` int(11) NOT NULL auto_increment,
|
||||
`title` varbinary(60) NOT NULL,
|
||||
`status` int(2) NOT NULL default '0',
|
||||
`top_level` int(2) NOT NULL default '0',
|
||||
`cid` int(11) default NULL,
|
||||
`pid` int(11) NOT NULL,
|
||||
`author_id` varchar(20) NOT NULL,
|
||||
PRIMARY KEY (`tid`),
|
||||
KEY `cid` (`cid`,`pid`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
|
||||
";
|
||||
$tsql[1]="select 1 from $DB_NAME.reply limit 1";
|
||||
$csql[1]="
|
||||
CREATE TABLE $DB_NAME.`reply` (
|
||||
`rid` int(11) NOT NULL auto_increment,
|
||||
`author_id` varchar(20) NOT NULL,
|
||||
`time` datetime NOT NULL default '2000-01-01 00:00:01',
|
||||
`content` text NOT NULL,
|
||||
`topic_id` int(11) NOT NULL,
|
||||
`status` int(2) NOT NULL default '0',
|
||||
`ip` varchar(30) NOT NULL,
|
||||
PRIMARY KEY (`rid`),
|
||||
KEY `author_id` (`author_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1 ;
|
||||
";
|
||||
$tsql[2]="
|
||||
ALTER TABLE $DB_NAME.`problem` DROP COLUMN `sample_Program`,
|
||||
DROP COLUMN `ratio`,
|
||||
DROP COLUMN `error`,
|
||||
DROP COLUMN `difficulty`,
|
||||
DROP COLUMN `submit_user`,
|
||||
DROP COLUMN `case_time_limit`;
|
||||
";
|
||||
$csql[2]="";
|
||||
$tsql[3]="select 1 from $DB_NAME.sim limit 1";
|
||||
$csql[3]="
|
||||
CREATE TABLE $DB_NAME.`sim` (
|
||||
`s_id` int(11) NOT NULL,
|
||||
`sim_s_id` int(11) NULL,
|
||||
`sim` int(11) NULL,
|
||||
PRIMARY KEY (`s_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;";
|
||||
|
||||
$tsql[4]="select 1 from $DB_NAME.mail limit 1";
|
||||
$csql[4]="
|
||||
CREATE TABLE $DB_NAME.`mail` (
|
||||
|
||||
`mail_id` int(11) NOT NULL auto_increment,
|
||||
`to_user` varchar(20) NOT NULL default '',
|
||||
`from_user` varchar(20) NOT NULL default '',
|
||||
`title` varchar(200) NOT NULL default '',
|
||||
`content` text,
|
||||
`new_mail` tinyint(1) NOT NULL default '1',
|
||||
`reply` tinyint(4) default '0',
|
||||
`in_date` datetime default NULL,
|
||||
`defunct` char(1) NOT NULL default 'N',
|
||||
PRIMARY KEY (`mail_id`),
|
||||
KEY `uid` (`to_user`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4 AUTO_INCREMENT=1000 ;";
|
||||
|
||||
$tsql[5]="ALTER TABLE $DB_NAME.`solution` MODIFY COLUMN `pass_rate` DECIMAL(4,3) UNSIGNED NOT NULL DEFAULT 0,MODIFY COLUMN in_date datetime not null default '2009-06-13 19:00:00', MODIFY COLUMN `user_id` CHAR(48) CHARACTER SET utf8mb4 NOT NULL,MODIFY COLUMN `ip` CHAR(15) CHARACTER SET utf8mb4 NOT NULL;";
|
||||
$csql[5]="";
|
||||
|
||||
$tsql[6]="select langmask from $DB_NAME.contest limit 1;";
|
||||
$csql[6]="ALTER TABLE $DB_NAME.`contest` ADD COLUMN `langmask` TINYINT NOT NULL DEFAULT 0 COMMENT 'bits for LANG to mask' AFTER `private`;";
|
||||
|
||||
$tsql[7]="repair table $DB_NAME.`compileinfo`,$DB_NAME.`contest` ,$DB_NAME.`contest_problem` ,$DB_NAME.`loginlog`,$DB_NAME.`news`,$DB_NAME.`privilege`,$DB_NAME.`problem` ,$DB_NAME.`solution`,$DB_NAME.`source_code`,$DB_NAME.`users`,$DB_NAME.`topic`,$DB_NAME.`reply`,$DB_NAME.`sim`,$DB_NAME.`mail`;";
|
||||
$csql[7]="optimize table $DB_NAME.`compileinfo`,$DB_NAME.`contest` ,$DB_NAME.`contest_problem` ,$DB_NAME.`loginlog`,$DB_NAME.`news`,$DB_NAME.`privilege`,$DB_NAME.`problem` ,$DB_NAME.`solution`,$DB_NAME.`source_code`,$DB_NAME.`users`,$DB_NAME.`topic`,$DB_NAME.`reply`,$DB_NAME.`sim`,$DB_NAME.`mail`;";
|
||||
|
||||
$csql[8]="";
|
||||
$tsql[8]="ALTER TABLE $DB_NAME.`contest` MODIFY COLUMN `langmask` INT UNSIGNED NOT NULL DEFAULT 0 COMMENT 'bits for LANG to mask';";
|
||||
$tsql[9]="select 1 from $DB_NAME.runtimeinfo limit 1";
|
||||
$csql[9]="CREATE TABLE $DB_NAME. `runtimeinfo` (
|
||||
`solution_id` int(11) NOT NULL DEFAULT '0',
|
||||
`error` text,
|
||||
PRIMARY KEY (`solution_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;
|
||||
";
|
||||
$tsql[10]="select pass_rate from $DB_NAME.solution limit 1";
|
||||
$csql[10]="ALTER TABLE $DB_NAME.`solution` ADD COLUMN `pass_rate` DECIMAL(4,3) UNSIGNED NOT NULL DEFAULT 0 AFTER `judgetime`;";
|
||||
|
||||
$csql[11]="";
|
||||
$tsql[11]="ALTER TABLE $DB_NAME.`users` MODIFY COLUMN `user_id` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
|
||||
$csql[12]="";
|
||||
$tsql[12]="ALTER TABLE $DB_NAME.`topic` MODIFY COLUMN `author_id` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
|
||||
$csql[13]="";
|
||||
$tsql[13]="ALTER TABLE $DB_NAME.`mail` MODIFY COLUMN `to_user` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id',MODIFY COLUMN `from_user` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
|
||||
$csql[14]="";
|
||||
$tsql[14]="ALTER TABLE $DB_NAME.`reply` MODIFY COLUMN `author_id` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
|
||||
$csql[15]="";
|
||||
$tsql[15]="ALTER TABLE $DB_NAME.`privilege` MODIFY COLUMN `user_id` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
|
||||
$csql[15]="";
|
||||
$tsql[15]="ALTER TABLE $DB_NAME.`loginlog` MODIFY COLUMN `user_id` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
|
||||
$csql[15]="";
|
||||
$tsql[15]="ALTER TABLE $DB_NAME.`news` MODIFY COLUMN `user_id` varchar(48) NOT NULL DEFAULT '' COMMENT 'user_id';";
|
||||
$tsql[16]="ALTER TABLE $DB_NAME.`sim` ADD INDEX `Index_sim_id`(`sim_s_id`);";
|
||||
$csql[16]="";
|
||||
$tsql[17]="ALTER TABLE $DB_NAME.`contest_problem` ADD INDEX `Index_contest_id`(`contest_id`);";
|
||||
$csql[17]="";
|
||||
$tsql[18]="ALTER TABLE $DB_NAME.`contest_problem` ADD INDEX `Index_problem_id`(`problem_id`);";
|
||||
$csql[18]="";
|
||||
|
||||
$tsql[18]="select 1 from $DB_NAME.custominput limit 1;";
|
||||
$csql[18]="CREATE TABLE $DB_NAME. `custominput` ( `solution_id` int(11) NOT NULL DEFAULT '0', `input_text` text, PRIMARY KEY (`solution_id`)) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;";
|
||||
|
||||
$tsql[19]="ALTER TABLE $DB_NAME.`loginlog` ADD INDEX `user_time_index`(`user_id`, `time`);";
|
||||
$csql[19]="";
|
||||
$tsql[20]="ALTER TABLE $DB_NAME.`contest` ADD `password` CHAR( 16 ) NOT NULL DEFAULT '' AFTER `langmask` ";
|
||||
$csql[20]="";
|
||||
$tsql[21]="CREATE TABLE $DB_NAME.`source_code_user` like source_code";
|
||||
$csql[21]="";
|
||||
|
||||
$tsql[22]="insert into $DB_NAME.source_code_user select * from $DB_NAME.source_code where solution_id not in (select solution_id from $DB_NAME.source_code_user) ";
|
||||
$csql[22]="";
|
||||
|
||||
$tsql[23]="select judger from $DB_NAME.solution limit 1 ";
|
||||
$csql[23]="ALTER TABLE $DB_NAME.`solution` ADD `judger` CHAR(16) NOT NULL DEFAULT 'LOCAL' ; ";
|
||||
|
||||
$tsql[24]="alter table $DB_NAME.solution modify column pass_rate decimal(4,3) NOT NULL DEFAULT 0;";
|
||||
$csql[24]="";
|
||||
|
||||
$csql[25]="";
|
||||
$tsql[25]="ALTER TABLE $DB_NAME. `solution` CHANGE `ip` `ip` CHAR( 46 ) CHARACTER SET utf8mb4 NOT NULL DEFAULT '';";
|
||||
$csql[26]="select 1 from $DB_NAME.printer limit 1";
|
||||
$tsql[26]="CREATE TABLE $DB_NAME. `printer` (
|
||||
`printer_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` char(48) NOT NULL,
|
||||
`in_date` datetime NOT NULL DEFAULT '2018-03-13 19:38:00',
|
||||
`status` smallint(6) NOT NULL DEFAULT '0',
|
||||
`worktime` timestamp NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`printer` CHAR(16) NOT NULL DEFAULT 'LOCAL',
|
||||
`content` text NOT NULL ,
|
||||
PRIMARY KEY (`printer_id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;";
|
||||
$csql[27]="select 1 from $DB_NAME.balloon limit 1";
|
||||
$tsql[27]="CREATE TABLE $DB_NAME. `balloon` (
|
||||
`balloon_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` char(48) NOT NULL,
|
||||
`sid` int(11) NOT NULL ,
|
||||
`cid` int(11) NOT NULL ,
|
||||
`pid` int(11) NOT NULL ,
|
||||
`status` smallint(6) NOT NULL DEFAULT '0',
|
||||
PRIMARY KEY (`balloon_id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4;";
|
||||
$csql[28]="select 1 from $DB_NAME.share_code limit 1";
|
||||
$tsql[28]="CREATE TABLE $DB_NAME.`share_code` (
|
||||
`share_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` varchar(48) DEFAULT NULL,
|
||||
`title` varchar(32) DEFAULT NULL,
|
||||
`share_code` text ,
|
||||
`language` varchar(32) DEFAULT NULL,
|
||||
`share_time` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`share_id`)
|
||||
) ENGINE=MyISAM AUTO_INCREMENT=1000 DEFAULT CHARSET=utf8mb4;";
|
||||
$tsql[29]="alter TABLE $DB_NAME.`contest` ADD `user_id` CHAR( 48 ) NOT NULL DEFAULT 'admin' AFTER `password` ";
|
||||
$csql[29]="update $DB_NAME.contest c inner JOIN (SELECT * FROM privilege WHERE rightstr LIKE 'm%') p ON concat('m',contest_id)=rightstr set c.user_id=p.user_id";
|
||||
$tsql[30]="alter TABLE $DB_NAME. `contest_problem` ADD `c_accepted` INT NOT NULL DEFAULT '0' AFTER `num` ,ADD `c_submit` INT NOT NULL DEFAULT '0' AFTER `c_accepted`";
|
||||
$csql[30]="";
|
||||
$tsql[31]="update $DB_NAME.contest_problem cp inner join (select count(1) submit,contest_id cid,num from $DB_NAME.solution where contest_id>0 group by contest_id,num) sb on cp.contest_id=sb.cid and cp.num=sb.num set cp.c_submit=sb.submit";
|
||||
$csql[31]="update $DB_NAME.contest_problem cp inner join (select count(1) ac,contest_id cid,num from $DB_NAME.solution where contest_id>0 and result=4 group by contest_id,num) sb on cp.contest_id=sb.cid and cp.num=sb.num set cp.c_accepted=sb.ac";
|
||||
$tsql[32]="alter table $DB_NAME.solution add column nick char(20) not null default '' after user_id ";
|
||||
$csql[32]="update $DB_NAME.solution s inner join users u on s.user_id=u.user_id set s.nick=u.nick";
|
||||
$tsql[33]="update $DB_NAME.problem p inner join (select problem_id pid ,count(1) submit from $DB_NAME.solution group by problem_id) s on p.problem_id=s.pid set p.submit=s.submit;";
|
||||
$csql[33]="update $DB_NAME.problem p inner JOIN ( SELECT count(1) as c,problem_id from solution where result=4 group by problem_id) s on p.problem_id=s.problem_id set p.accepted=s.c;";
|
||||
$tsql[34]="alter table $DB_NAME.privilege add index user_id_index(user_id);";
|
||||
$csql[34]="";
|
||||
$tsql[35]="ALTER TABLE $DB_NAME.`problem` CHANGE `time_limit` `time_limit` DECIMAL(10,3) NOT NULL DEFAULT '0';";
|
||||
$csql[35]="";
|
||||
$tsql[36]="alter table $DB_NAME.privilege add column valuestr char(11) not null default 'true' after rightstr; ";
|
||||
$csql[36]="";
|
||||
|
||||
$tsql[37]="alter table $DB_NAME.news modify column `time` datetime NOT NULL DEFAULT '2016-05-13 19:24:00';";
|
||||
$csql[37]="ALTER TABLE $DB_NAME.`news` ADD COLUMN `menu` int(11) NOT NULL DEFAULT 0 AFTER `importance`;";
|
||||
|
||||
$tsql[38]="delete from $DB_NAME.source_code where solution_id in (select solution_id from $DB_NAME.solution where problem_id=0 and result>4);";
|
||||
$csql[38]="";
|
||||
$tsql[39]="delete from $DB_NAME.source_code_user where solution_id in (select solution_id from $DB_NAME.solution where problem_id=0 and result>4);";
|
||||
$csql[39]="";
|
||||
$tsql[40]="delete from $DB_NAME.runtimeinfo where solution_id in (select solution_id from $DB_NAME.solution where problem_id=0 and result>4);";
|
||||
$csql[40]="delete from $DB_NAME.runtimeinfo where solution_id not in (select solution_id from $DB_NAME.solution);";
|
||||
$tsql[41]="delete from $DB_NAME.compileinfo where solution_id in (select solution_id from $DB_NAME.solution where problem_id=0 and result>4);";
|
||||
$csql[41]="delete from $DB_NAME.compileinfo where solution_id not in (select solution_id from $DB_NAME.solution);";
|
||||
$tsql[42]="";
|
||||
$csql[42]="delete from $DB_NAME.solution where problem_id=0 and result>4;";
|
||||
$tsql[43]="alter table $DB_NAME.problem add column remote_oj varchar(16) default NULL after solved;";
|
||||
$csql[43]="alter table $DB_NAME.problem add column remote_id varchar(16) default NULL after remote_oj;";
|
||||
$tsql[44]="alter table $DB_NAME.solution add column remote_oj char(16) not null default '' after judger;";
|
||||
$csql[44]="alter table $DB_NAME.solution add column remote_id char(16) not null default '' after remote_oj;";
|
||||
$tsql[45]="alter table $DB_NAME.news modify content mediumtext not null;";
|
||||
$csql[45]="alter table $DB_NAME.problem modify description mediumtext not null, modify input mediumtext not null, modify output mediumtext not null, modify hint mediumtext not null;";
|
||||
$tsql[46]="alter table $DB_NAME.users add column activecode varchar(16) not null default '' after school;";
|
||||
$csql[46]="";
|
||||
$tsql[47]="alter table $DB_NAME.users add column group_name varchar(16) not null default '' after school;";
|
||||
$csql[47]="";
|
||||
$tsql[48]="alter table $DB_NAME.loginlog add column log_id int not null auto_increment primary key first;";
|
||||
$csql[48]="delete from $DB_NAME.loginlog where time<curdate()-interval 6 month;";
|
||||
|
||||
$tsql[49]="alter table $DB_NAME.problem add index key_p_def(defunct);";
|
||||
$csql[49]="alter table $DB_NAME.contest add index key_c_def(defunct);";
|
||||
$tsql[50]="alter table $DB_NAME.contest add index key_c_end(end_time);";
|
||||
$csql[50]="alter table $DB_NAME.contest add index key_c_dend(defunct,end_time);";
|
||||
$tsql[51]="alter table $DB_NAME.users add column starred int default 0 after activecode ;";
|
||||
$csql[51]="";
|
||||
// 删除6个月以前的非正确源码,优化数据库空间。
|
||||
// delete from source_code where solution_id in (select solution_id from solution where result>4 and in_date<date_sub(now(),interval 6 month) ); //
|
||||
if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
echo "Executing...<br>";
|
||||
set_time_limit(60);
|
||||
for($i=0;isset($tsql[$i]);$i++){
|
||||
if($tsql[$i]){
|
||||
echo $tsql[$i]."<br>";
|
||||
echo "=".pdo_query($tsql[$i])."<hr>";
|
||||
}
|
||||
if($csql[$i]){
|
||||
echo $csql[$i]."<br>";
|
||||
echo "=".pdo_query($csql[$i])."<hr>";
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="container">
|
||||
<b>Update DataBase</b>
|
||||
Create New Tables ,drop useless columes.
|
||||
<b>Necessary for using plagiarism detection.</b>
|
||||
<form action='update_db.php' method=post>
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<input type='hidden' name='do' value='do'>
|
||||
<input type=submit value=Update>
|
||||
</form>
|
||||
|
||||
<?php if (file_exists("update_pw.php")) { ?>
|
||||
<a href="update_pw.php">Upgrade all users password storage form to get more security.</a>
|
||||
* only do once !
|
||||
<?php }?>
|
||||
</div>
|
||||
97
web/admin/user_add.php
Normal file
97
web/admin/user_add.php
Normal file
@@ -0,0 +1,97 @@
|
||||
<?php require_once("admin-header.php");
|
||||
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator']) || isset($_SESSION[$OJ_NAME.'_'.'user_adder']) )){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>Add User</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_USER."-".$MSG_ADD?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
require_once("../include/my_func.inc.php");
|
||||
|
||||
$pieces = explode("\n", trim($_POST['ulist']));
|
||||
//想支持中文,修改下行代码为:$pieces = preg_replace("/[^\x20-\x7e\x{4e00}-\x{9fa5}]/u", " ", $pieces); //修改代码支持user_id为中文
|
||||
$pieces = preg_replace("/[^\x20-\x7e]/", " ", $pieces); //!!important
|
||||
|
||||
$ulist = "";
|
||||
if(count($pieces)>0 && strlen($pieces[0])>0){
|
||||
for($i=0; $i<count($pieces); $i++){
|
||||
$id_pw = explode(" ", trim($pieces[$i]));
|
||||
if(count($id_pw) != 2){
|
||||
echo " ".$id_pw[0]." ... Error : Line format error!<br>";
|
||||
for($j=0; $j<count($id_pw); $j++)
|
||||
{
|
||||
$ulist = $ulist.$id_pw[$j]." ";
|
||||
}
|
||||
$ulist = trim($ulist)."\n";
|
||||
} else {
|
||||
$sql = "SELECT `user_id` FROM `users` WHERE `users`.`user_id` = ?";
|
||||
$result = pdo_query($sql, $id_pw[0]);
|
||||
$rows_cnt = count($result);
|
||||
|
||||
if($rows_cnt == 1){
|
||||
echo " ".$id_pw[0]." ... Error : User already exist!<br>";
|
||||
$ulist = $ulist.$id_pw[0]." ".$id_pw[1]."\n";
|
||||
} else {
|
||||
$passwd = pwGen($id_pw[1]);
|
||||
$sql = "INSERT INTO `users` (`user_id`, `password`, `reg_time`, `nick`) VALUES (?, ?, NOW(), ?);";
|
||||
pdo_query($sql, $id_pw[0], $passwd, $id_pw[0]);
|
||||
echo $id_pw[0]." is added!<br>";
|
||||
|
||||
$ip = ($_SERVER['REMOTE_ADDR']);
|
||||
$sql="INSERT INTO `loginlog`(user_id,password,ip,time) VALUES(?,?,?,NOW())";
|
||||
pdo_query($sql, $id_pw[0], "user added", $ip);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "<br>Remained lines have error!<hr>";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<form action=user_add.php method=post class="form-horizontal">
|
||||
<div>
|
||||
<label class="col-sm"><?php echo $MSG_USER_ID?> <?php echo $MSG_PASSWORD?></label>
|
||||
</div>
|
||||
<div>
|
||||
<?php echo "( Add new user & password with newline \n )"?>
|
||||
<br>
|
||||
<table width="100%">
|
||||
<tr>
|
||||
<td height="*">
|
||||
<p align=left>
|
||||
<textarea name='ulist' rows='10' style='width:100%;' placeholder='userid1 password1<?php echo "\n"?>userid2 password2<?php echo "\n"?>userid3 password3<?php echo "\n"?>
|
||||
<?php echo $MSG_PRIVATE_USERS_ADD?><?php echo "\n"?>'><?php if(isset($ulist)){ echo $ulist;}?></textarea>
|
||||
</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<button name="do" type="hidden" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE?></button>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button name="submit" type="reset" class="btn btn-default btn-block"><?php echo $MSG_RESET?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
41
web/admin/user_df_change.php
Normal file
41
web/admin/user_df_change.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php require_once("admin-header.php");
|
||||
require_once "../include/email.class.php";
|
||||
require_once("../include/check_get_key.php");
|
||||
$user_id=$_GET['cid'];
|
||||
//echo htmlentities($user_id,ENT_QUOTE,'UTF-8');
|
||||
if(!isset($_SESSION[$OJ_NAME.'_'.'administrator'])) exit();
|
||||
$sql="select `defunct`,email FROM `users` WHERE `user_id`=?";
|
||||
$result=pdo_query($sql,$user_id);
|
||||
$num=count($result);
|
||||
if ($num<1){
|
||||
echo "No Such User!";
|
||||
require_once("../oj-footer.php");
|
||||
exit(0);
|
||||
}
|
||||
$row=$result[0];
|
||||
if ($row[0]=='N'){
|
||||
$sql="UPDATE `users` SET `defunct`='Y' WHERE `user_id`=?";
|
||||
pdo_query($sql,$user_id);
|
||||
}else{
|
||||
$sql="UPDATE `users` SET `defunct`='N' WHERE `user_id`=?";
|
||||
pdo_query($sql,$user_id);
|
||||
if(isset($OJ_SaaS_ENABLE) && $OJ_SaaS_ENABLE && $domain == $DOMAIN ){
|
||||
create_subdomain($user_id,'syzoj',3);
|
||||
$address=$row['email'];
|
||||
$mailtitle = "$OJ_NAME 账号重置激活通知";//邮件主题
|
||||
$mailcontent = "$user_id:\n您好!\n
|
||||
您在".$DOMAIN."系统开通了子OJ,您的子系统域名是".$user_id.".".$DOMAIN."。\n
|
||||
请及时访问该系统,并注册一个新账号".$user_id.",自动成为管理员。\n\n\n
|
||||
$OJ_NAME 在线评测系统";//邮件内容
|
||||
email($address,$mailtitle,$mailcontent);
|
||||
|
||||
}
|
||||
?>
|
||||
<a href="user_list.php">Back</a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<script language=javascript>
|
||||
history.go(-1);
|
||||
</script>
|
||||
126
web/admin/user_import.php
Normal file
126
web/admin/user_import.php
Normal file
@@ -0,0 +1,126 @@
|
||||
<?php
|
||||
require_once ("admin-header.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME . '_' . 'administrator']) || isset($_SESSION[$OJ_NAME . '_problem_importer']))) {
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once ("../lang/$OJ_LANG.php");
|
||||
}
|
||||
require_once ("../include/const.inc.php");
|
||||
require_once ("../include/my_func.inc.php");
|
||||
?>
|
||||
|
||||
<?php
|
||||
function get_extension($file) {
|
||||
$info = pathinfo($file);
|
||||
return $info['extension'];
|
||||
}
|
||||
function import_user($filename) {
|
||||
$check=false;
|
||||
if (($h = fopen("{$filename}", "r")) !== FALSE) {
|
||||
// 文件中的每一行数据都被转换为我们调用的单个数组$data
|
||||
// 数组的每个元素以逗号分隔
|
||||
while (($data = fgetcsv($h, 1000, ",")) !== FALSE) {
|
||||
// 每个单独的数组都被存入到嵌套的数组中
|
||||
if ($data[0] == "学号") {
|
||||
$check=true;
|
||||
echo "导入名单:<hr>\n";
|
||||
$gb2312=false;
|
||||
continue;
|
||||
}else if (iconv("gb2312","utf-8",$data[0])=="学号") {
|
||||
$check=true;
|
||||
$gb2312=true;
|
||||
continue;
|
||||
}
|
||||
if($check){
|
||||
echo $data[0] . "<br>\n";
|
||||
$user_id = mb_trim($data[0]);
|
||||
$nick = $data[1];
|
||||
$password = pwGen(trim($data[2]));
|
||||
$school = "";
|
||||
$email = "";
|
||||
$group_name="";
|
||||
if (isset($data[3])) $school = $data[3];
|
||||
if (isset($data[4])) $email = $data[4];
|
||||
if (isset($data[5])) $group_name = $data[5];
|
||||
if($gb2312) {
|
||||
$nick=iconv("gb2312","utf-8",$nick);
|
||||
$school=iconv("gb2312","utf-8",$school);
|
||||
$group_name=iconv("gb2312","utf-8",$group_name);
|
||||
}
|
||||
if (mb_strlen($nick, 'utf-8') > 20) {
|
||||
$new_len = mb_strlen($nick, 'utf-8');
|
||||
if ($new_len > $max_length) {
|
||||
$max_length = $new_len;
|
||||
$longer = "ALTER TABLE `users` MODIFY COLUMN `nick` varchar($max_length) NULL DEFAULT '' ";
|
||||
pdo_query($longer);
|
||||
}
|
||||
}
|
||||
|
||||
$ip = "127.0.0.1";
|
||||
$sql = "INSERT INTO `users`(" . "`user_id`,`email`,`ip`,`accesstime`,`password`,`reg_time`,`nick`,`school`,`group_name`)" . "VALUES(?,?,?,NOW(),?,NOW(),?,?,?)on DUPLICATE KEY UPDATE `email`=?,`ip`=?,`accesstime`=NOW(),`password`=?,`reg_time`=now(),nick=?,`school`=?,`group_name`=?";
|
||||
pdo_query($sql, $user_id, $email, $ip, $password, $nick, $school,$group_name, $email, $ip, $password, $nick, $school,$group_name);
|
||||
|
||||
}else{
|
||||
echo "<h1>请用下载的模板填写,保存为UTF-8编码。</h1>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 关闭文件
|
||||
fclose($h);
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($_FILES["fps"])) {
|
||||
if ($_FILES["fps"]["error"] > 0) {
|
||||
echo " - Error: " . $_FILES["fps"]["error"] . "File size is too big, change in PHP.ini<br />";
|
||||
} else {
|
||||
$tempfile = $_FILES["fps"]["tmp_name"];
|
||||
if (get_extension($_FILES["fps"]["name"]) == "zip") {
|
||||
echo " - zip file, only fps/xml files in root dir are supported";
|
||||
$resource = zip_open($tempfile);
|
||||
$i = 1;
|
||||
$tempfile = tempnam("/tmp", "fps");
|
||||
while ($dir_resource = zip_read($resource)) {
|
||||
if (zip_entry_open($resource, $dir_resource)) {
|
||||
$file_name = $path . zip_entry_name($dir_resource);
|
||||
$file_path = substr($file_name, 0, strrpos($file_name, "/"));
|
||||
if (!is_dir($file_name)) {
|
||||
$file_size = zip_entry_filesize($dir_resource);
|
||||
$file_content = zip_entry_read($dir_resource, $file_size);
|
||||
file_put_contents($tempfile, $file_content);
|
||||
import_user($tempfile);
|
||||
}
|
||||
zip_entry_close($dir_resource);
|
||||
}
|
||||
}
|
||||
zip_close($resource);
|
||||
unlink($_FILES["fps"]["tmp_name"]);
|
||||
} else {
|
||||
import_user($tempfile);
|
||||
unlink($_FILES["fps"]["tmp_name"]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
?>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<h1>导入用户csv文件</h1>
|
||||
<form class='form-inline' action='user_import.php' method=post enctype="multipart/form-data">
|
||||
<div class='form-group'>
|
||||
<input class='form-control' type=file name='fps' >
|
||||
</div>
|
||||
<br><br>
|
||||
<br><br><br>
|
||||
<center>
|
||||
<div class='form-group'>
|
||||
<button class='btn btn-default btn-sm' type=submit>Upload to HUSTOJ</button>
|
||||
</div>
|
||||
</center>
|
||||
<?php require_once ("../include/set_post_key.php"); ?>
|
||||
</form>
|
||||
<a href="users.csv">下载模板</a>
|
||||
<?php
|
||||
} ?>
|
||||
194
web/admin/user_list.php
Normal file
194
web/admin/user_list.php
Normal file
@@ -0,0 +1,194 @@
|
||||
<?php
|
||||
require("admin-header.php");
|
||||
require_once("../include/set_get_key.php");
|
||||
if(!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'password_setter']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
if(isset($OJ_LANG)){
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
<title>User List</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_USER."-".$MSG_LIST?></h3></center>
|
||||
<div class='container'>
|
||||
<?php
|
||||
$sql = "SELECT COUNT('user_id') AS ids FROM `users`";
|
||||
$result = pdo_query($sql);
|
||||
$row = $result[0];
|
||||
$ids = intval($row['ids']);
|
||||
$idsperpage = 25;
|
||||
$pages = intval(ceil($ids/$idsperpage));
|
||||
if(isset($_GET['page'])){
|
||||
$page = intval($_GET['page']);
|
||||
}else{
|
||||
$page = 1;
|
||||
}
|
||||
$pagesperframe = 5;
|
||||
$frame = intval(ceil($page/$pagesperframe));
|
||||
$spage = ($frame-1)*$pagesperframe+1;
|
||||
$epage = min($spage+$pagesperframe-1, $pages);
|
||||
$sid = ($page-1)*$idsperpage;
|
||||
$sql = "";
|
||||
$gkeyword="";
|
||||
$trash="";
|
||||
if(isset($_GET['keyword']) && $_GET['keyword']!=""){
|
||||
$gkeyword = $_GET['keyword'];
|
||||
$keyword = "%$gkeyword%";
|
||||
$sql = "SELECT `user_id`,`nick`,email,`accesstime`,`reg_time`,`ip`,`school`,`group_name`,`defunct` FROM `users` WHERE (user_id LIKE ?) OR (nick LIKE ?) OR (school LIKE ?) or (ip like ?) ORDER BY `user_id` DESC";
|
||||
$result = pdo_query($sql,$keyword,$keyword,$keyword,$keyword);
|
||||
}else if(isset($_GET['trash'])){
|
||||
$trash="&trash";
|
||||
$sql = "SELECT `user_id`,`nick`,email,`accesstime`,`reg_time`,`ip`,`school`,`group_name`,`defunct` FROM `users` where defunct='Y' ORDER BY `accesstime` DESC LIMIT $sid, $idsperpage";
|
||||
$result = pdo_query($sql);
|
||||
}else{
|
||||
$sql = "SELECT `user_id`,`nick`,email,`accesstime`,`reg_time`,`ip`,`school`,`group_name`,`defunct` FROM `users` where defunct='N' ORDER BY `accesstime` DESC LIMIT $sid, $idsperpage";
|
||||
$result = pdo_query($sql);
|
||||
}
|
||||
?>
|
||||
|
||||
<center>
|
||||
<form action=user_list.php class="form-search form-inline">
|
||||
<input type="text" name="keyword" value="<?php echo htmlentities($gkeyword,ENT_QUOTES) ?>" class="form-control search-query" placeholder="<?php echo $MSG_USER_ID.', '.$MSG_NICK.', '.$MSG_SCHOOL?>">
|
||||
<button type="submit" class="form-control"><?php echo $MSG_SEARCH?></button>
|
||||
<a href="user_list.php?trash"><i class='icon large trash color grey' ></i></a>
|
||||
</form>
|
||||
</center>
|
||||
|
||||
<center>
|
||||
<table width=100% border=1 style="text-align:center;">
|
||||
<tr>
|
||||
<td><?php echo $MSG_USER_ID?></td>
|
||||
<td><?php echo $MSG_NICK?></td>
|
||||
<td>IP</td>
|
||||
<td><?php echo $MSG_EMAIL?></td>
|
||||
<td><?php echo $MSG_SCHOOL?></td>
|
||||
<td><?php echo $MSG_GROUP_NAME?></td>
|
||||
<td><?php echo $MSG_LAST_LOGIN?></td>
|
||||
<td><?php echo $MSG_REGISTER?></td>
|
||||
<td><?php echo $MSG_STATUS?></td>
|
||||
<td><?php echo $MSG_SETPASSWORD?></td>
|
||||
<td><?php echo $MSG_PRIVILEGE."-".$MSG_ADD ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
foreach($result as $row){
|
||||
echo "<tr>";
|
||||
echo "<td><a href='../userinfo.php?user=".$row['user_id']."'>".$row['user_id']."</a></td>";
|
||||
echo "<td><span fd='nick' user_id='".$row['user_id']."'>".$row['nick']."</span></td>";
|
||||
echo "<td><a href='user_list.php?keyword=".htmlentities(urlencode($row['ip']))."' >".$row['ip']."</td>";
|
||||
if($OJ_SaaS_ENABLE && $domain == $DOMAIN){
|
||||
echo "<td><a href='http://".$row['user_id'].".$DOMAIN' target=_blank >".$row['email']." </a></td>";
|
||||
}else{
|
||||
echo "<td>".$row['email']."</td>";
|
||||
}
|
||||
if($row['school']=="") $row['school']=" ";
|
||||
echo "<td><span fd='school' user_id='".$row['user_id']."'>".$row['school']."</span></td>";
|
||||
if($row['group_name']=="") $row['group_name']=" ";
|
||||
echo "<td><span fd='group_name' user_id='".$row['user_id']."'>".$row['group_name']."</span></td>";
|
||||
echo "<td>".$row['accesstime']."</td>";
|
||||
echo "<td>".$row['reg_time']."</td>";
|
||||
if(isset($_SESSION[$OJ_NAME.'_'.'administrator'])){
|
||||
echo "<td><a href=user_df_change.php?cid=".$row['user_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">".
|
||||
($row['defunct']=="N"?"<span class=green>$MSG_NORMAL</span>":"<span class=red>$MSG_DELETED</span>")."</a></td>";
|
||||
}
|
||||
else {
|
||||
echo "<td>".($row['defunct']=="N"?"<span>$MSG_NORMAL</span>":"<span>$MSG_DELETED</span>")."</td>";
|
||||
}
|
||||
echo "<td><a href=changepass.php?uid=".$row['user_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">"."Reset"."</a></td>";
|
||||
echo "<td><a href=privilege_add.php?uid=".$row['user_id']."&getkey=".$_SESSION[$OJ_NAME.'_'.'getkey'].">"."Add"."</a></td>";
|
||||
echo "</tr>";
|
||||
} ?>
|
||||
</table>
|
||||
</center>
|
||||
|
||||
<?php
|
||||
if(!(isset($_GET['keyword']) && $_GET['keyword']!=""))
|
||||
{
|
||||
echo "<div style='display:inline;'>";
|
||||
echo "<nav class='center'>";
|
||||
echo "<ul class='pagination pagination-sm'>";
|
||||
echo "<li class='page-item'><a href='user_list.php?page=".(strval(1))."$trash'><<</a></li>";
|
||||
echo "<li class='page-item'><a href='user_list.php?page=".($page==1?strval(1):strval($page-1))."$trash'><</a></li>";
|
||||
for($i=$spage; $i<=$epage; $i++){
|
||||
echo "<li class='".($page==$i?"active ":"")."page-item'><a title='go to page' href='user_list.php?page=".$i."$trash'>".$i."</a></li>";
|
||||
}
|
||||
echo "<li class='page-item'><a href='user_list.php?page=".($page==$pages?strval($page):strval($page+1))."$trash'>></a></li>";
|
||||
echo "<li class='page-item'><a href='user_list.php?page=".(strval($pages))."$trash'>>></a></li>";
|
||||
echo "</ul>";
|
||||
echo "</nav>";
|
||||
echo "</div>";
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<script>
|
||||
function admin_mod(){
|
||||
$("span[fd=group_name]").each(function(){
|
||||
let sp=$(this);
|
||||
let user_id=$(this).attr('user_id');
|
||||
$(this).dblclick(function(){
|
||||
let group_name=sp.text();
|
||||
sp.html("<form onsubmit='return false;'><input type=hidden name='m' value='user_update_group_name'><input type='hidden' name='user_id' value='"+user_id+"'><input type='text' name='group_name' value='"+group_name+"' selected='true' class='input-large' size=20 ></form>");
|
||||
let ipt=sp.find("input[name=group_name]");
|
||||
ipt.focus();
|
||||
ipt[0].select();
|
||||
sp.find("input").change(function(){
|
||||
let newgroup_name=sp.find("input[name=group_name]").val();
|
||||
$.post("ajax.php",sp.find("form").serialize()).done(function(){
|
||||
console.log("new group_name"+newgroup_name);
|
||||
sp.html(newgroup_name);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
$("span[fd=school]").each(function(){
|
||||
let sp=$(this);
|
||||
let user_id=$(this).attr('user_id');
|
||||
$(this).dblclick(function(){
|
||||
let school=sp.text();
|
||||
sp.html("<form onsubmit='return false;'><input type=hidden name='m' value='user_update_school'><input type='hidden' name='user_id' value='"+user_id+"'><input type='text' name='school' value='"+school+"' selected='true' class='input-large' size=20 ></form>");
|
||||
let ipt=sp.find("input[name=school]");
|
||||
ipt.focus();
|
||||
ipt[0].select();
|
||||
sp.find("input").change(function(){
|
||||
let newschool=sp.find("input[name=school]").val();
|
||||
$.post("ajax.php",sp.find("form").serialize()).done(function(){
|
||||
console.log("new school"+newschool);
|
||||
sp.html(newschool);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
$("span[fd=nick]").each(function(){
|
||||
let sp=$(this);
|
||||
let user_id=$(this).attr('user_id');
|
||||
$(this).dblclick(function(){
|
||||
let nick=sp.text();
|
||||
console.log("user_id:"+user_id+" nick:"+nick);
|
||||
sp.html("<form onsubmit='return false;'><input type=hidden name='m' value='user_update_nick'><input type='hidden' name='user_id' value='"+user_id+"'><input type='text' name='nick' value='"+nick+"' selected='true' class='input-mini' size=2 ></form>");
|
||||
let ipt=sp.find("input[name=nick]");
|
||||
ipt.focus();
|
||||
ipt[0].select();
|
||||
sp.find("input").change(function(){
|
||||
let newnick=sp.find("input[name=nick]").val();
|
||||
$.post("ajax.php",sp.find("form").serialize()).done(function(){
|
||||
console.log("new nick:"+newnick);
|
||||
sp.html(newnick);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
$(document).ready(function(){
|
||||
admin_mod();
|
||||
});
|
||||
|
||||
</script>
|
||||
70
web/admin/user_set_ip.php
Normal file
70
web/admin/user_set_ip.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php require("admin-header.php");
|
||||
|
||||
if (isset($OJ_LANG)) {
|
||||
require_once("../lang/$OJ_LANG.php");
|
||||
}
|
||||
?>
|
||||
|
||||
<title>User Set IP</title>
|
||||
<hr>
|
||||
<center><h3><?php echo $MSG_SET_LOGIN_IP?></h3></center>
|
||||
|
||||
<div class='container'>
|
||||
|
||||
<?php
|
||||
require_once("../include/set_get_key.php");
|
||||
$sql = "";
|
||||
if(isset($_POST['do'])){
|
||||
require_once("../include/check_post_key.php");
|
||||
|
||||
$user_id = $_POST['user_id'];
|
||||
$ip = $_POST['ip'];
|
||||
|
||||
if(false){
|
||||
$user_id = stripslashes($user_id);
|
||||
$ip = stripslashes($ip);
|
||||
}
|
||||
|
||||
$sql = "insert into loginlog (user_id,password,ip,time) value(?,?,?,now())";
|
||||
$result = pdo_query($sql,$user_id,"set ip by ".$_SESSION[$OJ_NAME."_user_id"],$ip);
|
||||
echo "<center><h4 class='text-danger'>User ".htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8')."'s Login IP Changed!</h4></center>";
|
||||
}
|
||||
?>
|
||||
|
||||
<form action=user_set_ip.php method=post class="form-horizontal">
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo $MSG_USER_ID?></label>
|
||||
<?php if(isset($_GET['uid'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_GET['uid'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else if(isset($_POST['user_id'])) { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" value="<?php echo htmlentities($_POST['user_id'], ENT_QUOTES, 'UTF-8');?>" type="text" required ></div>
|
||||
<?php } else { ?>
|
||||
<div class="col-sm-3"><input name="user_id" class="form-control" placeholder="<?php echo $MSG_USER_ID."*"?>" type="text" required ></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="col-sm-offset-3 col-sm-3 control-label"><?php echo "New IP"?></label>
|
||||
<?php if(isset($_POST['ip'])) { ?>
|
||||
<div class="col-sm-3"><input name="ip" class="form-control" value="<?php echo htmlentities($_POST['ip'], ENT_QUOTES, 'UTF-8')?>" type="text" autocomplete="off" required ></div>
|
||||
<?php } else { ?>
|
||||
<div class="col-sm-3"><input name="ip" class="form-control" placeholder="<?php echo "?.?.?.?*"?>" type="text" autocomplete="off" required ></div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<?php require_once("../include/set_post_key.php");?>
|
||||
<div class="col-sm-offset-4 col-sm-2">
|
||||
<button name="do" type="hidden" value="do" class="btn btn-default btn-block" ><?php echo $MSG_SAVE; ?></button>
|
||||
</div>
|
||||
<div class="col-sm-2">
|
||||
<button name="submit" type="reset" class="btn btn-default btn-block"><?php echo $MSG_RESET?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
</div>
|
||||
|
||||
<?php
|
||||
require("../oj-footer.php");
|
||||
?>
|
||||
10
web/admin/users.csv
Normal file
10
web/admin/users.csv
Normal file
@@ -0,0 +1,10 @@
|
||||
学号,姓名,密码,学校,邮箱,班级
|
||||
guest2022,name2023,pass2024,school2025,email2026@qq.com,24软工1
|
||||
guest2023,name2024,pass2025,school2026,email2027@qq.com,24软工1
|
||||
guest2024,name2025,pass2026,school2027,email2028@qq.com,24软工1
|
||||
guest2025,name2026,pass2027,school2028,email2029@qq.com,24软工1
|
||||
guest2026,name2027,pass2028,school2029,email2030@qq.com,24软工2
|
||||
guest2027,name2028,pass2029,school2030,email2031@qq.com,24软工2
|
||||
guest2028,name2029,pass2030,school2031,email2032@qq.com,24软工2
|
||||
guest2029,name2030,pass2031,school2032,email2033@qq.com,24软工2
|
||||
guest2030,name2031,pass2032,school2033,email2034@qq.com,24软工2
|
||||
|
145
web/admin/watch.php
Normal file
145
web/admin/watch.php
Normal file
@@ -0,0 +1,145 @@
|
||||
<?php
|
||||
require_once("../include/db_info.inc.php");
|
||||
require_once ("../include/my_func.inc.php");
|
||||
if (!(isset($_SESSION[$OJ_NAME.'_'.'administrator'])||isset($_SESSION[$OJ_NAME.'_'.'contest_creator'])||isset($_SESSION[$OJ_NAME.'_'.'problem_editor'])||isset($_SESSION[$OJ_NAME.'_'.'password_setter']))){
|
||||
echo "<a href='../loginpage.php'>Please Login First!</a>";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
$memory=array();
|
||||
exec("free -m|awk '{print $2 }'|tail -2",$memory);
|
||||
$total_mem=$memory[0];
|
||||
$total_swap=$memory[1];
|
||||
$delay=2;
|
||||
$logfile="/dev/shm/".basename(__FILE__,"php")."log";
|
||||
$history=@file_get_contents($logfile);
|
||||
if($history!=""){
|
||||
$history=json_decode($history);
|
||||
}else{
|
||||
$history=array();
|
||||
}
|
||||
$HL=count($history)-1;
|
||||
if($HL>=0){
|
||||
$info=$history[$HL];
|
||||
}
|
||||
if(function_exists('system')){
|
||||
date_default_timezone_set("PRC");
|
||||
if($HL<0||(isset($history[$HL][4]) && $history[$HL][4] <= (time()-$delay)*1000) ){
|
||||
$info=array();
|
||||
// system(" top -bn1 | grep \"Cpu\" | awk -F, '{print $4}' | awk '{print 100-$1}' ");
|
||||
exec(" top -bn1 | grep \"Cpu\" | awk -F, '{print $4}' | awk '{print 100-$1}' ",$info);
|
||||
$info[count($info)-1]=floatval($info[count($info)-1]);
|
||||
exec("free -m|grep Mem|awk '{print $7 }'",$info);
|
||||
$info[count($info)-1]=floatval($info[count($info)-1]);
|
||||
exec("free -m|grep Swap|awk '{print $3 }'",$info);
|
||||
$info[count($info)-1]=floatval($info[count($info)-1]);
|
||||
exec("netstat -s |grep 'connections established'|cut -d\ -f5",$info);
|
||||
$info[count($info)-1]=floatval($info[count($info)-1]);
|
||||
|
||||
array_push($info,(time())*1000);
|
||||
|
||||
exec("df -m|grep '/dev/vda3'|grep -v 'shm'|awk '{print $3 }'",$info);
|
||||
$info[count($info)-1]=floatval($info[count($info)-1]);
|
||||
exec("df -m|grep 'aliyun'|grep -v 'shm'|awk '{print $3} '",$info);
|
||||
$info[count($info)-1]=floatval($info[count($info)-1]);
|
||||
//echo json_encode($info);
|
||||
array_push($history,$info);
|
||||
while(count($history)>900) array_shift($history);
|
||||
file_put_contents($logfile,json_encode($history));
|
||||
// echo json_encode($history);
|
||||
}
|
||||
$chart_cpu=array();
|
||||
$chart_mem=array();
|
||||
$chart_swap=array();
|
||||
$chart_tcp=array();
|
||||
foreach($history as $sample ){
|
||||
array_push($chart_cpu,array($sample[4],$sample[0]));
|
||||
array_push($chart_mem,array($sample[4],$sample[1]/$total_mem*100));
|
||||
array_push($chart_swap,array($sample[4],$sample[2]/$total_swap*100));
|
||||
array_push($chart_tcp,array($sample[4],$sample[3]/2));
|
||||
}
|
||||
if(isset($_GET['json'])){
|
||||
echo json_encode(array($chart_cpu,$chart_mem,$chart_swap,$chart_tcp));
|
||||
exit() ;
|
||||
}else{
|
||||
$AG=array("_",".",":","i","!");
|
||||
$HL=count($history)-1;
|
||||
$cpu_ag="";
|
||||
$al=9-strlen(strval($info[0]));
|
||||
if($HL>$al){
|
||||
for($i=$al;$i>=0;$i--){
|
||||
$cpu_ag.= $AG[intval(log($history[$HL-$i][0],3))];
|
||||
}
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="">
|
||||
</head><body bgcolor="white">
|
||||
<?php if (!isset($_GET['notext'])){ ?>
|
||||
<h1 style="color:#ffffff">
|
||||
<span style="color:rgb(175,216,248)">CPU :<span id="cpu"><?php echo $info[0].$cpu_ag ?> </span></span><br>
|
||||
<span style="color:rgb(237,194,64)">FREE:<span id="mem"><?php echo $info[1] ?>M</span></span><br>
|
||||
<span style="color:rgb(77,167,77)">SWAP:<span id="swap"><?php echo $info[2] ?>M</span></span><br>
|
||||
<span style="color:rgb(203,75,75)">TCP :<span id="tcp"><?php echo $info[3] ?></span>pairs </span> <br>
|
||||
DISK:<span id="disk"><?php echo $info[5] ?></span>M <br>
|
||||
NAS :<span id="nas"><?php echo intval($info[6]/1024) ?></span>G <br>
|
||||
</h1>
|
||||
<?php } ?>
|
||||
<script> //window.setTimeout("location.reload()",5000); </script>
|
||||
<script src="/include/jquery-latest.js" > </script>
|
||||
<script src="/include/jquery.flot.js" > </script>
|
||||
<div id="panel" style="width:98%;height:180px" onclick='update()'>loading data ... </div>
|
||||
<script type="text/javascript">
|
||||
function update(){
|
||||
$.getJSON("<?php echo basename(__FILE__)?>?json",function(result){
|
||||
let cpu=result[0];
|
||||
let mem=result[1];
|
||||
let swap=result[2];
|
||||
let tcp=result[3];
|
||||
$.plot( $( "#panel" ), [ {
|
||||
label: "FREE:"+(<?php echo $memory[0]?>*mem[mem.length-1][1]/100).toFixed(0),data: mem,lines: {show: true}
|
||||
}
|
||||
,{ label: "CPU:"+cpu[cpu.length-1][1]+"%",data: cpu,bars: {show: true}
|
||||
}
|
||||
,{ label: "TCP:"+tcp[tcp.length-1][1]*2,data: tcp,lines: {show: true}
|
||||
}
|
||||
,{ label: "SWAP:"+(<?php echo $memory[1]?>*swap[swap.length-1][1]/100).toFixed(0),data: swap,lines: {show: true}
|
||||
}
|
||||
], { grid: {
|
||||
backgroundColor: {
|
||||
colors: [ "#aaaaee", "#ffffff" ]
|
||||
},
|
||||
color:"#00aa00",
|
||||
show:"true"
|
||||
},
|
||||
xaxis: {
|
||||
mode: "time" //,
|
||||
},
|
||||
legend: {
|
||||
position: "nw"
|
||||
}
|
||||
} );
|
||||
$("#cpu").text(cpu[cpu.length-1][1]+"%");
|
||||
$("#mem").text(mem[mem.length-1][1].toFixed(2)+"%");
|
||||
$("#swap").text(swap[swap.length-1][1].toFixed(2)+"%");
|
||||
$("#tcp").text(tcp[tcp.length-1][1]);
|
||||
});
|
||||
|
||||
}
|
||||
$(document).ready(function (){
|
||||
window.setInterval("update()",<?php echo $delay*1000 ?>);
|
||||
});
|
||||
</script>
|
||||
|
||||
<?php }
|
||||
|
||||
} ?>
|
||||
<?php if (!isset($_GET['notext'])){ ?>
|
||||
<br><br><br><br><br><br><br><br>
|
||||
<?php } ?>
|
||||
</body>
|
||||
Reference in New Issue
Block a user