Compare commits

..

4 Commits

Author SHA1 Message Date
76f10aa0be
feat: push docker image to git.m.ac registry
Some checks failed
continuous-integration/drone/push Build is failing
2022-09-19 16:21:16 +08:00
5dd5934e8c
fix: problem uploader 2022-09-19 16:02:44 +08:00
09e5234e5f
feat: user type manage 2022-09-19 15:42:26 +08:00
967b170ef4
fix: aa5e3063dc 2022-09-19 15:04:45 +08:00
5 changed files with 135 additions and 46 deletions

85
.drone.yml Normal file
View File

@ -0,0 +1,85 @@
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-db)
trigger:
event:
- push
steps:
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: baoshuo/s2oj-db
use_cache: true
context: db
dockerfile: db/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
tags:
- latest
- master
- "${DRONE_COMMIT_SHA:0:8}"
when:
event: push
branch: master
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-judger)
trigger:
event:
- push
steps:
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: baoshuo/s2oj-judger
use_cache: true
context: judger
dockerfile: judger/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
tags:
- latest
- master
- "${DRONE_COMMIT_SHA:0:8}"
when:
event: push
branch: master
---
kind: pipeline
type: docker
name: Build Docker Image (s2oj-web)
trigger:
event:
- push
steps:
- name: docker
image: plugins/docker
settings:
registry: git.m.ac
repo: baoshuo/s2oj-web
use_cache: true
dockerfile: web/Dockerfile
username: baoshuo
password:
from_secret: GITMAC_SECRET
tags:
- latest
- master
- "${DRONE_COMMIT_SHA:0:8}"
when:
event: push
branch: master

View File

@ -2,9 +2,6 @@ FROM ubuntu:20.04
ARG CLONE_ADDFLAG ARG CLONE_ADDFLAG
ADD . /opt/uoj
WORKDIR /opt/uoj
ENV DEBIAN_FRONTEND=noninteractive ENV DEBIAN_FRONTEND=noninteractive
RUN dpkg -s gnupg 2>/dev/null || (apt-get update && apt-get install -y gnupg) &&\ RUN dpkg -s gnupg 2>/dev/null || (apt-get update && apt-get install -y gnupg) &&\
echo "deb http://ppa.launchpad.net/stesie/libv8/ubuntu bionic main" | tee /etc/apt/sources.list.d/stesie-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D858A0DF &&\ echo "deb http://ppa.launchpad.net/stesie/libv8/ubuntu bionic main" | tee /etc/apt/sources.list.d/stesie-libv8.list && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D858A0DF &&\
@ -13,6 +10,9 @@ yes | pecl install yaml &&\
git clone https://github.com/phpv8/v8js.git --depth=1 -b 2.1.2 /tmp/pear/download/v8js-master && cd /tmp/pear/download/v8js-master &&\ git clone https://github.com/phpv8/v8js.git --depth=1 -b 2.1.2 /tmp/pear/download/v8js-master && cd /tmp/pear/download/v8js-master &&\
phpize && ./configure --with-php-config=/usr/bin/php-config --with-v8js=/opt/libv8-7.5 && make install && cd - phpize && ./configure --with-php-config=/usr/bin/php-config --with-v8js=/opt/libv8-7.5 && make install && cd -
ADD . /opt/uoj
WORKDIR /opt/uoj
# Install environment and set startup script # Install environment and set startup script
RUN sh web/install.sh -p && echo "\ RUN sh web/install.sh -p && echo "\
#!/bin/sh\n\ #!/bin/sh\n\

View File

@ -14,6 +14,8 @@
if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)) { if (isSuperUser($myUser) || isProblemManager($myUser) || isProblemUploader($myUser)) {
$new_problem_form = new UOJForm('new_problem'); $new_problem_form = new UOJForm('new_problem');
$new_problem_form->handle = function() { $new_problem_form->handle = function() {
global $myUser;
DB::query("insert into problems (title, uploader, is_hidden, submission_requirement) values ('New Problem', '{$myUser['username']}', 1, '{}')"); DB::query("insert into problems (title, uploader, is_hidden, submission_requirement) values ('New Problem', '{$myUser['username']}', 1, '{}')");
$id = DB::insert_id(); $id = DB::insert_id();
DB::query("insert into problems_contents (id, statement, statement_md) values ($id, '', '')"); DB::query("insert into problems_contents (id, statement, statement_md) values ($id, '', '')");
@ -113,29 +115,9 @@ EOD;
'url' => "/problems/template" 'url' => "/problems/template"
) )
); );
/*
<?php
echoLongTable(array('*'),
"problems left join best_ac_submissions on best_ac_submissions.submitter = '{$myUser['username']}' and problems.id = best_ac_submissions.problem_id", $cond, 'order by id asc',
$header,
'echoProblem',
array('page_len' => 3,
'table_classes' => array('table', 'table-bordered', 'table-hover', 'table-striped'),
'print_after_table' => function() {
global $myUser;
if (isSuperUser($myUser)) {
global $new_problem_form;
$new_problem_form->printHTML();
}
},
'head_pagination' => true
)
);
?>*/
$pag_config = array('page_len' => 40); $pag_config = array('page_len' => 40);
$pag_config['col_names'] = array('*'); $pag_config['col_names'] = array('best_ac_submissions.submission_id as submission_id', 'problems.id as id', 'problems.is_hidden as is_hidden', 'problems.title as title', 'problems.submit_num as submit_num', 'problems.ac_num as ac_num', 'problems.zan as zan', 'problems.extra_config as extra_config', 'problems.uploader as uploader');
$pag_config['table_name'] = "problems left join best_ac_submissions on best_ac_submissions.submitter = '{$myUser['username']}' and problems.id = best_ac_submissions.problem_id"; $pag_config['table_name'] = "problems left join best_ac_submissions on best_ac_submissions.submitter = '{$myUser['username']}' and problems.id = best_ac_submissions.problem_id";
$pag_config['cond'] = $cond; $pag_config['cond'] = $cond;
$pag_config['tail'] = "order by id asc"; $pag_config['tail'] = "order by id asc";

View File

@ -122,9 +122,6 @@
$options = array( $options = array(
'banneduser' => '设为封禁用户', 'banneduser' => '设为封禁用户',
'normaluser' => '设为普通用户', 'normaluser' => '设为普通用户',
'problem_uploader' => '设为题目上传者',
'problem_manager' => '设为题目管理员',
'contest_only' => '设为仅比赛参加者',
'superuser' => '设为超级用户' 'superuser' => '设为超级用户'
); );
$user_form->addSelect('op_type', $options, '操作类型', ''); $user_form->addSelect('op_type', $options, '操作类型', '');
@ -141,30 +138,52 @@
DB::update("update user_info set usergroup = 'U' where username = '{$username}'"); DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
DB::update("update user_info set usertype = 'student' where username = '{$username}'"); DB::update("update user_info set usertype = 'student' where username = '{$username}'");
break; break;
case 'problem_uploader':
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
$user = queryUser($username);
$user = addUserType($user, 'problem_uploader');
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
case 'problem_manager':
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
$user = queryUser($username);
$user = addUserType($user, 'problem_manager');
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
case 'contest_only':
DB::update("update user_info set usergroup = 'U' where username = '{$username}'");
$user = queryUser($username);
$user = addUserType($user, 'contest_only');
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
case 'superuser': case 'superuser':
DB::update("update user_info set usergroup = 'S' where username = '{$username}'"); DB::update("update user_info set usergroup = 'S' where username = '{$username}'");
DB::update("update user_info set usertype = 'student' where username = '{$username}'");
break; break;
} }
}; };
$user_form->runAtServer(); $user_form->runAtServer();
$usertype_form = new UOJForm('usertype');
$user_form->submit_button_config['align'] = 'compressed';
$usertype_form->addInput('usertype_username', 'text', '用户名', '',
function ($username) {
if (!validateUsername($username)) {
return '用户名不合法';
}
if (!queryUser($username)) {
return '用户不存在';
}
return '';
},
null
);
$usertype_options = array(
'problem_uploader' => '题目上传者',
'problem_manager' => '题目管理员',
'contest_only' => '仅比赛参加者',
);
$usertype_form->addSelect('usertype_type', $usertype_options, '角色', '');
$usertype_form->addSelect('usertype_op', array('add' => '添加', 'remove' => '移除'), '操作', '');
$usertype_form->handle = function() {
global $usertype_form;
$username = $_POST['usertype_username'];
switch ($_POST['usertype_type']) {
case 'problem_uploader':
case 'problem_manager':
case 'contest_only':
$user = queryUser($username);
$user = $_POST['usertype_op'] === 'add'
? addUserType($user, $_POST['usertype_type'])
: removeUserType($user, $_POST['usertype_type']);
DB::update("update user_info set usertype = '{$user['usertype']}' where username = '{$username}'");
break;
}
};
$usertype_form->runAtServer();
$blog_link_contests = new UOJForm('blog_link_contests'); $blog_link_contests = new UOJForm('blog_link_contests');
$blog_link_contests->addInput('blog_id', 'text', '博客ID', '', $blog_link_contests->addInput('blog_id', 'text', '博客ID', '',
@ -553,7 +572,10 @@ EOD;
<h3>修改用户密码</h3> <h3>修改用户密码</h3>
<?php $change_password_form->printHTML(); ?> <?php $change_password_form->printHTML(); ?>
<h3>用户类别设置</h3> <h3>用户类别设置</h3>
<p>在此处更新用户所属类别后会自动重置用户权限。</p>
<?php $user_form->printHTML(); ?> <?php $user_form->printHTML(); ?>
<h3>用户权限管理</h3>
<?php $usertype_form->printHTML(); ?>
<h3>修改用户真实姓名</h3> <h3>修改用户真实姓名</h3>
<?php $change_realname_form->printHTML(); ?> <?php $change_realname_form->printHTML(); ?>
<h3>用户名单</h3> <h3>用户名单</h3>

View File

@ -117,7 +117,7 @@ EOD;
<div id="div-$name" class="form-group"> <div id="div-$name" class="form-group">
<label for="input-$name" class="col-sm-2 control-label">$label_text</label> <label for="input-$name" class="col-sm-2 control-label">$label_text</label>
<div class="col-sm-3"> <div class="col-sm-3">
<select class="form-control" id="input-content" name="$name"> <select class="form-control" id="input-$name" name="$name">
EOD; EOD;
foreach ($options as $opt_name => $opt_label) { foreach ($options as $opt_name => $opt_label) {