source: trunk/admin/admin.php @ 61

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

Multi categories for the same picture

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