1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2005 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | // | branch : BSF (Best So Far) |
---|
8 | // | file : $RCSfile$ |
---|
9 | // | last update : $Date: 2005-08-15 22:01:00 +0000 (Mon, 15 Aug 2005) $ |
---|
10 | // | last modifier : $Author: plg $ |
---|
11 | // | revision : $Revision: 814 $ |
---|
12 | // +-----------------------------------------------------------------------+ |
---|
13 | // | This program is free software; you can redistribute it and/or modify | |
---|
14 | // | it under the terms of the GNU General Public License as published by | |
---|
15 | // | the Free Software Foundation | |
---|
16 | // | | |
---|
17 | // | This program is distributed in the hope that it will be useful, but | |
---|
18 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
19 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
20 | // | General Public License for more details. | |
---|
21 | // | | |
---|
22 | // | You should have received a copy of the GNU General Public License | |
---|
23 | // | along with this program; if not, write to the Free Software | |
---|
24 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
25 | // | USA. | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | |
---|
28 | //----------------------------------------------------------- include |
---|
29 | define('PHPWG_ROOT_PATH','./'); |
---|
30 | define('IN_ADMIN', true); |
---|
31 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
32 | include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' ); |
---|
33 | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | // | synchronize user informations | |
---|
36 | // +-----------------------------------------------------------------------+ |
---|
37 | |
---|
38 | sync_users(); |
---|
39 | |
---|
40 | //--------------------------------------- validating page and creation of title |
---|
41 | $page_valide = false; |
---|
42 | $title = ''; |
---|
43 | $username=''; |
---|
44 | if (isset($_POST['username'])) |
---|
45 | { |
---|
46 | $username = $_POST['username']; |
---|
47 | } |
---|
48 | else if (isset($_POST['userid'])) |
---|
49 | { |
---|
50 | $username = get_username($_POST['userid']); |
---|
51 | } |
---|
52 | else if (isset($_GET['user_id'])) |
---|
53 | { |
---|
54 | $username = get_username($_GET['user_id']); |
---|
55 | } |
---|
56 | |
---|
57 | $_GET['page'] = isset($_GET['page']) ? $_GET['page'] : 'intro'; |
---|
58 | |
---|
59 | switch ( $_GET['page'] ) |
---|
60 | { |
---|
61 | case 'user_list' : |
---|
62 | { |
---|
63 | $title = $lang['title_liste_users']; |
---|
64 | $page_valide = true; |
---|
65 | break; |
---|
66 | } |
---|
67 | case 'profile' : |
---|
68 | { |
---|
69 | $title = $lang['title_user_modify']; |
---|
70 | $page_valide = true; |
---|
71 | break; |
---|
72 | } |
---|
73 | case 'user_perm': |
---|
74 | $title = $lang['title_user_perm'].' '.$username; |
---|
75 | $page_valide = true; break; |
---|
76 | case 'group_list' : |
---|
77 | $title = $lang['title_groups']; $page_valide = true; break; |
---|
78 | case 'group_perm' : |
---|
79 | /*if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1; |
---|
80 | $query = 'SELECT name FROM '.GROUPS_TABLE; |
---|
81 | $query.= ' WHERE id = '.$_GET['group_id']; |
---|
82 | $query.= ';'; |
---|
83 | $result = pwg_query( $query ); |
---|
84 | if ( mysql_num_rows( $result ) > 0 ) |
---|
85 | { |
---|
86 | $row = mysql_fetch_array( $result );*/ |
---|
87 | $title = $lang['title_group_perm'];//.' "'.$row['name'].'"'; |
---|
88 | $page_valide = true; |
---|
89 | /*} |
---|
90 | else |
---|
91 | { |
---|
92 | $page_valide = false; |
---|
93 | }*/ |
---|
94 | break; |
---|
95 | case 'stats': |
---|
96 | $title = $lang['title_history']; $page_valide = true; break; |
---|
97 | case 'update': |
---|
98 | $title = $lang['title_update']; $page_valide = true; break; |
---|
99 | case 'configuration': |
---|
100 | $title = $lang['title_configuration']; $page_valide = true; break; |
---|
101 | case 'help': |
---|
102 | $title = $lang['title_instructions']; $page_valide = true; break; |
---|
103 | case 'cat_perm': |
---|
104 | $title = $lang['title_cat_perm']; |
---|
105 | if ( isset( $_GET['cat'] ) ) |
---|
106 | { |
---|
107 | check_cat_id( $_GET['cat'] ); |
---|
108 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
109 | { |
---|
110 | $result = get_cat_info( $page['cat'] ); |
---|
111 | $name = get_cat_display_name($result['name'], ''); |
---|
112 | $title.= ' "'.$name.'"'; |
---|
113 | } |
---|
114 | } |
---|
115 | $page_valide = true; |
---|
116 | break; |
---|
117 | case 'cat_list': |
---|
118 | $title = $lang['title_categories']; $page_valide = true; break; |
---|
119 | case 'cat_modify': |
---|
120 | $title = $lang['title_edit_cat']; $page_valide = true; break; |
---|
121 | case 'infos_images': |
---|
122 | $title = $lang['title_info_images']; $page_valide = true; break; |
---|
123 | case 'waiting': |
---|
124 | $title = $lang['title_waiting']; $page_valide = true; break; |
---|
125 | case 'thumbnail': |
---|
126 | $title = $lang['title_thumbnails']; |
---|
127 | if ( isset( $_GET['dir'] ) ) |
---|
128 | { |
---|
129 | $title.= ' '.$lang['title_thumbnails_2'].' <span class="titreImg">'; |
---|
130 | // $_GET['dir'] contains : |
---|
131 | // ./galleries/vieux_lyon ou |
---|
132 | // ./galleries/vieux_lyon/visite ou |
---|
133 | // ./galleries/vieux_lyon/visite/truc ... |
---|
134 | $dir = explode( "/", $_GET['dir'] ); |
---|
135 | $title.= $dir[2]; |
---|
136 | for ( $i = 2; $i < sizeof( $dir ) - 1; $i++ ) |
---|
137 | { |
---|
138 | $title.= ' > '.$dir[$i+1]; |
---|
139 | } |
---|
140 | $title.= "</span>"; |
---|
141 | } |
---|
142 | $page_valide = true; |
---|
143 | break; |
---|
144 | case 'comments' : |
---|
145 | $title = $lang['title_comments']; |
---|
146 | $page_valide = true; |
---|
147 | break; |
---|
148 | case 'picture_modify' : |
---|
149 | $title = $lang['title_picmod']; |
---|
150 | $page_valide = true; |
---|
151 | break; |
---|
152 | case 'remote_site' : |
---|
153 | { |
---|
154 | $title = $lang['remote_sites']; |
---|
155 | $page_valide = true; |
---|
156 | break; |
---|
157 | } |
---|
158 | case 'cat_options' : |
---|
159 | { |
---|
160 | $title = $lang['title_cat_options']; |
---|
161 | $page_valide = true; |
---|
162 | break; |
---|
163 | } |
---|
164 | case 'element_set' : |
---|
165 | { |
---|
166 | $title = 'batch management'; |
---|
167 | $page_valide = true; |
---|
168 | break; |
---|
169 | } |
---|
170 | case 'maintenance' : |
---|
171 | { |
---|
172 | $title = l10n('Maintenance'); |
---|
173 | $page_valide = true; |
---|
174 | break; |
---|
175 | } |
---|
176 | case 'representative' : |
---|
177 | { |
---|
178 | $title = l10n('Representative'); |
---|
179 | $page_valide = true; |
---|
180 | break; |
---|
181 | } |
---|
182 | // case 'element_set_unit' : |
---|
183 | // { |
---|
184 | // $title = 'batch management'; |
---|
185 | // $page_valide = true; |
---|
186 | // break; |
---|
187 | // } |
---|
188 | case 'intro' : |
---|
189 | { |
---|
190 | $_GET['page'] = 'intro'; |
---|
191 | $title = $lang['title_default']; |
---|
192 | $page_valide = true; |
---|
193 | break; |
---|
194 | } |
---|
195 | default : |
---|
196 | { |
---|
197 | break; |
---|
198 | } |
---|
199 | } |
---|
200 | if ( $title == '' ) $title = $lang['title_default']; |
---|
201 | |
---|
202 | // waiting |
---|
203 | $query = 'SELECT id FROM '.WAITING_TABLE; |
---|
204 | $query.= " WHERE validated='false'"; |
---|
205 | $query.= ';'; |
---|
206 | $result = pwg_query( $query ); |
---|
207 | $nb_waiting = ''; |
---|
208 | if ( mysql_num_rows( $result ) > 0 ) |
---|
209 | { |
---|
210 | $nb_waiting = ' [ '.mysql_num_rows( $result ).' ]'; |
---|
211 | } |
---|
212 | // comments |
---|
213 | $query = 'SELECT id FROM '.COMMENTS_TABLE; |
---|
214 | $query.= " WHERE validated='false'"; |
---|
215 | $query.= ';'; |
---|
216 | $result = pwg_query( $query ); |
---|
217 | $nb_comments = ''; |
---|
218 | if ( mysql_num_rows( $result ) > 0 ) |
---|
219 | { |
---|
220 | $nb_comments = ' [ '.mysql_num_rows( $result ).' ]'; |
---|
221 | } |
---|
222 | |
---|
223 | $link_start = PHPWG_ROOT_PATH.'admin.php?page='; |
---|
224 | $conf_link = $link_start.'configuration&section='; |
---|
225 | $opt_link = $link_start.'cat_options&section='; |
---|
226 | //----------------------------------------------------- template initialization |
---|
227 | include(PHPWG_ROOT_PATH.'include/page_header.php'); |
---|
228 | $template->set_filenames( array('admin'=>'admin.tpl') ); |
---|
229 | |
---|
230 | $template->assign_vars(array( |
---|
231 | 'L_TITLE'=>$lang['admin_panel'], |
---|
232 | 'L_LINKS'=>$lang['links'], |
---|
233 | 'L_GALLERY_INDEX'=>$lang['home'], |
---|
234 | 'L_GENERAL'=>$lang['general'], |
---|
235 | 'L_DEFAULT'=>$lang['gallery_default'], |
---|
236 | 'L_HISTORY'=>$lang['history'], |
---|
237 | 'L_FAQ'=>$lang['instructions'], |
---|
238 | 'L_CONFIGURATION'=>$lang['config'], |
---|
239 | 'L_CONFIG_GENERAL'=>$lang['general'], |
---|
240 | 'L_CONFIG_COMMENTS'=>$lang['comments'], |
---|
241 | 'L_CONFIG_DISPLAY'=>$lang['conf_default'], |
---|
242 | 'L_CONFIG_UPLOAD'=>$lang['upload'], |
---|
243 | 'L_CONFIG_SESSION'=>$lang['conf_cookie'], |
---|
244 | 'L_CONFIG_METADATA'=>$lang['metadata'], |
---|
245 | 'L_SITES'=>$lang['remote_sites'], |
---|
246 | 'L_CATEGORIES'=>$lang['categories'], |
---|
247 | 'L_MANAGE'=>$lang['manage'], |
---|
248 | 'L_IMAGES'=>$lang['pictures'], |
---|
249 | 'L_WAITING'=>$lang['waiting'].$nb_waiting, |
---|
250 | 'L_COMMENTS'=>$lang['comments'].$nb_comments, |
---|
251 | 'L_THUMBNAILS'=>$lang['thumbnails'], |
---|
252 | 'L_IDENTIFY'=>$lang['identification'], |
---|
253 | 'L_USERS'=>$lang['users'], |
---|
254 | 'L_GROUPS'=>$lang['groups'], |
---|
255 | 'L_AUTH'=>$lang['permissions'], |
---|
256 | 'L_UPDATE'=>$lang['update'], |
---|
257 | 'L_CAT_UPLOAD'=>$lang['upload'], |
---|
258 | 'L_CAT_COMMENTS'=>$lang['comments'], |
---|
259 | 'L_CAT_VISIBLE'=>$lang['lock'], |
---|
260 | 'L_CAT_STATUS'=>$lang['cat_security'], |
---|
261 | |
---|
262 | 'U_HISTORY'=>add_session_id($link_start.'stats' ), |
---|
263 | 'U_FAQ'=>add_session_id($link_start.'help' ), |
---|
264 | 'U_SITES'=>add_session_id($link_start.'remote_site'), |
---|
265 | 'U_MAINTENANCE'=>add_session_id($link_start.'maintenance'), |
---|
266 | 'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ), |
---|
267 | 'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ), |
---|
268 | 'U_CONFIG_DISPLAY'=>add_session_id($conf_link.'default' ), |
---|
269 | 'U_CONFIG_UPLOAD'=>add_session_id($conf_link.'upload' ), |
---|
270 | 'U_CONFIG_SESSION'=>add_session_id($conf_link.'session' ), |
---|
271 | 'U_CONFIG_METADATA'=>add_session_id($conf_link.'metadata' ), |
---|
272 | 'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ), |
---|
273 | 'U_CAT_UPLOAD'=>add_session_id($opt_link.'upload'), |
---|
274 | 'U_CAT_COMMENTS'=>add_session_id($opt_link.'comments'), |
---|
275 | 'U_CAT_VISIBLE'=>add_session_id($opt_link.'visible'), |
---|
276 | 'U_CAT_STATUS'=>add_session_id($opt_link.'status'), |
---|
277 | 'U_CAT_OPTIONS'=>add_session_id($link_start.'cat_options'), |
---|
278 | 'U_CAT_UPDATE'=>add_session_id($link_start.'update'), |
---|
279 | 'U_WAITING'=>add_session_id($link_start.'waiting' ), |
---|
280 | 'U_COMMENTS'=>add_session_id($link_start.'comments' ), |
---|
281 | 'U_CADDIE'=>add_session_id($link_start.'element_set&cat=caddie'), |
---|
282 | 'U_THUMBNAILS'=>add_session_id($link_start.'thumbnail' ), |
---|
283 | 'U_USERS'=>add_session_id($link_start.'user_list' ), |
---|
284 | 'U_GROUPS'=>add_session_id($link_start.'group_list' ), |
---|
285 | 'U_USERS_AUTH'=>add_session_id($link_start.'user_perm' ), |
---|
286 | 'U_GROUPS_AUTH'=>add_session_id($link_start.'group_perm'), |
---|
287 | 'U_CAT_AUTH'=>add_session_id($link_start.'cat_perm' ), |
---|
288 | 'U_RETURN'=>add_session_id(PHPWG_ROOT_PATH.'category.php') |
---|
289 | )); |
---|
290 | |
---|
291 | if ($conf['allow_random_representative']) |
---|
292 | { |
---|
293 | $template->assign_block_vars( |
---|
294 | 'representative', |
---|
295 | array( |
---|
296 | 'URL' => add_session_id($opt_link.'representative') |
---|
297 | ) |
---|
298 | ); |
---|
299 | } |
---|
300 | |
---|
301 | //--------------------------------------------------------------------- summary |
---|
302 | $link_start = PHPWG_ROOT_PATH.'admin.php?page='; |
---|
303 | //------------------------------------------------------------- content display |
---|
304 | $page['errors'] = array(); |
---|
305 | $page['infos'] = array(); |
---|
306 | |
---|
307 | if ($page_valide) |
---|
308 | { |
---|
309 | switch ($_GET['page']) |
---|
310 | { |
---|
311 | case 'comments' : |
---|
312 | { |
---|
313 | include(PHPWG_ROOT_PATH.'comments.php'); |
---|
314 | break; |
---|
315 | } |
---|
316 | case 'profile' : |
---|
317 | { |
---|
318 | include(PHPWG_ROOT_PATH.'profile.php'); |
---|
319 | break; |
---|
320 | } |
---|
321 | default : |
---|
322 | { |
---|
323 | include(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php'); |
---|
324 | } |
---|
325 | } |
---|
326 | } |
---|
327 | else |
---|
328 | { |
---|
329 | $template->assign_vars( |
---|
330 | array( |
---|
331 | 'ADMIN_CONTENT' |
---|
332 | =>'<div style="text-align:center">'.$lang['default_message'].'</div>' |
---|
333 | ) |
---|
334 | ); |
---|
335 | } |
---|
336 | // +-----------------------------------------------------------------------+ |
---|
337 | // | errors & infos | |
---|
338 | // +-----------------------------------------------------------------------+ |
---|
339 | if (count($page['errors']) != 0) |
---|
340 | { |
---|
341 | $template->assign_block_vars('errors',array()); |
---|
342 | foreach ($page['errors'] as $error) |
---|
343 | { |
---|
344 | $template->assign_block_vars('errors.error',array('ERROR'=>$error)); |
---|
345 | } |
---|
346 | } |
---|
347 | if (count($page['infos']) != 0) |
---|
348 | { |
---|
349 | $template->assign_block_vars('infos',array()); |
---|
350 | foreach ($page['infos'] as $info) |
---|
351 | { |
---|
352 | $template->assign_block_vars('infos.info',array('INFO'=>$info)); |
---|
353 | } |
---|
354 | } |
---|
355 | |
---|
356 | $template->parse('admin'); |
---|
357 | include(PHPWG_ROOT_PATH.'include/page_tail.php'); |
---|
358 | // +-----------------------------------------------------------------------+ |
---|
359 | // | order permission refreshment | |
---|
360 | // +-----------------------------------------------------------------------+ |
---|
361 | $query = ' |
---|
362 | UPDATE '.USER_CACHE_TABLE.' |
---|
363 | SET need_update = \'true\' |
---|
364 | ;'; |
---|
365 | pwg_query($query); |
---|
366 | ?> |
---|