diff --git a/checkin_notes b/checkin_notes
index de8e2f2728..514bb06d62 100755
--- a/checkin_notes
+++ b/checkin_notes
@@ -19775,5 +19775,12 @@ Rom 17 Nov 2004
Bruce 18 Nov 2004
- Bug fixes (thanks to Jens Seidler): set cross project id (CPID) to random value
when creating user account from Administrator form, and lower_case email address
- before inserting into database.
- html/ops/create_account_action.php
+ before inserting into database. Added script make_emails_lowercase.php which
+ goes through user database and changes email addresses to lowercase, and sets CPID
+ to a random string if it is currently 0 (empty). It should be safe to run this
+ script any number of times, on a damanged or undamaged user database, with no side
+ effects.
+
+ html/ops/
+ create_account_action.php
+ make_emails_lowercase.php
diff --git a/html/ops/make_emails_lowercase.php b/html/ops/make_emails_lowercase.php
new file mode 100644
index 0000000000..ff366d71ed
--- /dev/null
+++ b/html/ops/make_emails_lowercase.php
@@ -0,0 +1,67 @@
+\n
+ \n
+";
+
+
+require_once("../inc/util_ops.inc");
+require_once("../inc/util.inc");
+
+echo "
+
User database repair script. Lowercae(email_addr) and set CPID!=0\n
+";
+
+db_init();
+
+$query = "select count(*) from user";
+if (!($result = mysql_query($query))) {
+ echo "No rows found in USER database table";
+ exit();
+}
+$users_array = mysql_fetch_array($result);
+mysql_free_result($result);
+$number_of_users=$users_array[0];
+echo "Found $number_of_users users
";
+
+for ($id=1; $id<=$number_of_users; $id++) {
+ $query = "select email_addr,cross_project_id from user where id=$id";
+ if (!($result = mysql_query($query))) {
+ echo "Entry with id=$id was not found in USER database table";
+ exit(); // change to continue; if missing rows!
+ }
+
+ $user = mysql_fetch_object($result);
+ mysql_free_result($result);
+ $email_addr=$user->email_addr;
+ $cpid=$user->cross_project_id;
+
+ $new_email=strtolower(trim($email_addr));
+
+ if (strcmp($email_addr, $new_email))
+ echo "Problematic email address [$id] $email_addr becomes $new_email
";
+
+ if (!(strcmp($cpid,"0"))) {
+ $newcpid=random_string();
+ echo "Problematic CPID=0 for [$id] $email_addr gets CPID=$newcpid
";
+ }
+ else
+ $newcpid=$cpid;
+
+
+ if (strcmp($email_addr, $new_email) || strcmp($newcpid,$cpid)) {
+ $query="update user set email_addr='$new_email', cross_project_id='$newcpid' where id=$id";
+ // modify line that follows to enable changes to user database: change (1) to (0)
+ if (1)
+ echo "QUERY WOULD BE [$id] $query
[Modify html/ops/make_emails_lowercase.php to enable changes]
";
+ else {
+ $result = mysql_query($query);
+ echo "Doing $query
";
+ }
+ }
+}
+
+echo "
+ \n
+";