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