From c3c224561adb668e0dd7ab62073a9454124e68f0 Mon Sep 17 00:00:00 2001
From: "Leigh B. Stoller" <stoller@flux.utah.edu>
Date: Fri, 11 Mar 2005 19:25:44 +0000
Subject: [PATCH] Make sure the user name has at least two tokens, which people
 will hopefully understand as First and Last name!

---
 www/joinproject.php3 |  9 ++++++++-
 www/moduserinfo.php3 | 11 +++++++++--
 www/newproject.php3  |  9 ++++++++-
 3 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/www/joinproject.php3 b/www/joinproject.php3
index 89ced4c524..8a404876b2 100644
--- a/www/joinproject.php3
+++ b/www/joinproject.php3
@@ -1,7 +1,7 @@
 <?php
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2003 University of Utah and the Flux Group.
+# Copyright (c) 2000-2003, 2005 University of Utah and the Flux Group.
 # All rights reserved.
 #
 include("defs.php3");
@@ -434,6 +434,13 @@ if (! $returning) {
     elseif (! TBvalid_usrname($formfields[usr_name])) {
 	$errors["Full Name"] = TBFieldErrorString();
     }
+    # Make sure user name has at least two tokens!
+    $tokens = preg_split("/[\s]+/", $formfields[usr_name],
+			 -1, PREG_SPLIT_NO_EMPTY);
+    if (count($tokens) < 2) {
+	$errors["Full Name"] = "Please provide a first and last name";
+    }
+
     if (!isset($formfields[usr_affil]) ||
 	strcmp($formfields[usr_affil], "") == 0) {
 	$errors["Affiliation"] = "Missing Field";
diff --git a/www/moduserinfo.php3 b/www/moduserinfo.php3
index c558206c29..d596269fcb 100644
--- a/www/moduserinfo.php3
+++ b/www/moduserinfo.php3
@@ -1,7 +1,7 @@
 <?php
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2003 University of Utah and the Flux Group.
+# Copyright (c) 2000-2003, 2005 University of Utah and the Flux Group.
 # All rights reserved.
 #
 include("defs.php3");
@@ -432,7 +432,7 @@ else {
     # consisting of the 8 characters after an initial "$1$" and followed by a "$". 
     $unixpwd = explode('$', $row[usr_pswd]);
     if (strlen($unixpwd[0]) > 0)
-	# When there's no $ at the beginning, it's not an MD5 hash.
+	# When there's no $ at the beginning, its not an MD5 hash.
 	$randpwd = substr($unixpwd[0],0,8);
     else
 	$randpwd = substr($unixpwd[2],0,8); # The MD5 salt string.
@@ -470,6 +470,13 @@ if (!isset($formfields[usr_name]) ||
 elseif (! TBvalid_usrname($formfields[usr_name])) {
     $errors["Full Name"] = TBFieldErrorString();
 }
+# Make sure user name has at least two tokens!
+$tokens = preg_split("/[\s]+/", $formfields[usr_name],
+		     -1, PREG_SPLIT_NO_EMPTY);
+if (count($tokens) < 2) {
+    $errors["Full Name"] = "Please provide a first and last name";
+}
+
 if (!isset($formfields[usr_affil]) ||
     strcmp($formfields[usr_affil], "") == 0) {
     $errors["Affiliation"] = "Missing Field";
diff --git a/www/newproject.php3 b/www/newproject.php3
index 5a5f2c885e..560f50df03 100755
--- a/www/newproject.php3
+++ b/www/newproject.php3
@@ -1,7 +1,7 @@
 <?php
 #
 # EMULAB-COPYRIGHT
-# Copyright (c) 2000-2003 University of Utah and the Flux Group.
+# Copyright (c) 2000-2003, 2005 University of Utah and the Flux Group.
 # All rights reserved.
 #
 include("defs.php3");
@@ -586,6 +586,13 @@ if (! $returning) {
     elseif (! TBvalid_usrname($formfields[usr_name])) {
 	$errors["Full Name"] = TBFieldErrorString();
     }
+    # Make sure user name has at least two tokens!
+    $tokens = preg_split("/[\s]+/", $formfields[usr_name],
+			 -1, PREG_SPLIT_NO_EMPTY);
+    if (count($tokens) < 2) {
+	$errors["Full Name"] = "Please provide a first and last name";
+    }
+    
     if (!isset($formfields[usr_affil]) ||
 	strcmp($formfields[usr_affil], "") == 0) {
 	$errors["Affiliation"] = "Missing Field";
-- 
GitLab