source: trunk/admin/admin.php @ 21

Last change on this file since 21 was 21, checked in by z0rglub, 21 years ago

* empty log message *

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.2 KB
Line 
1<?php
2/***************************************************************************
3 *                                 admin.php                               *
4 *                            -------------------                          *
5 *   application          : PhpWebGallery 1.3                              *
6 *   author               : Pierrick LE GALL <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
18//----------------------------------------------------------- personnal include
19include_once( './include/isadmin.inc.php' );
20//----------------------------------------------------- template initialization
21$vtp = new VTemplate;
22$handle = $vtp->Open( '../template/'.$user['template'].'/admin/admin.vtp' );
23// language
24$vtp->setGlobalVar( $handle, 'page_title',  $lang['title_default'] );
25$vtp->setGlobalVar( $handle, 'menu_title',  $lang['menu_title'] );
26//--------------------------------------- validating page and creation of title
27$page_valide = false;
28$title = '';
29switch ( $_GET['page'] )
30{
31 case 'user_add':
32   $title = $lang['title_add'];           $page_valide = true; break;
33 case 'user_list':
34   $title = $lang['title_liste_users'];   $page_valide = true; break;
35 case 'user_modify':
36   $title = $lang['title_modify'];        $page_valide = true; break;
37 case 'user_perm':
38   if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1;
39   $query = 'SELECT status,username';
40   $query.= ' FROM '.PREFIX_TABLE.'users';
41   $query.= ' WHERE id = '.$_GET['user_id'];
42   $query.= ';';
43   $result = mysql_query( $query );
44   if ( mysql_num_rows( $result ) > 0 )
45   {
46     $row = mysql_fetch_array( $result );
47     $page['user_status']   = $row['status'];
48     if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest'];
49     $page['user_username'] = $row['username'];
50     $page_valide = true;
51     $title = $lang['title_user_perm'].' "'.$page['user_username'].'"';
52   }
53   else
54   {
55     $page_valide = false;
56   }
57   break;
58 case 'group_list' :
59   $title = $lang['title_groups'];        $page_valide = true; break;
60 case 'group_perm' :
61   if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
62   $query = 'SELECT name';
63   $query.= ' FROM '.PREFIX_TABLE.'groups';
64   $query.= ' WHERE id = '.$_GET['group_id'];
65   $query.= ';';
66   $result = mysql_query( $query );
67   if ( mysql_num_rows( $result ) > 0 )
68   {
69     $row = mysql_fetch_array( $result );
70     $title = $lang['title_group_perm'].' "'.$row['name'].'"';
71     $page_valide = true;
72   }
73   else
74   {
75     $page_valide = false;
76   }
77   break;
78 case 'historique':
79   $title = $lang['title_history'];       $page_valide = true; break;
80 case 'update':
81   $title = $lang['title_update'];        $page_valide = true; break;
82 case 'configuration':
83   $title = $lang['title_configuration']; $page_valide = true; break;
84 case 'manuel':
85   $title = $lang['title_instructions'];  $page_valide = true; break;
86 case 'cat_perm':
87   $title = $lang['title_cat_perm'];
88   if ( isset( $_GET['cat_id'] ) )
89   {
90     check_cat_id( $_GET['cat_id'] );
91     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
92     {
93       $result = get_cat_info( $page['cat'] );
94       $name = get_cat_display_name( $result['name'],' &gt; ', '' );
95       $title.= ' "'.$name.'"';
96     }
97   }
98   $page_valide = true;
99   break;
100 case 'cat_list':
101   $title = $lang['title_categories'];    $page_valide = true; break;
102 case 'cat_modify':
103   $title = $lang['title_edit_cat'];      $page_valide = true; break;
104 case 'infos_images':
105   $title = $lang['title_info_images'];   $page_valide = true; break;
106 case 'waiting':
107   $title = $lang['title_waiting'];       $page_valide = true; break;
108 case 'thumbnail':
109   $title = $lang['title_thumbnails'];
110   if ( isset( $_GET['dir'] ) )
111   {
112     $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
113     // $_GET['dir'] contient :
114     // ../galleries/vieux_lyon ou
115     // ../galleries/vieux_lyon/visite ou
116     // ../galleries/vieux_lyon/visite/truc ...
117     $dir = explode( "/", $_GET['dir'] );
118     $title.= $dir[2];
119     for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ )
120     {
121       $title.= ' &gt; '.$dir[$i];
122     }
123     $title.= "</span>";
124   }
125   $page_valide = true;
126   break;
127 default:
128   $title = $lang['title_default']; break;
129}
130if ( $title == '' ) $title = $lang['title_default'];
131$vtp->setGlobalVar( $handle, 'title', $title );
132//--------------------------------------------------------------------- summary
133$link_start = './admin.php?page=';
134// configuration
135$vtp->addSession( $handle, 'summary' );
136$vtp->setVar( $handle, 'summary.indent', '' );
137$vtp->setVar( $handle, 'summary.link',
138              add_session_id( $link_start.'configuration' ) );
139$vtp->setVar( $handle, 'summary.name', $lang['menu_config'] );
140$vtp->closeSession( $handle, 'summary' );
141// users
142$vtp->addSession( $handle, 'summary' );
143$vtp->setVar( $handle, 'summary.indent', '' );
144$vtp->setVar( $handle, 'summary.link',
145              add_session_id( $link_start.'user_list' ) );
146$vtp->setVar( $handle, 'summary.name', $lang['menu_users'] );
147$vtp->closeSession( $handle, 'summary' );
148// user list
149$vtp->addSession( $handle, 'summary' );
150$vtp->setVar( $handle, 'summary.indent', '&nbsp;&nbsp;' );
151$vtp->setVar( $handle, 'summary.link',
152              add_session_id( $link_start.'user_list' ) );
153$vtp->setVar( $handle, 'summary.name', $lang['menu_list_user'] );
154$vtp->closeSession( $handle, 'summary' );
155// user add
156$vtp->addSession( $handle, 'summary' );
157$vtp->setVar( $handle, 'summary.indent', '&nbsp;&nbsp;' );
158$vtp->setVar(
159  $handle, 'summary.link', add_session_id( $link_start.'user_add' ) );
160$vtp->setVar( $handle, 'summary.name', $lang['menu_add_user'] );
161$vtp->closeSession( $handle, 'summary' );
162// groups
163$vtp->addSession( $handle, 'summary' );
164$vtp->setVar( $handle, 'summary.indent', '' );
165$vtp->setVar( $handle, 'summary.link',
166              add_session_id( $link_start.'group_list' ) );
167$vtp->setVar( $handle, 'summary.name', $lang['menu_groups'] );
168$vtp->closeSession( $handle, 'summary' );
169// categories
170$vtp->addSession( $handle, 'summary' );
171$vtp->setVar( $handle, 'summary.indent', '' );
172$vtp->setVar( $handle, 'summary.link',add_session_id( $link_start.'cat_list'));
173$vtp->setVar( $handle, 'summary.name', $lang['menu_categories'] );
174$vtp->closeSession( $handle, 'summary' );
175// waiting
176$vtp->addSession( $handle, 'summary' );
177$vtp->setVar( $handle, 'summary.indent', '' );
178$vtp->setVar( $handle, 'summary.link',
179              add_session_id( $link_start.'waiting' ) );
180$query = 'select id from '.PREFIX_TABLE.'waiting;';
181$result = mysql_query( $query );
182$nb_waiting = '';
183if ( mysql_num_rows( $result ) > 0 )
184{
185  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
186}
187$vtp->setVar( $handle, 'summary.name', $lang['menu_waiting'].$nb_waiting );
188$vtp->closeSession( $handle, 'summary' );
189// update
190$vtp->addSession( $handle, 'summary' );
191$vtp->setVar( $handle, 'summary.indent', '' );
192$vtp->setVar( $handle, 'summary.link',
193              add_session_id( $link_start.'update' ) );
194$vtp->setVar( $handle, 'summary.name', $lang['menu_update'] );
195$vtp->closeSession( $handle, 'summary' );
196// thumbnails
197$vtp->addSession( $handle, 'summary' );
198$vtp->setVar( $handle, 'summary.indent', '' );
199$vtp->setVar( $handle, 'summary.link',
200              add_session_id( $link_start.'thumbnail' ) );
201$vtp->setVar( $handle, 'summary.name', $lang['menu_thumbnails'] );
202$vtp->closeSession( $handle, 'summary' );
203// history
204$vtp->addSession( $handle, 'summary' );
205$vtp->setVar( $handle, 'summary.indent', '' );
206$vtp->setVar( $handle, 'summary.link',
207              add_session_id( $link_start.'historique' ) );
208$vtp->setVar( $handle, 'summary.name', $lang['menu_history'] );
209$vtp->closeSession( $handle, 'summary' );
210// instructions
211$vtp->addSession( $handle, 'summary' );
212$vtp->setVar( $handle, 'summary.indent', '' );
213$vtp->setVar( $handle, 'summary.link',
214              add_session_id( $link_start.'manuel' ) );
215$vtp->setVar( $handle, 'summary.name', $lang['menu_instructions'] );
216$vtp->closeSession( $handle, 'summary' );
217// back to thumbnails page
218$vtp->addSession( $handle, 'summary' );
219$vtp->setVar( $handle, 'summary.indent', '' );
220$vtp->setVar( $handle, 'summary.link', add_session_id( '../category.php' ) );
221$vtp->setVar( $handle, 'summary.name', $lang['menu_back'] );
222$vtp->closeSession( $handle, 'summary' );
223//------------------------------------------------------------- content display
224if ( $page_valide )
225{
226  include ( $_GET['page'].'.php' );
227}
228else
229{
230  $vtp->setVar(
231    $handle, 'sub',
232    '<div style="text-align:center">'.$lang['default_message'].'</div>' );
233}
234//----------------------------------------------------------- html code display
235$code = $vtp->Display( $handle, 0 );
236echo $code;
237?>
Note: See TracBrowser for help on using the repository browser.