[geeklog-cvs] Geeklog-1.x/system lib-user.php,1.39,1.40

Dirk Haun dhaun at qs1489.pair.com
Sat May 26 15:32:01 EDT 2007


Update of /cvsroot/geeklog/Geeklog-1.x/system
In directory qs1489.pair.com:/tmp/cvs-serv1378/system

Modified Files:
	lib-user.php 
Log Message:
OpenID support, provided by Choplair


Index: lib-user.php
===================================================================
RCS file: /cvsroot/geeklog/Geeklog-1.x/system/lib-user.php,v
retrieving revision 1.39
retrieving revision 1.40
diff -C2 -d -r1.39 -r1.40
*** lib-user.php	21 Apr 2007 13:36:19 -0000	1.39
--- lib-user.php	26 May 2007 19:31:59 -0000	1.40
***************
*** 9,13 ****
  // | User-related functions needed in more than one place.                     |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2006 by the following authors:                         |
  // |                                                                           |
  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
--- 9,13 ----
  // | User-related functions needed in more than one place.                     |
  // +---------------------------------------------------------------------------+
! // | Copyright (C) 2000-2007 by the following authors:                         |
  // |                                                                           |
  // | Authors: Tony Bibbs        - tony AT tonybibbs DOT com                    |
***************
*** 225,228 ****
--- 225,229 ----
          $mailfrom = $_CONF['site_mail'];
      }
+ 
      return COM_mail ($useremail, $subject, $mailtext, $mailfrom);
  }
***************
*** 596,599 ****
--- 597,637 ----
  
      return $match_found;
+ }
+ 
+ /**
+ * Ensure unique username
+ *
+ * Checks that $username does not exist yet and creates a new unique username
+ * (based off of $username) if necessary.
+ * Mostly useful for creating accounts for remote users.
+ *
+ * @param    string  $username   initial username
+ * @return   string              unique username
+ * @bugs     Race conditions apply ...
+ *
+ */
+ function USER_uniqueUsername($username)
+ {
+     global $_TABLES;
+ 
+     if (function_exists('CUSTOM_uniqueUsername')) {
+         return CUSTOM_uniqueUsername($username);
+     }
+ 
+     $try = $username;
+     do {
+         $try = addslashes($try);
+         $uid = DB_getItem($_TABLES['users'], 'uid', "username = '$try'");
+         if (!empty($uid)) {
+             $r = rand(2, 9999);
+             if (strlen($username) > 12) {
+                 $try = sprintf('%s%d', substr($username, 0, 12), $r);
+             } else {
+                 $try = sprintf('%s%d', $username, $r);
+             }
+         }
+     } while (!empty($uid));
+ 
+     return $try;
  }
  




More information about the geeklog-cvs mailing list