1 | <?php |
---|
2 | /*************************************************************************** |
---|
3 | * liste_users.php is a part of PhpWebGallery * |
---|
4 | * ------------------- * |
---|
5 | * last update : Tuesday, July 16, 2002 * |
---|
6 | * email : pierrick@z0rglub.com * |
---|
7 | * * |
---|
8 | ***************************************************************************/ |
---|
9 | |
---|
10 | /*************************************************************************** |
---|
11 | * * |
---|
12 | * This program is free software; you can redistribute it and/or modify * |
---|
13 | * it under the terms of the GNU General Public License as published by * |
---|
14 | * the Free Software Foundation; * |
---|
15 | * * |
---|
16 | ***************************************************************************/ |
---|
17 | include_once( './include/isadmin.inc.php' ); |
---|
18 | //----------------------------------------------------- template initialization |
---|
19 | $sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_list.vtp' ); |
---|
20 | // language |
---|
21 | $vtp->setGlobalVar( $sub, 'listuser_confirm', $lang['listuser_confirm'] ); |
---|
22 | $vtp->setGlobalVar( $sub, 'listuser_modify_hint', |
---|
23 | $lang['listuser_modify_hint'] ); |
---|
24 | $vtp->setGlobalVar( $sub, 'listuser_modify', $lang['listuser_modify'] ); |
---|
25 | $vtp->setGlobalVar( $sub, 'listuser_permission', |
---|
26 | $lang['listuser_permission'] ); |
---|
27 | $vtp->setGlobalVar( $sub, 'listuser_permission_hint', |
---|
28 | $lang['listuser_permission_hint'] ); |
---|
29 | $vtp->setGlobalVar( $sub, 'listuser_delete_hint', |
---|
30 | $lang['listuser_delete_hint'] ); |
---|
31 | $vtp->setGlobalVar( $sub, 'listuser_delete', $lang['listuser_delete'] ); |
---|
32 | $vtp->setGlobalVar( $sub, 'yes', $lang['yes'] ); |
---|
33 | $vtp->setGlobalVar( $sub, 'no', $lang['no'] ); |
---|
34 | $vtp->setGlobalVar( $sub, 'listuser_button_all', |
---|
35 | $lang['listuser_button_all'] ); |
---|
36 | $vtp->setGlobalVar( $sub, 'listuser_button_invert', |
---|
37 | $lang['listuser_button_invert'] ); |
---|
38 | $vtp->setGlobalVar( $sub, 'listuser_button_create_address', |
---|
39 | $lang['listuser_button_create_address'] ); |
---|
40 | //--------------------------------------------------------------- delete a user |
---|
41 | if ( isset ( $_GET['delete'] ) && is_numeric( $_GET['delete'] ) ) |
---|
42 | { |
---|
43 | $query = 'select pseudo'; |
---|
44 | $query.= ' from '.$prefixeTable.'users'; |
---|
45 | $query.= ' where id = '.$_GET['delete']; |
---|
46 | $query.= ';'; |
---|
47 | $row = mysql_fetch_array( mysql_query( $query ) ); |
---|
48 | // confirm user deletion ? |
---|
49 | if ( $_GET['confirm'] != 1 ) |
---|
50 | { |
---|
51 | $vtp->addSession( $sub, 'deletion' ); |
---|
52 | $vtp->setVar( $sub, 'deletion.login', $row['pseudo'] ); |
---|
53 | $yes_url = './admin.php?page=user_list&delete='.$_GET['delete']; |
---|
54 | $yes_url.= '&confirm=1'; |
---|
55 | $vtp->setVar( $sub, 'deletion.yes_url', add_session_id( $yes_url ) ); |
---|
56 | $no_url = './admin.php?page=user_list'; |
---|
57 | $vtp->setVar( $sub, 'deletion.no_url', add_session_id( $no_url ) ); |
---|
58 | $vtp->closeSession( $sub, 'deletion' ); |
---|
59 | } |
---|
60 | // user deletion confirmed |
---|
61 | else |
---|
62 | { |
---|
63 | $vtp->addSession( $sub, 'confirmation' ); |
---|
64 | if ( $row['pseudo'] != 'visiteur' && $row['pseudo'] != $conf['webmaster'] ) |
---|
65 | { |
---|
66 | $query = 'select count(*) as nb_result'; |
---|
67 | $query.= ' from '.$prefixeTable.'users'; |
---|
68 | $query.= ' where id = '.$_GET['delete']; |
---|
69 | $query.= ';'; |
---|
70 | $row2 = mysql_fetch_array( mysql_query( $query ) ); |
---|
71 | if ( $row2['nb_result'] > 0 ) |
---|
72 | { |
---|
73 | delete_user( $_GET['delete'] ); |
---|
74 | $vtp->setVar( $sub, 'confirmation.class', 'info' ); |
---|
75 | $info = '"'.$row['pseudo'].'" '.$lang['listuser_info_deletion']; |
---|
76 | $vtp->setVar( $sub, 'confirmation.info', $info ); |
---|
77 | } |
---|
78 | else |
---|
79 | { |
---|
80 | $vtp->setVar( $sub, 'confirmation.class', 'erreur' ); |
---|
81 | $vtp->setVar( $sub, 'confirmation.info', $lang['user_err_unknown'] ); |
---|
82 | } |
---|
83 | } |
---|
84 | else |
---|
85 | { |
---|
86 | $vtp->setVar( $sub, 'confirmation.class', 'erreur' ); |
---|
87 | $vtp->setVar( $sub, 'confirmation.info', $lang['user_err_modify'] ); |
---|
88 | } |
---|
89 | $vtp->closeSession( $sub, 'confirmation' ); |
---|
90 | } |
---|
91 | } |
---|
92 | //------------------------------------------------------------------ users list |
---|
93 | else |
---|
94 | { |
---|
95 | $vtp->addSession( $sub, 'users' ); |
---|
96 | |
---|
97 | $action = './admin.php?'.$_SERVER['QUERY_STRING']; |
---|
98 | if ( !isset( $_GET['mail'] ) ) |
---|
99 | { |
---|
100 | $action.= '&mail=true'; |
---|
101 | } |
---|
102 | $vtp->setVar( $sub, 'users.form_action', $action ); |
---|
103 | |
---|
104 | $query = 'select id,pseudo,status,mail_address'; |
---|
105 | $query.= ' from '.$prefixeTable.'users'; |
---|
106 | $query.= ' order by status asc, pseudo asc'; |
---|
107 | $query.= ';'; |
---|
108 | $result = mysql_query( $query ); |
---|
109 | |
---|
110 | $current_status = ''; |
---|
111 | while ( $row = mysql_fetch_array( $result ) ) |
---|
112 | { |
---|
113 | // display the line indicating the status of the next users |
---|
114 | if ( $row['status'] != $current_status ) |
---|
115 | { |
---|
116 | if ( $current_status != '' ) |
---|
117 | { |
---|
118 | $vtp->closeSession( $sub, 'category' ); |
---|
119 | } |
---|
120 | $vtp->addSession( $sub, 'category' ); |
---|
121 | $title = $lang['listuser_user_group'].' '; |
---|
122 | switch ( $row['status'] ) |
---|
123 | { |
---|
124 | case 'admin' : |
---|
125 | { |
---|
126 | $title.= $lang['adduser_status_admin']; |
---|
127 | break; |
---|
128 | } |
---|
129 | case 'visiteur' : |
---|
130 | { |
---|
131 | $title.= $lang['adduser_status_guest']; |
---|
132 | break; |
---|
133 | } |
---|
134 | } |
---|
135 | $vtp->setVar( $sub, 'category.title', $title ); |
---|
136 | $current_status = $row['status']; |
---|
137 | } |
---|
138 | $vtp->addSession( $sub, 'user' ); |
---|
139 | // checkbox for mail management if the user has a mail address |
---|
140 | if ( $row['mail_address'] != '' && $row['pseudo'] != 'visiteur' ) |
---|
141 | { |
---|
142 | $vtp->addSession( $sub, 'checkbox' ); |
---|
143 | $vtp->setVar( $sub, 'checkbox.name', 'mail-'.$row['id'] ); |
---|
144 | $vtp->closeSession( $sub, 'checkbox' ); |
---|
145 | } |
---|
146 | // use a special color for the login of the user ? |
---|
147 | if ( $row['pseudo'] == $conf['webmaster'] ) |
---|
148 | { |
---|
149 | $vtp->setVar( $sub, 'user.color', 'red' ); |
---|
150 | } |
---|
151 | if ( $row['pseudo'] == "visiteur" ) |
---|
152 | { |
---|
153 | $vtp->setVar( $sub, 'user.color', 'green' ); |
---|
154 | } |
---|
155 | $vtp->setVar( $sub, 'user.login', $row['pseudo'] ); |
---|
156 | // modify or not modify ? |
---|
157 | if ( $row['pseudo'] == "visiteur" |
---|
158 | || ( $row['pseudo'] == $conf['webmaster'] |
---|
159 | && $user['pseudo'] != $conf['webmaster'] ) ) |
---|
160 | { |
---|
161 | $vtp->addSession( $sub, 'not_modify' ); |
---|
162 | $vtp->closeSession( $sub, 'not_modify' ); |
---|
163 | } |
---|
164 | else |
---|
165 | { |
---|
166 | $vtp->addSession( $sub, 'modify' ); |
---|
167 | $url = './admin.php?page=user_add&mode=modif&user_id='; |
---|
168 | $url.= $row['id']; |
---|
169 | $vtp->setVar( $sub, 'modify.url', add_session_id( $url ) ); |
---|
170 | $vtp->setVar( $sub, 'modify.login', $row['pseudo'] ); |
---|
171 | $vtp->closeSession( $sub, 'modify' ); |
---|
172 | } |
---|
173 | // manage permission or not ? |
---|
174 | if ( $row['pseudo'] == $conf['webmaster'] ) |
---|
175 | { |
---|
176 | $vtp->addSession( $sub, 'not_permission' ); |
---|
177 | $vtp->closeSession( $sub, 'not_permission' ); |
---|
178 | } |
---|
179 | else |
---|
180 | { |
---|
181 | $vtp->addSession( $sub, 'permission' ); |
---|
182 | $url = './admin.php?page=perm&user_id='.$row['id']; |
---|
183 | $vtp->setVar( $sub, 'permission.url', add_session_id( $url ) ); |
---|
184 | $vtp->setVar( $sub, 'permission.login', $row['pseudo'] ); |
---|
185 | $vtp->closeSession( $sub, 'permission' ); |
---|
186 | } |
---|
187 | // is the user deletable or not ? |
---|
188 | if ( $row['pseudo'] == 'visiteur' || $row['pseudo'] == $conf['webmaster'] ) |
---|
189 | { |
---|
190 | $vtp->addSession( $sub, 'not_delete' ); |
---|
191 | $vtp->closeSession( $sub, 'not_delete' ); |
---|
192 | } |
---|
193 | else |
---|
194 | { |
---|
195 | $vtp->addSession( $sub, 'delete' ); |
---|
196 | $url = './admin.php?page=user_list&delete='.$row['id']; |
---|
197 | $vtp->setVar( $sub, 'delete.url', add_session_id( $url ) ); |
---|
198 | $vtp->setVar( $sub, 'delete.login', $row['pseudo'] ); |
---|
199 | $vtp->closeSession( $sub, 'delete' ); |
---|
200 | } |
---|
201 | $vtp->closeSession( $sub, 'user' ); |
---|
202 | } |
---|
203 | $vtp->closeSession( $sub, 'category' ); |
---|
204 | // mail management : creation of the mail address if asked by administrator |
---|
205 | if ( isset( $_GET['mail'] ) ) |
---|
206 | { |
---|
207 | $mail_address = array(); |
---|
208 | $i = 0; |
---|
209 | $query = 'select'; |
---|
210 | $query.= ' id,mail_address'; |
---|
211 | $query.= ' from '.$prefixeTable.'users'; |
---|
212 | $query.= ';'; |
---|
213 | $result = mysql_query( $query ); |
---|
214 | while ( $row = mysql_fetch_array( $result ) ) |
---|
215 | { |
---|
216 | $key = 'mail-'.$row['id']; |
---|
217 | if ( $_POST[$key] == 1 ) |
---|
218 | { |
---|
219 | $mail_address[$i++] = $row['mail_address']; |
---|
220 | } |
---|
221 | } |
---|
222 | $mail_destination = ''; |
---|
223 | for ( $i = 0; $i < sizeof( $mail_address ); $i++ ) |
---|
224 | { |
---|
225 | $mail_destination.= $mail_address[$i]; |
---|
226 | if ( sizeof( $mail_address ) > 1 ) |
---|
227 | { |
---|
228 | $mail_destination.= ';'; |
---|
229 | } |
---|
230 | } |
---|
231 | if ( sizeof( $mail_address ) > 0 ) |
---|
232 | { |
---|
233 | $vtp->addSession( $sub, 'mail_link' ); |
---|
234 | $vtp->setVar( $sub, 'mail_link.mailto', $mail_destination ); |
---|
235 | $vtp->setVar( $sub, 'mail_link.mail_address_start', |
---|
236 | substr( $mail_destination, 0, 50 ) ); |
---|
237 | $vtp->closeSession( $sub, 'mail_link' ); |
---|
238 | } |
---|
239 | } |
---|
240 | $vtp->closeSession( $sub, 'users' ); |
---|
241 | } |
---|
242 | //----------------------------------------------------------- sending html code |
---|
243 | $vtp->Parse( $handle , 'sub', $sub ); |
---|
244 | ?> |
---|