2021-12-14 18:32:47 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2023-01-10 22:44:09 +00:00
|
|
|
namespace Shimmie2;
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
class CustomUserPageTheme extends UserPageTheme
|
|
|
|
{
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_login_page(Page $page): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $config;
|
|
|
|
$page->set_title("Login");
|
|
|
|
$page->set_heading("Login");
|
|
|
|
$page->disable_left();
|
|
|
|
$html = "
|
2013-06-19 19:09:22 +00:00
|
|
|
<form action='".make_link("user_admin/login")."' method='POST'>
|
|
|
|
<table summary='Login Form'>
|
|
|
|
<tr>
|
|
|
|
<td width='70'><label for='user'>Name</label></td>
|
|
|
|
<td width='70'><input id='user' type='text' name='user'></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td><label for='pass'>Password</label></td>
|
|
|
|
<td><input id='pass' type='password' name='pass'></td>
|
|
|
|
</tr>
|
|
|
|
<tr><td colspan='2'><input type='submit' value='Log In'></td></tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
2019-05-28 16:59:38 +00:00
|
|
|
if ($config->get_bool("login_signup_enabled")) {
|
|
|
|
$html .= "<small><a href='".make_link("user_admin/create")."'>Create Account</a></small>";
|
|
|
|
}
|
|
|
|
$page->add_block(new Block("Login", $html, "main", 90));
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param array<int, array{name: string, link: string}> $parts
|
|
|
|
*/
|
|
|
|
public function display_user_links(Page $page, User $user, array $parts): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
// no block in this theme
|
|
|
|
}
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_login_block(Page $page): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
// no block in this theme
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param array<array{link: string, name: string}> $parts
|
|
|
|
*/
|
|
|
|
public function display_user_block(Page $page, User $user, array $parts): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
$html = "";
|
|
|
|
$blocked = ["Pools", "Pool Changes", "Alias Editor", "My Profile"];
|
|
|
|
foreach ($parts as $part) {
|
|
|
|
if (in_array($part["name"], $blocked)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$html .= "<li><a href='{$part["link"]}'>{$part["name"]}</a>";
|
|
|
|
}
|
2020-06-24 14:40:25 +00:00
|
|
|
$b = new Block("User Links", $html, "user", 90);
|
|
|
|
$b->is_content = false;
|
|
|
|
$page->add_block($b);
|
2019-05-28 16:59:38 +00:00
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_signup_page(Page $page): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
2024-06-05 11:50:12 +00:00
|
|
|
global $config, $user;
|
2019-05-28 16:59:38 +00:00
|
|
|
$tac = $config->get_string("login_tac", "");
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2023-02-04 20:50:26 +00:00
|
|
|
$tac = send_event(new TextFormattingEvent($tac))->formatted;
|
2020-06-24 14:40:25 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>";
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2024-06-05 11:50:12 +00:00
|
|
|
$email_required = (
|
|
|
|
$config->get_bool("user_email_required") &&
|
|
|
|
!$user->can(Permissions::CREATE_OTHER_USER)
|
|
|
|
);
|
|
|
|
$email_text = $email_required ? "Email" : "Email (Optional)";
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
if (empty($tac)) {
|
|
|
|
$html = "";
|
|
|
|
} else {
|
|
|
|
$html = "<p>$tac</p>";
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$html .= "
|
2013-06-19 19:09:22 +00:00
|
|
|
<form action='".make_link("user_admin/create")."' method='POST'>
|
|
|
|
<table style='width: 300px;'>
|
|
|
|
<tr><td>Name</td><td><input type='text' name='name'></td></tr>
|
|
|
|
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
|
|
|
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
2024-06-05 11:50:12 +00:00
|
|
|
<tr><td>$email_text</td><td><input type='text' name='email'></td></tr>
|
|
|
|
$reca
|
2013-06-19 19:09:22 +00:00
|
|
|
<tr><td colspan='2'><input type='Submit' value='Create Account'></td></tr>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->set_title("Create Account");
|
|
|
|
$page->set_heading("Create Account");
|
|
|
|
$page->disable_left();
|
|
|
|
$page->add_block(new Block("Signup", $html));
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param array<string, int> $uploads
|
|
|
|
* @param array<string, int> $comments
|
|
|
|
* @param array<string, int> $events
|
|
|
|
*/
|
2024-01-15 14:23:00 +00:00
|
|
|
public function display_ip_list(Page $page, array $uploads, array $comments, array $events): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
$html = "<table id='ip-history' style='width: 400px;'>";
|
|
|
|
$html .= "<tr><td>Uploaded from: ";
|
|
|
|
foreach ($uploads as $ip => $count) {
|
|
|
|
$html .= "<br>$ip ($count)";
|
|
|
|
}
|
|
|
|
$html .= "</td><td>Commented from:";
|
|
|
|
foreach ($comments as $ip => $count) {
|
|
|
|
$html .= "<br>$ip ($count)";
|
|
|
|
}
|
|
|
|
$html .= "</td></tr>";
|
|
|
|
$html .= "<tr><td colspan='2'>(Most recent at top)</td></tr></table>";
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2019-05-28 16:59:38 +00:00
|
|
|
$page->add_block(new Block("IPs", $html));
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
|
2024-01-20 14:10:59 +00:00
|
|
|
/**
|
|
|
|
* @param string[] $stats
|
|
|
|
*/
|
|
|
|
public function display_user_page(User $duser, array $stats): void
|
2019-05-28 16:59:38 +00:00
|
|
|
{
|
|
|
|
global $page;
|
|
|
|
$page->disable_left();
|
|
|
|
parent::display_user_page($duser, $stats);
|
|
|
|
}
|
2013-06-19 19:09:22 +00:00
|
|
|
}
|