Changeset 21
- Timestamp:
- Jul 1, 2003, 11:27:20 AM (21 years ago)
- Location:
- trunk
- Files:
-
- 13 added
- 5 deleted
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/admin/admin.php
r10 r21 26 26 //--------------------------------------- validating page and creation of title 27 27 $page_valide = false; 28 $title = ''; 28 29 switch ( $_GET['page'] ) 29 30 { 30 31 case 'user_add': 31 $tit re = $lang['title_add']; $page_valide = true; break;32 $title = $lang['title_add']; $page_valide = true; break; 32 33 case 'user_list': 33 $tit re = $lang['title_liste_users']; $page_valide = true; break;34 $title = $lang['title_liste_users']; $page_valide = true; break; 34 35 case 'user_modify': 35 $titre = $lang['title_modify']; $page_valide = true; break; 36 $title = $lang['title_modify']; $page_valide = true; break; 37 case 'user_perm': 38 if ( !is_numeric( $_GET['user_id'] ) ) $_GET['user_id'] = -1; 39 $query = 'SELECT status,username'; 40 $query.= ' FROM '.PREFIX_TABLE.'users'; 41 $query.= ' WHERE id = '.$_GET['user_id']; 42 $query.= ';'; 43 $result = mysql_query( $query ); 44 if ( mysql_num_rows( $result ) > 0 ) 45 { 46 $row = mysql_fetch_array( $result ); 47 $page['user_status'] = $row['status']; 48 if ( $row['username'] == 'guest' ) $row['username'] = $lang['guest']; 49 $page['user_username'] = $row['username']; 50 $page_valide = true; 51 $title = $lang['title_user_perm'].' "'.$page['user_username'].'"'; 52 } 53 else 54 { 55 $page_valide = false; 56 } 57 break; 58 case 'group_list' : 59 $title = $lang['title_groups']; $page_valide = true; break; 60 case 'group_perm' : 61 if ( !is_numeric( $_GET['group_id'] ) ) $_GET['group_id'] = -1; 62 $query = 'SELECT name'; 63 $query.= ' FROM '.PREFIX_TABLE.'groups'; 64 $query.= ' WHERE id = '.$_GET['group_id']; 65 $query.= ';'; 66 $result = mysql_query( $query ); 67 if ( mysql_num_rows( $result ) > 0 ) 68 { 69 $row = mysql_fetch_array( $result ); 70 $title = $lang['title_group_perm'].' "'.$row['name'].'"'; 71 $page_valide = true; 72 } 73 else 74 { 75 $page_valide = false; 76 } 77 break; 36 78 case 'historique': 37 $tit re = $lang['title_history']; $page_valide = true; break;79 $title = $lang['title_history']; $page_valide = true; break; 38 80 case 'update': 39 $tit re = $lang['title_update']; $page_valide = true; break;81 $title = $lang['title_update']; $page_valide = true; break; 40 82 case 'configuration': 41 $tit re = $lang['title_configuration']; $page_valide = true; break;83 $title = $lang['title_configuration']; $page_valide = true; break; 42 84 case 'manuel': 43 $titre = $lang['title_instructions']; $page_valide = true; break; 44 case 'perm': 45 $titre = $lang['title_permissions']; $page_valide = true; break; 46 case 'cat': 47 $titre = $lang['title_categories']; $page_valide = true; break; 48 case 'edit_cat': 49 $titre = $lang['title_edit_cat']; $page_valide = true; break; 85 $title = $lang['title_instructions']; $page_valide = true; break; 86 case 'cat_perm': 87 $title = $lang['title_cat_perm']; 88 if ( isset( $_GET['cat_id'] ) ) 89 { 90 check_cat_id( $_GET['cat_id'] ); 91 if ( isset( $page['cat'] ) and is_numeric( $page['cat'] ) ) 92 { 93 $result = get_cat_info( $page['cat'] ); 94 $name = get_cat_display_name( $result['name'],' > ', '' ); 95 $title.= ' "'.$name.'"'; 96 } 97 } 98 $page_valide = true; 99 break; 100 case 'cat_list': 101 $title = $lang['title_categories']; $page_valide = true; break; 102 case 'cat_modify': 103 $title = $lang['title_edit_cat']; $page_valide = true; break; 50 104 case 'infos_images': 51 $tit re = $lang['title_info_images']; $page_valide = true; break;105 $title = $lang['title_info_images']; $page_valide = true; break; 52 106 case 'waiting': 53 $tit re = $lang['title_waiting']; $page_valide = true; break;107 $title = $lang['title_waiting']; $page_valide = true; break; 54 108 case 'thumbnail': 55 $tit re = $lang['title_thumbnails'];109 $title = $lang['title_thumbnails']; 56 110 if ( isset( $_GET['dir'] ) ) 57 111 { 58 $tit re.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">';112 $title.= ' '.$lang['title_thumbnails_2'].' <span style="color:#006699;">'; 59 113 // $_GET['dir'] contient : 60 114 // ../galleries/vieux_lyon ou … … 62 116 // ../galleries/vieux_lyon/visite/truc ... 63 117 $dir = explode( "/", $_GET['dir'] ); 64 $tit re.= $dir[2];118 $title.= $dir[2]; 65 119 for ( $i = 3; $i < sizeof( $dir ) - 1; $i++ ) 66 120 { 67 $tit re.= ' > '.$dir[$i];121 $title.= ' > '.$dir[$i]; 68 122 } 69 $tit re.= "</span>";123 $title.= "</span>"; 70 124 } 71 125 $page_valide = true; 72 126 break; 73 127 default: 74 $titre = $lang['title_default']; break; 75 } 76 $vtp->setGlobalVar( $handle, 'title', $titre ); 128 $title = $lang['title_default']; break; 129 } 130 if ( $title == '' ) $title = $lang['title_default']; 131 $vtp->setGlobalVar( $handle, 'title', $title ); 77 132 //--------------------------------------------------------------------- summary 78 133 $link_start = './admin.php?page='; … … 88 143 $vtp->setVar( $handle, 'summary.indent', '' ); 89 144 $vtp->setVar( $handle, 'summary.link', 90 add_session_id( $link_start.' liste_users' ) );145 add_session_id( $link_start.'user_list' ) ); 91 146 $vtp->setVar( $handle, 'summary.name', $lang['menu_users'] ); 92 147 $vtp->closeSession( $handle, 'summary' ); … … 105 160 $vtp->setVar( $handle, 'summary.name', $lang['menu_add_user'] ); 106 161 $vtp->closeSession( $handle, 'summary' ); 162 // groups 163 $vtp->addSession( $handle, 'summary' ); 164 $vtp->setVar( $handle, 'summary.indent', '' ); 165 $vtp->setVar( $handle, 'summary.link', 166 add_session_id( $link_start.'group_list' ) ); 167 $vtp->setVar( $handle, 'summary.name', $lang['menu_groups'] ); 168 $vtp->closeSession( $handle, 'summary' ); 107 169 // categories 108 170 $vtp->addSession( $handle, 'summary' ); 109 171 $vtp->setVar( $handle, 'summary.indent', '' ); 110 $vtp->setVar( $handle, 'summary.link', add_session_id( $link_start.'cat' ));172 $vtp->setVar( $handle, 'summary.link',add_session_id( $link_start.'cat_list')); 111 173 $vtp->setVar( $handle, 'summary.name', $lang['menu_categories'] ); 112 174 $vtp->closeSession( $handle, 'summary' ); -
trunk/admin/configuration.php
r20 r21 16 16 * * 17 17 ***************************************************************************/ 18 18 19 19 include_once( './include/isadmin.inc.php' ); 20 20 … … 49 49 if ( isset( $_POST['submit'] ) ) 50 50 { 51 //purge de la table des session si demandé 51 $int_pattern = '/^\d+$/'; 52 // empty session table if asked 52 53 if ( $_POST['empty_session_table'] == 1 ) 53 54 { … … 80 81 } 81 82 // periods must be integer values, they represents number of days 82 if ( ! is_int($_POST['short_period'] )83 or ! is_int($_POST['long_period'] ) )83 if ( !preg_match( $int_pattern, $_POST['short_period'] ) 84 or !preg_match( $int_pattern, $_POST['long_period'] ) ) 84 85 { 85 86 array_push( $error, $lang['err_periods'] ); … … 95 96 } 96 97 // session_id size must be an integer between 4 and 50 97 if ( ! is_int($_POST['session_id_size'] )98 if ( !preg_match( $int_pattern, $_POST['session_id_size'] ) 98 99 or $_POST['session_id_size'] < 4 99 100 or $_POST['session_id_size'] > 50 ) … … 102 103 } 103 104 // session_time must be an integer between 5 and 60, in minutes 104 if ( ! is_int($_POST['session_time'] )105 if ( !preg_match( $int_pattern, $_POST['session_time'] ) 105 106 or $_POST['session_time'] < 5 106 107 or $_POST['session_time'] > 60 ) … … 109 110 } 110 111 // max_user_listbox must be an integer between 0 and 255 included 111 if ( ! is_int($_POST['max_user_listbox'] )112 if ( !preg_match( $int_pattern, $_POST['max_user_listbox'] ) 112 113 or $_POST['max_user_listbox'] < 0 113 114 or $_POST['max_user_listbox'] > 255 ) … … 117 118 // the number of comments per page must be an integer between 5 and 50 118 119 // included 119 if ( ! is_int($_POST['nb_comment_page'] )120 if ( !preg_match( $int_pattern, $_POST['nb_comment_page'] ) 120 121 or $_POST['nb_comment_page'] < 5 121 122 or $_POST['nb_comment_page'] > 50 ) … … 124 125 } 125 126 // the maximum upload filesize must be an integer between 10 and 1000 126 if ( ! is_int($_POST['upload_maxfilesize'] )127 if ( !preg_match( $int_pattern, $_POST['upload_maxfilesize'] ) 127 128 or $_POST['upload_maxfilesize'] < 10 128 129 or $_POST['upload_maxfilesize'] > 1000 ) … … 132 133 // the maximum width of uploaded pictures must be an integer superior to 133 134 // 10 134 if ( ! is_int($_POST['upload_maxwidth'] )135 if ( !preg_match( $int_pattern, $_POST['upload_maxwidth'] ) 135 136 or $_POST['upload_maxwidth'] < 10 ) 136 137 { … … 139 140 // the maximum height of uploaded pictures must be an integer superior to 140 141 // 10 141 if ( ! is_int($_POST['upload_maxheight'] )142 if ( !preg_match( $int_pattern, $_POST['upload_maxheight'] ) 142 143 or $_POST['upload_maxheight'] < 10 ) 143 144 { … … 146 147 // the maximum width of uploaded thumbnails must be an integer superior to 147 148 // 10 148 if ( ! is_int($_POST['upload_maxwidth_thumbnail'] )149 if ( !preg_match( $int_pattern, $_POST['upload_maxwidth_thumbnail'] ) 149 150 or $_POST['upload_maxwidth_thumbnail'] < 10 ) 150 151 { … … 153 154 // the maximum width of uploaded thumbnails must be an integer superior to 154 155 // 10 155 if ( ! is_int($_POST['upload_maxheight_thumbnail'] )156 if ( !preg_match( $int_pattern, $_POST['upload_maxheight_thumbnail'] ) 156 157 or $_POST['upload_maxheight_thumbnail'] < 10 ) 157 158 { 158 159 array_push( $error, $lang['conf_err_upload_maxheight_thumbnail'] ); 159 160 } 160 $test = ''; 161 if ( is_int( $test ) ) echo 'salut'; exit(); 162 if ( $_POST['maxwidth'] != '' ) 163 { 164 if ( !ereg( "^[0-9]{2,}$", $_POST['maxwidth'] ) 165 or $_POST['maxwidth'] < 50 ) 166 { 167 $error[$i++] = $lang['err_maxwidth']; 168 } 169 } 170 if ( $_POST['maxheight'] != '' ) 171 { 172 if ( !ereg( "^[0-9]{2,}$", $_POST['maxheight'] ) 173 or $_POST['maxheight'] < 50 ) 174 { 175 $error[$i++] = $lang['err_maxheight']; 176 } 177 } 178 // on met à jour les paramètres de l'application 179 // dans le cas où il n'y aucune erreurs 180 if ( sizeof( $error ) == 0 ) 181 { 182 mysql_query( 'delete from '.PREFIX_TABLE.'config;' ); 183 $query = 'insert into '.PREFIX_TABLE.'config'; 161 162 if ( $_POST['maxwidth'] != '' 163 and ( !preg_match( $int_pattern, $_POST['maxwidth'] ) 164 or $_POST['maxwidth'] < 50 ) ) 165 { 166 array_push( $error, $lang['err_maxwidth'] ); 167 } 168 if ( $_POST['maxheight'] 169 and ( !preg_match( $int_pattern, $_POST['maxheight'] ) 170 or $_POST['maxheight'] < 50 ) ) 171 { 172 array_push( $error, $lang['err_maxheight'] ); 173 } 174 // updating configuraiton if no error found 175 if ( count( $error ) == 0 ) 176 { 177 mysql_query( 'DELETE FROM '.PREFIX_TABLE.'config;' ); 178 $query = 'INSERT INTO '.PREFIX_TABLE.'config'; 184 179 $query.= ' ('; 185 180 foreach ( $conf_infos as $i => $conf_info ) { … … 188 183 } 189 184 $query.= ')'; 190 $query.= ' values';185 $query.= ' VALUES'; 191 186 $query.= ' ('; 192 187 foreach ( $conf_infos as $i => $conf_info ) { … … 261 256 } 262 257 //----------------------------------------------------- template initialization 263 $sub = $vtp->Open( '../template/'.$user['template']. 264 '/admin/configuration.vtp' ); 265 // language 266 $vtp->setGlobalVar( $sub, 'conf_confirmation', $lang['conf_confirmation'] ); 267 $vtp->setGlobalVar( $sub, 'remote_site', $lang['remote_site'] ); 268 $vtp->setGlobalVar( $sub, 'delete', $lang['delete'] ); 269 $vtp->setGlobalVar( $sub, 'conf_remote_site_delete_info', 270 $lang['conf_remote_site_delete_info'] ); 271 $vtp->setGlobalVar( $sub, 'submit', $lang['submit'] ); 258 $sub = $vtp->Open( 259 '../template/'.$user['template'].'/admin/configuration.vtp' ); 260 261 $tpl = array( 'conf_confirmation','remote_site','delete', 262 'conf_remote_site_delete_info','submit' ); 263 templatize_array( $tpl, 'lang', $sub ); 272 264 //-------------------------------------------------------------- errors display 273 265 if ( sizeof( $error ) != 0 ) … … 346 338 $vtp->setVar( $sub, 'radio.option', $lang['conf_general_access_1'] ); 347 339 $checked = ''; 348 echo $access.'<br />';349 340 if ( $access == 'free' ) 350 341 { -
trunk/admin/include/functions.php
r19 r21 102 102 delete_image( $row['id'] ); 103 103 } 104 105 // destruction of the restrictions linked to the category106 $query = 'DELETE FROM '.PREFIX_TABLE.' restrictions';104 105 // destruction of the access linked to the category 106 $query = 'DELETE FROM '.PREFIX_TABLE.'user_access'; 107 107 $query.= ' WHERE cat_id = '.$id; 108 108 $query.= ';'; 109 109 mysql_query( $query ); 110 110 $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; 111 $query.= ' WHERE cat_id = '.$id; 112 $query.= ';'; 113 mysql_query( $query ); 114 111 115 // destruction of the sub-categories 112 116 $query = 'SELECT id'; … … 119 123 delete_category( $row['id'] ); 120 124 } 121 125 122 126 // destruction of the category 123 127 $query = 'DELETE FROM '.PREFIX_TABLE.'categories'; … … 157 161 // The delete_user function delete a user identified by the $user_id 158 162 // It also deletes : 159 // - all the restrictions linked to this user 163 // - all the access linked to this user 164 // - all the links to any group 160 165 // - all the favorites linked to this user 166 // - all sessions linked to this user 161 167 function delete_user( $user_id ) 162 168 { 163 // destruction of the restrictions linked to the user 164 $query = 'DELETE FROM '.PREFIX_TABLE.'restrictions'; 165 $query.= ' WHERE user_id = '.$user_id; 166 $query.= ';'; 167 mysql_query( $query ); 168 169 // destruction of the access linked to the user 170 $query = 'DELETE FROM '.PREFIX_TABLE.'user_access'; 171 $query.= ' WHERE user_id = '.$user_id; 172 $query.= ';'; 173 mysql_query( $query ); 174 175 // destruction of the group links for this user 176 $query = 'DELETE FROM '.PREFIX_TABLE.'user_group'; 177 $query.= ' WHERE user_id = '.$user_id; 178 $query.= ';'; 179 mysql_query( $query ); 180 169 181 // destruction of the favorites associated with the user 170 182 $query = 'DELETE FROM '.PREFIX_TABLE.'favorites'; 183 $query.= ' WHERE user_id = '.$user_id; 184 $query.= ';'; 185 mysql_query( $query ); 186 187 // destruction of the sessions linked with the user 188 $query = 'DELETE FROM '.PREFIX_TABLE.'sessions'; 171 189 $query.= ' WHERE user_id = '.$user_id; 172 190 $query.= ';'; … … 179 197 mysql_query( $query ); 180 198 } 181 199 200 // delete_group deletes a group identified by its $group_id. 201 // It also deletes : 202 // - all the access linked to this group 203 // - all the links between this group and any user 204 function delete_group( $group_id ) 205 { 206 // destruction of the access linked to the group 207 $query = 'DELETE FROM '.PREFIX_TABLE.'group_access'; 208 $query.= ' WHERE group_id = '.$group_id; 209 $query.= ';'; 210 mysql_query( $query ); 211 212 // destruction of the group links for this group 213 $query = 'DELETE FROM '.PREFIX_TABLE.'user_group'; 214 $query.= ' WHERE group_id = '.$group_id; 215 $query.= ';'; 216 mysql_query( $query ); 217 218 // destruction of the group 219 $query = 'DELETE FROM '.PREFIX_TABLE.'groups'; 220 $query.= ' WHERE id = '.$group_id; 221 $query.= ';'; 222 mysql_query( $query ); 223 } 224 182 225 // The check_favorites function deletes all the favorites of a user if he is 183 226 // not allowed to see them (the category or an upper category is restricted -
trunk/admin/include/isadmin.inc.php
r2 r21 15 15 * * 16 16 ***************************************************************************/ 17 define( PREFIX E_INCLUDE, '.' );17 define( PREFIX_INCLUDE, '.' ); 18 18 19 19 include_once( '../include/config.inc.php' ); 20 20 include_once( '../include/user.inc.php' ); 21 21 include( './include/functions.php' ); 22 23 $conf['lien_puce'] = $conf['repertoire_image'].'puce.gif';24 22 25 23 $isadmin = true; -
trunk/admin/user_list.php
r10 r21 18 18 //----------------------------------------------------- template initialization 19 19 $sub = $vtp->Open( '../template/'.$user['template'].'/admin/user_list.vtp' ); 20 // language 21 $vtp->setGlobalVar( $sub, 'listuser_confirm', $lang['listuser_confirm'] ); 22 $vtp->setGlobalVar( $sub, 'listuser_modify_hint', 23 $lang['listuser_modify_hint'] ); 24 $vtp->setGlobalVar( $sub, 'listuser_modify', $lang['listuser_modify'] ); 25 $vtp->setGlobalVar( $sub, 'listuser_permission', 26 $lang['listuser_permission'] ); 27 $vtp->setGlobalVar( $sub, 'listuser_permission_hint', 28 $lang['listuser_permission_hint'] ); 29 $vtp->setGlobalVar( $sub, 'listuser_delete_hint', 30 $lang['listuser_delete_hint'] ); 31 $vtp->setGlobalVar( $sub, 'listuser_delete', $lang['listuser_delete'] ); 32 $vtp->setGlobalVar( $sub, 'yes', $lang['yes'] ); 33 $vtp->setGlobalVar( $sub, 'no', $lang['no'] ); 34 $vtp->setGlobalVar( $sub, 'listuser_button_all', 35 $lang['listuser_button_all'] ); 36 $vtp->setGlobalVar( $sub, 'listuser_button_invert', 37 $lang['listuser_button_invert'] ); 38 $vtp->setGlobalVar( $sub, 'listuser_button_create_address', 39 $lang['listuser_button_create_address'] ); 20 $tpl = array( 'listuser_confirm','listuser_modify_hint','listuser_modify', 21 'listuser_permission','listuser_permission_hint', 22 'listuser_delete_hint','listuser_delete','yes','no', 23 'listuser_button_all','listuser_button_invert', 24 'listuser_button_create_address' ); 25 templatize_array( $tpl, 'lang', $sub ); 40 26 //--------------------------------------------------------------- delete a user 41 27 if ( isset ( $_GET['delete'] ) and is_numeric( $_GET['delete'] ) ) 42 28 { 43 $query = ' selectusername';44 $query.= ' from'.PREFIX_TABLE.'users';45 $query.= ' whereid = '.$_GET['delete'];29 $query = 'SELECT username'; 30 $query.= ' FROM '.PREFIX_TABLE.'users'; 31 $query.= ' WHERE id = '.$_GET['delete']; 46 32 $query.= ';'; 47 33 $row = mysql_fetch_array( mysql_query( $query ) ); … … 65 51 and $row['username'] != $conf['webmaster'] ) 66 52 { 67 $query = ' select count(*) asnb_result';68 $query.= ' from'.PREFIX_TABLE.'users';69 $query.= ' whereid = '.$_GET['delete'];53 $query = 'SELECT COUNT(*) AS nb_result'; 54 $query.= ' FROM '.PREFIX_TABLE.'users'; 55 $query.= ' WHERE id = '.$_GET['delete']; 70 56 $query.= ';'; 71 57 $row2 = mysql_fetch_array( mysql_query( $query ) ); … … 103 89 $vtp->setVar( $sub, 'users.form_action', $action ); 104 90 105 $query = ' selectid,username,status,mail_address';106 $query.= ' from'.PREFIX_TABLE.'users';107 $query.= ' order by status asc, username asc';91 $query = 'SELECT id,username,status,mail_address'; 92 $query.= ' FROM '.PREFIX_TABLE.'users'; 93 $query.= ' ORDER BY status ASC, username ASC'; 108 94 $query.= ';'; 109 95 $result = mysql_query( $query ); … … 123 109 switch ( $row['status'] ) 124 110 { 125 case 'admin' : 126 { 127 $title.= $lang['adduser_status_admin']; 128 break; 129 } 130 case 'guest' : 131 { 132 $title.= $lang['adduser_status_guest']; 133 break; 134 } 111 case 'admin' : $title.= $lang['adduser_status_admin']; break; 112 case 'guest' : $title.= $lang['adduser_status_guest']; break; 135 113 } 136 114 $vtp->setVar( $sub, 'category.title', $title ); … … 153 131 { 154 132 $vtp->setVar( $sub, 'user.color', 'green' ); 155 }156 if ( $row['username'] == 'guest' )157 {158 133 $vtp->setVar( $sub, 'user.login', $lang['guest'] ); 159 134 } … … 180 155 } 181 156 // manage permission or not ? 182 if ( $row['username'] == $conf['webmaster'] ) 157 if ( $row['username'] == $conf['webmaster'] 158 and $user['username'] != $conf['webmaster'] ) 183 159 { 184 160 $vtp->addSession( $sub, 'not_permission' ); … … 188 164 { 189 165 $vtp->addSession( $sub, 'permission' ); 190 $url = './admin.php?page= perm&user_id='.$row['id'];166 $url = './admin.php?page=user_perm&user_id='.$row['id']; 191 167 $vtp->setVar( $sub, 'permission.url', add_session_id( $url ) ); 192 168 $vtp->setVar( $sub, 'permission.login', $row['username'] ); … … 216 192 $mail_address = array(); 217 193 $i = 0; 218 $query = 'select'; 219 $query.= ' id,mail_address'; 220 $query.= ' from '.PREFIX_TABLE.'users'; 194 $query = 'SELECT id,mail_address'; 195 $query.= ' FROM '.PREFIX_TABLE.'users'; 221 196 $query.= ';'; 222 197 $result = mysql_query( $query ); -
trunk/admin/user_modify.php
r10 r21 21 21 $tpl = array( 'adduser_info_message', 'adduser_info_back', 'adduser_fill_form', 22 22 'login', 'new', 'password', 'mail_address', 'adduser_status', 23 'submit', 'adduser_info_password_updated' ); 23 'submit', 'adduser_info_password_updated','menu_groups', 24 'dissociate','adduser_associate' ); 24 25 templatize_array( $tpl, 'lang', $sub ); 25 26 //--------------------------------------------------------- form criteria check … … 35 36 $query.= ';'; 36 37 $row = mysql_fetch_array( mysql_query( $query ) ); 37 38 $page['username'] = $row['username']; 39 $page['status'] = $row['status']; 40 $page['mail_address'] = $row['mail_address']; 38 41 // user is not modifiable if : 39 42 // 1. the selected user is the user "guest" … … 67 70 $_POST['password'] ) ); 68 71 } 72 // association with groups management 73 if ( isset( $_POST['submit'] ) ) 74 { 75 // deletion of checked groups 76 $query = 'SELECT id,name'; 77 $query.= ' FROM '.PREFIX_TABLE.'groups'; 78 $query.= ' ORDER BY id ASC'; 79 $query.= ';'; 80 $result = mysql_query( $query ); 81 while ( $row = mysql_fetch_array( $result ) ) 82 { 83 $dissociate = 'dissociate-'.$row['id']; 84 if ( $_POST[$dissociate] == 1 ) 85 { 86 $query = 'DELETE FROM '.PREFIX_TABLE.'user_group'; 87 $query.= ' WHERE user_id = '.$_GET['user_id']; 88 $query.= ' AND group_id ='.$row['id']; 89 $query.= ';'; 90 mysql_query( $query ); 91 } 92 } 93 // create a new association between the user and a group 94 $query = 'INSERT INTO '.PREFIX_TABLE.'user_group'; 95 $query.= ' (user_id,group_id) VALUES'; 96 $query.= ' ('.$_GET['user_id'].','.$_POST['associate'].')'; 97 $query.= ';'; 98 mysql_query( $query ); 99 } 69 100 //-------------------------------------------------------------- errors display 70 101 if ( sizeof( $error ) != 0 ) … … 83 114 { 84 115 $vtp->addSession( $sub, 'confirmation' ); 85 $vtp->setVar( $sub, 'confirmation.username', $ row['username'] );116 $vtp->setVar( $sub, 'confirmation.username', $page['username'] ); 86 117 $url = add_session_id( './admin.php?page=user_list' ); 87 118 $vtp->setVar( $sub, 'confirmation.url', $url ); … … 92 123 $vtp->closeSession( $sub, 'password_updated' ); 93 124 } 94 $display_form = false;95 125 } 96 126 //------------------------------------------------------------------------ form … … 100 130 $action = './admin.php?page=user_modify&user_id='.$_GET['user_id']; 101 131 $vtp->setVar( $sub, 'form.form_action', add_session_id( $action ) ); 102 $vtp->setVar( $sub, 'form.user:username', $row['username'] ); 103 $vtp->setVar( $sub, 'form.user:password', $_POST['password'] ); 104 $vtp->setVar( $sub, 'form.user:mail_address', $_POST['mail_address'] ); 105 106 if ( !isset( $_POST['status'] ) ) 107 { 108 $_POST['status'] = 'guest'; 132 $vtp->setVar( $sub, 'form.user:username', $page['username'] ); 133 if ( isset( $_POST['mail_address'] ) ) 134 { 135 $page['mail_address'] = $_POST['mail_address']; 136 } 137 $vtp->setVar( $sub, 'form.user:mail_address', $page['mail_address'] ); 138 if ( isset( $_POST['status'] ) ) 139 { 140 $page['status'] = $_POST['status']; 109 141 } 110 142 $option = get_enums( PREFIX_TABLE.'users', 'status' ); … … 115 147 $vtp->setVar( $sub, 'status_option.option', 116 148 $lang['adduser_status_'.$option[$i]] ); 117 if( $option[$i] == $ _POST['status'] )149 if( $option[$i] == $page['status'] ) 118 150 { 119 151 $vtp->setVar( $sub, 'status_option.selected', ' selected="selected"' ); … … 121 153 $vtp->closeSession( $sub, 'status_option' ); 122 154 } 155 // groups linked with this user 156 $query = 'SELECT id,name'; 157 $query.= ' FROM '.PREFIX_TABLE.'user_group, '.PREFIX_TABLE.'groups'; 158 $query.= ' WHERE group_id = id'; 159 $query.= ' AND user_id = '.$_GET['user_id']; 160 $query.= ';'; 161 $result = mysql_query( $query ); 162 $user_groups = array(); 163 if ( mysql_num_rows( $result ) > 0 ) 164 { 165 $vtp->addSession( $sub, 'groups' ); 166 while ( $row = mysql_fetch_array( $result ) ) 167 { 168 $vtp->addSession( $sub, 'group' ); 169 $vtp->setVar( $sub, 'group.name', $row['name'] ); 170 $vtp->setVar( $sub, 'group.dissociate_id', $row['id'] ); 171 $vtp->closeSession( $sub, 'group' ); 172 array_push( $user_groups, $row['id'] ); 173 } 174 $vtp->closeSession( $sub, 'groups' ); 175 } 176 // empty group not to take into account 177 $vtp->addSession( $sub, 'associate_group' ); 178 $vtp->setVar( $sub, 'associate_group.value', 'undef' ); 179 $vtp->setVar( $sub, 'associate_group.option', '' ); 180 $vtp->closeSession( $sub, 'associate_group' ); 181 // groups not linked yet to the user 182 $query = 'SELECT id,name'; 183 $query.= ' FROM '.PREFIX_TABLE.'groups'; 184 $query.= ' ORDER BY id ASC'; 185 $query.= ';'; 186 $result = mysql_query( $query ); 187 while ( $row = mysql_fetch_array( $result ) ) 188 { 189 if ( !in_array( $row['id'], $user_groups ) ) 190 { 191 $vtp->addSession( $sub, 'associate_group' ); 192 $vtp->setVar( $sub, 'associate_group.value', $row['id'] ); 193 $vtp->setVar( $sub, 'associate_group.option', $row['name'] ); 194 $vtp->closeSession( $sub, 'associate_group' ); 195 } 196 } 197 123 198 $url = add_session_id( './admin.php?page=user_list' ); 124 199 $vtp->setVar( $sub, 'form.url_back', $url ); -
trunk/include/config.inc.php
r20 r21 21 21 $lang = array(); 22 22 23 include_once( PREFIX E_INCLUDE.'./include/functions.inc.php' );24 include_once( PREFIX E_INCLUDE.'./include/vtemplate.class.php' );23 include_once( PREFIX_INCLUDE.'./include/functions.inc.php' ); 24 include_once( PREFIX_INCLUDE.'./include/vtemplate.class.php' ); 25 25 26 26 // How to change the order of display for images in a category ? -
trunk/include/functions.inc.php
r17 r21 19 19 include( 'functions_category.inc.php' ); 20 20 include( 'functions_xml.inc.php' ); 21 include( 'functions_group.inc.php' ); 21 22 22 23 //----------------------------------------------------------- generic functions … … 320 321 function database_connection() 321 322 { 322 // $cfgHote,$cfgUser,$cfgPassword,$cfgBase; 323 324 $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' ); 325 $mysql_conf = getChild( $xml_content, 'mysql' ); 326 327 $cfgHote = getAttribute( $mysql_conf, 'host' ); 328 $cfgUser = getAttribute( $mysql_conf, 'user' ); 329 $cfgPassword = getAttribute( $mysql_conf, 'password' ); 330 $cfgBase = getAttribute( $mysql_conf, 'base' ); 323 // $xml_content = getXmlCode( PREFIXE_INCLUDE.'./include/database_config.xml' ); 324 // $mysql_conf = getChild( $xml_content, 'mysql' ); 325 326 // $cfgHote = getAttribute( $mysql_conf, 'host' ); 327 // $cfgUser = getAttribute( $mysql_conf, 'user' ); 328 // $cfgPassword = getAttribute( $mysql_conf, 'password' ); 329 // $cfgBase = getAttribute( $mysql_conf, 'base' ); 330 // define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) ); 331 332 include( PREFIX_INCLUDE.'./include/mysql.inc.php' ); 333 define( PREFIX_TABLE, $prefix_table ); 331 334 332 335 @mysql_connect( $cfgHote, $cfgUser, $cfgPassword ) … … 334 337 @mysql_select_db( $cfgBase ) 335 338 or die ( "Could not connect to database" ); 336 337 define( PREFIX_TABLE, getAttribute( $mysql_conf, 'tablePrefix' ) );338 339 } 339 340 -
trunk/include/functions_category.inc.php
r19 r21 15 15 * * 16 16 ***************************************************************************/ 17 17 18 function get_subcats_id( $cat_id ) 18 19 { 19 $restricted_cat = array(); 20 $i = 0; 20 $restricted_cats = array(); 21 21 22 $query = ' selectid';23 $query.= ' from'.PREFIX_TABLE.'categories';24 $query.= ' whereid_uppercat = '.$cat_id;22 $query = 'SELECT id'; 23 $query.= ' FROM '.PREFIX_TABLE.'categories'; 24 $query.= ' WHERE id_uppercat = '.$cat_id; 25 25 $query.= ';'; 26 26 $result = mysql_query( $query ); 27 27 while ( $row = mysql_fetch_array( $result ) ) 28 28 { 29 $restricted_cat[$i++] = $row['id']; 30 $sub_restricted_cat = get_subcats_id( $row['id'] ); 31 for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ ) 32 { 33 $restricted_cat[$i++] = $sub_restricted_cat[$j]; 34 } 35 } 36 37 return $restricted_cat; 29 array_push( $restricted_cats, $row['id'] ); 30 $sub_restricted_cats = get_subcats_id( $row['id'] ); 31 foreach ( $sub_restricted_cats as $sub_restricted_cat ) { 32 array_push( $restricted_cats, $sub_restricted_cat ); 33 } 34 } 35 return $restricted_cats; 38 36 } 39 37 -
trunk/include/functions_user.inc.php
r16 r21 145 145 mysql_query( $query ); 146 146 // 3. retrieving the id of the newly created user 147 $query = ' selectid';148 $query.= ' from'.PREFIX_TABLE.'users';149 $query.= " whereusername = '".$login."';";147 $query = 'SELECT id'; 148 $query.= ' FROM '.PREFIX_TABLE.'users'; 149 $query.= " WHERE username = '".$login."';"; 150 150 $row = mysql_fetch_array( mysql_query( $query ) ); 151 151 $user_id = $row['id']; 152 // 4. adding restrictions to the new user, the same as the user "guest"153 $query = ' selectcat_id';154 $query.= ' from '.PREFIX_TABLE.'restrictions as r';152 // 4. adding access to the new user, the same as the user "guest" 153 $query = 'SELECT cat_id'; 154 $query.= ' FROM '.PREFIX_TABLE.'user_access as ua'; 155 155 $query.= ','.PREFIX_TABLE.'users as u '; 156 $query.= ' where u.id = r.user_id';156 $query.= ' where u.id = ua.user_id'; 157 157 $query.= " and u.username = 'guest';"; 158 158 $result = mysql_query( $query ); 159 159 while( $row = mysql_fetch_array( $result ) ) 160 160 { 161 $query = ' insert into '.PREFIX_TABLE.'restrictions';162 $query.= ' (user_id,cat_id) values';161 $query = 'INSERT INTO '.PREFIX_TABLE.'user_access'; 162 $query.= ' (user_id,cat_id) VALUES'; 163 163 $query.= ' ('.$user_id.','.$row['cat_id'].');'; 164 164 mysql_query ( $query ); … … 182 182 if ( sizeof( $error ) == 0 ) 183 183 { 184 $query = ' update'.PREFIX_TABLE.'users';185 $query.= " setstatus = '".$status."'";184 $query = 'UPDATE '.PREFIX_TABLE.'users'; 185 $query.= " SET status = '".$status."'"; 186 186 if ( $use_new_password ) 187 187 { … … 197 197 $query.= 'NULL'; 198 198 } 199 $query.= ' whereid = '.$user_id;199 $query.= ' WHERE id = '.$user_id; 200 200 $query.= ';'; 201 echo $query;202 201 mysql_query( $query ); 203 202 } … … 210 209 211 210 if ( $user['is_the_guest'] 212 and ( $conf['acces '] == 'restreint' or $page['cat'] == 'fav' ) )211 and ( $conf['access'] == 'restricted' or $page['cat'] == 'fav' ) ) 213 212 { 214 213 echo '<div style="text-align:center;">'.$lang['only_members'].'<br />'; … … 222 221 // If the $check_invisible parameter is set to true, invisible categories 223 222 // are added to the restricted one in the array. 224 function get_restrictions( $user_id, $user_status, $check_invisible ) 225 { 226 // 1. getting the ids of the restricted categories 223 function get_restrictions( $user_id, $user_status, 224 $check_invisible, $use_groups = true ) 225 { 226 // 1. retrieving ids of private categories 227 $query = 'SELECT id'; 228 $query.= ' FROM '.PREFIX_TABLE.'categories'; 229 $query.= " WHERE status = 'private'"; 230 $query.= ';'; 231 $result = mysql_query( $query ); 232 $privates = array(); 233 while ( $row = mysql_fetch_array( $result ) ) 234 { 235 array_push( $privates, $row['id'] ); 236 } 237 // 2. retrieving all authorized categories for the user 238 $authorized = array(); 239 // 2.1. retrieving authorized categories thanks to personnal user 240 // authorization 227 241 $query = 'SELECT cat_id'; 228 $query.= ' FROM '.PREFIX_TABLE.' restrictions';242 $query.= ' FROM '.PREFIX_TABLE.'user_access'; 229 243 $query.= ' WHERE user_id = '.$user_id; 230 244 $query.= ';'; 231 245 $result = mysql_query( $query ); 232 233 $restriction = array();234 246 while ( $row = mysql_fetch_array( $result ) ) 235 247 { 236 array_push( $restriction, $row['cat_id'] ); 237 } 248 array_push( $authorized, $row['cat_id'] ); 249 } 250 // 2.2. retrieving authorized categories thanks to group authorization to 251 // which the user is a member 252 if ( $use_groups ) 253 { 254 $query = 'SELECT ga.cat_id'; 255 $query.= ' FROM '.PREFIX_TABLE.'user_group as ug'; 256 $query.= ', '.PREFIX_TABLE.'group_access as ga'; 257 $query.= ' WHERE ug.group_id = ga.group_id'; 258 $query.= ' AND ug.user_id = '.$user_id; 259 $query.= ';'; 260 $result = mysql_query( $query ); 261 while ( $row = mysql_fetch_array( $result ) ) 262 { 263 array_push( $authorized, $row['cat_id'] ); 264 } 265 $authorized = array_unique( $authorized ); 266 } 267 268 $forbidden = array(); 269 foreach ( $privates as $private ) { 270 if ( !in_array( $private, $authorized ) ) 271 { 272 array_push( $forbidden, $private ); 273 } 274 } 275 238 276 if ( $check_invisible ) 239 277 { 240 // 2. adding to the restricted categories, the invisible ones278 // 3. adding to the restricted categories, the invisible ones 241 279 if ( $user_status != 'admin' ) 242 280 { 243 281 $query = 'SELECT id'; 244 282 $query.= ' FROM '.PREFIX_TABLE.'categories'; 245 $query.= " WHERE status = 'invisible';";283 $query.= " WHERE visible = 'false';"; 246 284 $result = mysql_query( $query ); 247 285 while ( $row = mysql_fetch_array( $result ) ) 248 286 { 249 array_push( $ restriction, $row['id'] );250 } 251 } 252 } 253 return $restriction;287 array_push( $forbidden, $row['id'] ); 288 } 289 } 290 } 291 return array_unique( $forbidden ); 254 292 } 255 293 … … 259 297 function get_all_restrictions( $user_id, $user_status ) 260 298 { 261 $restricted_cat = get_restrictions( $user_id, $user_status, true ); 262 $i = sizeof( $restricted_cat ); 263 for ( $k = 0; $k < sizeof( $restricted_cat ); $k++ ) 264 { 265 $sub_restricted_cat = get_subcats_id( $restricted_cat[$k] ); 266 for ( $j = 0; $j < sizeof( $sub_restricted_cat ); $j++ ) 267 { 268 $restricted_cat[$i++] = $sub_restricted_cat[$j]; 269 } 270 } 271 return $restricted_cat; 299 $restricted_cats = get_restrictions( $user_id, $user_status, true ); 300 foreach ( $restricted_cats as $restricted_cat ) { 301 $sub_restricted_cats = get_subcats_id( $restricted_cat ); 302 foreach ( $sub_restricted_cats as $sub_restricted_cat ) { 303 array_push( $restricted_cats, $sub_restricted_cat ); 304 } 305 } 306 return $restricted_cats; 272 307 } 273 308 … … 278 313 function is_user_allowed( $category_id, $restrictions ) 279 314 { 280 global $user;281 282 315 $lowest_category_id = $category_id; 283 316 … … 285 318 while ( !$is_root and !in_array( $category_id, $restrictions ) ) 286 319 { 287 $query = ' selectid_uppercat';288 $query.= ' from'.PREFIX_TABLE.'categories';289 $query.= ' whereid = '.$category_id;320 $query = 'SELECT id_uppercat'; 321 $query.= ' FROM '.PREFIX_TABLE.'categories'; 322 $query.= ' WHERE id = '.$category_id; 290 323 $query.= ';'; 291 324 $row = mysql_fetch_array( mysql_query( $query ) ); 292 if ( $row['id_uppercat'] == "")325 if ( $row['id_uppercat'] == '' ) 293 326 { 294 327 $is_root = true; -
trunk/include/functions_xml.inc.php
r13 r21 19 19 define( ATT_REG, '\w+' ); 20 20 define( VAL_REG, '[^"]*' ); 21 22 21 //------------------------------------------------------------------- functions 23 22 // getContent returns the content of a tag … … 33 32 $content = preg_replace( '/^<[^>]+>/', '', $element ); 34 33 // deleting end of the tag 35 $content = preg_replace( '/<\/ \w+>$/', '', $content );34 $content = preg_replace( '/<\/[^>]+>$/', '', $content ); 36 35 // replacing multiple instance of space character 37 36 $content = preg_replace( '/\s+/', ' ', $content ); … … 40 39 } 41 40 42 // The function get Attribute returns the value corresponding to the attribute43 // $attribute for the tag $element.41 // The function get Attribute returns the value corresponding to the 42 // attribute $attribute for the tag $element. 44 43 function getAttribute( $element, $attribute ) 45 44 { -
trunk/include/init.inc.php
r9 r21 15 15 * * 16 16 ***************************************************************************/ 17 define( PREFIX E_INCLUDE, '' );18 17 define( PREFIX_INCLUDE, '' ); 18 19 19 include_once( './include/config.inc.php' ); 20 20 include_once( './include/user.inc.php' ); -
trunk/include/user.inc.php
r13 r21 25 25 'long_period', 'template' ); 26 26 27 $query_user = ' select';27 $query_user = 'SELECT'; 28 28 for ( $i = 0; $i < sizeof( $infos ); $i++ ) 29 29 { … … 38 38 $query_user.= $infos[$i]; 39 39 } 40 $query_user.= ' from'.PREFIX_TABLE.'users';40 $query_user.= ' FROM '.PREFIX_TABLE.'users'; 41 41 $query_done = false; 42 42 $user['is_the_guest'] = false; … … 45 45 { 46 46 $page['session_id'] = $_GET['id']; 47 $query = ' selectuser_id,expiration,ip';48 $query.= ' from'.PREFIX_TABLE.'sessions';49 $query.= " whereid = '".$_GET['id']."'";47 $query = 'SELECT user_id,expiration,ip'; 48 $query.= ' FROM '.PREFIX_TABLE.'sessions'; 49 $query.= " WHERE id = '".$_GET['id']."'"; 50 50 $query.= ';'; 51 51 $result = mysql_query( $query ); … … 57 57 // deletion of the session from the database, 58 58 // because it is out-of-date 59 $delete_query = ' delete from'.PREFIX_TABLE.'sessions';60 $delete_query.= " whereid = '".$page['session_id']."'";59 $delete_query = 'DELETE FROM '.PREFIX_TABLE.'sessions'; 60 $delete_query.= " WHERE id = '".$page['session_id']."'"; 61 61 $delete_query.= ';'; 62 62 mysql_query( $delete_query ); … … 66 66 if ( $_SERVER['REMOTE_ADDR'] == $row['ip'] ) 67 67 { 68 $query_user .= ' whereid = '.$row['user_id'];68 $query_user .= ' WHERE id = '.$row['user_id']; 69 69 $query_done = true; 70 70 } … … 74 74 if ( !$query_done ) 75 75 { 76 $query_user .= ' whereid = 2';76 $query_user .= ' WHERE id = 2'; 77 77 $user['is_the_guest'] = true; 78 78 } … … 83 83 // affectation of each value retrieved in the users table into a variable 84 84 // of the array $user. 85 for ( $i = 0; $i < sizeof( $infos ); $i++ ) 86 { 87 $user[$infos[$i]] = $row[$infos[$i]]; 85 foreach ( $infos as $info ) { 86 $user[$info] = $row[$info]; 88 87 // If the field is true or false, the variable is transformed into a 89 88 // boolean value. 90 if ( $row[$info s[$i]] == 'true' || $row[$infos[$i]] == 'false' )89 if ( $row[$info] == 'true' or $row[$info] == 'false' ) 91 90 { 92 $user[$info s[$i]] = get_boolean( $row[$infos[$i]] );91 $user[$info] = get_boolean( $row[$info] ); 93 92 } 94 93 } -
trunk/include/vtemplate.class.php
r2 r21 3 3 * VIRTUAL-TEMPLATE 4 4 * 5 * Version : 1.3. 1 Base Edition ( Juillet 2002 ) build 65 * Version : 1.3.2 Base Edition ( Decembre 2003 ) build 1 6 6 * 7 7 * Address : http://vtemplate.sourceforge.net 8 8 * 9 9 * Authors: 10 * + THIEBAUT Jean-Baptiste(J.Baptiste@leweby.com) -http://www.leweby.com .10 * + THIEBAUT Jean-Baptiste(J.Baptiste@leweby.com) - http://www.leweby.com . 11 11 * + CAMPANA François (fc@netouaibe.com). 12 12 * Licence: GPL. 13 * 14 * 13 15 * 14 * 16 * 15 17 *****************************************************************/ 16 18 17 if ( !isset($DEFINE_VTEMPLATE) ) 18 { 19 define("ALL",1); 20 define("VARTAG","{#"); // Tag d'ouverture des variables : 21 // vous pouvez changer ce paramètre. 22 define("VTEMPLATE_VERSION","1.3.1"); 23 define("VTEMPLATE_TYPE","BA"); 24 define("VTEMPLATE_BUILD","6"); 25 26 27 class Err 28 { 29 var $msg; 30 var $titre; 31 32 function error( $errno, $arg = "", $code = 0, $disp = 0 ) 33 { 19 if ( !isset($DEFINE_VTEMPLATE) ){ 20 define("ALL",1); 21 define("VARTAG","{#"); // Tag d'ouverture des variables : vous pouvez changer ce paramètre. 22 define("VTEMPLATE_VERSION","1.3.1"); 23 define("VTEMPLATE_TYPE","BA"); 24 define("VTEMPLATE_BUILD","6"); 25 26 27 class Err { 28 var $msg; 29 var $titre; 30 31 function error($errno,$arg="",$code=0,$disp=0){ 34 32 // Gestion des erreurs 35 switch($errno) 36 { 37 case 1: 38 $this->titre="Erreur de session n° $code"; 39 $this->msg = "La zone $arg est déjà ouverte.Avant d'ajouter une session sur cette zone, vous devez la fermer à l'aide de la fonction closeSession().<br>" ; 40 break; 41 case 2: 42 $this->titre="Erreur de session n° $code"; 43 $this->msg = "Vous tentez de fermer une session de la zone $arg alors qu'aucune session pour cette zone n'existe.Pour ouvrir une session, utilisez la fonction addSession().<br>"; 44 break; 45 case 3: 46 $this->titre="Erreur de session n° $code"; 47 $var = $arg[1]; 48 $zone = $arg[0]; 49 $this->msg = "Vous essayez de valoriser la variable $var sans avoir créer de session de la zone $zone.Utilisez la fonction addSession() pour créer une session, puis setVar pour valoriser une variable.<br>"; 50 break; 51 case 4: 52 $this->titre="Erreur de session n° $code"; 53 $var = $arg[1]; 54 $zone = $arg[0]; 55 $this->msg = "La variable $var que vous souhaitez valoriser n'existe pas dans la zone $zone.<br>"; 56 break; 57 case 5: 58 $this->titre="Erreur de parsing n° $code"; 59 $this->msg = "Vous utilisez des caractère non autorisés pour déclarer vos zones.Vous pouvez utiliser tous les caractères à l'exception de \'{\' , \'#\' \'}\' et \'|\'.<br>"; 60 break; 61 case 6: 62 $this->titre="Erreur de parsing n° $code"; 63 $this->msg = "Vous ne pouvez pas utiliser le même nom ($arg)de zone plusieurs fois.<br>"; 64 break; 65 case 7: 66 $this->titre="Erreur de parsing n° $code"; 67 $this->msg = "Vous avez oublié de fermer la zone $arg.<br>"; 68 break; 69 case 8: 70 $this->titre="Erreur de traitement n° $code"; 71 $this->msg = "Le fichier template $arg est introuvable.<br>"; 72 break; 73 case 9: 74 $this->titre="Erreur de traitement n° $code"; 75 $this->msg = "Impossible d'ouvrir le fichier $arg.Vérifiez les droits de ce fichier.<br>"; 76 break; 77 case 10: 78 $this->titre="Erreur de traitement n° $code"; 79 $this->msg = "Impossible de lire le fichier template $arg.<br>"; 80 break; 81 case 11: 82 $this->titre="Erreur de traitement n° $code"; 83 $this->msg = "La zone $arg est introuvable.Vérifiez la syntaxe de cette zone.<br>"; 84 break; 85 case 12: 86 $this->titre="Erreur de traitement n° $code"; 87 $this->msg = "La variable $arg est introuvable .Vérifiez la syntaxe de la variable.<br>"; 88 break; 89 case 13: 90 $this->titre="Erreur de traitement n° $code"; 91 $this->msg = "L'identifiant de fichier spécifié n'existe pas.Vérifiez les fonctions Open() de votre script.<br>"; 92 break; 93 case 14: 94 $this->titre="Erreur de traitement n° $code"; 95 $var = $arg[1]; 96 $file = $arg[0]; 97 $this->msg = "La variable $var dans le fichier $file est introuvable.Vérifiez la syntaxe de la variable.<br>"; 98 break; 99 case 15: 100 $this->titre="Erreur de traitement n° $code"; 101 $var = $arg[2]; 102 $zone = $arg[1]; 103 $fichier = $arg[0]; 104 $this->msg = "La variable $var dans la zone $zone du fichier $fichier est introuvable.Vérifiez la syntaxe de la variable et du nom de la zone.<br>"; 105 break; 106 default: 107 $this->titre = "Erreur inconnue $code"; 108 $this->msg = "Veuillez le rapporter aux auteurs de la classe."; 109 } 110 $this->titre .= ": <br>"; 111 if ($disp){ 112 $web = "Pour plus d'informations, consultez la <a href=\"http://www.virtual-solution.net/vtemplate/docs/debug-mod.php?version=".VTEMPLATE_VERSION."&build=".VTEMPLATE_BUILD."&type=".VTEMPLATE_TYPE."&error=$code\" target=\"_blank\">doc en ligne</a>"; 113 echo "<font face=verdana size=2 color=red><u>$this->titre</u><i>$this->msg</i>$web<br><br></font>"; 114 } 115 return -1; 116 } 33 switch($errno){ 34 case 1: 35 $this->titre="Erreur de session n° $code"; 36 $this->msg = "La zone $arg est déjà ouverte.Avant d'ajouter une session sur cette zone, vous devez la fermer à l'aide de la fonction closeSession().<br>" ; 37 break; 38 case 2: 39 $this->titre="Erreur de session n° $code"; 40 $this->msg = "Vous tentez de fermer une session de la zone $arg alors qu'aucune session pour cette zone n'existe.Pour ouvrir une session, utilisez la fonction addSession().<br>"; 41 break; 42 case 3: 43 $this->titre="Erreur de session n° $code"; 44 $var = $arg[1]; 45 $zone = $arg[0]; 46 $this->msg = "Vous essayez de valoriser la variable $var sans avoir créer de session de la zone $zone.Utilisez la fonction addSession() pour créer une session, puis setVar pour valoriser une variable.<br>"; 47 break; 48 case 4: 49 $this->titre="Erreur de session n° $code"; 50 $var = $arg[1]; 51 $zone = $arg[0]; 52 $this->msg = "La variable $var que vous souhaitez valoriser n'existe pas dans la zone $zone.<br>"; 53 break; 54 case 5: 55 $this->titre="Erreur de parsing n° $code"; 56 $this->msg = "Vous utilisez des caractère non autorisés pour déclarer vos zones.Vous pouvez utiliser tous les caractères à l'exception de \'{\' , \'#\' \'}\' et \'|\'.<br>"; 57 break; 58 case 6: 59 $this->titre="Erreur de parsing n° $code"; 60 $this->msg = "Vous ne pouvez pas utiliser le même nom ($arg)de zone plusieurs fois.<br>"; 61 break; 62 case 7: 63 $this->titre="Erreur de parsing n° $code"; 64 $this->msg = "Vous avez oublié de fermer la zone $arg.<br>"; 65 break; 66 case 8: 67 $this->titre="Erreur de traitement n° $code"; 68 $this->msg = "Le fichier template $arg est introuvable.<br>"; 69 break; 70 case 9: 71 $this->titre="Erreur de traitement n° $code"; 72 $this->msg = "Impossible d'ouvrir le fichier $arg.Vérifiez les droits de ce fichier.<br>"; 73 break; 74 case 10: 75 $this->titre="Erreur de traitement n° $code"; 76 $this->msg = "Impossible de lire le fichier template $arg.<br>"; 77 break; 78 case 11: 79 $this->titre="Erreur de traitement n° $code"; 80 $this->msg = "La zone $arg est introuvable.Vérifiez la syntaxe de cette zone.<br>"; 81 break; 82 case 12: 83 $this->titre="Erreur de traitement n° $code"; 84 $this->msg = "La variable $arg est introuvable .Vérifiez la syntaxe de la variable.<br>"; 85 break; 86 case 13: 87 $this->titre="Erreur de traitement n° $code"; 88 $this->msg = "L'identifiant de fichier spécifié n'existe pas.Vérifiez les fonctions Open() de votre script.<br>"; 89 break; 90 case 14: 91 $this->titre="Erreur de traitement n° $code"; 92 $var = $arg[1]; 93 $file = $arg[0]; 94 $this->msg = "La variable $var dans le fichier $file est introuvable.Vérifiez la syntaxe de la variable.<br>"; 95 break; 96 case 15: 97 $this->titre="Erreur de traitement n° $code"; 98 $var = $arg[2]; 99 $zone = $arg[1]; 100 $fichier = $arg[0]; 101 $this->msg = "La variable $var dans la zone $zone du fichier $fichier est introuvable.Vérifiez la syntaxe de la variable et du nom de la zone.<br>"; 102 break; 103 default: 104 $this->titre = "Erreur inconnue $code"; 105 $this->msg = "Veuillez le rapporter aux auteurs de la classe."; 106 } 107 $this->titre .= ": <br>"; 108 if ($disp){ 109 $web = "Pour plus d'informations, consultez la <a href=\"http://www.virtual-solution.net/vtemplate/docs/debug-mod.php?version=".VTEMPLATE_VERSION."&build=".VTEMPLATE_BUILD."&type=".VTEMPLATE_TYPE."&error=$code\" target=\"_blank\">doc en ligne</a>"; 110 echo "<font face=verdana size=2 color=red><u>$this->titre</u><i>$this->msg</i>$web<br><br></font>"; 111 } 112 return -1; 113 } 117 114 // Fin classe 115 } 116 117 class Session extends err{ 118 119 var $name; // Name of the session 120 var $globalvar = array(); // List of global variable of the session 121 var $varlist = array(); // List of var in this session 122 var $subzone = array(); // list of sub-zone 123 var $temp; // Generated code for the current session 124 var $generated = NULL; // The final code 125 var $source; // Source code 126 var $used=0; // Indicates if the session contain used variable 127 var $stored; // Give the filename were is stored the session 128 129 function Session($name,$source,$stored){ 130 $this->name = $name; 131 $this->source = $source; 132 $this->stored = $stored; 133 $this->parseVar(); 134 } 135 136 function parseVar(){ 137 // Récupération des noms des variables 138 $regle = "|".VARTAG."(.*)}|sU"; 139 preg_match_all ($regle,$this->source,$var1); 140 // Création du tableau de variable à partir de la liste parsée. 141 $this->varlist=@array_merge($var[1],$var1[1]); 142 return 1; 143 } 144 145 function init(){ 146 if($this->used) return $this->error(1,array($this->stored,$this->name),"SESSION1",1); 147 // Reset generated code 148 $this->temp = $this->source; 149 $this->used = 1; 150 } 151 function closeSession(){ 152 // Check if the zone has been used. 153 if(!$this->used) return $this->error(2,array($this->stored,$this->name),"SESSION2",1); 154 // Set Globals vars. 155 $this->generateCode(); 156 $this->used=0; 157 return 1; 158 } 159 160 function reset(){ 161 $this->used = 0; 162 $this->generated = NULL; 163 return 1; 164 } 165 166 function addSubZone(&$subzone){ 167 $this->subzone[$subzone->name] = &$subzone; 168 return 1; 169 } 170 171 function setVar($varname,$value){ 172 if (!$this->used) return $this->error(3,array($this->stored,$this->name,$varname),"SESSION3",1); 173 if (!in_array($varname,$this->varlist)) return $this->error(4,array($this->name,$varname),"SESSION4",1); 174 $regle = "(\\".VARTAG."$varname\})"; 175 $this->temp = preg_replace($regle,$value,$this->temp); 176 return 1; 177 } 178 179 function dispVar(){ 180 echo "Liste variables de $this->name:<br>"; 181 foreach ( $this->varlist as $vars ) 182 echo "$vars <br>"; 183 } 184 185 function setGlobalVar($varname,$value){ 186 $set = 0; 187 if (in_array($varname,$this->varlist)){ 188 // Replace the var into this session 189 $this->globalvar[$varname]=$value; 190 $set = 1; 191 } 192 // Replace the var into sub zones 193 foreach(array_keys($this->subzone) as $subzone){ 194 $set = $this->subzone[$subzone]->setGlobalVar($varname,$value) || $set; 195 } 196 return $set; 197 } 198 199 function replaceGlobalVar(){ 200 if ( count($this->globalvar) ) 201 foreach($this->globalvar as $varname => $value){ 202 $regle = "(\\".VARTAG."$varname\})"; 203 $this->temp = preg_replace($regle,$value,$this->temp); 204 } 205 } 206 207 208 function generateCode(){ 209 if ($this->used == 0) return $this->generated; 210 // Replace global var. 211 if ( count($this->globalvar) ) $this->replaceGlobalVar(); 212 // Replace all unused variable by "" 213 $regle = "|\\".VARTAG."([^}]*)\}|"; 214 $this->temp = preg_replace($regle,"",$this->temp); 215 // Generate the subzone(s) code 216 if(count($this->subzone)){ 217 foreach(array_keys($this->subzone) as $subzone){ 218 $text = ($this->subzone[$subzone]->used) ? $this->subzone[$subzone]->generateCode() : $this->subzone[$subzone]->generated; 219 $this->temp = preg_replace("(\|$subzone\|)",$text,$this->temp); 220 $this->subzone[$subzone]->reset(); 221 } 118 222 } 119 120 class Session extends err{ 121 122 var $name; // Name of the session 123 var $globalvar = array(); // List of global variable of the session 124 var $varlist = array(); // List of var in this session 125 var $subzone = array(); // list of sub-zone 126 var $temp; // Generated code for the current session 127 var $generated = NULL; // The final code 128 var $source; // Source code 129 var $used=0; // Indicates if the session contain used variable 130 var $stored; // Give the filename were is stored the session 131 132 function Session($name,$source,$stored){ 133 $this->name = $name; 134 $this->source = $source; 135 $this->stored = $stored; 136 $this->parseVar(); 137 } 138 139 function parseVar(){ 140 // Récupération des noms des variables 141 $regle = "|".VARTAG."(.*)}|sU"; 142 preg_match_all ($regle,$this->source,$var1); 143 // Création du tableau de variable à partir de la liste parsée. 144 $this->varlist=@array_merge($var[1],$var1[1]); 145 return 1; 146 } 147 148 function init(){ 149 if($this->used) return $this->error(1,array($this->stored,$this->name),"SESSION1",1); 150 // Reset generated code 151 $this->temp = $this->source; 152 $this->used = 1; 153 } 154 function closeSession(){ 155 // Check if the zone has been used. 156 if(!$this->used) return $this->error(2,array($this->stored,$this->name),"SESSION2",1); 157 // Set Globals vars. 158 $this->generateCode(); 159 $this->used=0; 160 return 1; 161 } 162 163 function reset(){ 164 $this->used = 0; 165 $this->generated = NULL; 166 return 1; 167 } 168 169 function addSubZone(&$subzone){ 170 $this->subzone[$subzone->name] = &$subzone; 171 return 1; 172 } 173 174 function setVar($varname,$value){ 175 if (!$this->used) return $this->error(3,array($this->stored,$this->name,$varname),"SESSION3",1); 176 if (!in_array($varname,$this->varlist)) return $this->error(4,array($this->name,$varname),"SESSION4",1); 177 $regle = "(\\".VARTAG."$varname\})"; 178 $this->temp = preg_replace($regle,$value,$this->temp); 179 return 1; 180 } 181 182 function dispVar(){ 183 echo "Liste variables de $this->name:<br>"; 184 foreach ( $this->varlist as $vars ) 185 echo "$vars <br>"; 186 } 187 188 function setGlobalVar($varname,$value){ 189 $set = 0; 190 if (in_array($varname,$this->varlist)){ 191 // Replace the var into this session 192 $this->globalvar[$varname]=$value; 193 $set = 1; 194 } 195 // Replace the var into sub zones 196 foreach(array_keys($this->subzone) as $subzone){ 197 $set = $this->subzone[$subzone]->setGlobalVar($varname,$value) || $set; 198 } 199 return $set; 200 } 201 202 function replaceGlobalVar(){ 203 if ( count($this->globalvar) ) 204 foreach($this->globalvar as $varname => $value){ 205 $regle = "(\\".VARTAG."$varname\})"; 206 $this->temp = preg_replace($regle,$value,$this->temp); 207 } 208 } 209 210 211 function generateCode(){ 212 if ($this->used == 0) return $this->generated; 213 // Replace global var. 214 if ( count($this->globalvar) ) $this->replaceGlobalVar(); 215 // Replace all unused variable by "" 216 $regle = "|\\".VARTAG."(.*)\}|"; 217 $this->temp = preg_replace($regle,"",$this->temp); 218 // Generate the subzone(s) code 219 if(count($this->subzone)){ 220 foreach(array_keys($this->subzone) as $subzone){ 221 $text = ($this->subzone[$subzone]->used) ? $this->subzone[$subzone]->generateCode() : $this->subzone[$subzone]->generated; 222 $this->temp = preg_replace("(\|$subzone\|)",$text,$this->temp); 223 $this->subzone[$subzone]->reset(); 224 } 225 } 226 $this->generated .= $this->temp; 227 return $this->generated; 228 } 229 230 function inVarList($varname){ 231 return in_array($varname,$this->varlist); 232 } 223 $this->generated .= $this->temp; 224 return $this->generated; 225 } 226 227 function inVarList($varname){ 228 return in_array($varname,$this->varlist); 229 } 233 230 234 231 // Fin classe 235 236 237 232 } 233 234 class VTemplate_Private extends Err{ 238 235 /**************************************** 239 240 241 242 243 244 236 * Private Class. * 237 * ***************************************/ 238 239 var $sources=array(); // Sources des zones issues de la premiere partie du parsing. 240 var $sessions=array(); // Tableau de sessions 241 var $v_global=array(); // Globla var array. 245 242 246 243 /**************************************************************** 247 244 Parsing Functions for Template files. ( PF 1.0 ) 248 ****************************************************************/249 250 245 ****************************************************************/ 246 247 function getNom($code){ 251 248 // Retourne le premier nom de zone qu'il trouve dans le code 252 249 253 250 preg_match("(<!--VTP_([^()]+)-->)sU",$code,$reg); 254 251 255 256 252 // Tester la présence des caratère invalides dans le nom ( | et {}); 253 if (@count(explode("|",$reg[1]))>1 || @count(explode("{",$reg[1]))>1 || @count(explode("}",$reg[1]))>1) exit($this->error(5,$reg[1],"PARSE1",1)); 257 254 258 259 260 261 255 return @$reg[1]; 256 } 257 258 function endTag($code,$nom){ 262 259 // Renvoie TRUE(1) si le tag de fermeture est présent. 263 260 264 265 266 267 268 269 261 preg_match("(<!--/VTP_$nom-->)sU",$code,$reg); 262 263 return ($reg[0]!="<!--/VTP_$nom-->") ? 0 : 1; 264 } 265 266 function getSource($code,$nom,$type=0){ 270 267 // Retourne le source de la zone de nom $nom 271 268 272 273 274 275 276 277 269 preg_match_all ("(<!--VTP_$nom-->(.*)<!--/VTP_$nom-->)sU",$code,$reg); 270 271 return $reg[$type][0]; 272 } 273 274 function parseZone($code_source,$nom_zone="|root|"){ 278 275 // Fonction récursive de parsing du fichier template 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 276 // Vérification que la zone n'existe pas 277 if (isset($this->sources[$nom_zone])) exit($this->error(6,$nom_zone,"PARSE2",1)); 278 279 // Enregistrement du code source 280 $this->sources[$nom_zone]["source"]=$code_source; 281 282 // Rappel de la fonction pour chaque fils. 283 while($nom_fils=$this->getNom($this->sources[$nom_zone]["source"])){ 284 285 // Vérification que le tag de fin est présent. 286 if (!$this->endTag($code_source,$nom_fils)) exit($this->error(7,$nom_fils,"PARSE3",1)); 287 288 // Parse le fils 289 $this->parseZone($this->getSource($this->sources[$nom_zone]["source"],$nom_fils,1),$nom_fils); 290 291 // Enregistre le nom du fils dans la liste des fils 292 $this->sources[$nom_zone]["fils"][]=$nom_fils; 293 294 // Remplace le code du fils dans le source du père 295 $this->sources[$nom_zone]["source"]=str_replace( 296 $this->getSource($this->sources[$nom_zone]["source"],$nom_fils,0), 297 "|$nom_fils|", 298 $this->sources[$nom_zone]["source"] 299 ); 300 // Teste si la zone $nom_fils n'existe pas plusieurs fois dans la zone $nom_zone 301 if (count(explode("|$nom_fils|",$this->sources[$nom_zone]["source"]))>2) exit($this->error(6,$nom_fils,"PARSE4",1)); 302 }// fin While 303 304 return 1; 305 } 309 306 310 307 /**************************************************************** 311 308 Session Management functions ( SMF 1.0 ) 312 ****************************************************************/313 314 309 ****************************************************************/ 310 311 function createSession($handle,$zone = "|root|"){ 315 312 // Create a new session of the zone 316 313 $this->sessions[$handle][$zone] = new Session($zone,$this->sources[$zone]["source"],$this->file_name[$handle]); 317 314 318 315 // Create sub-zone 319 320 321 322 323 324 316 if (@count($this->sources[$zone]["fils"])){ 317 foreach($this->sources[$zone]["fils"] as $subzone){ 318 $this->createSession($handle,$subzone); 319 $this->sessions[$handle][$zone]->addSubZone($this->sessions[$handle][$subzone]); 320 } 321 } 325 322 326 323 //end createSession 327 324 } 328 325 329 326 330 327 /**************************************************************** 331 328 Global Variable Management Functions ( GVMF 1.0 ) 332 ****************************************************************/333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 329 ****************************************************************/ 330 331 function setGZone($handle,$zone,$var,$value){ 332 // Define Global var for $zone and its sub-zone. 333 // Set global value to $zone vars. 334 return $this->sessions[$handle][$zone]->setGlobalVar($var,$value); 335 } 336 337 function setGFile($handle,$var,$value) { 338 return $this->sessions[$handle]["|root|"]->setGlobalVar($var,$value); 339 } 340 341 function setGAll($var,$value){ 342 $declare = 0; 343 $this->v_global[$var]=$value; 344 if (is_array($this->sessions)){ 345 foreach($this->sessions as $handle => $v){ 346 $declare = $this->setGFile($handle,$var,$value) || $declare; 347 } 348 } 349 return $declare; 350 } 351 352 function setGOpened($handle){ 356 353 // Set Global var into the opened file 357 358 359 360 361 354 foreach($this->v_global as $name => $val){ 355 $this->setGFile($handle,$name,$val); 356 } 357 return 1; 358 } 362 359 363 360 // Fin VTemplate_Private 364 365 366 367 361 } 362 363 364 class VTemplate extends VTemplate_Private{ 368 365 /**************************************** 369 370 366 * Public Class. * 367 * ***************************************/ 371 368 372 369 … … 376 373 377 374 378 375 function Open($nomfichier){ 379 376 // Ouverture d'un fichier source et retourne le handle de ce fichier 380 377 // Création du handle: 381 378 $handle = "{".count($this->sessions)."}" ; 382 379 383 380 384 381 // Récupération du source à parser 385 386 387 388 389 382 if (!@file_exists($nomfichier)) return $this->error(8,$nomfichier,"TTT1",1); 383 if (!$f_id=@fopen($nomfichier,"r")) return $this->error(9,$nomfichier,"TTT2",1); 384 if (!$source=@fread($f_id, filesize($nomfichier))) return $this->error(10,$nomfichier,"TTT3",1); 385 clearstatcache(); 386 fclose($f_id); 390 387 391 388 // Store the filename 392 389 $this->file_name[$handle]=$nomfichier; 393 390 394 391 // Parse les zones 395 392 $this->parseZone($source); 396 393 397 394 // Création du tableau de session 398 395 $this->createSession($handle); 399 396 400 397 //Nettoyage des variables temporaires 401 398 $this->sources=NULL; 402 399 403 400 // Set global var. 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 401 $this->setGOpened($handle); 402 403 $this->addSession($handle); 404 return $handle; 405 } 406 407 function newSession($handle="{0}",$nom_zone = "|root|"){ 408 if ( $this->sessions[$handle][$nom_zone]->used ) $this->closeSession($handle,$nom_zone); 409 $this->addSession($handle,$nom_zone,$cache,$time,$num_session); 410 return 1; 411 } 412 413 function addSession($handle="{0}",$nom_zone = "|root|"){ 414 // Does the zone exist ? 415 if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT4",1); 416 $this->sessions[$handle][$nom_zone]->init(); 417 return 1; 418 } 419 420 function closeSession($handle="{0}",$nom_zone = "|root|"){ 424 421 // Close the current session and all his sub-session 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 422 // Check if the zone exists. 423 if(!isset($this->sessions[$handle][$nom_zone])) return $this->error(11,array($nom_zone,$this->file_name[$handle]),"TTT5",1); 424 // Closing sub-zone 425 $this->sessions[$handle][$nom_zone]->closeSession(); 426 return 1; 427 } 428 429 function setGlobalVar($arg1,$arg2,$arg3){ 430 if ($arg1 == 1){ 431 if (!$this->setGAll($arg2,$arg3)) return $this->error(12,$arg2,"TTT6",1); 432 return 1; 433 } 434 if (!isset($this->sessions[$arg1])) return $this->error(13,$arg1,"TTT7",1); 435 $tab=explode(".",$arg2); 436 if (count($tab)==1){ 437 if (!$this->setGFile($arg1,$arg2,$arg3)) return $this->error(14,array($this->file_name[$arg1],$arg2),"TTT8",1); 438 } 439 else if (count($tab==2)){ 440 if (!isset($this->sessions[$arg1][$tab[0]])) return $this->error(11,array($tab[0],$this->file_name[$arg1],"TTT9",1)); 441 if (!$this->setGZone($arg1,$tab[0],$tab[1],$arg3)) return $this->error(15,array($this->file_name[$arg1],$tab[0],$tab[1]),"TTT10",1); 442 } 443 return 1; 444 } 445 446 function setVar($handle,$zone_var,$val){ 447 // Fill the variable 448 $tab=explode(".",$zone_var); 449 if(count($tab)==2){ 450 $zone=$tab[0]; 451 $var=$tab[1]; 452 } 453 else 454 { 455 $zone="|root|"; 456 $var=$tab[0]; 457 } 458 459 // Teste l'existence de la zone dans la liste 460 if (!isset($this->sessions[$handle][$zone])) return $this->error(11,array($this->file_name[$handle],$zone),"TTT11",1); 461 462 //Enregistre la variable 463 return $this->sessions[$handle][$zone]->setVar($var,$val); 464 } 465 466 function Parse($handle_dest,$zone_var_dest,$handle_source,$zone_source="|root|"){ 467 if($this->sessions[$handle_source][$zone_source]->used == 1) $this->closeSession($handle_source,$zone_source); 468 $this->setVar($handle_dest,$zone_var_dest, $this->sessions[$handle_source][$zone_source]->generated); 469 } 470 471 function setVarF($handle,$zone_var,$file){ 475 472 // Fonction qui ouvre le fichier file et copie ce qu'il y a dedans dans une variable. 476 473 $tab=explode(".",$zone_var); 477 474 478 475 // Récupération nom de la zone et de la variable. 479 480 481 482 483 484 485 486 487 476 if(count($tab)==2){ 477 $zone=$tab[0]; 478 $var=$tab[1]; 479 } 480 else 481 { 482 $zone="|root|"; 483 $var=$tab[0]; 484 } 488 485 // Teste l'existence de la zone dans la liste 489 490 491 492 493 494 495 496 486 if (!is_object($this->sessions[$handle][$zone])) return $this->error(11,array($handle,$zone),"TTT12",1); 487 488 // Récupération du source à lire 489 if (!@file_exists($file)) return $this->error(8,$file,"TTT13",1); 490 if (!$f_id=@fopen($file,"r")) return $this->error(9,$file,"TTT14",1); 491 if (!$val=@fread($f_id, filesize($file))) return $this->error(10,$file,"TTT15",1); 492 clearstatcache(); 493 fclose($f_id); 497 494 498 495 //Enregistre la variable 499 return $this->sessions[$handle][$zone]->setVar($var,$val); 500 } 501 502 function isZone($handle, $zone="|root|") 503 { 504 return isset($this->sessions[$handle][$zone]) ; 505 } 506 507 function Display($handle="{0}",$display=1,$zone="|root|"){ 508 $this->closeSession($handle,$zone); 509 $c_genere = $this->sessions[$handle][$zone]->generated; 496 return $this->sessions[$handle][$zone]->setVar($var,$val); 497 } 498 499 500 501 502 503 function isZone($handle, $zone="|root|") 504 { 505 return isset($this->sessions[$handle][$zone]) ; 506 } 507 508 function Display($handle="{0}",$display=1,$zone="|root|"){ 509 $this->closeSession($handle,$zone); 510 $c_genere = $this->sessions[$handle][$zone]->generated; 510 511 511 if ($display) echo $c_genere; else return ($c_genere); 512 } 512 if ($display) echo $c_genere; else return ($c_genere); 513 } 514 //fonction complementaire version BETA 515 516 /* 517 * 518 On peut l'utiliser : 519 - SetVarTab($array): tout les couples clef/valeur sont valorisées 520 - SetVarTab($array,$index) seuls les couples clef/valeur dont la clef est dans le tableau index ou dont la valeur == $index (si pas tableau) 521 Si $index contient ou est une clef de type zone.clef, la clef sera extraite du texte est servira d'index pour $array 522 523 Vincent 524 */ 525 526 function setVarTab($handle,$zones,$index = array()){ 527 if (is_array($index)) 528 { 529 if (count($index)>0) 530 { 531 reset($index); 532 while (list (, $key) = each ($index)) 533 { 534 $tab=explode(".",$key); 535 if(count($tab)==2){ 536 $var=$tab[1]; 537 } 538 else 539 { 540 $var=$tab[0]; 541 } 542 setVar($handle,$key,$zones[$var]); 543 } 544 } 545 else 546 { 547 reset($zones); 548 while (list ($key, $val) = each ($zones)) 549 { 550 setVar($handle,$key,$val); 551 } 552 } 553 } 554 else 555 { 556 setVar($handle,$index,$zones[$index]); 557 } 558 } 559 560 function setGlobalVarTab($handle,$zones,$index = array()){ 561 562 if (is_array($index)) 563 { 564 if (count($index)>0) 565 { 566 reset($index); 567 while (list (, $key) = each ($index)) 568 { 569 $tab=explode(".",$key); 570 if(count($tab)==2){ 571 $var=$tab[1]; 572 } 573 else 574 { 575 $var=$tab[0]; 576 } 577 setGlobalVar($handle,$key,$zones[$var]); 578 } 579 } 580 else 581 { 582 reset($zones); 583 while (list ($key, $val) = each ($zones)) 584 { 585 GlobalVar($handle,$key,$val); 586 } 587 } 588 } 589 else 590 { 591 setBlobalVar($handle,$index,$zones[$index]); 592 } 593 } 594 595 596 597 513 598 514 599 515 600 // End VTemplate 516 517 601 } 602 $DEFINE_VTEMPLATE = 1; 518 603 } 519 604 ?> -
trunk/index.php
r10 r21 1 1 <?php 2 include_once( './include/mysql.inc.php' );2 define( PREFIX_INCLUDE, '' ); 3 3 include_once( './include/functions.inc.php' ); 4 4 database_connection(); 5 // r écupération des informations de configuration du site6 $query = 'select acces';7 $query .= 'from'.PREFIX_TABLE.'config;';5 // retrieving configuration informations 6 $query = 'SELECT access'; 7 $query.= ' FROM '.PREFIX_TABLE.'config;'; 8 8 $row = mysql_fetch_array( mysql_query( $query ) ); 9 $url = 'category'; 10 if ( $row['acces'] == 'restreint' ) 11 { 12 $url = 'identification'; 13 } 9 if ( $row['access'] == 'restricted' ) $url = 'identification'; 10 else $url = 'category'; 14 11 // redirection 15 12 $url.= '.php'; -
trunk/language/francais.php
r20 r21 16 16 $lang['guest'] = 'visiteur'; 17 17 $lang['mail_address'] = 'adresse mail'; 18 $lang['public'] = 'publique'; 19 $lang['private'] = 'privée'; 20 $lang['add'] = 'ajouter'; 21 $lang['dissociate'] = 'dissocier'; 18 22 // end version 1.3 19 23 … … 219 223 $lang['title_add'] = 'Ajouter un utilisateur'; 220 224 $lang['title_modify'] = 'Modifier un utilisateur'; 225 $lang['title_groups'] = 'Gestion des groupes'; 221 226 // end version 1.3 222 227 $lang['title_liste_users'] = 'Liste des utilisateurs'; … … 225 230 $lang['title_configuration'] = 'Configuration de PhpWebGallery'; 226 231 $lang['title_instructions'] = 'Instructions'; 227 $lang['title_permissions'] = 'Modifier les permissions pour un utilisateur'; 232 // start version 1.3 233 // $lang['title_permissions'] = 'Modifier les permissions pour un utilisateur'; 234 $lang['title_user_perm'] = 'Modifier les permissions pour l\'utilisateur'; 235 $lang['title_cat_perm'] = 'Modifier les permissions pour la catégorie'; 236 $lang['title_group_perm'] = 'Modifier les permissions pour le groupe'; 237 // end version 1.3 228 238 $lang['title_categories'] = 'Gestion des catégories'; 229 239 $lang['title_edit_cat'] = 'Editer une catégorie'; … … 232 242 $lang['title_thumbnails_2'] = 'pour'; 233 243 $lang['title_default'] = 'Administration de PhpWebGallery'; 234 244 235 245 $lang['menu_title'] = 'Administration'; 236 246 $lang['menu_config'] = 'Configuration'; … … 244 254 $lang['menu_instructions'] = 'Instructions'; 245 255 $lang['menu_back'] = 'Page diapo'; 246 256 // start version 1.3 257 $lang['menu_groups'] = 'Groupes'; 258 // end version 1.3 259 247 260 $lang['title_waiting'] = 'Images en attente de validation'; 248 261 $lang['menu_waiting'] = 'En attente'; … … 384 397 // start version 1.3 385 398 // $lang['adduser_status_member'] = 'membre'; 399 $lang['adduser_associate'] = 'Associer au groupe'; 386 400 // end version 1.3 387 401 $lang['adduser_status_guest'] = 'visiteur'; 388 402 403 // start version 1.3 404 $lang['group_add'] = 'Ajouter un groupe'; 405 $lang['group_add_error1'] = 'Le nom du groupe ne doit pas comporter de " ou de \''; 406 $lang['group_add_error2'] = 'Ce nom de groupe est déjà utilisé'; 407 $lang['group_confirm'] = 'Etes-vous sûr de vouloir supprimer le groupe'; 408 $lang['group_list_title'] = 'Liste des groupes existants'; 409 $lang['group_err_unknown'] = 'Ce groupe n\'existe pas dans la base de données'; 410 // end version 1.3 411 389 412 // page permissions 390 413 $lang['permuser_info_message'] = 'Permissions enregistrées'; … … 394 417 $lang['permuser_forbidden'] = 'interdit'; 395 418 $lang['permuser_parent_forbidden'] = 'catégorie parente interdite'; 396 $lang['permuser_cat_title'] = 'Modifier les permissions pour '; 419 // start version 1.3 420 // $lang['permuser_cat_title'] = 'Modifier les permissions pour '; 421 // end version 1.3 397 422 398 423 // page liste utilisateurs … … 434 459 $lang['editcat_status'] = 'Status'; 435 460 $lang['editcat_status_info'] = '(invisible sauf pour les administrateurs)'; 436 461 // start version 1.3 462 $lang['editcat_visible'] = 'Visible'; 463 // end version 1.3 437 464 // page info images 438 465 $lang['infoimage_err_date'] = 'date erronée'; -
trunk/picture.php
r19 r21 29 29 } 30 30 //---------------------------------------- incrementation of the number of hits 31 $query = ' update'.PREFIX_TABLE.'images';32 $query.= ' sethit=hit+1';33 $query.= ' whereid='.$_GET['image_id'];31 $query = 'UPDATE '.PREFIX_TABLE.'images'; 32 $query.= ' SET hit=hit+1'; 33 $query.= ' WHERE id='.$_GET['image_id']; 34 34 $query.= ';'; 35 35 @mysql_query( $query ); … … 38 38 $cat_directory = $page['cat_dir']; // by default 39 39 //------------------------------------- main picture information initialization 40 $query = ' selectid,date_available,comment,hit';40 $query = 'SELECT id,date_available,comment,hit'; 41 41 $query.= ',author,name,file,date_creation,filesize,width,height,cat_id'; 42 $query.= ' from'.PREFIX_TABLE.'images';42 $query.= ' FROM '.PREFIX_TABLE.'images'; 43 43 $query.= $page['where']; 44 $query.= ' andid = '.$_GET['image_id'];44 $query.= ' AND id = '.$_GET['image_id']; 45 45 $query.= $conf['order_by']; 46 46 $query.= ';'; … … 60 60 $page['cat_id'] = $row['cat_id']; 61 61 // retrieving the number of the picture in its category (in order) 62 $query = ' selectid';63 $query.= ' from'.PREFIX_TABLE.'images';62 $query = 'SELECT id'; 63 $query.= ' FROM '.PREFIX_TABLE.'images'; 64 64 $query.= $page['where']; 65 65 $query.= $conf['order_by']; … … 79 79 { 80 80 // verify if the picture is already in the favorite of the user 81 $query = ' select count(*) asnb_fav';82 $query.= ' from'.PREFIX_TABLE.'favorites';83 $query.= ' whereimage_id = '.$page['id'];84 $query.= ' anduser_id = '.$user['id'];81 $query = 'SELECT COUNT(*) AS nb_fav'; 82 $query.= ' FROM '.PREFIX_TABLE.'favorites'; 83 $query.= ' WHERE image_id = '.$page['id']; 84 $query.= ' AND user_id = '.$user['id']; 85 85 $query.= ';'; 86 86 $result = mysql_query( $query ); … … 88 88 if ( $row['nb_fav'] == 0 ) 89 89 { 90 $query = ' insert into'.PREFIX_TABLE.'favorites';91 $query.= ' (image_id,user_id) values';90 $query = 'INSERT INTO '.PREFIX_TABLE.'favorites'; 91 $query.= ' (image_id,user_id) VALUES'; 92 92 $query.= ' ('.$page['id'].','.$user['id'].')'; 93 93 $query.= ';'; … … 97 97 if ( $_GET['add_fav'] == 0 ) 98 98 { 99 $query = ' delete from'.PREFIX_TABLE.'favorites';100 $query.= ' whereuser_id = '.$user['id'];101 $query.= ' andimage_id = '.$page['id'];99 $query = 'DELETE FROM '.PREFIX_TABLE.'favorites'; 100 $query.= ' WHERE user_id = '.$user['id']; 101 $query.= ' AND image_id = '.$page['id']; 102 102 $query.= ';'; 103 103 $result = mysql_query( $query ); … … 121 121 $page['num'] = 0; 122 122 } 123 $query = ' selectid';124 $query.= ' from'.PREFIX_TABLE.'images';123 $query = 'SELECT id'; 124 $query.= ' FROM '.PREFIX_TABLE.'images'; 125 125 $query.= $page['where']; 126 126 $query.= $conf['order_by']; 127 $query.= ' limit'.$page['num'].',1';127 $query.= ' LIMIT '.$page['num'].',1'; 128 128 $query.= ';'; 129 129 $result = mysql_query( $query ); … … 144 144 //----------------------------------------------------- template initialization 145 145 $vtp = new VTemplate; 146 $handle = $vtp->Open( './template/default/picture.vtp' ); 147 // language 148 $vtp->setGlobalVar( $handle, 'back', $lang['back'] ); 149 $vtp->setGlobalVar( $handle, 'submit', $lang['submit'] ); 150 $vtp->setGlobalVar( $handle, 'comments_title', $lang['comments_title'] ); 151 $vtp->setGlobalVar( $handle, 'comments_del', $lang['comments_del'] ); 152 $vtp->setGlobalVar( $handle, 'delete', $lang['delete'] ); 153 $vtp->setGlobalVar( $handle, 'comments_add', $lang['comments_add'] ); 154 $vtp->setGlobalVar( $handle, 'author', $lang['author'] ); 155 // user 156 $vtp->setGlobalVar( $handle, 'page_style', $user['style'] ); 157 $vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] ); 158 // structure 159 $vtp->setGlobalVar( $handle, 'frame_start', get_frame_start() ); 160 $vtp->setGlobalVar( $handle, 'frame_begin', get_frame_begin() ); 161 $vtp->setGlobalVar( $handle, 'frame_end', get_frame_end() ); 146 $handle = $vtp->Open( './template/'.$user['template'].'/picture.vtp' ); 147 initialize_template(); 148 149 $tpl = array( 'back','submit','comments_title','comments_del','delete', 150 'comments_add','author' ); 151 templatize_array( $tpl, 'lang', $handle ); 152 $vtp->setGlobalVar( $handle, 'text_color', $user['couleur_text'] ); 162 153 //------------------------------------------------------------------ page title 163 if ( $page['name'] != "")154 if ( $page['name'] != '' ) 164 155 { 165 156 $vtp->setGlobalVar( $handle, 'page_title', $page['name'] ); … … 173 164 { 174 165 $prev = $page['num'] - 1; 175 $query = ' selectid,name,file,tn_ext,cat_id';176 $query.= ' from'.PREFIX_TABLE.'images';166 $query = 'SELECT id,name,file,tn_ext,cat_id'; 167 $query.= ' FROM '.PREFIX_TABLE.'images'; 177 168 $query.= $page['where']; 178 169 $query.= $conf['order_by']; 179 $query.= ' limit'.$prev.',1';170 $query.= ' LIMIT '.$prev.',1'; 180 171 $query.= ';'; 181 172 $result = mysql_query( $query ); … … 198 189 $prev_title = $lang['previous_image'].' : '; 199 190 $alt_thumbnaill = ''; 200 if ( $row['name'] != "" ) 201 { 202 $alt_thumbnail = $row['name']; 203 } 204 else 205 { 206 $alt_thumbnail = $file; 207 } 191 if ( $row['name'] != '' ) $alt_thumbnail = $row['name']; 192 else $alt_thumbnail = $file; 208 193 $prev_title.= $alt_thumbnail; 209 194 … … 321 306 $vtp->addSession( $handle, 'info_line' ); 322 307 $vtp->setVar( $handle, 'info_line.name', $lang['creation_date'].' : ' ); 323 $tab_date= explode( '-', $page['date_creation'] );308 list( $year,$month,$day ) = explode( '-', $page['date_creation'] ); 324 309 $vtp->setVar( $handle, 'info_line.content', 325 $ tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0]);310 $day.'/'.$month.'/'.$year ); 326 311 $vtp->closeSession( $handle, 'info_line' ); 327 312 } … … 329 314 $vtp->addSession( $handle, 'info_line' ); 330 315 $vtp->setVar( $handle, 'info_line.name', $lang['registration_date'].' : ' ); 331 $tab_date= explode( '-', $page['date_available'] );316 list( $year,$month,$day ) = explode( '-', $page['date_available'] ); 332 317 $vtp->setVar( $handle, 'info_line.content', 333 $ tab_date[2].'/'.$tab_date[1].'/'.$tab_date[0]);318 $day.'/'.$month.'/'.$year ); 334 319 $vtp->closeSession( $handle, 'info_line' ); 335 320 // size in pixels 336 321 $vtp->addSession( $handle, 'info_line' ); 337 322 $vtp->setVar( $handle, 'info_line.name', $lang['size'].' : ' ); 338 if ( $original_width != $final_width ||$original_height != $final_height )323 if ( $original_width != $final_width or $original_height != $final_height ) 339 324 { 340 325 $content = '[ <a href="'.$lien_image.'" title="'.$lang['true_size'].'">'; … … 380 365 $vtp->closeSession( $handle, 'info_line' ); 381 366 //------------------------------------------------------- favorite manipulation 382 if ( $page['cat'] != 'fav' &&!$user['is_the_guest'] )367 if ( $page['cat'] != 'fav' and !$user['is_the_guest'] ) 383 368 { 384 369 $url = './picture.php?cat='.$page['cat'].'&image_id='.$page['id']; … … 442 427 443 428 $file = substr ( $row['file'], 0, strrpos ( $row['file'], ".") ); 444 $lien_thumbnail = $cat_directory. "thumbnail/";429 $lien_thumbnail = $cat_directory.'thumbnail/'; 445 430 $lien_thumbnail.= $conf['prefix_thumbnail'].$file.".".$row['tn_ext']; 446 431 … … 481 466 if ( isset( $_POST['content'] ) && $_POST['content'] != '' ) 482 467 { 483 $author = $user[' pseudo'];484 if ( $_POST['author'] != "")468 $author = $user['username']; 469 if ( $_POST['author'] != '' ) 485 470 { 486 471 $author = $_POST['author']; 487 472 } 488 $query = ' insert into'.PREFIX_TABLE.'comments';489 $query.= ' (author,date,image_id,content) values';473 $query = 'INSERT INTO '.PREFIX_TABLE.'comments'; 474 $query.= ' (author,date,image_id,content) VALUES'; 490 475 $query.= " ('".$author."',".time().",".$page['id']; 491 476 $query.= ",'".htmlspecialchars( $_POST['content'], ENT_QUOTES)."');"; … … 497 482 && $user['status'] == 'admin' ) 498 483 { 499 $query = ' delete from'.PREFIX_TABLE.'comments';500 $query.= ' whereid = '.$_GET['del'].';';484 $query = 'DELETE FROM '.PREFIX_TABLE.'comments'; 485 $query.= ' WHERE id = '.$_GET['del'].';'; 501 486 mysql_query( $query ); 502 487 } 503 488 // number of comment for this picture 504 $query = ' select count(*) asnb_comments';505 $query.= ' from'.PREFIX_TABLE.'comments';506 $query.= ' whereimage_id = '.$page['id'].';';489 $query = 'SELECT COUNT(*) AS nb_comments'; 490 $query.= ' FROM '.PREFIX_TABLE.'comments'; 491 $query.= ' WHERE image_id = '.$page['id'].';'; 507 492 $row = mysql_fetch_array( mysql_query( $query ) ); 508 493 $page['nb_comments'] = $row['nb_comments']; … … 515 500 } 516 501 if( !isset( $_GET['start'] ) 517 ||!is_numeric( $_GET['start'] )518 || ( is_numeric( $_GET['start'] ) &&$_GET['start'] < 0 ) )502 or !is_numeric( $_GET['start'] ) 503 or ( is_numeric( $_GET['start'] ) and $_GET['start'] < 0 ) ) 519 504 { 520 505 $page['start'] = 0; … … 532 517 $vtp->setGlobalVar( $handle, 'nb_comments', $page['nb_comments'] ); 533 518 534 $query = ' selectid,author,date,image_id,content';535 $query.= ' from'.PREFIX_TABLE.'comments';536 $query.= ' whereimage_id = '.$page['id'];537 $query.= ' order by date asc';538 $query.= ' limit'.$page['start'].', '.$conf['nb_comment_page'].';';519 $query = 'SELECT id,author,date,image_id,content'; 520 $query.= ' FROM '.PREFIX_TABLE.'comments'; 521 $query.= ' WHERE image_id = '.$page['id']; 522 $query.= ' ORDER BY date ASC'; 523 $query.= ' LIMIT '.$page['start'].', '.$conf['nb_comment_page'].';'; 539 524 $result = mysql_query( $query ); 540 525 … … 581 566 $code = $vtp->Display( $handle, 0 ); 582 567 echo $code; 583 //------------------------------------------------------------ log informations584 $query = 'insert into '.PREFIX_TABLE.'history';585 $query.= ' (date,login,IP,page,titre,categorie) values';586 $query.= " (".time().", '".$user['pseudo']."','".$_SERVER['REMOTE_ADDR']."'";587 $query.= ",'picture','".$page['file']."','".$intitule_cat."');";588 @mysql_query( $query );589 568 ?> -
trunk/register.php
r2 r21 17 17 18 18 //----------------------------------------------------------- personnal include 19 include_once( "./include/init.inc.php");19 include_once( './include/init.inc.php' ); 20 20 //-------------------------------------------------- access authorization check 21 if ( $conf['acces '] == "restreint" )21 if ( $conf['access'] == "restricted" ) 22 22 { 23 23 echo $lang['only_members']; -
trunk/template/default/admin/user_modify.vtp
r9 r21 35 35 <tr> 36 36 <td>{#new} {#password}<input type="checkbox" name="use_new_pwd" value="1" /></td> 37 <td><input type="text" name="password" value=" {#user:password}" /></td>37 <td><input type="text" name="password" value="" /></td> 38 38 </tr> 39 39 <tr> … … 48 48 <option value="{#value}"{#selected}>{#option}</option> 49 49 <!--/VTP_status_option--> 50 </select> 51 </td> 52 </tr> 53 <!--VTP_groups--> 54 <tr> 55 <td valign="top">{#menu_groups}</td> 56 <td> 57 <table> 58 <!--VTP_group--> 59 <tr> 60 <td>{#name}</td> 61 <td><input type="checkbox" name="dissociate-{#dissociate_id}" value="1" /> {#dissociate}</td> 62 </tr> 63 <!--/VTP_group--> 64 </table> 65 </td> 66 </tr> 67 <!--/VTP_groups--> 68 <tr> 69 <td>{#adduser_associate}</td> 70 <td> 71 <select name="associate"> 72 <!--VTP_associate_group--> 73 <option value="{#value}">{#option}</option> 74 <!--/VTP_associate_group--> 50 75 </select> 51 76 </td> -
trunk/template/default/picture.vtp
r2 r21 1 1 <html> 2 2 <head> 3 {# page_style}3 {#style} 4 4 <!-- Specific style to picture.php--> 5 5 <style type="text/css"> … … 45 45 </head> 46 46 <body> 47 {#header} 47 48 <table style="width:100%;height:100%;"> 48 49 <tr align="center" valign="middle"> … … 163 164 <!--/VTP_comments--> 164 165 </table> 166 {#footer} 165 167 </body> 166 168 </html>
Note: See TracChangeset
for help on using the changeset viewer.