2007-07-16 19:47:25 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class UserPageTheme extends Themelet {
|
2009-01-04 19:18:37 +00:00
|
|
|
public function display_login_page(Page $page) {
|
2007-07-17 02:23:24 +00:00
|
|
|
$page->set_title("Login");
|
|
|
|
$page->set_heading("Login");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block("Login There",
|
|
|
|
"There should be a login box to the left"));
|
2007-07-16 19:47:25 +00:00
|
|
|
}
|
|
|
|
|
2017-09-17 17:59:48 +00:00
|
|
|
/**
|
2019-05-28 16:31:20 +00:00
|
|
|
* #param User[] $users
|
2017-09-17 17:59:48 +00:00
|
|
|
*/
|
2018-07-22 18:23:34 +00:00
|
|
|
public function display_user_list(Page $page, array $users, User $user, int $page_num, int $page_total) {
|
2009-05-30 13:47:57 +00:00
|
|
|
$page->set_title("User List");
|
|
|
|
$page->set_heading("User List");
|
|
|
|
$page->add_block(new NavBlock());
|
2017-09-17 17:59:48 +00:00
|
|
|
|
|
|
|
$html = "<table class='zebra'>";
|
|
|
|
|
|
|
|
$html .= "<tr>";
|
|
|
|
$html .= "<td>Name</td>";
|
|
|
|
if($user->can('delete_user'))
|
|
|
|
$html .= "<td>Email</td>";
|
|
|
|
$html .= "<td>Class</td>";
|
|
|
|
$html .= "<td>Action</td>";
|
|
|
|
$html .= "</tr>";
|
|
|
|
|
|
|
|
$h_username = html_escape(@$_GET['username']);
|
|
|
|
$h_email = html_escape(@$_GET['email']);
|
|
|
|
$h_class = html_escape(@$_GET['class']);
|
|
|
|
|
|
|
|
$html .= "<tr>" . make_form("user_admin/list", "GET");
|
|
|
|
$html .= "<td><input type='text' name='username' value='$h_username'/></td>";
|
|
|
|
if($user->can('delete_user'))
|
2018-07-22 18:23:34 +00:00
|
|
|
$html .= "<td><input type='text' name='email' value='$h_email'/></td>";
|
2017-09-17 17:59:48 +00:00
|
|
|
$html .= "<td><input type='text' name='class' value='$h_class'/></td>";
|
|
|
|
$html .= "<td><input type='submit' value='Search'/></td>";
|
|
|
|
$html .= "</form></tr>";
|
|
|
|
|
2009-05-30 13:47:57 +00:00
|
|
|
foreach($users as $duser) {
|
2017-09-17 17:59:48 +00:00
|
|
|
$h_name = html_escape($duser->name);
|
|
|
|
$h_email = html_escape($duser->email);
|
|
|
|
$h_class = html_escape($duser->class->name);
|
|
|
|
$u_link = make_link("user/" . url_escape($duser->name));
|
|
|
|
$u_posts = make_link("post/list/user_id=" . url_escape($duser->id) . "/1");
|
|
|
|
|
2009-05-30 13:47:57 +00:00
|
|
|
$html .= "<tr>";
|
2017-09-17 17:59:48 +00:00
|
|
|
$html .= "<td><a href='$u_link'>$h_name</a></td>";
|
|
|
|
if($user->can('delete_user'))
|
|
|
|
$html .= "<td>$h_email</td>";
|
|
|
|
$html .= "<td>$h_class</td>";
|
|
|
|
$html .= "<td><a href='$u_posts'>Show Posts</a></td>";
|
2009-05-30 13:47:57 +00:00
|
|
|
$html .= "</tr>";
|
|
|
|
}
|
2017-09-17 17:59:48 +00:00
|
|
|
|
2009-05-30 13:47:57 +00:00
|
|
|
$html .= "</table>";
|
2017-09-17 17:59:48 +00:00
|
|
|
|
2009-05-30 13:47:57 +00:00
|
|
|
$page->add_block(new Block("Users", $html));
|
2018-07-22 18:23:34 +00:00
|
|
|
$this->display_paginator($page, "user_admin/list", $this->get_args(), $page_num, $page_total);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function ueie($var) {
|
|
|
|
if(isset($_GET[$var])) return $var."=".url_escape($_GET[$var]);
|
|
|
|
else return "";
|
|
|
|
}
|
|
|
|
protected function get_args() {
|
|
|
|
$args = "";
|
|
|
|
// Check if each arg is actually empty and skip it if so
|
|
|
|
if(strlen($this->ueie("username")))
|
|
|
|
$args .= $this->ueie("username")."&";
|
|
|
|
if(strlen($this->ueie("email")))
|
|
|
|
$args .= $this->ueie("email")."&";
|
|
|
|
if(strlen($this->ueie("class")))
|
|
|
|
$args .= $this->ueie("class")."&";
|
|
|
|
// If there are no args at all, set $args to null to prevent an unnecessary ? at the end of the paginator url
|
|
|
|
if(strlen($args) == 0)
|
|
|
|
$args = null;
|
|
|
|
return $args;
|
2009-05-30 13:47:57 +00:00
|
|
|
}
|
|
|
|
|
2009-01-04 19:18:37 +00:00
|
|
|
public function display_user_links(Page $page, User $user, $parts) {
|
2007-08-01 17:11:46 +00:00
|
|
|
# $page->add_block(new Block("User Links", join(", ", $parts), "main", 10));
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:18:37 +00:00
|
|
|
public function display_user_block(Page $page, User $user, $parts) {
|
2007-07-19 14:32:25 +00:00
|
|
|
$h_name = html_escape($user->name);
|
2012-01-12 20:46:34 +00:00
|
|
|
$html = 'Logged in as '.$h_name;
|
2009-08-03 09:46:40 +00:00
|
|
|
foreach($parts as $part) {
|
2012-01-12 20:46:34 +00:00
|
|
|
$html .= '<br><a href="'.$part["link"].'">'.$part["name"].'</a>';
|
2009-08-03 09:46:40 +00:00
|
|
|
}
|
2007-07-19 14:32:25 +00:00
|
|
|
$page->add_block(new Block("User Links", $html, "left", 90));
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:18:37 +00:00
|
|
|
public function display_signup_page(Page $page) {
|
2007-07-16 19:47:25 +00:00
|
|
|
global $config;
|
2007-08-01 15:08:40 +00:00
|
|
|
$tac = $config->get_string("login_tac", "");
|
2007-07-16 19:47:25 +00:00
|
|
|
|
2010-01-05 19:06:04 +00:00
|
|
|
if($config->get_bool("login_tac_bbcode")) {
|
|
|
|
$tfe = new TextFormattingEvent($tac);
|
|
|
|
send_event($tfe);
|
|
|
|
$tac = $tfe->formatted;
|
|
|
|
}
|
2007-08-01 15:02:05 +00:00
|
|
|
|
2007-07-16 19:47:25 +00:00
|
|
|
if(empty($tac)) {$html = "";}
|
2012-01-12 20:46:34 +00:00
|
|
|
else {$html = '<p>'.$tac.'</p>';}
|
2007-07-16 19:47:25 +00:00
|
|
|
|
2012-02-13 20:51:34 +00:00
|
|
|
$h_reca = "<tr><td colspan='2'>".captcha_get_html()."</td></tr>";
|
2009-11-10 03:21:02 +00:00
|
|
|
|
2012-01-12 20:46:34 +00:00
|
|
|
$html .= '
|
|
|
|
'.make_form(make_link("user_admin/create"))."
|
2012-03-13 15:23:56 +00:00
|
|
|
<table class='form'>
|
2012-03-11 15:49:37 +00:00
|
|
|
<tbody>
|
2015-01-06 13:04:39 +00:00
|
|
|
<tr><th>Name</th><td><input type='text' name='name' required></td></tr>
|
|
|
|
<tr><th>Password</th><td><input type='password' name='pass1' required></td></tr>
|
|
|
|
<tr><th>Repeat Password</th><td><input type='password' name='pass2' required></td></tr>
|
|
|
|
<tr><th>Email (Optional)</th><td><input type='email' name='email'></td></tr>
|
2012-03-11 15:49:37 +00:00
|
|
|
$h_reca
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr><td colspan='2'><input type='Submit' value='Create Account'></td></tr>
|
|
|
|
</tfoot>
|
2007-07-16 19:47:25 +00:00
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
|
|
|
|
$page->set_title("Create Account");
|
|
|
|
$page->set_heading("Create Account");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block("Signup", $html));
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:18:37 +00:00
|
|
|
public function display_signups_disabled(Page $page) {
|
2007-07-27 00:49:03 +00:00
|
|
|
$page->set_title("Signups Disabled");
|
|
|
|
$page->set_heading("Signups Disabled");
|
|
|
|
$page->add_block(new NavBlock());
|
|
|
|
$page->add_block(new Block("Signups Disabled",
|
|
|
|
"The board admin has disabled the ability to create new accounts~"));
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:18:37 +00:00
|
|
|
public function display_login_block(Page $page) {
|
2007-07-16 19:47:25 +00:00
|
|
|
global $config;
|
2012-01-12 20:46:34 +00:00
|
|
|
$html = '
|
|
|
|
'.make_form(make_link("user_admin/login"))."
|
2012-03-14 20:28:15 +00:00
|
|
|
<table style='width: 100%;' class='form'>
|
2012-03-11 15:49:37 +00:00
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<th><label for='user'>Name</label></th>
|
|
|
|
<td><input id='user' type='text' name='user'></td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<th><label for='pass'>Password</label></th>
|
|
|
|
<td><input id='pass' type='password' name='pass'></td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr><td colspan='2'><input type='submit' value='Log In'></td></tr>
|
|
|
|
</tfoot>
|
2009-08-03 18:58:12 +00:00
|
|
|
</table>
|
2007-07-16 19:47:25 +00:00
|
|
|
</form>
|
|
|
|
";
|
|
|
|
if($config->get_bool("login_signup_enabled")) {
|
2007-07-27 13:05:48 +00:00
|
|
|
$html .= "<small><a href='".make_link("user_admin/create")."'>Create Account</a></small>";
|
2007-07-16 19:47:25 +00:00
|
|
|
}
|
|
|
|
$page->add_block(new Block("Login", $html, "left", 90));
|
|
|
|
}
|
2009-01-04 19:18:37 +00:00
|
|
|
|
2019-02-22 21:04:09 +00:00
|
|
|
public function display_ip_list(Page $page, array $uploads, array $comments, array $events) {
|
2007-07-19 14:32:25 +00:00
|
|
|
$html = "<table id='ip-history'>";
|
|
|
|
$html .= "<tr><td>Uploaded from: ";
|
2007-12-08 03:23:53 +00:00
|
|
|
$n = 0;
|
2007-07-19 14:32:25 +00:00
|
|
|
foreach($uploads as $ip => $count) {
|
2012-01-12 20:46:34 +00:00
|
|
|
$html .= '<br>'.$ip.' ('.$count.')';
|
2007-12-08 03:23:53 +00:00
|
|
|
if(++$n >= 20) {
|
|
|
|
$html .= "<br>...";
|
|
|
|
break;
|
|
|
|
}
|
2007-07-19 14:32:25 +00:00
|
|
|
}
|
2007-12-08 03:23:53 +00:00
|
|
|
|
2007-07-19 14:32:25 +00:00
|
|
|
$html .= "</td><td>Commented from:";
|
2007-12-08 03:23:53 +00:00
|
|
|
$n = 0;
|
2007-07-19 14:32:25 +00:00
|
|
|
foreach($comments as $ip => $count) {
|
2012-01-12 20:46:34 +00:00
|
|
|
$html .= '<br>'.$ip.' ('.$count.')';
|
2007-12-08 03:23:53 +00:00
|
|
|
if(++$n >= 20) {
|
|
|
|
$html .= "<br>...";
|
|
|
|
break;
|
|
|
|
}
|
2007-07-19 14:32:25 +00:00
|
|
|
}
|
2007-12-08 03:23:53 +00:00
|
|
|
|
2019-02-22 21:04:09 +00:00
|
|
|
$html .= "</td><td>Logged Events:";
|
|
|
|
$n = 0;
|
2019-02-22 21:05:53 +00:00
|
|
|
foreach($events as $ip => $count) {
|
2019-02-22 21:04:09 +00:00
|
|
|
$html .= '<br>'.$ip.' ('.$count.')';
|
|
|
|
if(++$n >= 20) {
|
|
|
|
$html .= "<br>...";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-19 14:32:25 +00:00
|
|
|
$html .= "</td></tr>";
|
2019-02-22 21:04:09 +00:00
|
|
|
$html .= "<tr><td colspan='3'>(Most recent at top)</td></tr></table>";
|
2007-07-19 14:32:25 +00:00
|
|
|
|
2014-10-10 21:19:54 +00:00
|
|
|
$page->add_block(new Block("IPs", $html, "main", 70));
|
2007-07-19 14:32:25 +00:00
|
|
|
}
|
|
|
|
|
2009-08-18 21:30:52 +00:00
|
|
|
public function display_user_page(User $duser, $stats) {
|
|
|
|
global $page, $user;
|
|
|
|
assert(is_array($stats));
|
2012-01-12 20:46:34 +00:00
|
|
|
$stats[] = 'User ID: '.$duser->id;
|
2009-08-18 21:30:52 +00:00
|
|
|
|
2012-02-13 20:51:34 +00:00
|
|
|
$page->set_title(html_escape($duser->name)."'s Page");
|
|
|
|
$page->set_heading(html_escape($duser->name)."'s Page");
|
2007-07-26 11:49:52 +00:00
|
|
|
$page->add_block(new NavBlock());
|
2013-03-03 18:27:06 +00:00
|
|
|
$page->add_block(new Block("Stats", join("<br>", $stats), "main", 10));
|
2007-07-19 14:32:25 +00:00
|
|
|
|
2007-07-26 11:49:52 +00:00
|
|
|
if(!$user->is_anonymous()) {
|
2012-03-12 17:29:03 +00:00
|
|
|
if($user->id == $duser->id || $user->can("edit_user_info")) {
|
2014-10-10 21:19:54 +00:00
|
|
|
$page->add_block(new Block("Options", $this->build_options($duser), "main", 60));
|
2007-07-26 11:49:52 +00:00
|
|
|
}
|
2007-07-19 14:32:25 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-01-04 19:41:03 +00:00
|
|
|
protected function build_options(User $duser) {
|
2015-09-12 10:43:28 +00:00
|
|
|
global $config, $user;
|
2012-01-22 19:14:35 +00:00
|
|
|
$html = "";
|
2012-01-24 16:40:36 +00:00
|
|
|
if($duser->id != $config->get_int('anon_id')){ //justa fool-admin protection so they dont mess around with anon users.
|
2012-01-22 19:14:35 +00:00
|
|
|
|
2015-07-12 21:14:57 +00:00
|
|
|
if($user->can('edit_user_name')) {
|
|
|
|
$html .= "
|
|
|
|
<p>".make_form(make_link("user_admin/change_name"))."
|
|
|
|
<input type='hidden' name='id' value='{$duser->id}'>
|
|
|
|
<table class='form'>
|
|
|
|
<thead><tr><th colspan='2'>Change Name</th></tr></thead>
|
|
|
|
<tbody><tr><th>New name</th><td><input type='text' name='name' value='".html_escape($duser->name)."'></td></tr></tbody>
|
|
|
|
<tfoot><tr><td colspan='2'><input type='Submit' value='Set'></td></tr></tfoot>
|
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
}
|
|
|
|
|
2009-08-11 16:07:03 +00:00
|
|
|
$html .= "
|
2015-07-12 21:14:57 +00:00
|
|
|
<p>".make_form(make_link("user_admin/change_pass"))."
|
2012-01-22 19:14:35 +00:00
|
|
|
<input type='hidden' name='id' value='{$duser->id}'>
|
2012-03-13 15:23:56 +00:00
|
|
|
<table class='form'>
|
2012-03-11 15:49:37 +00:00
|
|
|
<thead>
|
|
|
|
<tr><th colspan='2'>Change Password</th></tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr><th>Password</th><td><input type='password' name='pass1'></td></tr>
|
|
|
|
<tr><th>Repeat Password</th><td><input type='password' name='pass2'></td></tr>
|
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
|
|
|
</tfoot>
|
2012-01-22 19:14:35 +00:00
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
|
|
|
|
<p>".make_form(make_link("user_admin/change_email"))."
|
|
|
|
<input type='hidden' name='id' value='{$duser->id}'>
|
2012-03-13 15:23:56 +00:00
|
|
|
<table class='form'>
|
2012-03-11 15:49:37 +00:00
|
|
|
<thead><tr><th colspan='2'>Change Email</th></tr></thead>
|
|
|
|
<tbody><tr><th>Address</th><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr></tbody>
|
|
|
|
<tfoot><tr><td colspan='2'><input type='Submit' value='Set'></td></tr></tfoot>
|
2012-01-22 19:14:35 +00:00
|
|
|
</table>
|
|
|
|
</form>
|
|
|
|
";
|
|
|
|
|
2012-03-31 18:25:27 +00:00
|
|
|
$i_user_id = int_escape($duser->id);
|
|
|
|
|
|
|
|
if($user->can("edit_user_class")) {
|
2015-08-02 19:39:41 +00:00
|
|
|
global $_shm_user_classes;
|
2012-03-11 15:49:25 +00:00
|
|
|
$class_html = "";
|
2015-08-02 19:39:41 +00:00
|
|
|
foreach($_shm_user_classes as $name => $values) {
|
2012-02-14 20:38:19 +00:00
|
|
|
$h_name = html_escape($name);
|
|
|
|
$h_title = html_escape(ucwords($name));
|
|
|
|
$h_selected = ($name == $duser->class->name ? " selected" : "");
|
2012-03-11 15:49:25 +00:00
|
|
|
$class_html .= "<option value='$h_name'$h_selected>$h_title</option>\n";
|
2012-02-14 20:38:19 +00:00
|
|
|
}
|
|
|
|
$html .= "
|
2012-03-11 15:49:25 +00:00
|
|
|
<p>".make_form(make_link("user_admin/change_class"))."
|
|
|
|
<input type='hidden' name='id' value='$i_user_id'>
|
|
|
|
<table style='width: 300px;'>
|
2012-03-11 15:53:15 +00:00
|
|
|
<thead><tr><th colspan='2'>Change Class</th></tr></thead>
|
|
|
|
<tbody><tr><td><select name='class'>$class_html</select></td></tr></tbody>
|
|
|
|
<tfoot><tr><td><input type='submit' value='Set'></td></tr></tfoot>
|
2012-03-11 15:49:25 +00:00
|
|
|
</table>
|
2012-01-22 19:14:35 +00:00
|
|
|
</form>
|
2012-03-31 18:25:27 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
|
|
|
|
if($user->can("delete_user")) {
|
|
|
|
$html .= "
|
2012-03-11 15:49:25 +00:00
|
|
|
<p>".make_form(make_link("user_admin/delete_user"))."
|
|
|
|
<input type='hidden' name='id' value='$i_user_id'>
|
|
|
|
<table style='width: 300px;'>
|
2012-03-11 15:53:15 +00:00
|
|
|
<thead>
|
|
|
|
<tr><th colspan='2'>Delete User</th></tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
2012-03-12 17:44:07 +00:00
|
|
|
<tr><td><input type='checkbox' name='with_images'> Delete images</td></tr>
|
|
|
|
<tr><td><input type='checkbox' name='with_comments'> Delete comments</td></tr>
|
2012-03-11 15:53:15 +00:00
|
|
|
</tbody>
|
|
|
|
<tfoot>
|
|
|
|
<tr><td><input type='button' class='shm-unlocker' data-unlock-sel='.deluser' value='Unlock'></td></tr>
|
|
|
|
<tr><td><input type='submit' class='deluser' value='Delete User' disabled='true'/></td></tr>
|
|
|
|
</tfoot>
|
2012-03-11 15:49:25 +00:00
|
|
|
</table>
|
2012-02-14 20:38:19 +00:00
|
|
|
</form>
|
|
|
|
";
|
2012-01-22 19:14:35 +00:00
|
|
|
}
|
2009-08-11 16:07:03 +00:00
|
|
|
}
|
2007-07-19 14:32:25 +00:00
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
// }}}
|
2007-07-16 19:47:25 +00:00
|
|
|
}
|
2014-04-25 02:28:53 +00:00
|
|
|
|