source: trunk/admin.php @ 755

Last change on this file since 755 was 755, checked in by plg, 19 years ago
  • new feature : caddie. The purpose is batch management, especially concerning elements to categories associations. This is the very first release, needs many improvements.
  • new function : array_from_query. Firstly used by "caddie" feature, it may be useful in many cases.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.9 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-03-25 22:10:55 +0000 (Fri, 25 Mar 2005) $
10// | last modifier : $Author: plg $
11// | revision      : $Revision: 755 $
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//--------------------------------------- validating page and creation of title
34$page_valide = false;
35$title = '';
36$username='';
37if (isset($_POST['username']))
38{
39  $username = $_POST['username'];
40}
41else if (isset($_POST['userid']))
42{
43  $username = get_username($_POST['userid']);
44}
45else if (isset($_GET['user_id']))
46{
47  $username = get_username($_GET['user_id']);
48}
49
50if (isset( $_GET['page'] ))
51switch ( $_GET['page'] )
52{
53 case 'user_list':
54   $title = $lang['title_liste_users'];   $page_valide = true; break;
55 case 'profile':
56   $title = $lang['title_user_modify'];
57         $page_valide = true; 
58         break;
59 case 'user_perm':
60   $title = $lang['title_user_perm'].' '.$username;
61   $page_valide = true; break;
62 case 'group_list' :
63   $title = $lang['title_groups'];        $page_valide = true; break;
64 case 'group_perm' :
65   /*if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
66   $query = 'SELECT name FROM '.GROUPS_TABLE;
67   $query.= ' WHERE id = '.$_GET['group_id'];
68   $query.= ';';
69   $result = pwg_query( $query );
70   if ( mysql_num_rows( $result ) > 0 )
71   {
72     $row = mysql_fetch_array( $result );*/
73     $title = $lang['title_group_perm'];//.' "'.$row['name'].'"';
74     $page_valide = true;
75   /*}
76   else
77   {
78     $page_valide = false;
79   }*/
80   break;
81 case 'stats':
82   $title = $lang['title_history'];       $page_valide = true; break;
83 case 'update':
84   $title = $lang['title_update'];        $page_valide = true; break;
85 case 'configuration':
86   $title = $lang['title_configuration']; $page_valide = true; break;
87 case 'admin_phpinfo':
88   $title = $lang['phpinfos']; $page_valide = true; break;
89 case 'help':
90   $title = $lang['title_instructions'];  $page_valide = true; break;
91 case 'cat_perm':
92   $title = $lang['title_cat_perm'];
93   if ( isset( $_GET['cat_id'] ) )
94   {
95     check_cat_id( $_GET['cat_id'] );
96     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
97     {
98       $result = get_cat_info( $page['cat'] );
99       $name = get_cat_display_name($result['name'], '');
100       $title.= ' "'.$name.'"';
101     }
102   }
103   $page_valide = true;
104   break;
105 case 'cat_list':
106   $title = $lang['title_categories'];    $page_valide = true; break;
107 case 'cat_modify':
108   $title = $lang['title_edit_cat'];      $page_valide = true; break;
109 case 'infos_images':
110   $title = $lang['title_info_images'];   $page_valide = true; break;
111 case 'waiting':
112   $title = $lang['title_waiting'];       $page_valide = true; break;
113 case 'thumbnail':
114   $title = $lang['title_thumbnails'];
115   if ( isset( $_GET['dir'] ) )
116   {
117     $title.= ' '.$lang['title_thumbnails_2'].' <span class="titreImg">';
118     // $_GET['dir'] contains :
119     // ./galleries/vieux_lyon ou
120     // ./galleries/vieux_lyon/visite ou
121     // ./galleries/vieux_lyon/visite/truc ...
122     $dir = explode( "/", $_GET['dir'] );
123     $title.= $dir[2];
124     for ( $i = 2; $i < sizeof( $dir ) - 1; $i++ )
125     {
126       $title.= ' &gt; '.$dir[$i+1];
127     }
128     $title.= "</span>";
129   }
130   $page_valide = true;
131   break;
132 case 'comments' :
133   $title = $lang['title_comments'];
134   $page_valide = true;
135   break;
136 case 'picture_modify' :
137   $title = $lang['title_picmod'];
138   $page_valide = true;
139   break;
140 case 'remote_site' :
141 {
142   $title = $lang['remote_sites'];
143   $page_valide = true;
144   break;
145 }
146 case 'cat_options' :
147 {
148   $title = $lang['title_cat_options'];
149   $page_valide = true;
150   break;
151 }
152 case 'element_set_global' :
153 {
154   $title = 'batch management';
155   $page_valide = true;
156   break;
157 }
158 default:
159   $title = $lang['title_default']; break;
160}
161if ( $title == '' ) $title = $lang['title_default'];
162
163// waiting
164$query = 'SELECT id FROM '.WAITING_TABLE;
165$query.= " WHERE validated='false'";
166$query.= ';';
167$result = pwg_query( $query );
168$nb_waiting = '';
169if ( mysql_num_rows( $result ) > 0 )
170{
171  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
172}
173// comments
174$query = 'SELECT id FROM '.COMMENTS_TABLE;
175$query.= " WHERE validated='false'";
176$query.= ';';
177$result = pwg_query( $query );
178$nb_comments = '';
179if ( mysql_num_rows( $result ) > 0 )
180{
181  $nb_comments =  ' [ '.mysql_num_rows( $result ).' ]';
182}
183
184$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
185$conf_link = $link_start.'configuration&amp;section=';
186$opt_link = $link_start.'cat_options&amp;section=';
187//----------------------------------------------------- template initialization
188include(PHPWG_ROOT_PATH.'include/page_header.php');
189$template->set_filenames( array('admin'=>'admin.tpl') );
190
191$template->assign_vars(array(
192  'L_TITLE'=>$lang['admin_panel'],
193  'L_LINKS'=>$lang['links'],
194  'L_GALLERY_INDEX'=>$lang['home'],
195  'L_GENERAL'=>$lang['general'],
196  'L_DEFAULT'=>$lang['gallery_default'],
197  'L_PHPINFO'=>$lang['phpinfos'],
198  'L_HISTORY'=>$lang['history'],
199  'L_FAQ'=>$lang['instructions'],
200  'L_CONFIGURATION'=>$lang['config'],
201  'L_CONFIG_GENERAL'=>$lang['general'],
202  'L_CONFIG_COMMENTS'=>$lang['comments'],
203  'L_CONFIG_DISPLAY'=>$lang['conf_default'],
204  'L_CONFIG_UPLOAD'=>$lang['upload'],
205  'L_CONFIG_SESSION'=>$lang['conf_cookie'],
206  'L_CONFIG_METADATA'=>$lang['metadata'],
207  'L_SITES'=>$lang['remote_sites'],
208  'L_CATEGORIES'=>$lang['categories'],
209  'L_MANAGE'=>$lang['manage'],
210  'L_IMAGES'=>$lang['pictures'],
211  'L_WAITING'=>$lang['waiting'].$nb_waiting,
212  'L_COMMENTS'=>$lang['comments'].$nb_comments,
213  'L_THUMBNAILS'=>$lang['thumbnails'],
214  'L_IDENTIFY'=>$lang['identification'],
215  'L_USERS'=>$lang['users'],
216  'L_GROUPS'=>$lang['groups'],
217  'L_AUTH'=>$lang['permissions'],
218  'L_UPDATE'=>$lang['update'],
219  'L_CAT_UPLOAD'=>$lang['upload'],
220  'L_CAT_COMMENTS'=>$lang['comments'],
221  'L_CAT_VISIBLE'=>$lang['lock'],
222  'L_CAT_STATUS'=>$lang['cat_security'],
223
224  'U_HISTORY'=>add_session_id($link_start.'stats' ),
225  'U_FAQ'=>add_session_id($link_start.'help' ),
226  'U_SITES'=>add_session_id($link_start.'remote_site'),
227  'U_PHPINFO'=>add_session_id($link_start.'admin_phpinfo' ),
228  'U_CONFIG_GENERAL'=>add_session_id($conf_link.'general' ),
229  'U_CONFIG_COMMENTS'=>add_session_id($conf_link.'comments' ),
230  'U_CONFIG_DISPLAY'=>add_session_id($conf_link.'default' ),
231  'U_CONFIG_UPLOAD'=>add_session_id($conf_link.'upload' ),
232  'U_CONFIG_SESSION'=>add_session_id($conf_link.'session' ),
233  'U_CONFIG_METADATA'=>add_session_id($conf_link.'metadata' ),
234  'U_CATEGORIES'=>add_session_id($link_start.'cat_list' ),
235  'U_CAT_UPLOAD'=>add_session_id($opt_link.'upload'),
236  'U_CAT_COMMENTS'=>add_session_id($opt_link.'comments'),
237  'U_CAT_VISIBLE'=>add_session_id($opt_link.'visible'),
238  'U_CAT_STATUS'=>add_session_id($opt_link.'status'),
239  'U_CAT_OPTIONS'=>add_session_id($link_start.'cat_options'),
240  'U_CAT_UPDATE'=>add_session_id($link_start.'update'),
241  'U_WAITING'=>add_session_id($link_start.'waiting' ),
242  'U_COMMENTS'=>add_session_id($link_start.'comments' ),
243  'U_SET'=>add_session_id($link_start.'element_set_global'),
244  'U_THUMBNAILS'=>add_session_id($link_start.'thumbnail' ),
245  'U_USERS'=>add_session_id($link_start.'profile' ),
246  'U_GROUPS'=>add_session_id($link_start.'group_list' ),
247  'U_USERS_AUTH'=>add_session_id($link_start.'user_perm' ),
248  'U_GROUPS_AUTH'=>add_session_id($link_start.'group_perm'),
249  'U_CAT_AUTH'=>add_session_id($link_start.'cat_perm' ),
250  'U_RETURN'=>add_session_id(PHPWG_ROOT_PATH.'category.php')
251  ));
252
253//--------------------------------------------------------------------- summary
254$link_start = PHPWG_ROOT_PATH.'admin.php?page=';
255//------------------------------------------------------------- content display
256if ( $page_valide )
257{
258  if ($_GET['page']=='comments') include ( PHPWG_ROOT_PATH.'comments.php');
259        elseif ($_GET['page']=='profile') include ( PHPWG_ROOT_PATH.'profile.php');
260  else include ( PHPWG_ROOT_PATH.'admin/'.$_GET['page'].'.php' );
261}
262else
263{
264  $template->assign_vars(array ('ADMIN_CONTENT'=> '<div style="text-align:center">'.$lang['default_message'].'</div>') );
265}
266$template->parse('admin');
267include(PHPWG_ROOT_PATH.'include/page_tail.php');
268// +-----------------------------------------------------------------------+
269// |                     order permission refreshment                      |
270// +-----------------------------------------------------------------------+
271$query = '
272UPDATE '.USER_FORBIDDEN_TABLE.'
273  SET need_update = \'true\'
274;';
275pwg_query($query);
276?>
Note: See TracBrowser for help on using the repository browser.