source: trunk/web/punbb/admin_users.php @ 1

Last change on this file since 1 was 1, checked in by dj3c1t, 12 years ago

import initial

File size: 17.6 KB
Line 
1<?php
2/***********************************************************************
3
4  Copyright (C) 2002-2005  Rickard Andersson (rickard@punbb.org)
5
6  This file is part of PunBB.
7
8  PunBB is free software; you can redistribute it and/or modify it
9  under the terms of the GNU General Public License as published
10  by the Free Software Foundation; either version 2 of the License,
11  or (at your option) any later version.
12
13  PunBB is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  GNU General Public License for more details.
17
18  You should have received a copy of the GNU General Public License
19  along with this program; if not, write to the Free Software
20  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21  MA  02111-1307  USA
22
23************************************************************************/
24
25
26// Tell header.php to use the admin template
27define('PUN_ADMIN_CONSOLE', 1);
28
29define('PUN_ROOT', './');
30require PUN_ROOT.'include/common.php';
31require PUN_ROOT.'include/common_admin.php';
32
33
34if ($pun_user['g_id'] > PUN_MOD)
35        message($lang_common['No permission']);
36
37
38// Show IP statistics for a certain user ID
39if (isset($_GET['ip_stats']))
40{
41        $ip_stats = intval($_GET['ip_stats']);
42        if ($ip_stats < 1)
43                message($lang_common['Bad request']);
44
45
46        $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Utilisateurs';
47        require PUN_ROOT.'header.php';
48
49?>
50<div class="linkst">
51        <div class="inbox">
52                <div><a href="javascript:history.go(-1)">Retour</a></div>
53        </div>
54</div>
55
56<div id="users1" class="blocktable">
57        <h2><span>Utilisateurs</span></h2>
58        <div class="box">
59                <div class="inbox">
60                        <table cellspacing="0">
61                        <thead>
62                                <tr>
63                                        <th class="tcl" scope="col">Adresse <acronym title="Internet Protocol" lang="en">IP</acronym></th>
64                                        <th class="tc2" scope="col">DerniÚre visite</th>
65                                        <th class="tc3" scope="col">Occurences</th>
66                                        <th class="tcr" scope="col">Action</th>
67                                </tr>
68                        </thead>
69                        <tbody>
70<?php
71
72        $result = $db->query('SELECT poster_ip, MAX(posted) AS last_used, COUNT(id) AS used_times FROM '.$db->prefix.'posts WHERE poster_id='.$ip_stats.' GROUP BY poster_ip ORDER BY last_used DESC') or error('Impossible de retrouver les informations des messages', __FILE__, __LINE__, $db->error());
73        if ($db->num_rows($result))
74        {
75                while ($cur_ip = $db->fetch_assoc($result))
76                {
77
78?>
79                                <tr>
80                                        <td class="tcl"><a href="moderate.php?get_host=<?php echo $cur_ip['poster_ip'] ?>"><?php echo $cur_ip['poster_ip'] ?></a></td>
81                                        <td class="tc2"><?php echo format_time($cur_ip['last_used']) ?></td>
82                                        <td class="tc3"><?php echo $cur_ip['used_times'] ?></td>
83                                        <td class="tcr"><a href="admin_users.php?show_users=<?php echo $cur_ip['poster_ip'] ?>">Trouver plus d'utilisateur pour cette <acronym title="Internet Protocol" lang="en">IP</acronym></a></td>
84                                </tr>
85<?php
86
87                }
88        }
89        else
90                echo "\t\t\t\t".'<tr><td class="tcl" colspan="4">Il n\'y a actuellement aucun message de cet utilisateur dans les forums.</td></tr>'."\n";
91
92?>
93                        </tbody>
94                        </table>
95                </div>
96        </div>
97</div>
98
99<div class="linksb">
100        <div class="inbox">
101                <div><a href="javascript:history.go(-1)">Retour</a></div>
102        </div>
103</div>
104<?php
105
106        require PUN_ROOT.'footer.php';
107}
108
109
110if (isset($_GET['show_users']))
111{
112        $ip = $_GET['show_users'];
113
114        if (!preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $ip))
115                message('L\'adresse IP soumise n\'est pas correctement formée.');
116
117
118        $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Utilisateurs';
119        require PUN_ROOT.'header.php';
120
121?>
122<div class="linkst">
123        <div class="inbox">
124                <div><a href="javascript:history.go(-1)">Retour</a></div>
125        </div>
126</div>
127
128<div id="users2" class="blocktable">
129        <h2><span>Utilisateurs</span></h2>
130        <div class="box">
131                <div class="inbox">
132                        <table cellspacing="0">
133                        <thead>
134                                <tr>
135                                        <th class="tcl" scope="col">Nom d'utilisateur</th>
136                                        <th class="tc2" scope="col">E-mail</th>
137                                        <th class="tc3" scope="col">Titre/Statut</th>
138                                        <th class="tc4" scope="col">Messages</th>
139                                        <th class="tc5" scope="col">Note admin</th>
140                                        <th class="tcr" scope="col">Actions</th>
141                                </tr>
142                        </thead>
143                        <tbody>
144<?php
145
146        $result = $db->query('SELECT DISTINCT poster_id, poster FROM '.$db->prefix.'posts WHERE poster_ip=\''.$db->escape($ip).'\' ORDER BY poster DESC') or error('Impossible de retrouver les informations des messages', __FILE__, __LINE__, $db->error());
147        $num_posts = $db->num_rows($result);
148
149        if ($num_posts)
150        {
151                // Loop through users and print out some info
152                for ($i = 0; $i < $num_posts; ++$i)
153                {
154                        list($poster_id, $poster) = $db->fetch_row($result);
155
156                        $result2 = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u INNER JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND u.id='.$poster_id) or error('Impossible de retrouver les informations utilisateur', __FILE__, __LINE__, $db->error());
157
158                        if (($user_data = $db->fetch_assoc($result2)))
159                        {
160                                $user_title = get_title($user_data);
161
162                                $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">Voir stats IP</a> - <a href="search.php?action=show_user&amp;user_id='.$user_data['id'].'">Afficher messages</a>';
163
164?>
165                                <tr>
166                                        <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td>
167                                        <td class="tc2"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></td>
168                                        <td class="tc3"><?php echo $user_title ?></td>
169                                        <td class="tc4"><?php echo $user_data['num_posts'] ?></td>
170                                        <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? $user_data['admin_note'] : '&#160;' ?></td>
171                                        <td class="tcr"><?php echo $actions ?></td>
172                                </tr>
173<?php
174
175                        }
176                        else
177                        {
178
179?>
180                                <tr>
181                                        <td class="tcl"><?php echo pun_htmlspecialchars($poster) ?></td>
182                                        <td class="tc2">&#160;</td>
183                                        <td class="tc3">Invité</td>
184                                        <td class="tc4">&#160;</td>
185                                        <td class="tc5">&#160;</td>
186                                        <td class="tcr">&#160;</td>
187                                </tr>
188<?php
189
190                        }
191                }
192        }
193        else
194                echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">L\'adresse IP soumise est introuvable dans la base de données.</td></tr>'."\n";
195
196?>
197                        </tbody>
198                        </table>
199                </div>
200        </div>
201</div>
202
203<div class="linksb">
204        <div class="inbox">
205                <div><a href="javascript:history.go(-1)">Retour</a></div>
206        </div>
207</div>
208<?php
209        require PUN_ROOT.'footer.php';
210}
211
212
213else if (isset($_POST['find_user']))
214{
215        $form = $_POST['form'];
216        $form['username'] = $_POST['username'];
217
218        // trim() all elements in $form
219        $form = array_map('trim', $form);
220        $conditions = array();
221       
222        $posts_greater = trim($_POST['posts_greater']);
223        $posts_less = trim($_POST['posts_less']);
224        $last_post_after = trim($_POST['last_post_after']);
225        $last_post_before = trim($_POST['last_post_before']);
226        $registered_after = trim($_POST['registered_after']);
227        $registered_before = trim($_POST['registered_before']);
228        $order_by = $_POST['order_by'];
229        $direction = $_POST['direction'];
230        $user_group = $_POST['user_group'];
231
232        if (preg_match('/[^0-9]/', $posts_greater.$posts_less))
233                message('Vous avez saisi une donnée non-numérique dans un champ qui en requiÚre une.');
234
235        // Try to convert date/time to timestamps
236        if ($last_post_after != '')
237                $last_post_after = strtotime($last_post_after);
238        if ($last_post_before != '')
239                $last_post_before = strtotime($last_post_before);
240        if ($registered_after != '')
241                $registered_after = strtotime($registered_after);
242        if ($registered_before != '')
243                $registered_before = strtotime($registered_before);
244
245        if ($last_post_after == -1 || $last_post_before == -1 || $registered_after == -1 || $registered_before == -1)
246                message('Vous avez saisi une date/heure invalide.');
247
248        if ($last_post_after != '')
249                $conditions[] = 'u.last_post>'.$last_post_after;
250        if ($last_post_before != '')
251                $conditions[] = 'u.last_post<'.$last_post_before;
252        if ($registered_after != '')
253                $conditions[] = 'u.registered>'.$registered_after;
254        if ($registered_before != '')
255                $conditions[] = 'u.registered<'.$registered_before;
256
257        $like_command = ($db_type == 'pgsql') ? 'ILIKE' : 'LIKE';
258        while (list($key, $input) = @each($form))
259        {
260                if ($input != '')
261                        $conditions[] = 'u.'.$db->escape($key).' '.$like_command.' \''.$db->escape(str_replace('*', '%', $input)).'\'';
262        }
263
264        if ($posts_greater != '')
265                $conditions[] = 'u.num_posts>'.$posts_greater;
266        if ($posts_less != '')
267                $conditions[] = 'u.num_posts<'.$posts_less;
268
269        if ($user_group != 'all')
270                $conditions[] = 'u.group_id='.$db->escape($user_group);
271
272        if (empty($conditions))
273                message('Vous n\'avez saisi aucun critÚres de recherche.');
274
275
276        $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Utilisateurs';
277        require PUN_ROOT.'header.php';
278
279?>
280<div class="linkst">
281        <div class="inbox">
282                <div><a href="javascript:history.go(-1)">Retour</a></div>
283        </div>
284</div>
285
286<div id="users2" class="blocktable">
287        <h2><span>Utilisateurs</span></h2>
288        <div class="box">
289                <div class="inbox">
290                        <table cellspacing="0">
291                        <thead>
292                                <tr>
293                                        <th class="tcl" scope="col">Nom d'utilisateur</th>
294                                        <th class="tc2" scope="col">E-mail</th>
295                                        <th class="tc3" scope="col">Titre/Status</th>
296                                        <th class="tc4" scope="col">Messages</th>
297                                        <th class="tc5" scope="col">Note admin</th>
298                                        <th class="tcr" scope="col">Actions</th>
299                                </tr>
300                        </thead>
301                        <tbody>
302<?php
303
304        $result = $db->query('SELECT u.id, u.username, u.email, u.title, u.num_posts, u.admin_note, g.g_id, g.g_user_title FROM '.$db->prefix.'users AS u LEFT JOIN '.$db->prefix.'groups AS g ON g.g_id=u.group_id WHERE u.id>1 AND '.implode(' AND ', $conditions).' ORDER BY '.$db->escape($order_by).' '.$db->escape($direction)) or error('Impossible de retrouver les informations utilisateurs', __FILE__, __LINE__, $db->error());
305        if ($db->num_rows($result))
306        {
307                while ($user_data = $db->fetch_assoc($result))
308                {
309                        $user_title = get_title($user_data);
310
311                        // This script is a special case in that we want to display "Not verified" for non-verified users
312                        if (($user_data['g_id'] == '' || $user_data['g_id'] == PUN_UNVERIFIED) && $user_title != $lang_common['Banned'])
313                                $user_title = '<span class="warntext">Not verified</span>';
314
315                        $actions = '<a href="admin_users.php?ip_stats='.$user_data['id'].'">Voir stats IP</a> - <a href="search.php?action=show_user&amp;user_id='.$user_data['id'].'">Afficher messages</a>';
316
317?>
318                                <tr>
319                                        <td class="tcl"><?php echo '<a href="profile.php?id='.$user_data['id'].'">'.pun_htmlspecialchars($user_data['username']).'</a>' ?></td>
320                                        <td class="tc2"><a href="mailto:<?php echo $user_data['email'] ?>"><?php echo $user_data['email'] ?></a></td>
321                                        <td class="tc3"><?php echo $user_title ?></td>
322                                        <td class="tc4"><?php echo $user_data['num_posts'] ?></td>
323                                        <td class="tc5"><?php echo ($user_data['admin_note'] != '') ? $user_data['admin_note'] : '&#160;' ?></td>
324                                        <td class="tcr"><?php echo $actions ?></td>
325                                </tr>
326<?php
327
328                }
329        }
330        else
331                echo "\t\t\t\t".'<tr><td class="tcl" colspan="6">Aucun résultat.</td></tr>'."\n";
332
333?>
334                        </tbody>
335                        </table>
336                </div>
337        </div>
338</div>
339
340<div class="linksb">
341        <div class="inbox">
342                <div><a href="javascript:history.go(-1)">Retour</a></div>
343        </div>
344</div>
345<?php
346
347        require PUN_ROOT.'footer.php';
348}
349
350
351else
352{
353        $page_title = pun_htmlspecialchars($pun_config['o_board_title']).' / Admin / Utilisateurs';
354        $focus_element = array('find_user', 'username');
355        require PUN_ROOT.'header.php';
356
357        generate_admin_menu('users');
358
359?>
360        <div class="blockform">
361                <h2><span>Recherche d'utilisateur</span></h2>
362                <div class="box">
363                        <form id="find_user" method="post" action="admin_users.php?action=find_user">
364                                <p class="submittop"><input type="submit" name="find_user" value=" Rechercher " tabindex="1" /></p>
365                                <div class="inform">
366                                        <fieldset>
367                                                <legend>Saisissez vos critÚres de recherche</legend>
368                                                <div class="infldset">
369                                                        <p>Recherche d'utilisateur dans la base de données. Vous pouvez saisir un ou plusieurs termes à rechercher. Utilisez le caractÚre astérisque (*) comme joker.</p>
370                                                        <table  class="aligntop" cellspacing="0">
371                                                                <tr>
372                                                                        <th scope="row">Nom d'utilisateur</th>
373                                                                        <td><input type="text" name="username" size="25" maxlength="25" tabindex="2" /></td>
374                                                                </tr>
375                                                                <tr>
376                                                                        <th scope="row">Adresse e-mail</th>
377                                                                        <td><input type="text" name="form[email]" size="30" maxlength="50" tabindex="3" /></td>
378                                                                </tr>
379                                                                <tr>
380                                                                        <th scope="row">Titre</th>
381                                                                        <td><input type="text" name="form[title]" size="30" maxlength="50" tabindex="4" /></td>
382                                                                </tr>
383                                                                <tr>
384                                                                        <th scope="row">Nom réel</th>
385                                                                        <td><input type="text" name="form[realname]" size="30" maxlength="40" tabindex="5" /></td>
386                                                                </tr>
387                                                                <tr>
388                                                                        <th scope="row">Site web</th>
389                                                                        <td><input type="text" name="form[url]" size="35" maxlength="100" tabindex="6" /></td>
390                                                                </tr>
391                                                                <tr>
392                                                                        <th scope="row">ICQ</th>
393                                                                        <td><input type="text" name="form[icq]" size="12" maxlength="12" tabindex="7" /></td>
394                                                                </tr>
395                                                                <tr>
396                                                                        <th scope="row">MSN Messenger</th>
397                                                                        <td><input type="text" name="form[msn]" size="30" maxlength="50" tabindex="8" /></td>
398                                                                </tr>
399                                                                <tr>
400                                                                        <th scope="row">AOL IM</th>
401                                                                        <td><input type="text" name="form[aim]" size="20" maxlength="20" tabindex="9" /></td>
402                                                                </tr>
403                                                                <tr>
404                                                                        <th scope="row">Yahoo! Messenger</th>
405                                                                        <td><input type="text" name="form[yahoo]" size="20" maxlength="20" tabindex="10" /></td>
406                                                                </tr>
407                                                                <tr>
408                                                                        <th scope="row">Lieu</th>
409                                                                        <td><input type="text" name="form[location]" size="30" maxlength="30" tabindex="11" /></td>
410                                                                </tr>
411                                                                <tr>
412                                                                        <th scope="row">Signature</th>
413                                                                        <td><input type="text" name="form[signature]" size="35" maxlength="512" tabindex="12" /></td>
414                                                                </tr>
415                                                                <tr>
416                                                                        <th scope="row">Note admin</th>
417                                                                        <td><input type="text" name="form[admin_note]" size="30" maxlength="30" tabindex="13" /></td>
418                                                                </tr>
419                                                                <tr>
420                                                                        <th scope="row">Nombre de messages supérieur à</th>
421                                                                        <td><input type="text" name="posts_greater" size="5" maxlength="8" tabindex="14" /></td>
422                                                                </tr>
423                                                                <tr>
424                                                                        <th scope="row">Nombre de messages inférieur à</th>
425                                                                        <td><input type="text" name="posts_less" size="5" maxlength="8" tabindex="15" /></td>
426                                                                </tr>
427                                                                <tr>
428                                                                        <th scope="row">Le dernier message est aprÚs le</th>
429                                                                        <td><input type="text" name="last_post_after" size="24" maxlength="19" tabindex="16" />
430                                                                        <span>(yyyy-mm-dd hh:mm:ss)</span></td>
431                                                                </tr>
432                                                                <tr>
433                                                                        <th scope="row">Le dernier message est avant le</th>
434                                                                        <td><input type="text" name="last_post_before" size="24" maxlength="19" tabindex="17" />
435                                                                        <span>(yyyy-mm-dd hh:mm:ss)</span></td>
436                                                                </tr>
437                                                                <tr>
438                                                                        <th scope="row">Inscrit aprÚs le</th>
439                                                                        <td><input type="text" name="registered_after" size="24" maxlength="19" tabindex="18" />
440                                                                        <span>(yyyy-mm-dd hh:mm:ss)</span></td>
441                                                                </tr>
442                                                                <tr>
443                                                                        <th scope="row">Inscrit avant le</th>
444                                                                        <td><input type="text" name="registered_before" size="24" maxlength="19" tabindex="19" />
445                                                                        <span>(yyyy-mm-dd hh:mm:ss)</span></td>
446                                                                </tr>
447                                                                <tr>
448                                                                        <th scope="row">Trier par</th>
449                                                                        <td>
450                                                                                <select name="order_by" tabindex="20">
451                                                                                        <option value="username" selected="selected">Nom d'utilisateur</option>
452                                                                                        <option value="email">e-mail</option>
453                                                                                        <option value="num_posts">messages</option>
454                                                                                        <option value="last_post">dernier message</option>
455                                                                                        <option value="registered">inscriptions</option>
456                                                                                </select>&#160;&#160;&#160;<select name="direction" tabindex="21">
457                                                                                        <option value="ASC" selected="selected">croissant</option>
458                                                                                        <option value="DESC">décroissant</option>
459                                                                                </select>
460                                                                        </td>
461                                                                </tr>
462                                                                <tr>
463                                                                        <th scope="row">Groupe utilisateurs</th>
464                                                                        <td>
465                                                                                <select name="user_group" tabindex="22">
466                                                                                                <option value="all" selected="selected">Tous les groupes</option>
467<?php
468
469        $result = $db->query('SELECT g_id, g_title FROM '.$db->prefix.'groups WHERE g_id!='.PUN_GUEST.' ORDER BY g_title') or error('Impossible de retrouver la liste des groupes', __FILE__, __LINE__, $db->error());
470
471        while ($cur_group = $db->fetch_assoc($result))
472                echo "\t\t\t\t\t\t\t\t\t\t\t".'<option value="'.$cur_group['g_id'].'">'.pun_htmlspecialchars($cur_group['g_title']).'</option>'."\n";
473
474?>
475                                                                                </select>
476                                                                        </td>
477                                                                </tr>
478                                                        </table>
479                                                </div>
480                                        </fieldset>
481                                </div>
482                                <p class="submitend"><input type="submit" name="find_user" value=" Rechercher " tabindex="23" /></p>
483                        </form>
484                </div>
485
486                <h2 class="block2"><span>Recherche <acronym title="Internet Protocol" lang="en">IP</acronym></span></h2>
487                <div class="box">
488                        <form method="get" action="admin_users.php">
489                                <div class="inform">
490                                        <fieldset>
491                                                <legend>Saisissez une adresse <acronym title="Internet Protocol" lang="en">IP</acronym> à rechercher</legend>
492                                                <div class="infldset">
493                                                        <table class="aligntop" cellspacing="0">
494                                                                <tr>
495                                                                        <th scope="row">Adresse <acronym title="Internet Protocol" lang="en">IP</acronym><div><input type="submit" value=" Trouver " tabindex="25" /></div></th>
496                                                                        <td><input type="text" name="show_users" size="18" maxlength="15" tabindex="24" />
497                                                                        <span>L'adresse <acronym title="Internet Protocol" lang="en">IP</acronym> à rechercher dans la base de données.</span></td>
498                                                                </tr>
499                                                        </table>
500                                                </div>
501                                        </fieldset>
502                                </div>
503                        </form>
504                </div>
505        </div>
506        <div class="clearer"></div>
507</div>
508<?php
509
510        require PUN_ROOT.'footer.php';
511}
Note: See TracBrowser for help on using the repository browser.