My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
--- admin_bans.php 2007-03-17 01:01:25.000000000 +0000
+++ admin_bans2.php 2009-11-09 21:36:10.000000000 +0000
@@ -275,6 +275,113 @@
}


+// find a ban
+else if (isset($_POST['find_ban']))
+{
+ $form = $_POST['form'];
+ $form['username'] = $_POST['username'];
+
+ // trim() all elements in $form
+ $form = array_map('trim', $form);
+ $conditions = array();
+
+ $expire_after = trim($_POST['expire_after']);
+ $expire_before = trim($_POST['expire_before']);
+ $order_by = $_POST['order_by'];
+ $direction = $_POST['direction'];
+
+ // Try to convert date/time to timestamps
+ if ($expire_after != '')
+ $expire_after = strtotime($expire_after);
+ if ($expire_before != '')
+ $expire_before = strtotime($expire_before);
+
+ if ($expire_after == -1 || $expire_before == -1)
+ message('You entered an invalid date/time.');
+
+ if ($expire_after != '')
+ $conditions[] = 'expire>'.$expire_after;
+ if ($expire_before != '')
+ $conditions[] = 'expire<'.$expire_before;
+
+ $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
+ while (list($key, $input) = @each($form))
+ {
+ if ($input != '' && in_array($key, array('username', 'email', 'ip', 'message')))
+ $conditions[] = $db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\'';
+ }
+
+ if (empty($conditions))
+ message('You didn\'t enter any search terms.');
+
+ $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Bans';
+ require PUN_ROOT.'header.php';
+?>
+<div class="linkst">
+ <div class="inbox">
+ <div><a href="javascript:history.go(-1)">Go back</a></div>
+ </div>
+</div>
+
+<div id="bans1" class="blocktable">
+ <h2><span>Users</span></h2>
+ <div class="box">
+ <div class="inbox">
+ <table cellspacing="0">
+ <thead>
+ <tr>
+ <th class="tcl" scope="col">Username</th>
+ <th class="tc2" scope="col">E-mail</th>
+ <th class="tc3" scope="col">IP/IP-ranges</th>
+ <th class="tc4" scope="col">Reason</th>
+ <th class="tc5" scope="col">Expire</th>
+ <th class="tcr" scope="col">Action</th>
+ </tr>
+ </thead>
+ <tbody>
+<?php
+
+ $result = $db->query('SELECT id, username, email, ip, message, expire FROM '.$db->prefix.'bans WHERE '.implode(' AND ', $conditions).' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction)) or error('Unable to fetch ban info', __FILE__, __LINE__, $db->error());
+ if ($db->num_rows($result))
+ {
+ while ($ban_data = $db->fetch_assoc($result))
+ {
+ $actions = '<a href="admin_bans.php?edit_ban=' . $ban_data['id'] . '">Edit</a> - <a href="admin_bans.php?del_ban=' . $ban_data['id'] . '">Remove</a>';
+ $expire = format_time($ban_data['expire'], true);
+
+?>
+ <tr>
+ <td class="tcl"><?php echo pun_htmlspecialchars($ban_data['username']) ?></td>
+ <td class="tc2"><?php echo $ban_data['email']; ?></td>
+ <td class="tc3"><?php echo $ban_data['ip']; ?></td>
+ <td class="tc4"><?php echo pun_htmlspecialchars($ban_data['message']) ?></td>
+ <td class="tc5"><?php echo $expire ?></td>
+ <td class="tcr"><?php echo $actions ?></td>
+ </tr>
+<?php
+
+ }
+ }
+ else
+ echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">No match.</td></tr>'."\n";
+
+?>
+ </tbody>
+ </table>
+ </div>
+ </div>
+</div>
+
+<div class="linksb">
+ <div class="inbox">
+ <div><a href="javascript:history.go(-1)">Go back</a></div>
+ </div>
+</div>
+<?php
+ require PUN_ROOT.'footer.php';
+ die();
+}
+
$page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Bans';
$focus_element = array('bans', 'new_ban_user');
require PUN_ROOT.'header.php';
@@ -305,54 +412,62 @@
</form>
</div>

- <h2 class="block2"><span>Existing bans</span></h2>
+ <h2 class="block2"><span>Ban search</span></h2>
<div class="box">
- <div class="fakeform">
-<?php
-
-$result = $db->query('SELECT id, username, ip, email, message, expire FROM '.$db->prefix.'bans ORDER BY id') or error('Unable to fetch ban list', __FILE__, __LINE__, $db->error());
-if ($db->num_rows($result))
-{
- while ($cur_ban = $db->fetch_assoc($result))
- {
- $expire = format_time($cur_ban['expire'], true);
-
-?>
+ <form id="find_ban" method="post" action="admin_bans.php?action=find_ban">
+ <p class="submittop"><input type="submit" name="find_ban" value="Submit search" tabindex="1" /></p>
<div class="inform">
<fieldset>
- <legend>Ban expires: <?php echo $expire ?></legend>
+ <legend>Enter search criteria</legend>
<div class="infldset">
- <table cellspacing="0">
-<?php if ($cur_ban['username'] != ''): ?> <tr>
- <th>Username</th>
- <td><?php echo pun_htmlspecialchars($cur_ban['username']) ?></td>
- </tr>
-<?php endif; ?><?php if ($cur_ban['email'] != ''): ?> <tr>
- <th>E-mail</th>
- <td><?php echo $cur_ban['email'] ?></td>
- </tr>
-<?php endif; ?><?php if ($cur_ban['ip'] != ''): ?> <tr>
- <th>IP/IP-ranges</th>
- <td><?php echo $cur_ban['ip'] ?></td>
- </tr>
-<?php endif; ?><?php if ($cur_ban['message'] != ''): ?> <tr>
- <th>Reason</th>
- <td><?php echo pun_htmlspecialchars($cur_ban['message']) ?></td>
+ <p>Search for bans in the database. You can enter one or more terms to search for. Wildcards in the form of asterisks (*) are accepted.</p>
+ <table class="aligntop" cellspacing="0">
+ <tr>
+ <th scope="row">Username</th>
+ <td><input type="text" name="username" size="25" maxlength="25" tabindex="2" /></td>
+ </tr>
+ <tr>
+ <th scope="row">E-mail</th>
+ <td><input type="text" name="form[email]" size="25" maxlength="25" tabindex="3" /></td>
+ </tr>
+ <tr>
+ <th scope="row">IP/IP-ranges</th>
+ <td><input type="text" name="form[ip]" size="25" maxlength="25" tabindex="4" /></td>
+ </tr>
+ <tr>
+ <th scope="row">Reason</th>
+ <td><input type="text" name="form[message]" size="25" maxlength="25" tabindex="5" /></td>
+ </tr>
+ <tr>
+ <th scope="row">Expire after</th>
+ <td><input type="text" name="expire_after" size="24" maxlength="19" tabindex="6" />
+ <span>(yyyy-mm-dd hh:mm:ss)</span></td>
</tr>
-<?php endif; ?> </table>
- <p class="linkactions"><a href="admin_bans.php?edit_ban=<?php echo $cur_ban['id'] ?>">Edit</a> - <a href="admin_bans.php?del_ban=<?php echo $cur_ban['id'] ?>">Remove</a></p>
+ <tr>
+ <th scope="row">Expire before</th>
+ <td><input type="text" name="expire_before" size="24" maxlength="19" tabindex="7" />
+ <span>(yyyy-mm-dd hh:mm:ss)</span></td>
+ </tr>
+ <tr>
+ <th scope="row">Order by</th>
+ <td>
+ <select name="order_by" tabindex="8">
+ <option value="username" selected="selected">username</option>
+ <option value="email">e-mail</option>
+ <option value="ip">ip</option>
+ <option value="expire">expire</option>
+ </select>&nbsp;&nbsp;&nbsp;<select name="direction" tabindex="9">
+ <option value="ASC" selected="selected">ascending</option>
+ <option value="DESC">descending</option>
+ </select>
+ </td>
+ </tr>
+ </table>
</div>
</fieldset>
</div>
-<?php
-
- }
-}
-else
- echo "\t\t\t\t".'<p>No bans in list.</p>'."\n";
-
-?>
- </div>
+ <p class="submitend"><input type="submit" name="find_ban" value="Submit search" tabindex="10" /></p>
+ </form>
</div>
</div>
<div class="clearer"></div>

Change log

r48 by guillaume.duhamel on Nov 9, 2009   Diff
Fixed a stupid bug
Go to: 
Project members, sign in to write a code review

Older revisions

r46 by guillaume.duhamel on Nov 9, 2009   Diff
Some simple patch for fluxbb that
provides a ban search
feature instead of displaying the ban
list.
All revisions of this file

File info

Size: 7596 bytes, 219 lines
Powered by Google Project Hosting