diff --git a/db/app_uoj233.sql b/db/app_uoj233.sql index 1b30ada..fce837f 100644 --- a/db/app_uoj233.sql +++ b/db/app_uoj233.sql @@ -818,6 +818,7 @@ CREATE TABLE `user_info` ( `images_size_limit` int(11) UNSIGNED NOT NULL DEFAULT 104857600, /* 100 MiB */ `codeforces_handle` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `github` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', + `website` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', PRIMARY KEY (`username`), KEY `ac_num` (`ac_num`,`username`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4; diff --git a/web/app/controllers/user_info_edit.php b/web/app/controllers/user_info_edit.php index 38a663d..e4a2f4d 100644 --- a/web/app/controllers/user_info_edit.php +++ b/web/app/controllers/user_info_edit.php @@ -122,6 +122,16 @@ EOD); $vdata['codeforces_handle'] = $codeforces_handle; + return ''; + }, null); + $update_profile_form->addVInput('website', 'text', UOJLocale::get('user::website'), $user['website'], + function($url, &$vdata) { + if ($url && !validateURL($url)) { + return '链接格式不合法。'; + } + + $vdata['website'] = $url; + return ''; }, null); $update_profile_form->handle = function(&$vdata) use ($user, $myUser) { @@ -131,6 +141,7 @@ EOD); $esc_sex = DB::escape($_POST['sex']); $esc_motto = DB::escape($vdata['motto']); $esc_codeforces_handle = DB::escape($vdata['codeforces_handle']); + $esc_website = DB::escape($vdata['website']); if (isSuperUser($myUser)) { $esc_school = DB::escape($vdata['school']); @@ -138,7 +149,7 @@ EOD); 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', github = '$esc_github' 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', website = '$esc_website' WHERE username = '{$user['username']}'"); }; $update_profile_form->submit_button_config['margin_class'] = 'mt-3'; $update_profile_form->submit_button_config['text'] = '更新'; diff --git a/web/app/locale/user/en.php b/web/app/locale/user/en.php index d4e3f0d..5e72ddd 100644 --- a/web/app/locale/user/en.php +++ b/web/app/locale/user/en.php @@ -1,5 +1,6 @@ 'Website', 'admin' => 'Admin', 'student' => 'Student', 'teacher' => 'Teacher', diff --git a/web/app/locale/user/zh-cn.php b/web/app/locale/user/zh-cn.php index f7fe5c5..c4528f4 100644 --- a/web/app/locale/user/zh-cn.php +++ b/web/app/locale/user/zh-cn.php @@ -1,5 +1,6 @@ '网址', 'admin' => '管理员', 'student' => '学生', 'teacher' => '老师', diff --git a/web/app/upgrade/6_user_info_v2/up.sql b/web/app/upgrade/6_user_info_v2/up.sql index 0892e4e..416ffbf 100644 --- a/web/app/upgrade/6_user_info_v2/up.sql +++ b/web/app/upgrade/6_user_info_v2/up.sql @@ -1,2 +1,3 @@ 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 ''; +ALTER TABLE `user_info` ADD COLUMN `website` varchar(50) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT ''; diff --git a/web/app/views/user-info.php b/web/app/views/user-info.php index 3caf4f4..6b55c43 100644 --- a/web/app/views/user-info.php +++ b/web/app/views/user-info.php @@ -197,6 +197,14 @@ function fTime($time, $gran = -1) { + +