source: trunk/admin/admin.php @ 202

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

Display a message of warning if file admin/install.php is still present
after install.

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