Changeset 630 for trunk/profile.php


Ignore:
Timestamp:
Dec 2, 2004, 4:42:57 PM (19 years ago)
Author:
gweltas
Message:

Update of the user preferences panel.
Deletion of some PREFIX_TABLE occurences

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/profile.php

    r593 r630  
    6868    array_push( $errors, $lang['periods_error'] );
    6969  }
    70   $mail_error = validate_mail_address( $_POST['mail_address'] );
    71   if ( $mail_error != '' ) array_push( $errors, $mail_error );
     70       
     71  if ( $_POST['mail_address']!= $user['mail_address'])
     72  {
     73    if (!empty($_POST['password']))
     74                  array_push( $errors, $lang['reg_err_pass'] );
     75                else
     76                {
     77                // retrieving the encrypted password of the login submitted
     78    $query = 'SELECT password FROM '.USERS_TABLE.'
     79              WHERE username = \''.$user['username'].'\';';
     80    $row = mysql_fetch_array(pwg_query($query));
     81    if ($row['password'] == md5($_POST['password']))
     82    {
     83      $mail_error = validate_mail_address( $_POST['mail_address'] );
     84      if ( !empty($mail_error)) array_push( $errors, $mail_error );
     85    }
     86    else
     87      array_push( $errors, $lang['reg_err_pass'] );
     88          }
     89  }
     90 
    7291  // password must be the same as its confirmation
    7392  if ( isset( $_POST['use_new_pwd'] )
    74        and $_POST['password'] != $_POST['passwordConf'] )
     93       and $_POST['use_new_pwd'] != $_POST['passwordConf'] )
    7594    array_push( $errors, $lang['reg_err_pass'] );
    7695 
     
    93112    {
    94113      $query = 'UPDATE '.USERS_TABLE;
    95       $query.= " SET password = '".md5( $_POST['password'] )."'";
     114      $query.= " SET password = '".md5( $_POST['use_new_pwd'] )."'";
    96115      $query.= ' WHERE id = '.$user['id'];
    97116      $query.= ';';
    98117      pwg_query( $query );
    99118    }
    100     if ( isset( $_POST['create_cookie'] ) )
    101     {
    102       setcookie( 'id',$page['session_id'],$_POST['cookie_expiration'],
    103                  cookie_path() );
    104       // update the expiration date of the session
    105       $query = 'UPDATE '.SESSIONS_TABLE;
    106       $query.= ' SET expiration = '.$_POST['cookie_expiration'];
    107       $query.= " WHERE id = '".$page['session_id']."'";
    108       $query.= ';';
    109       pwg_query( $query );
    110     }
     119
    111120    // redirection
    112     $url = 'category.php';
    113     if ( !isset($_POST['create_cookie']) ) $url = add_session_id( $url,true );
    114     redirect( $url );
     121    redirect(add_session_id(PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING']));
    115122  }
    116123}
     
    125132
    126133$template->assign_vars(array(
     134  'USERNAME'=>$user['username'],
     135  'EMAIL'=>$user['mail_address'],
    127136  'LANG_SELECT'=>language_select($user['language'], 'language'),
    128137  'NB_IMAGE_LINE'=>$user['nb_image_line'],
     
    130139  'STYLE_SELECT'=>style_select($user['template'], 'template'),
    131140  'RECENT_PERIOD'=>$user['recent_period'],
     141  'MAXWIDTH'=>$user['maxwidth'],
     142  'MAXHEIGHT'=>$user['maxheight'],
    132143 
    133144  $expand=>'checked="checked"',
     
    135146 
    136147  'L_TITLE' => $lang['customize_title'],
    137   'L_PASSWORD' => $lang['password'],
    138   'L_NEW' =>  $lang['new'],
    139   'L_CONFIRM' =>  $lang['reg_confirm'],
    140   'L_COOKIE' =>  $lang['create_cookie'],
     148  'L_REGISTRATION_INFO' => $lang['register_title'],
     149  'L_PREFERENCES' => $lang['preferences'],
     150  'L_USERNAME' => $lang['login'],
     151  'L_EMAIL' => $lang['mail_address'],
     152  'L_CURRENT_PASSWORD' => $lang['password'],
     153  'L_CURRENT_PASSWORD_HINT' => $lang['password_hint'],
     154  'L_NEW_PASSWORD' =>  $lang['new_password'],
     155  'L_NEW_PASSWORD_HINT' => $lang['new_password_hint'],
     156  'L_CONFIRM_PASSWORD' =>  $lang['reg_confirm'],
     157  'L_CONFIRM_PASSWORD_HINT' => $lang['confirm_password_hint'],
    141158  'L_LANG_SELECT'=>$lang['language'],
    142159  'L_NB_IMAGE_LINE'=>$lang['nb_image_per_row'],
     
    146163  'L_EXPAND_TREE'=>$lang['auto_expand'],
    147164  'L_NB_COMMENTS'=>$lang['show_nb_comments'],
     165  'L_MAXWIDTH'=>$lang['maxwidth'],
     166  'L_MAXHEIGHT'=>$lang['maxheight'],
    148167  'L_YES'=>$lang['yes'],
    149168  'L_NO'=>$lang['no'],
    150169  'L_SUBMIT'=>$lang['submit'],
     170  'L_RETURN' =>  $lang['home'],
     171  'L_RETURN_HINT' =>  $lang['home_hint'], 
    151172 
    152173  'F_ACTION'=>add_session_id(PHPWG_ROOT_PATH.'profile.php'),
     
    154175  'U_RETURN' => add_session_id(PHPWG_ROOT_PATH.'category.php?'.$_SERVER['QUERY_STRING'])
    155176  ));
    156        
     177 
    157178//-------------------------------------------------------------- errors display
    158179if ( sizeof( $errors ) != 0 )
     
    164185  }
    165186}
    166 
    167 $template->assign_block_vars('text',array(
    168   'F_LABEL'=>$lang['maxwidth'],
    169   'F_NAME'=>'maxwidth',
    170   'F_VALUE'=>$user['maxwidth']
    171   ));
    172 
    173 $template->assign_block_vars('text',array(
    174   'F_LABEL'=>$lang['maxheight'],
    175   'F_NAME'=>'maxheight',
    176   'F_VALUE'=>$user['maxheight']
    177   ));
    178 
    179 $template->assign_block_vars('text',array(
    180   'F_LABEL'=>$lang['mail_address'],
    181   'F_NAME'=>'mail_address',
    182   'F_VALUE'=>$user['mail_address']
    183   ));
    184 
    185187//----------------------------------------------------------- html code display
    186188$template->pparse('profile');
Note: See TracChangeset for help on using the changeset viewer.