プロフィール編集

守矢諏訪子 <suwako@076.moe>、2026-11-10 22:15
コミット 2680b67c29e1da106240102f7b04563c62489be7 ・親 2e4f443 ・ファイルを見る

8個のファイル、+348 -26

変更 route.php
@@ -88,6 +88,8 @@
8888 $routes[] = Route::add('GET', 'logout', User::class.'@logout');
8989 $routes[] = Route::add('GET', 'verify/{token}', User::class.'@verify');
9090 $routes[] = Route::add('GET', 'profile/{name}', User::class.'@profile');
91+ $routes[] = Route::add('GET', 'profile/{name}/edit', User::class.'@editProfile');
92+ $routes[] = Route::add('POST', 'profile/{name}/edit', User::class.'@editProfile');
9193
9294 $routes[] = Route::add('GET', 'memberonly', Page::class.'@memberonly');
9395 $routes[] = Route::add('GET', 'staffonly', Page::class.'@staffonly');
@@ -50,8 +50,8 @@
5050 $path = ROOT.$section;
5151 $posts = [];
5252 $isMember = $user !== NULL && $user->role !== Roles::BANNED;
53- $isPaywall = $user !== NULL && $user->role >= Roles::SUBSCRIBER;
54- $isStaff = $user !== NULL && $user->role & (Roles::ADMIN | Roles::STAFF);
53+ $isPaywall = $user !== NULL && ($user->role & Roles::SUBSCRIBER);
54+ $isStaff = $user !== NULL && ($user->role & (Roles::ADMIN | Roles::STAFF));
5555
5656 if (!is_dir($path)) return $posts;
5757 $files = glob($path.'/*.md');
@@ -151,8 +151,8 @@
151151 $auth = new Auth();
152152 $user = $auth->getLoggedInUser();
153153 $isMember = $user !== NULL && $user->role !== Roles::BANNED;
154- $isPaywall = $user !== NULL && $user->role >= Roles::SUBSCRIBER;
155- $isStaff = $user !== NULL && $user->role & (Roles::ADMIN | Roles::STAFF);
154+ $isPaywall = $user !== NULL && ($user->role & Roles::SUBSCRIBER);
155+ $isStaff = $user !== NULL && ($user->role & (Roles::ADMIN | Roles::STAFF));
156156 $tmpl->assign('user', $user);
157157
158158 $tmpl->assign('pagetit', $pagetit);
@@ -77,7 +77,7 @@
7777 $this->pagetit .= 'ホーム';
7878 $this->tmpl->assign('pagetit', $this->pagetit);
7979
80- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
80+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
8181 $data = $this->op->getReseller(['with_statistics' => true]);
8282 $domain = $this->op->listDomains(['order_by.renewal_date' => 'asc', 'status' => 'ACT']);
8383 $this->tmpl->assign('data', $data->data);
@@ -96,7 +96,7 @@
9696 try {
9797 $this->pagetit .= '請求書一覧';
9898 $this->tmpl->assign('pagetit', $this->pagetit);
99- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
99+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
100100 $data = $this->op->listInvoices();
101101 $this->tmpl->assign('data', $data->data);
102102 $this->tmpl->render('listinvoices');
@@ -114,7 +114,7 @@
114114 $this->pagetit .= '請求書一覧';
115115 $this->tmpl->assign('pagetit', $this->pagetit);
116116
117- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
117+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
118118 $data = $this->op->listPayments();
119119 $this->tmpl->assign('data', $data->data);
120120 $this->tmpl->render('listpayments');
@@ -132,7 +132,7 @@
132132 $this->pagetit .= '請求書一覧';
133133 $this->tmpl->assign('pagetit', $this->pagetit);
134134
135- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
135+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
136136 $data = $this->op->listTransactions();
137137 $this->tmpl->assign('data', $data->data);
138138 $this->tmpl->render('listtransactions');
@@ -150,7 +150,7 @@
150150 $this->pagetit .= '顧客様検索';
151151 $this->tmpl->assign('pagetit', $this->pagetit);
152152
153- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
153+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
154154 $data = $this->op->listCustomers();
155155 $this->tmpl->assign('data', $data->data);
156156 $this->tmpl->render('listcustomers');
@@ -217,7 +217,7 @@
217217
218218 $err = [];
219219
220- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
220+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
221221
222222 if (!empty($_POST)) {
223223 if (NULL === $_POST['last_name'] || $_POST['last_name'] === ''
@@ -270,7 +270,7 @@
270270 $this->pagetit .= "顧客様「{$handle}」の表示";
271271 $this->tmpl->assign('pagetit', $this->pagetit);
272272
273- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
273+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
274274 $data = $this->op->getCustomer($handle, true);
275275 $this->tmpl->assign('data', $data->data);
276276 $this->tmpl->render('getcustomer');
@@ -295,7 +295,7 @@
295295 $this->pagetit .= "顧客様「{$handle}」の表示";
296296 $this->tmpl->assign('pagetit', $this->pagetit);
297297
298- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
298+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
299299 if (empty($_POST)) goto render_confirm;
300300
301301 if (isset($_POST['delete_reject'])) {
@@ -325,7 +325,7 @@
325325 $this->pagetit .= 'TLD一覧';
326326 $this->tmpl->assign('pagetit', $this->pagetit);
327327
328- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
328+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
329329 $data = $this->op->listTlds();
330330 $this->tmpl->assign('data', $data->data);
331331 $this->tmpl->render('listtlds');
@@ -349,7 +349,7 @@
349349 $this->pagetit .= "{$tld}の表示";
350350 $this->tmpl->assign('pagetit', $this->pagetit);
351351
352- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
352+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
353353 $data = $this->op->getTld($tld);
354354 $this->tmpl->assign('data', $data->data);
355355 $this->tmpl->render('gettld');
@@ -367,7 +367,7 @@
367367 $this->pagetit .= 'ドメイン確認';
368368 $this->tmpl->assign('pagetit', $this->pagetit);
369369
370- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
370+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
371371 $data = $this->op->listDomains($domains, true);
372372 $this->tmpl->assign('data', $data->data);
373373 $this->tmpl->render('checkdomain');
@@ -387,7 +387,7 @@
387387 $this->pagetit .= 'ドメイン確認';
388388 $this->tmpl->assign('pagetit', $this->pagetit);
389389
390- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
390+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
391391 if (!empty($domains)) {
392392 $data = $this->op->checkDomainAvailable($domains, true);
393393 $this->tmpl->assign('data', $data->data);
@@ -412,7 +412,7 @@
412412 $this->pagetit .= 'ドメイン値段一覧';
413413 $this->tmpl->assign('pagetit', $this->pagetit);
414414
415- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
415+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
416416 $data = $this->op->getDomainPrices(['domain.name' => $domainname, 'domain.extension' => $domainext]);
417417 $this->tmpl->assign('data', $data->data);
418418 $this->tmpl->render('getdomainprices');
@@ -430,7 +430,7 @@
430430 $this->pagetit .= 'DNS一覧';
431431 $this->tmpl->assign('pagetit', $this->pagetit);
432432
433- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
433+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
434434 $data = $this->op->listDnsZones();
435435 $this->tmpl->assign('data', $data->data);
436436 $this->tmpl->render('listdnszones');
@@ -454,7 +454,7 @@
454454 $this->pagetit .= "{$domain}のDNS管理";
455455 $this->tmpl->assign('pagetit', $this->pagetit);
456456
457- if (!$this->user || $this->user->role !== Roles::ADMIN) goto noaccess;
457+ if (!$this->user || !($this->user->role & Roles::ADMIN)) goto noaccess;
458458 $data = ['rec' => $this->op->listZoneRecords($domain), 'zone' => $this->op->getDnsZone($domain)];
459459 $this->tmpl->assign('data', $data->data);
460460 $this->tmpl->render('getdns');
@@ -55,6 +55,8 @@
5555 protected int $tokenDuration = 31536000; // 1年間
5656 protected int $verifyDuration = 86400; // 確認メールのリンクの有効期限(24時間)
5757 protected int $verifyResendInterval = 600; // 確認メールの再送の間隔(10分)
58+ /** アップロードをis_uploaded_fileで確認する(テストではfalse) */
59+ protected bool $checkUploads = true;
5860 protected string|int|null $algo = PASSWORD_ARGON2ID;
5961
6062 public function __construct(?string $username = null) {
@@ -71,6 +73,7 @@
7173 unset($this->pubUser->password);
7274 unset($this->pubUser->tokens);
7375 unset($this->pubUser->verifyToken);
76+ $this->pubUser->avatarUrl = avatar_url($this->pubUser);
7477 return $this->pubUser;
7578 }
7679
@@ -81,12 +84,21 @@
8184 unset($user->tokens);
8285 unset($user->verifyToken, $user->verifyExpire, $user->verifySent);
8386 $myself = $this->getUserData();
84- if (!$myself || ($myself->id != $user->id && $myself->role < Roles::STAFF)) $user->email = '(秘密)';
87+ // 以前は「role < STAFF」で比べていたので、ビットを足すと(Fediverse等)全員にメールアドレスが見えた
88+ $isStaff = $myself && ($myself->role & (Roles::STAFF | Roles::ADMIN));
89+ if (!$myself || ($myself->id != $user->id && !$isStaff)) $user->email = '(秘密)';
90+ $user->canEdit = $myself && ($myself->id == $user->id || ($myself->role & Roles::ADMIN));
91+ $user->bioHtml = nl2br(htmlspecialchars((string)($user->bio ?? ''), ENT_QUOTES, 'UTF-8'), false);
92+ $user->avatar = avatar_url($user);
8593 $user->name = namecolor($user);
8694 $user->regDate = date('Y年m月d日', $user->regDate);
8795 $user->gender = $user->gender === Gender::MALE ? '男' : ($user->gender === Gender::FEMALE ? '女' : '不明');
8896
8997 switch (true) {
98+ // 以前は「role & BANNED」(BANNEDは0なので常に偽)だった
99+ case ($user->role === Roles::BANNED):
100+ $user->role = 'BANされた';
101+ break;
90102 case ($user->role & Roles::ADMIN):
91103 $user->role = '管理者';
92104 break;
@@ -96,15 +108,11 @@
96108 case ($user->role & (Roles::FSUBSCRIBER | Roles::PSUBSCRIBER | Roles::NSUBSCRIBER | Roles::SUBSCRIBER)):
97109 $user->role = '支援者♡';
98110 break;
99- case ($user->role & Roles::BANNED):
100- $user->role = 'BANされた';
101- break;
102111 default:
103112 $user->role = 'ユーザー';
104113 break;
105114 }
106115
107- $user->avatar = '/static/user/'.($user->avatar === '' ? 'noicon.png' : $user->username.'/'.$user->avatar);
108116 $user->altName = $user->displayname ?: $user->username;
109117 unset($user->username);
110118 unset($user->displayname);
@@ -370,6 +378,190 @@
370378 }
371379
372380 /**
381+ * プロフィールを編集する
382+ *
383+ * 本人:表示名、性別、名前の色、自己紹介、アイコン、パスワード(現在のパスワードが必要)、メールアドレス(同じ)
384+ * 管理者:他のユーザーの表示名等とロール(パスワードとメールアドレスは本人だけ)
385+ *
386+ * @param string $username 編集するユーザー
387+ * @param array $in displayname, gender, namecolor(#rrggbb又は空), bio, removeAvatar,
388+ * currentPassword, newPassword, newPasswordVerify, email, roles(管理者:ビットの配列)
389+ * @param array|null $avatar $_FILES['avatar']
390+ * @return Result
391+ */
392+ public function updateProfile(string $username, array $in, ?array $avatar = null): Result {
393+ if (!AUTH_ENABLED) return Result::Error('エラー:認証システムは無効です。');
394+ $me = $this->id > 0 ? $this->getUserData() : null;
395+ $path = $this->userPath($username);
396+ if (!$me || $path === null) return Result::Error('エラー:ユーザーが見つかりません。');
397+ $user = json_decode((string)file_get_contents($path));
398+ if (!$user instanceof \stdClass) return Result::Error('エラー:ユーザーが見つかりません。');
399+ $self = $me->id == $user->id;
400+ $admin = (bool)($me->role & Roles::ADMIN);
401+ if (!$self && !$admin) return Result::Error('エラー:権限がありません。');
402+
403+ $errors = [];
404+ $notices = [];
405+
406+ // 表示名
407+ if (array_key_exists('displayname', $in)) {
408+ $d = trim(preg_replace('/[\x00-\x1f\x7f]/u', '', (string)$in['displayname']));
409+ if (mb_strlen($d) > 50) $errors[] = 'エラー:表示名は50文字までです。';
410+ else $user->displayname = $d;
411+ }
412+ // 性別
413+ if (array_key_exists('gender', $in)) {
414+ $g = (int)$in['gender'];
415+ $user->gender = in_array($g, [\Gender::UNKNOWN, \Gender::MALE, \Gender::FEMALE], true) ? $g : \Gender::UNKNOWN;
416+ }
417+ // 名前の色(styleに入るので、色だけ許可する)
418+ if (array_key_exists('namecolor', $in)) {
419+ $c = trim((string)$in['namecolor']);
420+ if ($c === '') $user->namecolor = '';
421+ else if (preg_match('/^#[0-9a-fA-F]{6}$/', $c)) $user->namecolor = "color: {$c};";
422+ else $errors[] = 'エラー:名前の色は「#rrggbb」の形式で入力して下さい。';
423+ }
424+ // 自己紹介
425+ if (array_key_exists('bio', $in)) {
426+ $b = trim(str_replace(["\r\n", "\r"], "\n", (string)$in['bio']));
427+ if (mb_strlen($b) > 500) $errors[] = 'エラー:自己紹介は500文字までです。';
428+ else $user->bio = $b;
429+ }
430+
431+ // アイコン
432+ $oldAvatar = (string)($user->avatar ?? '');
433+ $newAvatar = null;
434+ if ($avatar && ($avatar['error'] ?? UPLOAD_ERR_NO_FILE) !== UPLOAD_ERR_NO_FILE) {
435+ if (!$res->isSuccess) $errors[] = 'エラー:'.$res->message;
436+ else $newAvatar = $res->data['name'];
437+ } else if (!empty($in['removeAvatar'])) {
438+ $user->avatar = '';
439+ }
440+
441+ // パスワード(本人だけ)
442+ if ($self && (string)($in['newPassword'] ?? '') !== '') {
443+ if (!password_verify((string)($in['currentPassword'] ?? ''), $user->password)) {
444+ $errors[] = 'エラー:現在のパスワードが一致していません。';
445+ } else {
446+ $res = $this->verifyPassword((string)$in['newPassword'], (string)($in['newPasswordVerify'] ?? ''));
447+ if (!$res->isSuccess) $errors[] = $res->message;
448+ else {
449+ $user->password = password_hash((string)$in['newPassword'], $this->algo);
450+ // 他の端末のログインを取り消す(このログインは残す)
451+ $current = $this->token ? hash('sha256', $this->token) : '';
452+ $user->tokens = array_values(array_filter($user->tokens ?? [], fn($t) => hash_equals((string)($t->token ?? ''), $current)));
453+ $notices[] = 'パスワードを変更しました。';
454+ }
455+ }
456+ }
457+
458+ // メールアドレス(本人だけ)
459+ $sendVerify = null;
460+ $email = trim((string)($in['email'] ?? ''));
461+ if ($self && $email !== '' && $email !== $user->email) {
462+ if (!password_verify((string)($in['currentPassword'] ?? ''), $user->password)) {
463+ $errors[] = 'エラー:メールアドレスを変更するには現在のパスワードを入力して下さい。';
464+ } else {
465+ $res = $this->verifyEmail($email);
466+ if (!$res->isSuccess) $errors[] = $res->message;
467+ else if ($this->requiresVerification()) {
468+ // 確認するまでは前のメールアドレスのまま
469+ $sendVerify = bin2hex(random_bytes(32));
470+ $user->pendingEmail = $email;
471+ $user->verifyToken = hash('sha256', $sendVerify);
472+ $user->verifyExpire = time() + $this->verifyDuration;
473+ $user->verifySent = time();
474+ } else {
475+ $user->email = $email;
476+ $notices[] = 'メールアドレスを変更しました。';
477+ }
478+ }
479+ }
480+
481+ // ロール(管理者だけ)
482+ if ($admin && isset($in['roles']) && is_array($in['roles'])) {
483+ $role = Roles::BANNED;
484+ foreach ($in['roles'] as $bit) {
485+ $bit = (int)$bit;
486+ if (isset(Roles::LABELS[$bit])) $role |= $bit;
487+ }
488+ // 最後の管理者は管理者を外せない
489+ if (($user->role & Roles::ADMIN) && !($role & Roles::ADMIN) && $this->countAdmins() <= 1) {
490+ $errors[] = 'エラー:最後の管理者のロールは外せません。';
491+ } else {
492+ $user->role = $role;
493+ // Fediverseのロールの既定(全員に付与)を使わず、以後はビットで判断する
494+ $user->fediDefault = true;
495+ }
496+ }
497+
498+ if (!empty($errors)) {
499+ return Result::Error(implode('<br />', array_map(fn($e) => htmlspecialchars($e, ENT_QUOTES, 'UTF-8'), $errors)));
500+ }
501+
502+ if ($newAvatar !== null) $user->avatar = $newAvatar;
503+ $json = json_encode($user, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
504+ if (file_put_contents($path, $json, LOCK_EX) === false) {
505+ logger(LogType::Auth, '【updateProfile】JSONファイルを変更出来なかった。パス:'.$path);
506+ return Result::Error('エラー:ユーザーデータの保存に失敗。');
507+ }
508+ if ($oldAvatar !== '' && $oldAvatar !== ($user->avatar ?? '')) {
509+ \Std\Lib\Fedi\Media::remove('/public/static/user/'.$user->username.'/'.$oldAvatar);
510+ }
511+
512+ if ($sendVerify !== null) {
513+ $mailUser = clone $user;
514+ $mailUser->email = $email;
515+ if ($this->sendVerificationMail($mailUser, $sendVerify)->isSuccess) {
516+ $notices[] = "確認メールを「{$email}」に送信しました。リンクを開くとメールアドレスが変わります。";
517+ } else {
518+ $notices[] = '確認メールの送信に失敗しました。メールアドレスは変わっていません。';
519+ }
520+ }
521+
522+ return Result::Success(implode(' ', $notices) ?: 'プロフィールを保存しました。', ['user' => $user]);
523+ }
524+
525+ /**
526+ * プロフィールの編集画面用のデータ(パスワード等を除く)
527+ *
528+ * @param string $username ユーザー
529+ * @return \stdClass|null 編集出来ない場合はnull
530+ */
531+ public function getEditableUser(string $username): ?\stdClass {
532+ $me = $this->id > 0 ? $this->getUserData() : null;
533+ $path = $this->userPath($username);
534+ if (!$me || $path === null) return null;
535+ $user = json_decode((string)file_get_contents($path));
536+ if (!$user instanceof \stdClass) return null;
537+ if ($me->id != $user->id && !($me->role & Roles::ADMIN)) return null;
538+ unset($user->password, $user->tokens, $user->verifyToken);
539+ $user->isSelf = $me->id == $user->id;
540+ $user->isAdmin = (bool)($me->role & Roles::ADMIN);
541+ $user->colorHex = preg_match('/#[0-9a-fA-F]{6}/', (string)($user->namecolor ?? ''), $m) ? $m[0] : '';
542+ $user->avatarUrl = avatar_url($user);
543+ return $user;
544+ }
545+
546+ /** ユーザー名からJSONファイルのパス */
547+ private function userPath(string $username): ?string {
548+ if (!preg_match('/^[A-Za-z0-9]+$/', $username)) return null;
549+ foreach ($this->userFiles() as $path) {
550+ if (preg_match('/^\d+\.'.$username.'\.json$/', basename($path))) return $path;
551+ }
552+ return null;
553+ }
554+
555+ private function countAdmins(): int {
556+ $n = 0;
557+ foreach ($this->userFiles() as $path) {
558+ $d = json_decode((string)file_get_contents($path));
559+ if ($d instanceof \stdClass && (($d->role ?? 0) & Roles::ADMIN)) $n++;
560+ }
561+ return $n;
562+ }
563+
564+ /**
373565 * 登録時にメールアドレスの確認が必要か
374566 *
375567 * @return bool
@@ -397,6 +589,11 @@
397589 if (($data->verifyExpire ?? 0) < time()) return Result::Error($invalid);
398590
399591 $data->verified = true;
592+ // メールアドレスの変更の確認
593+ if (isset($data->pendingEmail)) {
594+ $data->email = $data->pendingEmail;
595+ unset($data->pendingEmail);
596+ }
400597 unset($data->verifyToken, $data->verifyExpire, $data->verifySent);
401598 $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
402599 if (file_put_contents($path, $json, LOCK_EX) === false) {
変更 util.php
@@ -373,6 +373,16 @@
373373 return $color.$suffix;
374374 }
375375
376+/**
377+ * アイコンのURL(無ければnoicon.png)
378+ */
379+function avatar_url(\stdClass $user): string {
380+ $avatar = (string)($user->avatar ?? '');
381+ $name = (string)($user->username ?? '');
382+ if ($avatar === '' || $name === '' || !is_file(ROOT."/public/static/user/{$name}/{$avatar}")) return '/static/user/noicon.png';
383+ return "/static/user/{$name}/".rawurlencode($avatar);
384+}
385+
376386 function make_csrf_token(?bool $force = false): string {
377387 if (null !== getcookie('csrf_token') && !$force) return getcookie('csrf_token');
378388 $token = bin2hex(random_bytes(32));
@@ -0,0 +1,100 @@
1+{@ include(common/header) @}
2+ <h1 class="paragraph">プロフィールの編集({{ $e->username }})</h1>
3+{@ if ($error) @}
4+ <p>
5+ <div class="errormes">
6+ {{{ $error }}}
7+ </div>
8+ </p>
9+{@ endif @}
10+{@ if ($message) @}
11+ <p class="paragraph">{{ $message }}</p>
12+{@ endif @}
13+
14+ <form action="/profile/{{ $e->username }}/edit" method="POST" enctype="multipart/form-data">
15+ <input type="hidden" name="csrf_token" value="{{ $csrf }}" />
16+ <table>
17+ <tbody>
18+ <tr>
19+ <td>アイコン:</td>
20+ <td>
21+ <img src="{{ $e->avatarUrl }}" alt="" style="max-width: 100px; max-height: 100px;" /><br />
22+ <input type="file" name="avatar" accept="image/png,image/jpeg,image/gif" /><br />
23+{@ if ($e->avatar !== '') @}
24+ <label><input type="checkbox" name="removeAvatar" value="1" /> アイコンを削除する</label>
25+{@ endif @}
26+ </td>
27+ </tr>
28+ <tr>
29+ <td><label for="displayname">表示名:</label></td>
30+ <td><input type="text" id="displayname" name="displayname" maxlength="50" value="{{ $e->displayname }}" /></td>
31+ </tr>
32+ <tr>
33+ <td><label for="gender">性別:</label></td>
34+ <td>
35+ <select id="gender" name="gender">
36+ <option value="-1"{{{ $e->gender === -1 ? ' selected="selected"' : '' }}}>不明</option>
37+ <option value="0"{{{ $e->gender === 0 ? ' selected="selected"' : '' }}}>男</option>
38+ <option value="1"{{{ $e->gender === 1 ? ' selected="selected"' : '' }}}>女</option>
39+ </select>
40+ </td>
41+ </tr>
42+ <tr>
43+ <td><label for="namecolor">名前の色:</label></td>
44+ <td>
45+ <label><input type="checkbox" name="usecolor" value="1"{{{ $e->colorHex !== '' ? ' checked="checked"' : '' }}} /> 色を指定する</label>
46+ <input type="color" id="namecolor" name="namecolor" value="{{ $e->colorHex !== '' ? $e->colorHex : '#ea79d8' }}" />
47+ </td>
48+ </tr>
49+ <tr>
50+ <td><label for="bio">自己紹介:</label></td>
51+ <td><textarea id="bio" name="bio" rows="5" cols="50" maxlength="500">{{ $e->bio ?? '' }}</textarea></td>
52+ </tr>
53+{@ if ($fediEnabled && $e->fedi) @}
54+ <tr>
55+ <td>Fediverse:</td>
56+ <td><label><input type="checkbox" name="locked" value="1"{{{ $locked ? ' checked="checked"' : '' }}} /> フォローを承認制にする</label></td>
57+ </tr>
58+{@ endif @}
59+{@ if ($e->isSelf) @}
60+ <tr>
61+ <td><label for="email">メールアドレス:</label></td>
62+ <td>
63+ <input type="email" id="email" name="email" value="{{ $e->email }}" />
64+{@ if (isset($e->pendingEmail)) @}
65+ <br /><small>「{{ $e->pendingEmail }}」の確認待ち</small>
66+{@ endif @}
67+ </td>
68+ </tr>
69+ <tr>
70+ <td><label for="newPassword">新しいパスワード:</label></td>
71+ <td><input type="password" id="newPassword" name="newPassword" autocomplete="new-password" /></td>
72+ </tr>
73+ <tr>
74+ <td><label for="newPasswordVerify">新しいパスワード(確認):</label></td>
75+ <td><input type="password" id="newPasswordVerify" name="newPasswordVerify" autocomplete="new-password" /></td>
76+ </tr>
77+ <tr>
78+ <td><label for="currentPassword">現在のパスワード:</label></td>
79+ <td><input type="password" id="currentPassword" name="currentPassword" autocomplete="current-password" /><br /><small>メールアドレスかパスワードを変更する場合は必須</small></td>
80+ </tr>
81+{@ endif @}
82+{@ if ($e->isAdmin) @}
83+ <tr>
84+ <td>ロール(管理者):</td>
85+ <td>
86+{@ foreach ($roles as $bit => $label) @}
87+ <label><input type="checkbox" name="roles[]" value="{{ $bit }}"{{{ ($e->role & $bit) || ($bit === \Roles::FEDIVERSE && $e->fedi) ? ' checked="checked"' : '' }}} /> {{ $label }}</label><br />
88+{@ endforeach @}
89+ <small>全部外すとBANになります。</small>
90+ </td>
91+ </tr>
92+{@ endif @}
93+ <tr>
94+ <td></td>
95+ <td><button>保存</button> <a href="/profile/{{ $e->username }}">戻る</a></td>
96+ </tr>
97+ </tbody>
98+ </table>
99+ </form>
100+{@ include(common/footer) @}
@@ -4,7 +4,7 @@
44 <table>
55 <tbody>
66 <tr>
7- <td rowspan="4"><img src="{{ $u->avatar }}" alt="{{ $u->altName }}" style="max-width: 100px; max-height: 100px; width: 100%; height: 100%;" /></td>
7+ <td rowspan="5"><img src="{{ $u->avatar }}" alt="{{ $u->altName }}" style="max-width: 100px; max-height: 100px; width: 100%; height: 100%;" /></td>
88 <td>登録日:{{ $u->regDate }}</td>
99 </tr>
1010 <tr>
@@ -16,7 +16,20 @@
1616 <tr>
1717 <td>メールアドレス:{{ $u->email }}</td>
1818 </tr>
19+ <tr>
20+ <td>
21+{@ if ($u->fediverse !== '') @}
22+ Fediverse:<a href="/microblog/user/{{ $name }}">{{ $u->fediverse }}</a>
23+{@ endif @}
24+{@ if ($u->canEdit) @}
25+ <a href="/profile/{{ $name }}/edit">プロフィールを編集</a>
26+{@ endif @}
27+ </td>
28+ </tr>
1929 </tbody>
2030 </table>
2131 </p>
22-{@ include(common/footer) @}
32+{@ if ($u->bioHtml !== '') @}
33+ <p class="paragraph">{{{ $u->bioHtml }}}</p>
34+{@ endif @}
35+{@ include(common/footer) @}