source: trunk/admin/admin.php @ 29

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

template as user_template for displaying pictures in the template

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