Skip to content

Commit 9d21a7f

Browse files
committed
Fix search by IP in admin panel
1 parent 7611309 commit 9d21a7f

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

featherbb/Controller/Admin/Users.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,12 +164,14 @@ public function showusers($req, $res, $args)
164164
{
165165
Container::get('hooks')->fire('controller.admin.users.showusers');
166166

167-
if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $args['ip']) && !@preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $args['ip'])) {
167+
$search_ip = Input::query('ip');
168+
169+
if (!@preg_match('%^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$%', $search_ip) && !@preg_match('%^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$%', $search_ip)) {
168170
throw new Error(__('Bad IP message'), 400);
169171
}
170172

171173
// Fetch user count
172-
$num_users = $this->model->get_num_users_ip($args['ip']);
174+
$num_users = $this->model->get_num_users_ip($search_ip);
173175

174176
// Determine the user offset (based on $_GET['p'])
175177
$num_pages = ceil($num_users / 50);
@@ -181,10 +183,10 @@ public function showusers($req, $res, $args)
181183
'title' => array(Utils::escape(ForumSettings::get('o_board_title')), __('Admin'), __('Users'), __('Results head')),
182184
'active_page' => 'admin',
183185
'admin_console' => true,
184-
'paging_links' => '<span class="pages-label">'.__('Pages').' </span>'.Url::paginate_old($num_pages, $p, '?ip_stats='.$args['ip']),
186+
'paging_links' => '<span class="pages-label">'.__('Pages').' </span>'.Url::paginate_old($num_pages, $p, '?ip_stats='.$search_ip),
185187
'page' => $p,
186188
'start_from' => $start_from,
187-
'info' => $this->model->get_info_poster($args['ip'], $start_from),
189+
'info' => $this->model->get_info_poster($search_ip, $start_from),
188190
)
189191
)->addTemplate('admin/users/show_users.php')->display();
190192
}

featherbb/Model/Admin/Users.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ public function ban_users()
529529

530530
public function get_user_search()
531531
{
532-
$form = Input::query('form') ? Input::query('form') : array();
532+
$form = Input::query('form', [], false);
533533
$form = Container::get('hooks')->fire('model.admin.model.users.get_user_search.form', $form);
534534

535535
$search = array();

featherbb/View/admin/users/admin_users.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,15 +153,15 @@
153153

154154
<h2 class="block2"><span><?php _e('IP search head') ?></span></h2>
155155
<div class="box">
156-
<form method="get" action="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3Cspan+class%3D"pl-ent"><?= Router::pathFor('adminUsers') ?>">
156+
<form method="get" action="proxy.php?url=https%3A%2F%2Fgithub.com%2F%3Cspan+class%3D"pl-ent"><?= Router::pathFor('usersIpShow') ?>">
157157
<div class="inform">
158158
<fieldset>
159159
<legend><?php _e('IP search subhead') ?></legend>
160160
<div class="infldset">
161161
<table class="aligntop">
162162
<tr>
163163
<th scope="row"><?php _e('IP address label') ?><div><input type="submit" value="<?php _e('Find IP address') ?>" tabindex="26" /></div></th>
164-
<td><input type="text" name="show_users" size="18" maxlength="15" tabindex="24" />
164+
<td><input type="text" name="ip" size="18" maxlength="15" tabindex="24" />
165165
<span><?php _e('IP address help') ?></span></td>
166166
</tr>
167167
</table>

featherbb/routes.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
Route::group('/users', function() {
172172
Route::map(['GET', 'POST'], '', '\FeatherBB\Controller\Admin\Users:display')->setName('adminUsers');
173173
Route::get('/ip-stats/id/{id:[0-9]+}', '\FeatherBB\Controller\Admin\Users:ipstats')->setName('usersIpStats');
174-
Route::get('/show-users/ip/{ip}', '\FeatherBB\Controller\Admin\Users:showusers')->setName('usersIpShow');
174+
Route::get('/show-users', '\FeatherBB\Controller\Admin\Users:showusers')->setName('usersIpShow');
175175
});
176176

177177
})->add(new IsAdmMod);

0 commit comments

Comments
 (0)