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