From 0fdde906b5f9f9b88dceb83b9242b887e9a847c4 Mon Sep 17 00:00:00 2001 From: Bruce Allen Date: Fri, 19 Nov 2004 14:12:13 +0000 Subject: [PATCH] - New user database email-lowercasing script more efficient, handles case where user.id is not contiguous. svn path=/trunk/boinc/; revision=4607 --- checkin_notes | 8 ++++++-- html/ops/make_emails_lowercase.php | 27 +++++++++++++-------------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/checkin_notes b/checkin_notes index b700754d5b..d9712e97d6 100755 --- a/checkin_notes +++ b/checkin_notes @@ -19874,15 +19874,19 @@ Rom 19 Nov 2004 lib/ gui_rpc_client.C -Bruce 19 Nov 2004 UTC (from Reinhard Prix) +Bruce 19 Nov 2004 UTC - Added nice macro (wxWidgets.m4) to CVS for detection of wxWidgets. Now switch off clientgui build (with nice warning) if wxWidgets is - not found. + not found. (thanks Reinhard Prix) - Use outcome of pthread tests and corresponding flags to set pthreads CFLAGS correctly. + - New user database email-lowercasing script more efficient, handles case + where user.id is not contiguous. configure.ac Makefile.am m4/ wxWidgets.m4 + html/ops/ + make_emails_lowercase.php diff --git a/html/ops/make_emails_lowercase.php b/html/ops/make_emails_lowercase.php index ff366d71ed..202847265c 100644 --- a/html/ops/make_emails_lowercase.php +++ b/html/ops/make_emails_lowercase.php @@ -20,23 +20,22 @@ 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); +$query = "select id, email_addr,cross_project_id from user"; +$result = mysql_query($query); + +// loop over all users +while ($user = mysql_fetch_object($result)) { + + $id=$user->id; $email_addr=$user->email_addr; $cpid=$user->cross_project_id; - + $new_email=strtolower(trim($email_addr)); if (strcmp($email_addr, $new_email)) @@ -49,18 +48,18 @@ for ($id=1; $id<=$number_of_users; $id++) { 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"; + $update="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
"; + mysql_query($update); + echo "Doing $update
\n"; } } } +mysql_free_result($result); echo " \n