mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-22 18:08:42 +00:00
fix: data uploaded by zip success but not commited and can't checkout using svn
If we upload data and problem.conf online, we may cannot checkout the existing data using svn. This commit fixed it. Also changed some button's position.
This commit is contained in:
parent
be94141d94
commit
32d4340e76
@ -74,21 +74,19 @@ EOD;
|
|||||||
|
|
||||||
//上传数据
|
//上传数据
|
||||||
if($_POST['problem_data_file_submit']=='submit'){
|
if($_POST['problem_data_file_submit']=='submit'){
|
||||||
if ($_FILES["problem_data_file"]["error"] > 0)
|
if ($_FILES["problem_data_file"]["error"] > 0){
|
||||||
{
|
|
||||||
$errmsg = "Error: ".$_FILES["problem_data_file"]["error"];
|
$errmsg = "Error: ".$_FILES["problem_data_file"]["error"];
|
||||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||||
}
|
}
|
||||||
else
|
else{
|
||||||
{
|
|
||||||
//if($_FILES["problem_data_file"]["type"]=='application/zip'){
|
//if($_FILES["problem_data_file"]["type"]=='application/zip'){
|
||||||
$up_filename="/tmp/".rand(0,100000000)."data.zip";
|
$up_filename="/tmp/".rand(0,100000000)."data.zip";
|
||||||
move_uploaded_file($_FILES["problem_data_file"]["tmp_name"], $up_filename);
|
move_uploaded_file($_FILES["problem_data_file"]["tmp_name"], $up_filename);
|
||||||
$zip = new ZipArchive;
|
$zip = new ZipArchive;
|
||||||
if ($zip->open($up_filename) === TRUE)
|
if ($zip->open($up_filename) === TRUE){
|
||||||
{
|
|
||||||
$zip->extractTo("/var/svn/problem/{$problem['id']}/cur/{$problem['id']}/1");
|
$zip->extractTo("/var/svn/problem/{$problem['id']}/cur/{$problem['id']}/1");
|
||||||
$zip->close();
|
$zip->close();
|
||||||
|
svnCommitZipData($problem['id'], 'data');
|
||||||
echo "<script>alert('上传成功!')</script>";
|
echo "<script>alert('上传成功!')</script>";
|
||||||
}else{
|
}else{
|
||||||
$errmsg = "解压失败!";
|
$errmsg = "解压失败!";
|
||||||
@ -104,7 +102,6 @@ EOD;
|
|||||||
|
|
||||||
//添加配置文件
|
//添加配置文件
|
||||||
if($_POST['problem_settings_file_submit']=='submit'){
|
if($_POST['problem_settings_file_submit']=='submit'){
|
||||||
|
|
||||||
if($_POST['use_builtin_checker'] and $_POST['n_tests'] and $_POST['input_pre'] and $_POST['input_suf'] and $_POST['output_pre'] and $_POST['output_suf'] and $_POST['time_limit'] and $_POST['memory_limit']){
|
if($_POST['use_builtin_checker'] and $_POST['n_tests'] and $_POST['input_pre'] and $_POST['input_suf'] and $_POST['output_pre'] and $_POST['output_suf'] and $_POST['time_limit'] and $_POST['memory_limit']){
|
||||||
if(!is_dir("/var/svn/problem/{$problem['id']}/cur/{$problem['id']}/1/")){
|
if(!is_dir("/var/svn/problem/{$problem['id']}/cur/{$problem['id']}/1/")){
|
||||||
mkdir("/var/svn/problem/{$problem['id']}/cur/{$problem['id']}/1/");
|
mkdir("/var/svn/problem/{$problem['id']}/cur/{$problem['id']}/1/");
|
||||||
@ -138,12 +135,12 @@ EOD;
|
|||||||
fwrite($setfile, "time_limit ".$_POST['time_limit']."\n");
|
fwrite($setfile, "time_limit ".$_POST['time_limit']."\n");
|
||||||
fwrite($setfile, "memory_limit ".$_POST['memory_limit']."\n");
|
fwrite($setfile, "memory_limit ".$_POST['memory_limit']."\n");
|
||||||
fclose($setfile);
|
fclose($setfile);
|
||||||
|
svnCommitZipData($problem['id'], 'conf');
|
||||||
if(!$has_legacy){
|
if(!$has_legacy){
|
||||||
echo "<script>alert('添加成功!')</script>";
|
echo "<script>alert('添加成功!')</script>";
|
||||||
}else{
|
}else{
|
||||||
echo "<script>alert('替换成功!')</script>";
|
echo "<script>alert('替换成功!')</script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
$errmsg = "添加配置文件失败,请检查是否所有输入框都已填写!";
|
$errmsg = "添加配置文件失败,请检查是否所有输入框都已填写!";
|
||||||
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
becomeMsgPage('<div>' . $errmsg . '</div><a href="/problem/'.$problem['id'].'/manage/data">返回</a>');
|
||||||
@ -167,7 +164,7 @@ EOD;
|
|||||||
<p><a>svn://{$http_host}/problem/{$problem['id']}</a></p>
|
<p><a>svn://{$http_host}/problem/{$problem['id']}</a></p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<label class="col-sm-3 control-label">ZIP上传数据</label>
|
<label class="col-sm-3 control-label">上传数据</label>
|
||||||
<div class="col-sm-9">
|
<div class="col-sm-9">
|
||||||
<div class="form-control-static">
|
<div class="form-control-static">
|
||||||
<row>
|
<row>
|
||||||
@ -777,10 +774,10 @@ EOD
|
|||||||
<p class="help-block">请上传.zip文件</p>
|
<p class="help-block">请上传.zip文件</p>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="problem_data_file_submit" value="submit">
|
<input type="hidden" name="problem_data_file_submit" value="submit">
|
||||||
<button type="submit" class="btn btn-success">上传</button>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
<button type="submit" class="btn btn-success">上传</button>
|
||||||
|
</form>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -863,10 +860,10 @@ EOD
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" name="problem_settings_file_submit" value="submit">
|
<input type="hidden" name="problem_settings_file_submit" value="submit">
|
||||||
<div align="center"><button type="submit" class="btn btn-success">确定</button></div>
|
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
|
<button type="submit" class="btn btn-success">确定</button>
|
||||||
|
</form>
|
||||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -362,4 +362,34 @@ EOD
|
|||||||
error_log('hack successfully but sync failed.');
|
error_log('hack successfully but sync failed.');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function svnCommitZipData($problem, $type) {
|
||||||
|
$id = $problem['id'];
|
||||||
|
$cur_dir = "/var/svn/problem/$id/cur/$id";
|
||||||
|
$svnusr = UOJConfig::$data['svn']['our-root']['username'];
|
||||||
|
$svnpwd = UOJConfig::$data['svn']['our-root']['password'];
|
||||||
|
|
||||||
|
if($type=='conf'){
|
||||||
|
exec(
|
||||||
|
<<<EOD
|
||||||
|
cd $cur_dir
|
||||||
|
svn add 1/problem.conf --username $svnusr --password $svnpwd
|
||||||
|
svn commit -m "update problem.conf by online conf editor." --username $svnusr --password $svnpwd
|
||||||
|
EOD
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else if($type=='data'){
|
||||||
|
exec(
|
||||||
|
<<<EOD
|
||||||
|
cd $cur_dir
|
||||||
|
svn add * --username $svnusr --password $svnpwd
|
||||||
|
svn commit -m "add testdata from zip file online." --username $svnusr --password $svnpwd
|
||||||
|
EOD
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
error_log("svnCommitZipData: invalid argument");
|
||||||
|
return "invalid argument";
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user