Ignore:
Timestamp:
Oct 2, 2007, 12:07:47 AM (17 years ago)
Author:
rub
Message:

Resolved 0000759: email unique for each user

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_user.inc.php

    r2084 r2115  
    2525// +-----------------------------------------------------------------------+
    2626
    27 // validate_mail_address verifies whether the given mail address has the
    28 // right format. ie someone@domain.com "someone" can contain ".", "-" or
    29 // even "_". Exactly as "domain". The extension doesn't have to be
    30 // "com". The mail address can also be empty.
     27// validate_mail_address:
     28//   o verifies whether the given mail address has the
     29//     right format. ie someone@domain.com "someone" can contain ".", "-" or
     30//     even "_". Exactly as "domain". The extension doesn't have to be
     31//     "com". The mail address can also be empty.
     32//   o check if address could be empty
     33//   o check if address is not used by a other user
    3134// If the mail address doesn't correspond, an error message is returned.
    32 function validate_mail_address( $mail_address )
    33 {
    34   global $lang, $conf;
     35//
     36function validate_mail_address($mail_address)
     37{
     38  global $conf;
    3539
    3640  if (empty($mail_address) and
     
    3943    return '';
    4044  }
     45
    4146  $regex = '/^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)*\.[a-z]+$/';
    4247  if ( !preg_match( $regex, $mail_address ) )
    4348  {
    44     return $lang['reg_err_mail_address'];
     49    return l10n('reg_err_mail_address');
     50  }
     51 
     52  if (defined("PHPWG_INSTALLED") and !empty($mail_address))
     53  {
     54    $query = '
     55select count(*)
     56from '.USERS_TABLE.'
     57where upper('.$conf['user_fields']['email'].') = upper(\''.$mail_address.'\')
     58;';
     59    list($count) = mysql_fetch_array(pwg_query($query));
     60    if ($count != 0)
     61    {
     62      return l10n('reg_err_mail_address_dbl');
     63    }
    4564  }
    4665}
     
    4867function register_user($login, $password, $mail_address, $errors = array())
    4968{
    50   global $lang, $conf;
     69  global $conf;
    5170
    5271  if ($login == '')
    5372  {
    54     array_push($errors, $lang['reg_err_login1']);
     73    array_push($errors, l10n('reg_err_login1'));
    5574  }
    5675  if (ereg("^.* $", $login))
    5776  {
    58     array_push($errors, $lang['reg_err_login2']);
     77    array_push($errors, l10n('reg_err_login2'));
    5978  }
    6079  if (ereg("^ .*$", $login))
    6180  {
    62     array_push($errors, $lang['reg_err_login3']);
     81    array_push($errors, l10n('reg_err_login3'));
    6382  }
    6483  if (get_userid($login))
    6584  {
    66     array_push($errors, $lang['reg_err_login5']);
     85    array_push($errors, l10n('reg_err_login5'));
    6786  }
    6887  $mail_error = validate_mail_address($mail_address);
Note: See TracChangeset for help on using the changeset viewer.