source: trunk/admin.php @ 375

Last change on this file since 375 was 375, checked in by gweltas, 20 years ago

New default template - User side

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.3 KB
Line 
1<?php
2// +-----------------------------------------------------------------------+
3// |                               admin.php                               |
4// +-----------------------------------------------------------------------+
5// | application   : PhpWebGallery <http://phpwebgallery.net>              |
6// | branch        : BSF (Best So Far)                                     |
7// +-----------------------------------------------------------------------+
8// | file          : $RCSfile$
9// | last update   : $Date: 2004-02-26 18:33:45 +0000 (Thu, 26 Feb 2004) $
10// | last modifier : $Author: gweltas $
11// | revision      : $Revision: 375 $
12// +-----------------------------------------------------------------------+
13// | This program is free software; you can redistribute it and/or modify  |
14// | it under the terms of the GNU General Public License as published by  |
15// | the Free Software Foundation                                          |
16// |                                                                       |
17// | This program is distributed in the hope that it will be useful, but   |
18// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
19// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
20// | General Public License for more details.                              |
21// |                                                                       |
22// | You should have received a copy of the GNU General Public License     |
23// | along with this program; if not, write to the Free Software           |
24// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
25// | USA.                                                                  |
26// +-----------------------------------------------------------------------+
27
28//----------------------------------------------------------- include
29define('PHPWG_ROOT_PATH','./');
30include_once( PHPWG_ROOT_PATH.'include/common.inc.php' );
31include_once( './admin/include/isadmin.inc.php' );
32//----------------------------------------------------- template initialization
33$vtp = new VTemplate;
34$handle = $vtp->Open( './template/'.$user['template'].'/admin.vtp' );
35// language
36$tpl = array( 'title_default','charset','install_warning' );
37templatize_array( $tpl, 'lang', $handle );
38$vtp->setGlobalVar( $handle, 'style', './template/'.$user['template'].'/'.$user['template'].'-admin.css');
39//-------------------------------------------------- install.php still exists ?
40if ( is_file( './install.php' ) )
41{
42  $vtp->addSession( $handle, 'install_warning' );
43  $vtp->closeSession( $handle, 'install_warning' );
44}
45//--------------------------------------- validating page and creation of title
46$page_valide = false;
47$title = '';
48if (isset( $_GET['page'] ))
49switch ( $_GET['page'] )
50{
51 case 'user_list':
52   $title = $lang['title_liste_users'];   $page_valide = true; break;
53 case 'user_modify':
54   $title = $lang['title_modify'];        $page_valide = true; break;
55 case 'user_perm':
56   if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1;
57   $query = 'SELECT status,username';
58   $query.= ' FROM '.USERS_TABLE;
59   $query.= ' WHERE id = '.$_GET['user_id'];
60   $query.= ';';
61   $result = mysql_query( $query );
62   if ( mysql_num_rows( $result ) > 0 )
63   {
64     $row = mysql_fetch_array( $result );
65     $page['user_status']   = $row['status'];
66     if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest'];
67     $page['user_username'] = $row['username'];
68     $page_valide = true;
69     $title = $lang['title_user_perm'].' "'.$page['user_username'].'"';
70   }
71   else
72   {
73     $page_valide = false;
74   }
75   break;
76 case 'group_list' :
77   $title = $lang['title_groups'];        $page_valide = true; break;
78 case 'group_perm' :
79   if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1;
80   $query = 'SELECT name';
81   $query.= ' FROM '.PREFIX_TABLE.'groups';
82   $query.= ' WHERE id = '.$_GET['group_id'];
83   $query.= ';';
84   $result = mysql_query( $query );
85   if ( mysql_num_rows( $result ) > 0 )
86   {
87     $row = mysql_fetch_array( $result );
88     $title = $lang['title_group_perm'].' "'.$row['name'].'"';
89     $page_valide = true;
90   }
91   else
92   {
93     $page_valide = false;
94   }
95   break;
96 case 'stats':
97   $title = $lang['title_history'];       $page_valide = true; break;
98 case 'update':
99   $title = $lang['title_update'];        $page_valide = true; break;
100 case 'configuration':
101   $title = $lang['title_configuration']; $page_valide = true; break;
102 case 'help':
103   $title = $lang['title_instructions'];  $page_valide = true; break;
104 case 'cat_perm':
105   $title = $lang['title_cat_perm'];
106   if ( isset( $_GET['cat_id'] ) )
107   {
108     check_cat_id( $_GET['cat_id'] );
109     if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) )
110     {
111       $result = get_cat_info( $page['cat'] );
112       $name = get_cat_display_name( $result['name'],' &gt; ', '' );
113       $title.= ' "'.$name.'"';
114     }
115   }
116   $page_valide = true;
117   break;
118 case 'cat_list':
119   $title = $lang['title_categories'];    $page_valide = true; break;
120 case 'cat_modify':
121   $title = $lang['title_edit_cat'];      $page_valide = true; break;
122 case 'infos_images':
123   $title = $lang['title_info_images'];   $page_valide = true; break;
124 case 'waiting':
125   $title = $lang['title_waiting'];       $page_valide = true; break;
126 case 'thumbnail':
127   $title = $lang['title_thumbnails'];
128   if ( isset( $_GET['dir'] ) )
129   {
130     $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';
131     // $_GET['dir'] contains :
132     // ./galleries/vieux_lyon ou
133     // ./galleries/vieux_lyon/visite ou
134     // ./galleries/vieux_lyon/visite/truc ...
135     $dir = explode( "/", $_GET['dir'] );
136     $title.= $dir[2];
137     for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ )
138     {
139       $title.= ' &gt; '.$dir[$i];
140     }
141     $title.= "</span>";
142   }
143   $page_valide = true;
144   break;
145 case 'comments' :
146   $title = $lang['title_comments'];
147   $page_valide = true;
148   break;
149 case 'picture_modify' :
150   $title = $lang['title_picmod'];
151   $page_valide = true;
152   break;
153 default:
154   $title = $lang['title_default']; break;
155}
156if ( $title == '' ) $title = $lang['title_default'];
157$vtp->setGlobalVar( $handle, 'title', $title );
158//--------------------------------------------------------------------- summary
159$link_start = './admin.php?page=';
160// configuration
161$vtp->addSession( $handle, 'summary' );
162$vtp->setVar( $handle, 'summary.indent', '' );
163$vtp->setVar( $handle, 'summary.link',
164              add_session_id( $link_start.'configuration' ) );
165$vtp->setVar( $handle, 'summary.name', $lang['menu_config'] );
166$vtp->closeSession( $handle, 'summary' );
167// users
168$vtp->addSession( $handle, 'summary' );
169$vtp->setVar( $handle, 'summary.indent', '| ' );
170$vtp->setVar( $handle, 'summary.link',
171              add_session_id( $link_start.'user_list' ) );
172$vtp->setVar( $handle, 'summary.name', $lang['menu_users'] );
173$vtp->closeSession( $handle, 'summary' );
174// groups
175$vtp->addSession( $handle, 'summary' );
176$vtp->setVar( $handle, 'summary.indent', '| ' );
177$vtp->setVar( $handle, 'summary.link',
178              add_session_id( $link_start.'group_list' ) );
179$vtp->setVar( $handle, 'summary.name', $lang['menu_groups'] );
180$vtp->closeSession( $handle, 'summary' );
181// categories
182$vtp->addSession( $handle, 'summary' );
183$vtp->setVar( $handle, 'summary.indent', '| ' );
184$vtp->setVar( $handle, 'summary.link',add_session_id( $link_start.'cat_list'));
185$vtp->setVar( $handle, 'summary.name', $lang['menu_categories'] );
186$vtp->closeSession( $handle, 'summary' );
187// waiting
188$vtp->addSession( $handle, 'summary' );
189$vtp->setVar( $handle, 'summary.indent', '| ' );
190$vtp->setVar( $handle, 'summary.link',
191              add_session_id( $link_start.'waiting' ) );
192$query = 'SELECT id';
193$query.= ' FROM '.PREFIX_TABLE.'waiting';
194$query.= " WHERE validated='false'";
195$query.= ';';
196$result = mysql_query( $query );
197$nb_waiting = '';
198if ( mysql_num_rows( $result ) > 0 )
199{
200  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
201}
202$vtp->setVar( $handle, 'summary.name', $lang['menu_waiting'].$nb_waiting );
203$vtp->closeSession( $handle, 'summary' );
204// comments
205$vtp->addSession( $handle, 'summary' );
206$vtp->setVar( $handle, 'summary.indent', '| ' );
207$vtp->setVar( $handle, 'summary.link',
208              add_session_id( $link_start.'comments' ) );
209$query = 'SELECT id';
210$query.= ' FROM '.PREFIX_TABLE.'comments';
211$query.= " WHERE validated='false'";
212$query.= ';';
213$result = mysql_query( $query );
214$nb_waiting = '';
215if ( mysql_num_rows( $result ) > 0 )
216{
217  $nb_waiting =  ' [ '.mysql_num_rows( $result ).' ]';
218}
219$vtp->setVar( $handle, 'summary.name', $lang['menu_comments'].$nb_waiting );
220$vtp->closeSession( $handle, 'summary' );
221// update
222$vtp->addSession( $handle, 'summary' );
223$vtp->setVar( $handle, 'summary.indent', '| ' );
224$vtp->setVar( $handle, 'summary.link',
225              add_session_id( $link_start.'update' ) );
226$vtp->setVar( $handle, 'summary.name', $lang['menu_update'] );
227$vtp->closeSession( $handle, 'summary' );
228// thumbnails
229$vtp->addSession( $handle, 'summary' );
230$vtp->setVar( $handle, 'summary.indent', '| ' );
231$vtp->setVar( $handle, 'summary.link',
232              add_session_id( $link_start.'thumbnail' ) );
233$vtp->setVar( $handle, 'summary.name', $lang['menu_thumbnails'] );
234$vtp->closeSession( $handle, 'summary' );
235// history
236$vtp->addSession( $handle, 'summary' );
237$vtp->setVar( $handle, 'summary.indent', '| ' );
238$vtp->setVar( $handle, 'summary.link',
239              add_session_id( $link_start.'stats' ) );
240$vtp->setVar( $handle, 'summary.name', $lang['menu_history'] );
241$vtp->closeSession( $handle, 'summary' );
242// instructions
243$vtp->addSession( $handle, 'summary' );
244$vtp->setVar( $handle, 'summary.indent', '| ' );
245$vtp->setVar( $handle, 'summary.link',
246              add_session_id( $link_start.'help' ) );
247$vtp->setVar( $handle, 'summary.name', $lang['menu_instructions'] );
248$vtp->closeSession( $handle, 'summary' );
249// back to thumbnails page
250$vtp->addSession( $handle, 'summary' );
251$vtp->setVar( $handle, 'summary.indent', '| ' );
252$vtp->setVar( $handle, 'summary.link', add_session_id( './category.php' ) );
253$vtp->setVar( $handle, 'summary.name', $lang['menu_back'] );
254$vtp->closeSession( $handle, 'summary' );
255//------------------------------------------------------------- content display
256if ( $page_valide )
257{
258  include ( './admin/'.$_GET['page'].'.php' );
259}
260else
261{
262  $vtp->setVar(
263    $handle, 'sub',
264    '<div style="text-align:center">'.$lang['default_message'].'</div>' );
265}
266//----------------------------------------------------------- html code display
267$code = $vtp->Display( $handle, 0 );
268echo $code;
269?>
Note: See TracBrowser for help on using the repository browser.