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-19 00:31:09 +0000 (Thu, 19 Feb 2004) $ |
---|
10 | // | last modifier : $Author: gweltas $ |
---|
11 | // | revision : $Revision: 364 $ |
---|
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 |
---|
29 | define('PHPWG_ROOT_PATH','./'); |
---|
30 | include_once( PHPWG_ROOT_PATH.'include/common.inc.php' ); |
---|
31 | include_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' ); |
---|
37 | templatize_array( $tpl, 'lang', $handle ); |
---|
38 | //-------------------------------------------------- install.php still exists ? |
---|
39 | if ( is_file( './install.php' ) ) |
---|
40 | { |
---|
41 | $vtp->addSession( $handle, 'install_warning' ); |
---|
42 | $vtp->closeSession( $handle, 'install_warning' ); |
---|
43 | } |
---|
44 | //--------------------------------------- validating page and creation of title |
---|
45 | $page_valide = false; |
---|
46 | $title = ''; |
---|
47 | if (isset( $_GET['page'] )) |
---|
48 | switch ( $_GET['page'] ) |
---|
49 | { |
---|
50 | case 'user_list': |
---|
51 | $title = $lang['title_liste_users']; $page_valide = true; break; |
---|
52 | case 'user_modify': |
---|
53 | $title = $lang['title_modify']; $page_valide = true; break; |
---|
54 | case 'user_perm': |
---|
55 | if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1; |
---|
56 | $query = 'SELECT status,username'; |
---|
57 | $query.= ' FROM '.USERS_TABLE; |
---|
58 | $query.= ' WHERE id = '.$_GET['user_id']; |
---|
59 | $query.= ';'; |
---|
60 | $result = mysql_query( $query ); |
---|
61 | if ( mysql_num_rows( $result ) > 0 ) |
---|
62 | { |
---|
63 | $row = mysql_fetch_array( $result ); |
---|
64 | $page['user_status'] = $row['status']; |
---|
65 | if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest']; |
---|
66 | $page['user_username'] = $row['username']; |
---|
67 | $page_valide = true; |
---|
68 | $title = $lang['title_user_perm'].' "'.$page['user_username'].'"'; |
---|
69 | } |
---|
70 | else |
---|
71 | { |
---|
72 | $page_valide = false; |
---|
73 | } |
---|
74 | break; |
---|
75 | case 'group_list' : |
---|
76 | $title = $lang['title_groups']; $page_valide = true; break; |
---|
77 | case 'group_perm' : |
---|
78 | if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1; |
---|
79 | $query = 'SELECT name'; |
---|
80 | $query.= ' FROM '.PREFIX_TABLE.'groups'; |
---|
81 | $query.= ' WHERE id = '.$_GET['group_id']; |
---|
82 | $query.= ';'; |
---|
83 | $result = mysql_query( $query ); |
---|
84 | if ( mysql_num_rows( $result ) > 0 ) |
---|
85 | { |
---|
86 | $row = mysql_fetch_array( $result ); |
---|
87 | $title = $lang['title_group_perm'].' "'.$row['name'].'"'; |
---|
88 | $page_valide = true; |
---|
89 | } |
---|
90 | else |
---|
91 | { |
---|
92 | $page_valide = false; |
---|
93 | } |
---|
94 | break; |
---|
95 | case 'stats': |
---|
96 | $title = $lang['title_history']; $page_valide = true; break; |
---|
97 | case 'update': |
---|
98 | $title = $lang['title_update']; $page_valide = true; break; |
---|
99 | case 'configuration': |
---|
100 | $title = $lang['title_configuration']; $page_valide = true; break; |
---|
101 | case 'help': |
---|
102 | $title = $lang['title_instructions']; $page_valide = true; break; |
---|
103 | case 'cat_perm': |
---|
104 | $title = $lang['title_cat_perm']; |
---|
105 | if ( isset( $_GET['cat_id'] ) ) |
---|
106 | { |
---|
107 | check_cat_id( $_GET['cat_id'] ); |
---|
108 | if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) |
---|
109 | { |
---|
110 | $result = get_cat_info( $page['cat'] ); |
---|
111 | $name = get_cat_display_name( $result['name'],' > ', '' ); |
---|
112 | $title.= ' "'.$name.'"'; |
---|
113 | } |
---|
114 | } |
---|
115 | $page_valide = true; |
---|
116 | break; |
---|
117 | case 'cat_list': |
---|
118 | $title = $lang['title_categories']; $page_valide = true; break; |
---|
119 | case 'cat_modify': |
---|
120 | $title = $lang['title_edit_cat']; $page_valide = true; break; |
---|
121 | case 'infos_images': |
---|
122 | $title = $lang['title_info_images']; $page_valide = true; break; |
---|
123 | case 'waiting': |
---|
124 | $title = $lang['title_waiting']; $page_valide = true; break; |
---|
125 | case 'thumbnail': |
---|
126 | $title = $lang['title_thumbnails']; |
---|
127 | if ( isset( $_GET['dir'] ) ) |
---|
128 | { |
---|
129 | $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">'; |
---|
130 | // $_GET['dir'] contains : |
---|
131 | // ./galleries/vieux_lyon ou |
---|
132 | // ./galleries/vieux_lyon/visite ou |
---|
133 | // ./galleries/vieux_lyon/visite/truc ... |
---|
134 | $dir = explode( "/", $_GET['dir'] ); |
---|
135 | $title.= $dir[2]; |
---|
136 | for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ ) |
---|
137 | { |
---|
138 | $title.= ' > '.$dir[$i]; |
---|
139 | } |
---|
140 | $title.= "</span>"; |
---|
141 | } |
---|
142 | $page_valide = true; |
---|
143 | break; |
---|
144 | case 'comments' : |
---|
145 | $title = $lang['title_comments']; |
---|
146 | $page_valide = true; |
---|
147 | break; |
---|
148 | case 'picture_modify' : |
---|
149 | $title = $lang['title_picmod']; |
---|
150 | $page_valide = true; |
---|
151 | break; |
---|
152 | default: |
---|
153 | $title = $lang['title_default']; break; |
---|
154 | } |
---|
155 | if ( $title == '' ) $title = $lang['title_default']; |
---|
156 | $vtp->setGlobalVar( $handle, 'title', $title ); |
---|
157 | //--------------------------------------------------------------------- summary |
---|
158 | $link_start = './admin.php?page='; |
---|
159 | // configuration |
---|
160 | $vtp->addSession( $handle, 'summary' ); |
---|
161 | $vtp->setVar( $handle, 'summary.indent', '' ); |
---|
162 | $vtp->setVar( $handle, 'summary.link', |
---|
163 | add_session_id( $link_start.'configuration' ) ); |
---|
164 | $vtp->setVar( $handle, 'summary.name', $lang['menu_config'] ); |
---|
165 | $vtp->closeSession( $handle, 'summary' ); |
---|
166 | // users |
---|
167 | $vtp->addSession( $handle, 'summary' ); |
---|
168 | $vtp->setVar( $handle, 'summary.indent', '| ' ); |
---|
169 | $vtp->setVar( $handle, 'summary.link', |
---|
170 | add_session_id( $link_start.'user_list' ) ); |
---|
171 | $vtp->setVar( $handle, 'summary.name', $lang['menu_users'] ); |
---|
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 = ''; |
---|
197 | if ( 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 = ''; |
---|
214 | if ( 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 |
---|
255 | if ( $page_valide ) |
---|
256 | { |
---|
257 | include ( './admin/'.$_GET['page'].'.php' ); |
---|
258 | } |
---|
259 | else |
---|
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 ); |
---|
267 | echo $code; |
---|
268 | ?> |
---|