mirror of
https://github.com/renbaoshuo/S2OJ.git
synced 2024-11-26 04:28:41 +00:00
feat(web/user/edit): github
This commit is contained in:
parent
e33e3ef413
commit
b433a907e5
@ -70,6 +70,16 @@ EOD);
|
|||||||
|
|
||||||
$vdata['qq'] = $qq;
|
$vdata['qq'] = $qq;
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}, null);
|
||||||
|
$update_profile_form->addVInput('github', 'text', 'GitHub', $user['github'],
|
||||||
|
function($github, &$vdata) {
|
||||||
|
if ($github && !validateGitHubUsername($github)) {
|
||||||
|
return 'GitHub 用户名不合法。';
|
||||||
|
}
|
||||||
|
|
||||||
|
$vdata['github'] = $github;
|
||||||
|
|
||||||
return '';
|
return '';
|
||||||
}, null);
|
}, null);
|
||||||
if (isSuperUser($myUser)) {
|
if (isSuperUser($myUser)) {
|
||||||
@ -117,6 +127,7 @@ EOD);
|
|||||||
$update_profile_form->handle = function(&$vdata) use ($user, $myUser) {
|
$update_profile_form->handle = function(&$vdata) use ($user, $myUser) {
|
||||||
$esc_email = DB::escape($vdata['email']);
|
$esc_email = DB::escape($vdata['email']);
|
||||||
$esc_qq = DB::escape($vdata['qq']);
|
$esc_qq = DB::escape($vdata['qq']);
|
||||||
|
$esc_github = DB::escape($vdata['github']);
|
||||||
$esc_sex = DB::escape($vdata['sex']);
|
$esc_sex = DB::escape($vdata['sex']);
|
||||||
$esc_motto = DB::escape($vdata['motto']);
|
$esc_motto = DB::escape($vdata['motto']);
|
||||||
$esc_codeforces_handle = DB::escape($vdata['codeforces_handle']);
|
$esc_codeforces_handle = DB::escape($vdata['codeforces_handle']);
|
||||||
@ -127,7 +138,7 @@ EOD);
|
|||||||
DB::update("UPDATE user_info SET school = '$esc_school' WHERE username = '{$user['username']}'");
|
DB::update("UPDATE user_info SET school = '$esc_school' WHERE username = '{$user['username']}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
DB::update("UPDATE user_info SET email = '$esc_email', qq = '$esc_qq', sex = '$esc_sex', motto = '$esc_motto', codeforces_handle = '$esc_codeforces_handle' WHERE username = '{$user['username']}'");
|
DB::update("UPDATE user_info SET email = '$esc_email', qq = '$esc_qq', sex = '$esc_sex', motto = '$esc_motto', codeforces_handle = '$esc_codeforces_handle', github = '$esc_github' WHERE username = '{$user['username']}'");
|
||||||
};
|
};
|
||||||
$update_profile_form->submit_button_config['margin_class'] = 'mt-3';
|
$update_profile_form->submit_button_config['margin_class'] = 'mt-3';
|
||||||
$update_profile_form->submit_button_config['text'] = '更新';
|
$update_profile_form->submit_button_config['text'] = '更新';
|
||||||
|
@ -55,3 +55,7 @@ function validateURL($url) {
|
|||||||
function validateString($str) {
|
function validateString($str) {
|
||||||
return preg_match('/[^0-9a-zA-Z]/', $str) !== true;
|
return preg_match('/[^0-9a-zA-Z]/', $str) !== true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateGitHubUsername($username) {
|
||||||
|
return is_string($username) && preg_match('/^[a-zA-Z0-9_-]{1,20}$/', $username);
|
||||||
|
}
|
||||||
|
@ -1 +1,2 @@
|
|||||||
ALTER TABLE `user_info` DROP COLUMN IF EXISTS `codeforces_handle`;
|
ALTER TABLE `user_info` DROP COLUMN IF EXISTS `codeforces_handle`;
|
||||||
|
ALTER TABLE `user_info` DROP COLUMN IF EXISTS `github`;
|
||||||
|
@ -1 +1,2 @@
|
|||||||
ALTER TABLE `user_info` ADD COLUMN `codeforces_handle` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
ALTER TABLE `user_info` ADD COLUMN `codeforces_handle` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||||
|
ALTER TABLE `user_info` ADD COLUMN `github` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '';
|
||||||
|
Loading…
Reference in New Issue
Block a user