source: trunk/admin.php @ 232

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

Modifications linked to the move of admin.php to the root directory of PhpWebGallery

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 9.6 KB
Line 
1<?php
2/***************************************************************************
3 *                                 admin.php                               *
4 *                            -------------------                          *
5 *   application   : PhpWebGallery 1.3 <http://phpwebgallery.net>          *
6 *   author        : Pierrick LE GALL <pierrick@z0rglub.com>               *
7 *                                                                         *
8 *   $Id: admin.php 228 2003-11-03 21:35:24Z z0rglub $
9 *                                                                         *
10 ***************************************************************************/
11
12/***************************************************************************
13 *                                                                         *
14 *   This program is free software; you can redistribute it and/or modify  *
15 *   it under the terms of the GNU General Public License as published by  *
16 *   the Free Software Foundation;                                         *
17 *                                                                         *
18 ***************************************************************************/
19
20//----------------------------------------------------------- personnal include
21include_once( './admin/include/isadmin.inc.php' );
22//----------------------------------------------------- template initialization
23$vtp = new VTemplate;
24$handle = $vtp->Open( './template/'.$user['template'].'/admin.vtp' );
25// language
26$tpl = array( 'title_default','charset','install_warning' );
27templatize_array( $tpl, 'lang', $handle );
28//-------------------------------------------------- install.php still exists ?
29if ( is_file( './install.php' ) )
30{
31  $vtp->addSession( $handle, 'install_warning' );
32  $vtp->closeSession( $handle, 'install_warning' );
33}
34//--------------------------------------- validating page and creation of title
35$page_valide = false;
36$title = '';
37switch ( $_GET['page'] )
38{
39 case 'user_list':
40   $title = $lang['title_liste_users'];   $page_valide = true; break;
41 case 'user_modify':
42   $title = $lang['title_modify'];        $page_valide = true; break;
43 case 'user_perm':
44   if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1;
45   $query = 'SELECT status,username';
46   $query.= ' FROM '.PREFIX_TABLE.'users';
47   $query.= ' WHERE id = '.$_GET['user_id'];
48   $query.= ';';
49   $result = mysql_query( $query );
50   if ( mysql_num_rows( $result ) > 0 )
51   {
52     $row = mysql_fetch_array( $result );
53     $page['user_status']   = $row['status'];
54     if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest'];
55     $page['user_username'] = $row['username'];
56     $page_valide = true;
57     $title = $lang['title_user_perm'].' "'.$page['user_username'].'"';
58   }
59   else
60   {
61     $page_valide = false;
62   }
63   break;
64 case 'group_list' :
65   $title = $lang['title_groups'];        $page_valide = true; break;
66 case 'group_perm' :
67   if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
68   $query = 'SELECT name';
69   $query.= ' FROM '.PREFIX_TABLE.'groups';
70   $query.= ' WHERE id = '.$_GET['group_id'];
71   $query.= ';';
72   $result = mysql_query( $query );
73   if ( mysql_num_rows( $result ) > 0 )
74   {
75     $row = mysql_fetch_array( $result );
76     $title = $lang['title_group_perm'].' "'.$row['name'].'"';
77     $page_valide = true;
78   }
79   else
80   {
81     $page_valide = false;
82   }
83   break;
84 case 'stats':
85   $title = $lang['title_history'];       $page_valide = true; break;
86 case 'update':
87   $title = $lang['title_update'];        $page_valide = true; break;
88 case 'configuration':
89   $title = $lang['title_configuration']; $page_valide = true; break;
90 case 'help':
91   $title = $lang['title_instructions'];  $page_valide = true; break;
92 case 'cat_perm':
93   $title = $lang['title_cat_perm'];
94   if ( isset( $_GET['cat_id'] ) )
95   {
96     check_cat_id( $_GET['cat_id'] );
97     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
98     {
99       $result = get_cat_info( $page['cat'] );
100       $name = get_cat_display_name( $result['name'],' &gt; ', '' );
101       $title.= ' "'.$name.'"';
102     }
103   }
104   $page_valide = true;
105   break;
106 case 'cat_list':
107   $title = $lang['title_categories'];    $page_valide = true; break;
108 case 'cat_modify':
109   $title = $lang['title_edit_cat'];      $page_valide = true; break;
110 case 'infos_images':
111   $title = $lang['title_info_images'];   $page_valide = true; break;
112 case 'waiting':
113   $title = $lang['title_waiting'];       $page_valide = true; break;
114 case 'thumbnail':
115   $title = $lang['title_thumbnails'];
116   if ( isset( $_GET['dir'] ) )
117   {
118     $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
119     // $_GET['dir'] contains :
120     // ./galleries/vieux_lyon ou
121     // ./galleries/vieux_lyon/visite ou
122     // ./galleries/vieux_lyon/visite/truc ...
123     $dir = explode( "/", $_GET['dir'] );
124     $title.= $dir[2];
125     for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ )
126     {
127       $title.= ' &gt; '.$dir[$i];
128     }
129     $title.= "</span>";
130   }
131   $page_valide = true;
132   break;
133 case 'comments' :
134   $title = $lang['title_comments'];
135   $page_valide = true;
136   break;
137 case 'picture_modify' :
138   $title = $lang['title_picmod'];
139   $page_valide = true;
140   break;
141 default:
142   $title = $lang['title_default']; break;
143}
144if ( $title == '' ) $title = $lang['title_default'];
145$vtp->setGlobalVar( $handle, 'title', $title );
146//--------------------------------------------------------------------- summary
147$link_start = './admin.php?page=';
148// configuration
149$vtp->addSession( $handle, 'summary' );
150$vtp->setVar( $handle, 'summary.indent', '' );
151$vtp->setVar( $handle, 'summary.link',
152              add_session_id( $link_start.'configuration' ) );
153$vtp->setVar( $handle, 'summary.name', $lang['menu_config'] );
154$vtp->closeSession( $handle, 'summary' );
155// users
156$vtp->addSession( $handle, 'summary' );
157$vtp->setVar( $handle, 'summary.indent', '| ' );
158$vtp->setVar( $handle, 'summary.link',
159              add_session_id( $link_start.'user_list' ) );
160$vtp->setVar( $handle, 'summary.name', $lang['menu_users'] );
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';
181$query.= ' FROM '.PREFIX_TABLE.'waiting';
182$query.= " WHERE validated='false'";
183$query.= ';';
184$result = mysql_query( $query );
185$nb_waiting = '';
186if ( mysql_num_rows( $result ) > 0 )
187{
188  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
189}
190$vtp->setVar( $handle, 'summary.name', $lang['menu_waiting'].$nb_waiting );
191$vtp->closeSession( $handle, 'summary' );
192// comments
193$vtp->addSession( $handle, 'summary' );
194$vtp->setVar( $handle, 'summary.indent', '| ' );
195$vtp->setVar( $handle, 'summary.link',
196              add_session_id( $link_start.'comments' ) );
197$query = 'SELECT id';
198$query.= ' FROM '.PREFIX_TABLE.'comments';
199$query.= " WHERE validated='false'";
200$query.= ';';
201$result = mysql_query( $query );
202$nb_waiting = '';
203if ( mysql_num_rows( $result ) > 0 )
204{
205  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
206}
207$vtp->setVar( $handle, 'summary.name', $lang['menu_comments'].$nb_waiting );
208$vtp->closeSession( $handle, 'summary' );
209// update
210$vtp->addSession( $handle, 'summary' );
211$vtp->setVar( $handle, 'summary.indent', '| ' );
212$vtp->setVar( $handle, 'summary.link',
213              add_session_id( $link_start.'update' ) );
214$vtp->setVar( $handle, 'summary.name', $lang['menu_update'] );
215$vtp->closeSession( $handle, 'summary' );
216// thumbnails
217$vtp->addSession( $handle, 'summary' );
218$vtp->setVar( $handle, 'summary.indent', '| ' );
219$vtp->setVar( $handle, 'summary.link',
220              add_session_id( $link_start.'thumbnail' ) );
221$vtp->setVar( $handle, 'summary.name', $lang['menu_thumbnails'] );
222$vtp->closeSession( $handle, 'summary' );
223// history
224$vtp->addSession( $handle, 'summary' );
225$vtp->setVar( $handle, 'summary.indent', '| ' );
226$vtp->setVar( $handle, 'summary.link',
227              add_session_id( $link_start.'stats' ) );
228$vtp->setVar( $handle, 'summary.name', $lang['menu_history'] );
229$vtp->closeSession( $handle, 'summary' );
230// instructions
231$vtp->addSession( $handle, 'summary' );
232$vtp->setVar( $handle, 'summary.indent', '| ' );
233$vtp->setVar( $handle, 'summary.link',
234              add_session_id( $link_start.'help' ) );
235$vtp->setVar( $handle, 'summary.name', $lang['menu_instructions'] );
236$vtp->closeSession( $handle, 'summary' );
237// back to thumbnails page
238$vtp->addSession( $handle, 'summary' );
239$vtp->setVar( $handle, 'summary.indent', '| ' );
240$vtp->setVar( $handle, 'summary.link', add_session_id( './category.php' ) );
241$vtp->setVar( $handle, 'summary.name', $lang['menu_back'] );
242$vtp->closeSession( $handle, 'summary' );
243//------------------------------------------------------------- content display
244if ( $page_valide )
245{
246  include ( './admin/'.$_GET['page'].'.php' );
247}
248else
249{
250  $vtp->setVar(
251    $handle, 'sub',
252    '<div style="text-align:center">'.$lang['default_message'].'</div>' );
253}
254//----------------------------------------------------------- html code display
255$code = $vtp->Display( $handle, 0 );
256echo $code;
257?>
Note: See TracBrowser for help on using the repository browser.