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. 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.

svn path=/trunk/boinc/; revision=4596
This commit is contained in:
Bruce Allen 2004-11-18 13:14:28 +00:00
parent 4361518814
commit 174bcb427c
2 changed files with 76 additions and 2 deletions

View File

@ -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

View File

@ -0,0 +1,67 @@
<?php
echo "
<!-- Script for repairing user database if some email addresses in lower case and/or some CPID=0 -->\n
<!-- \$Id$ -->\n
";
require_once("../inc/util_ops.inc");
require_once("../inc/util.inc");
echo "
<HTML><HEAD><TITLE>User database repair script. Lowercae(email_addr) and set CPID!=0</TITLE></HEAD><BODY>\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<br/>";
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<br/>";
if (!(strcmp($cpid,"0"))) {
$newcpid=random_string();
echo "Problematic CPID=0 for [$id] $email_addr gets CPID=$newcpid<br/>";
}
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 <br/>[Modify html/ops/make_emails_lowercase.php to enable changes]<br/>";
else {
$result = mysql_query($query);
echo "Doing $query<br/>";
}
}
}
echo "
</BODY></HTML>\n
";