Changeset 26 for trunk/profile.php
- Timestamp:
- Jul 21, 2003, 9:47:14 PM (21 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/profile.php
r17 r26 29 29 check_cat_id( $_GET['cat'] ); 30 30 //------------------------------------------------------ update & customization 31 $infos = array( 'nb_image_line', 'nb_line_page', ' theme', 'language',31 $infos = array( 'nb_image_line', 'nb_line_page', 'language', 32 32 'maxwidth', 'maxheight', 'expand', 'show_nb_comments', 33 33 'short_period', 'long_period', 'template', 'mail_address' ); … … 36 36 // - on teste si chacune des variables est passée en argument à la page 37 37 // - ce qui signifie que l'on doit venir de la page de personnalisation 38 $error = array();38 $errors = array(); 39 39 if ( isset( $_POST['submit'] ) ) 40 40 { 41 $i = 0; 42 if ( $_POST['maxwidth'] != '' ) 43 { 44 if ( !ereg( "^[0-9]{2,}$", $_POST['maxwidth'] ) 45 || $_POST['maxwidth'] < 50 ) 46 { 47 $error[$i++] = $lang['err_maxwidth']; 48 } 49 } 50 if ( $_POST['maxheight'] != '' ) 51 { 52 if ( !ereg( "^[0-9]{2,}$", $_POST['maxheight'] ) 53 || $_POST['maxheight'] < 50 ) 54 { 55 $error[$i++] = $lang['err_maxheight']; 56 } 57 } 58 // les période doivent être des entiers, il représentent des nombres de jours 59 if ( !ereg( "^[0-9]*$", $_POST['short_period'] ) 60 || !ereg("^[0-9]*$", $_POST['long_period'] ) ) 61 { 62 $error[$i++] = $lang['err_periods']; 41 $int_pattern = '/^\d+$/'; 42 if ( $_POST['maxwidth'] != '' 43 and ( !preg_match( $int_pattern, $_POST['maxwidth'] ) 44 or $_POST['maxwidth'] < 50 ) ) 45 { 46 array_push( $errors, $lang['err_maxwidth'] ); 47 } 48 if ( $_POST['maxheight'] 49 and ( !preg_match( $int_pattern, $_POST['maxheight'] ) 50 or $_POST['maxheight'] < 50 ) ) 51 { 52 array_push( $errors, $lang['err_maxheight'] ); 53 } 54 // periods must be integer values, they represents number of days 55 if ( !preg_match( $int_pattern, $_POST['short_period'] ) 56 or !preg_match( $int_pattern, $_POST['long_period'] ) ) 57 { 58 array_push( $errors, $lang['err_periods'] ); 63 59 } 64 60 else 65 61 { 66 // l a période longue doit être supérieure à la période courte62 // long period must be longer than short period 67 63 if ( $_POST['long_period'] <= $_POST['short_period'] 68 || $_POST['short_period'] <= 0 ) 69 { 70 $error[$i++] = $lang['err_periods_2']; 71 } 72 } 73 // le mail doit être conforme à qqch du type : nom@serveur.com 74 if( $_POST['mail_address'] != "" 75 && !ereg( "([_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+)", 76 $_POST['mail_address'] ) ) 77 { 78 $error[$i++] = $lang['reg_err_mail_address']; 64 or $_POST['short_period'] <= 0 ) 65 { 66 array_push( $errors, $lang['err_periods_2'] ); 67 } 68 } 69 $mail_error = validate_mail_address( $_POST['mail_address'] ); 70 if ( $mail_error != '' ) 71 { 72 array_push( $errors, $mail_error ); 79 73 } 80 74 if ( $_POST['use_new_pwd'] == 1 ) 81 75 { 82 // on vérifie que le password rentré correspond bien 83 // à la confirmation faite par l'utilisateur 76 // password must be the same as its confirmation 84 77 if ( $_POST['password'] != $_POST['passwordConf'] ) 85 78 { 86 $error[$i++] = $lang['reg_err_pass'];79 array_push( $errors, $lang['reg_err_pass'] ); 87 80 } 88 81 } 89 82 90 if ( sizeof( $error ) == 0 ) 91 { 92 $tab_theme = explode( ' - ', $_POST['theme'] ); 93 $_POST['theme'] = $tab_theme[0].'/'.$tab_theme[1]; 94 95 $query = 'update '.PREFIX_TABLE.'users'; 96 $query.= ' set'; 97 for ( $i = 0; $i < sizeof( $infos ); $i++ ) 98 { 99 if ( $i > 0 ) 100 { 101 $query.= ','; 102 } 103 else 104 { 105 $query.= ' '; 106 } 107 $query.= $infos[$i]; 83 if ( count( $errors ) == 0 ) 84 { 85 $query = 'UPDATE '.PREFIX_TABLE.'users'; 86 $query.= ' SET '; 87 foreach ( $infos as $i => $info ) { 88 if ( $i > 0 ) $query.= ','; 89 $query.= $info; 108 90 $query.= ' = '; 109 if ( $_POST[$infos[$i]] == '' ) 110 { 111 $query.= 'NULL'; 112 } 113 else 114 { 115 $query.= "'".$_POST[$infos[$i]]."'"; 116 } 117 } 118 $query.= ' where id = '.$user['id']; 91 if ( $_POST[$info] == '' ) $query.= 'NULL'; 92 else $query.= "'".$_POST[$info]."'"; 93 } 94 $query.= ' WHERE id = '.$user['id']; 119 95 $query.= ';'; 120 96 mysql_query( $query ); … … 122 98 if ( $_POST['use_new_pwd'] == 1 ) 123 99 { 124 $query = ' update'.PREFIX_TABLE.'users';125 $query.= " setpassword = '".md5( $_POST['password'] )."'";126 $query.= ' whereid = '.$user['id'];100 $query = 'UPDATE '.PREFIX_TABLE.'users'; 101 $query.= " SET password = '".md5( $_POST['password'] )."'"; 102 $query.= ' WHERE id = '.$user['id']; 127 103 $query.= ';'; 128 104 mysql_query( $query ); 129 echo '<br />'.$query;130 105 } 131 106 // redirection … … 133 108 if ( $page['cat'] == 'search' ) 134 109 { 135 $url.= '&search='.$_GET['search'].'& amp;mode='.$_GET['mode'];110 $url.= '&search='.$_GET['search'].'&mode='.$_GET['mode']; 136 111 } 137 112 $url = add_session_id( $url, true ); … … 157 132 $vtp->setGlobalVar( $handle, 'form_action', add_session_id( $url ) ); 158 133 //-------------------------------------------------------------- errors display 159 if ( sizeof( $error) != 0 )134 if ( count( $errors ) != 0 ) 160 135 { 161 136 $vtp->addSession( $handle, 'errors' ); 162 for ( $i = 0; $i < sizeof( $error ); $i++ ) 163 { 137 foreach ( $errors as $error ) { 164 138 $vtp->addSession( $handle, 'li' ); 165 $vtp->setVar( $handle, 'li.li', $error [$i]);139 $vtp->setVar( $handle, 'li.li', $error ); 166 140 $vtp->closeSession( $handle, 'li' ); 167 141 } … … 221 195 $vtp->setVar( $handle, 'option.option', $option[$i] ); 222 196 if ( $option[$i] == $user['template'] ) 223 {224 $vtp->setVar( $handle, 'option.selected', ' selected="selected"' );225 }226 $vtp->closeSession( $handle, 'option' );227 }228 $vtp->closeSession( $handle, 'select' );229 $vtp->closeSession( $handle, 'line' );230 }231 //----------------------------------------------------------------------- theme232 if ( in_array( 'theme', $infos ) )233 {234 $vtp->addSession( $handle, 'line' );235 $vtp->setVar( $handle, 'line.name', $lang['customize_theme'] );236 $vtp->addSession( $handle, 'select' );237 $vtp->setVar( $handle, 'select.name', 'theme' );238 $option = get_themes( './theme/' );239 for ( $i = 0; $i < sizeof( $option ); $i++ )240 {241 $vtp->addSession( $handle, 'option' );242 $vtp->setVar( $handle, 'option.option', $option[$i] );243 if ( $option[$i] == str_replace( '/', ' - ', $user['theme'] ) )244 197 { 245 198 $vtp->setVar( $handle, 'option.selected', ' selected="selected"' );
Note: See TracChangeset
for help on using the changeset viewer.