source: trunk/admin.php @ 809

Last change on this file since 809 was 809, checked in by plg, 19 years ago
  • new : maintenance screen in administration. There you can update categories informations (number of images, date of the last added element), update images informations (path, average rate), purge obsolete sessions, purge history.
  • new : ability to have random representative for categories. This configuration parameter is set to false by default.
  • new : ability to set an element as representative of a category without belonging to the category. Thus, administrator can choose representative even for empty categories.
  • improvement : semantically superior design for category edition screen by regrouping fields in fieldsets. The improved screen contains action buttons as in category list screen.
  • new : ability to move a virtual category (ie change its parent category).
  • bug fixed : the sync_users function checks all user children tables (access, cache, group association).
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 11.5 KB
Line 
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-13 23:09:54 +0000 (Sat, 13 Aug 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 809 $
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
29define('PHPWG_ROOT_PATH','./');
30define('IN_ADMIN', true);
31include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
32include_once( PHPWG_ROOT_PATH.'admin/include/isadmin.inc.php' );
33
34// +-----------------------------------------------------------------------+
35// |                    synchronize user informations                      |
36// +-----------------------------------------------------------------------+
37
38sync_users();
39
40//--------------------------------------- validating page and creation of title
41$page_valide = false;
42$title = '';
43$username='';
44if (isset($_POST['username']))
45{
46  $username = $_POST['username'];
47}
48else if (isset($_POST['userid']))
49{
50  $username = get_username($_POST['userid']);
51}
52else if (isset($_GET['user_id']))
53{
54  $username = get_username($_GET['user_id']);
55}
56
57if (isset( $_GET['page'] ))
58switch ( $_GET['page'] )
59{
60  case 'user_list' :
61  {
62    $title = $lang['title_liste_users'];
63    $page_valide = true;
64    break;
65  }
66  case 'profile' :
67  {
68    $title = $lang['title_user_modify'];
69    $page_valide = true; 
70    break;
71  }
72 case 'user_perm':
73   $title = $lang['title_user_perm'].' '.$username;
74   $page_valide = true; break;
75 case 'group_list' :
76   $title = $lang['title_groups'];        $page_valide = true; break;
77 case 'group_perm' :
78   /*if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
79   $query = 'SELECT name FROM '.GROUPS_TABLE;
80   $query.= ' WHERE id = '.$_GET['group_id'];
81   $query.= ';';
82   $result = pwg_query( $query );
83   if ( mysql_num_rows( $result ) > 0 )
84   {
85     $row = mysql_fetch_array( $result );*/
86     $title = $lang['title_group_perm'];//.' "'.$row['name'].'"';
87     $page_valide = true;
88   /*}
89   else
90   {
91     $page_valide = false;
92   }*/
93   break;
94 case 'stats':
95   $title = $lang['title_history'];       $page_valide = true; break;
96 case 'update':
97   $title = $lang['title_update'];        $page_valide = true; break;
98 case 'configuration':
99   $title = $lang['title_configuration']; $page_valide = true; break;
100 case 'admin_phpinfo':
101   $title = $lang['phpinfos']; $page_valide = true; break;
102 case 'help':
103   $title = $lang['title_instructions'];  $page_valide = true; break;
104 case 'cat_perm':
105   $title = $lang['title_cat_perm'];
106   if ( isset( $_GET['cat'] ) )
107   {
108     check_cat_id( $_GET['cat'] );
109     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
110     {
111       $result = get_cat_info( $page['cat'] );
112       $name = get_cat_display_name($result['name'], '');
113       $title.= ' "'.$name.'"';
114     }
115   }
116   $page_valide = true;
117   break;
118 case 'cat_list':
119   $title = $lang['title_categories'];    $page_valide = true; break;
120 case 'cat_modify':
121   $title = $lang['title_edit_cat'];      $page_valide = true; break;
122 case 'infos_images':
123   $title = $lang['title_info_images'];   $page_valide = true; break;
124 case 'waiting':
125   $title = $lang['title_waiting'];       $page_valide = true; break;
126 case 'thumbnail':
127   $title = $lang['title_thumbnails'];
128   if ( isset( $_GET['dir'] ) )
129   {
130     $title.= ' '.$lang['title_thumbnails_2'].' <span class="titreImg">';
131     // $_GET['dir'] contains :
132     // ./galleries/vieux_lyon ou
133     // ./galleries/vieux_lyon/visite ou
134     // ./galleries/vieux_lyon/visite/truc ...
135     $dir = explode( "/", $_GET['dir'] );
136     $title.= $dir[2];
137     for ( $i = 2; $i < sizeof( $dir ) - 1; $i++ )
138     {
139       $title.= ' &gt; '.$dir[$i+1];
140     }
141     $title.= "</span>";
142   }
143   $page_valide = true;
144   break;
145 case 'comments' :
146   $title = $lang['title_comments'];
147   $page_valide = true;
148   break;
149 case 'picture_modify' :
150   $title = $lang['title_picmod'];
151   $page_valide = true;
152   break;
153 case 'remote_site' :
154 {
155   $title = $lang['remote_sites'];
156   $page_valide = true;
157   break;
158 }
159 case 'cat_options' :
160 {
161   $title = $lang['title_cat_options'];
162   $page_valide = true;
163   break;
164 }
165 case 'element_set' :
166 {
167   $title = 'batch management';
168   $page_valide = true;
169   break;
170 }
171 case 'maintenance' :
172 {
173   $title = l10n('Maintenance');
174   $page_valide = true;
175   break;
176 }
177 case 'representative' :
178 {
179   $title = l10n('Representative');
180   $page_valide = true;
181   break;
182 }
183//  case 'element_set_unit' :
184//  {
185//    $title = 'batch management';
186//    $page_valide = true;
187//    break;
188//  }
189 default:
190   $title = $lang['title_default']; break;
191}
192if ( $title == '' ) $title = $lang['title_default'];
193
194// waiting
195$query = 'SELECT id FROM '.WAITING_TABLE;
196$query.= " WHERE validated='false'";
197$query.= ';';
198$result = pwg_query( $query );
199$nb_waiting = '';
200if ( mysql_num_rows( $result ) > 0 )
201{
202  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
203}
204// comments
205$query = 'SELECT id FROM '.COMMENTS_TABLE;
206$query.= " WHERE validated='false'";
207$query.= ';';
208$result = pwg_query( $query );
209$nb_comments = '';
210if ( mysql_num_rows( $result ) > 0 )
211{
212  $nb_comments =  ' [ '.mysql_num_rows( $result ).' ]';
213}
214
215$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
216$conf_link = $link_start.'configuration&amp;section=';
217$opt_link = $link_start.'cat_options&amp;section=';
218//----------------------------------------------------- template initialization
219include(PHPWG_ROOT_PATH.'include/page_header.php');
220$template->set_filenames( array('admin'=>'admin.tpl') );
221
222$template->assign_vars(array(
223  'L_TITLE'=>$lang['admin_panel'],
224  'L_LINKS'=>$lang['links'],
225  'L_GALLERY_INDEX'=>$lang['home'],
226  'L_GENERAL'=>$lang['general'],
227  'L_DEFAULT'=>$lang['gallery_default'],
228  'L_PHPINFO'=>$lang['phpinfos'],
229  'L_HISTORY'=>$lang['history'],
230  'L_FAQ'=>$lang['instructions'],
231  'L_CONFIGURATION'=>$lang['config'],
232  'L_CONFIG_GENERAL'=>$lang['general'],
233  'L_CONFIG_COMMENTS'=>$lang['comments'],
234  'L_CONFIG_DISPLAY'=>$lang['conf_default'],
235  'L_CONFIG_UPLOAD'=>$lang['upload'],
236  'L_CONFIG_SESSION'=>$lang['conf_cookie'],
237  'L_CONFIG_METADATA'=>$lang['metadata'],
238  'L_SITES'=>$lang['remote_sites'],
239  'L_CATEGORIES'=>$lang['categories'],
240  'L_MANAGE'=>$lang['manage'],
241  'L_IMAGES'=>$lang['pictures'],
242  'L_WAITING'=>$lang['waiting'].$nb_waiting,
243  'L_COMMENTS'=>$lang['comments'].$nb_comments,
244  'L_THUMBNAILS'=>$lang['thumbnails'],
245  'L_IDENTIFY'=>$lang['identification'],
246  'L_USERS'=>$lang['users'],
247  'L_GROUPS'=>$lang['groups'],
248  'L_AUTH'=>$lang['permissions'],
249  'L_UPDATE'=>$lang['update'],
250  'L_CAT_UPLOAD'=>$lang['upload'],
251  'L_CAT_COMMENTS'=>$lang['comments'],
252  'L_CAT_VISIBLE'=>$lang['lock'],
253  'L_CAT_STATUS'=>$lang['cat_security'],
254
255  'U_HISTORY'=>add_session_id($link_start.'stats' ),
256  'U_FAQ'=>add_session_id($link_start.'help' ),
257  'U_SITES'=>add_session_id($link_start.'remote_site'),
258  'U_PHPINFO'=>add_session_id($link_start.'admin_phpinfo' ),
259  'U_MAINTENANCE'=>add_session_id($link_start.'maintenance'),
260  'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ),
261  'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ),
262  'U_CONFIG_DISPLAY'=>add_session_id($conf_link.'default' ),
263  'U_CONFIG_UPLOAD'=>add_session_id($conf_link.'upload' ),
264  'U_CONFIG_SESSION'=>add_session_id($conf_link.'session' ),
265  'U_CONFIG_METADATA'=>add_session_id($conf_link.'metadata' ),
266  'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ),
267  'U_CAT_UPLOAD'=>add_session_id($opt_link.'upload'),
268  'U_CAT_COMMENTS'=>add_session_id($opt_link.'comments'),
269  'U_CAT_VISIBLE'=>add_session_id($opt_link.'visible'),
270  'U_CAT_STATUS'=>add_session_id($opt_link.'status'),
271  'U_CAT_OPTIONS'=>add_session_id($link_start.'cat_options'),
272  'U_CAT_UPDATE'=>add_session_id($link_start.'update'),
273  'U_WAITING'=>add_session_id($link_start.'waiting' ),
274  'U_COMMENTS'=>add_session_id($link_start.'comments' ),
275  'U_CADDIE'=>add_session_id($link_start.'element_set&amp;cat=caddie'),
276  'U_THUMBNAILS'=>add_session_id($link_start.'thumbnail' ),
277  'U_USERS'=>add_session_id($link_start.'user_list' ),
278  'U_GROUPS'=>add_session_id($link_start.'group_list' ),
279  'U_USERS_AUTH'=>add_session_id($link_start.'user_perm' ),
280  'U_GROUPS_AUTH'=>add_session_id($link_start.'group_perm'),
281  'U_CAT_AUTH'=>add_session_id($link_start.'cat_perm' ),
282  'U_RETURN'=>add_session_id(PHPWG_ROOT_PATH.'category.php')
283  ));
284
285if ($conf['allow_random_representative'])
286{
287  $template->assign_block_vars(
288    'representative',
289    array(
290      'URL' => add_session_id($opt_link.'representative')
291      )
292    );
293}
294 
295//--------------------------------------------------------------------- summary
296$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
297//------------------------------------------------------------- content display
298$page['errors'] = array();
299$page['infos'] = array();
300
301if ($page_valide)
302{
303  switch ($_GET['page'])
304  {
305    case 'comments' :
306    {
307      include(PHPWG_ROOT_PATH.'comments.php');
308      break;
309    }
310    case 'profile' :
311    {
312      include(PHPWG_ROOT_PATH.'profile.php');
313      break;
314    }
315    default :
316    {
317      include(PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php');
318    }
319  }
320}
321else
322{
323  $template->assign_vars(
324    array(
325      'ADMIN_CONTENT'
326      =>'<div style="text-align:center">'.$lang['default_message'].'</div>'
327      )
328    );
329}
330// +-----------------------------------------------------------------------+
331// |                            errors & infos                             |
332// +-----------------------------------------------------------------------+
333if (count($page['errors']) != 0)
334{
335  $template->assign_block_vars('errors',array());
336  foreach ($page['errors'] as $error)
337  {
338    $template->assign_block_vars('errors.error',array('ERROR'=>$error));
339  }
340}
341if (count($page['infos']) != 0)
342{
343  $template->assign_block_vars('infos',array());
344  foreach ($page['infos'] as $info)
345  {
346    $template->assign_block_vars('infos.info',array('INFO'=>$info));
347  }
348}
349
350$template->parse('admin');
351include(PHPWG_ROOT_PATH.'include/page_tail.php');
352// +-----------------------------------------------------------------------+
353// |                     order permission refreshment                      |
354// +-----------------------------------------------------------------------+
355$query = '
356UPDATE '.USER_CACHE_TABLE.'
357  SET need_update = \'true\'
358;';
359pwg_query($query);
360?>
Note: See TracBrowser for help on using the repository browser.