~catch-drupal/+junk/pressflow-content-cache-variable

« back to all changes in this revision

Viewing changes to modules/user/user.module

  • Committer: David Strauss
  • Date: 2010-06-18 17:01:06 UTC
  • mfrom: (82.1.2 merge-drupal-6.17)
  • Revision ID: david@fourkitchens.com-20100618170106-eveqf9sepqonszf9
Drupal 6.17 (via testing branch)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
<?php
2
 
// $Id: user.module,v 1.892.2.20 2010/03/01 11:42:50 goba Exp $
 
2
// $Id: user.module,v 1.892.2.25 2010/06/02 12:47:58 goba Exp $
3
3
 
4
4
/**
5
5
 * @file
378
378
 * Verify the syntax of the given name.
379
379
 */
380
380
function user_validate_name($name) {
381
 
  if (!strlen($name)) return t('You must enter a username.');
382
 
  if (substr($name, 0, 1) == ' ') return t('The username cannot begin with a space.');
383
 
  if (substr($name, -1) == ' ') return t('The username cannot end with a space.');
384
 
  if (strpos($name, '  ') !== FALSE) return t('The username cannot contain multiple spaces in a row.');
385
 
  if (ereg("[^\x80-\xF7 [:alnum:]@_.-]", $name)) return t('The username contains an illegal character.');
 
381
  if (!strlen($name)) {
 
382
    return t('You must enter a username.');
 
383
  }
 
384
  if (substr($name, 0, 1) == ' ') {
 
385
    return t('The username cannot begin with a space.');
 
386
  }
 
387
  if (substr($name, -1) == ' ') {
 
388
    return t('The username cannot end with a space.');
 
389
  }
 
390
  if (strpos($name, '  ') !== FALSE) {
 
391
    return t('The username cannot contain multiple spaces in a row.');
 
392
  }
 
393
  if (preg_match('/[^\x{80}-\x{F7} a-z0-9@_.\'-]/i', $name)) {
 
394
    return t('The username contains an illegal character.');
 
395
  }
386
396
  if (preg_match('/[\x{80}-\x{A0}'.          // Non-printable ISO-8859-1 + NBSP
387
397
                   '\x{AD}'.                 // Soft-hyphen
388
398
                   '\x{2000}-\x{200F}'.      // Various space characters
391
401
                   '\x{FEFF}'.               // Byte order mark
392
402
                   '\x{FF01}-\x{FF60}'.      // Full-width latin
393
403
                   '\x{FFF9}-\x{FFFD}'.      // Replacement characters
394
 
                   '\x{0}]/u',               // NULL byte
 
404
                   '\x{0}-\x{1F}]/u',        // NULL byte and control characters
395
405
                   $name)) {
396
406
    return t('The username contains an illegal character.');
397
407
  }
398
 
  if (strpos($name, '@') !== FALSE && !eregi('@([0-9a-z](-?[0-9a-z])*.)+[a-z]{2}([zmuvtg]|fo|me)?$', $name)) return t('The username is not a valid authentication ID.');
399
 
  if (strlen($name) > USERNAME_MAX_LENGTH) return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
 
408
  if (drupal_strlen($name) > USERNAME_MAX_LENGTH) {
 
409
    return t('The username %name is too long: it must be %max characters or less.', array('%name' => $name, '%max' => USERNAME_MAX_LENGTH));
 
410
  }
400
411
}
401
412
 
402
413
function user_validate_mail($mail) {
1154
1165
    $accounts[$uid] = user_load($uid);
1155
1166
  }
1156
1167
  $valid = TRUE;
1157
 
  if ($account = $accounts[$uid]) {
 
1168
  if (($account = $accounts[$uid]) && isset($map[$index + 1]) && $map[$index + 1] == 'edit') {
1158
1169
    // Since the path is like user/%/edit/category_name, the category name will
1159
1170
    // be at a position 2 beyond the index corresponding to the % wildcard.
1160
1171
    $category_index = $index + 2;
1239
1250
    if ($value) {
1240
1251
      db_query("UPDATE {authmap} SET authname = '%s' WHERE uid = %d AND module = '%s'", $value, $account->uid, $module[1]);
1241
1252
      if (!db_affected_rows()) {
1242
 
        db_query("INSERT INTO {authmap} (authname, uid, module) VALUES ('%s', %d, '%s')", $value, $account->uid, $module[1]);
 
1253
        @db_query("INSERT INTO {authmap} (authname, uid, module) VALUES ('%s', %d, '%s')", $value, $account->uid, $module[1]);
1243
1254
      }
1244
1255
    }
1245
1256
    else {
1335
1346
  global $user;
1336
1347
  if (!$user->uid) {
1337
1348
    form_set_error('name', t('Sorry, unrecognized username or password. <a href="@password">Have you forgotten your password?</a>', array('@password' => url('user/password'))));
1338
 
    watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_state['values']['name']));
1339
1349
  }
1340
1350
}
1341
1351
 
1368
1378
    user_authenticate_finalize($form_values);
1369
1379
    return $user;
1370
1380
  }
 
1381
  else {
 
1382
    watchdog('user', 'Login attempt failed for %user.', array('%user' => $form_values['name']));
 
1383
  }
1371
1384
}
1372
1385
 
1373
1386
/**
1441
1454
  }
1442
1455
}
1443
1456
 
 
1457
/**
 
1458
 * Generates a unique URL for a user to login and reset their password.
 
1459
 *
 
1460
 * @param object $account
 
1461
 *   An object containing the user account.
 
1462
 *
 
1463
 * @return
 
1464
 *   A unique URL that provides a one-time log in for the user, from which
 
1465
 *   they can change their password.
 
1466
 */
1444
1467
function user_pass_reset_url($account) {
1445
1468
  $timestamp = time();
1446
1469
  return url("user/reset/$account->uid/$timestamp/". user_pass_rehash($account->pass, $timestamp, $account->login), array('absolute' => TRUE));