2012-05-23 00:25:19 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
// repair user.global_prefs fields that were corrupted
|
2012-05-25 20:39:37 +00:00
|
|
|
// (non-parsable XML) by a bug at some point.
|
|
|
|
//
|
|
|
|
// This fixes 2 types of corruption:
|
|
|
|
// - missing </venue> tag before closing </global_preferences>
|
|
|
|
// - \" instead of "
|
2012-05-23 00:25:19 +00:00
|
|
|
|
|
|
|
require_once("../inc/boinc_db.inc");
|
|
|
|
|
|
|
|
// insert "\n</venue>\n" before "</global_preferences>"
|
|
|
|
// This fixes an XML error introduced at some point in the past
|
|
|
|
//
|
|
|
|
function repair_prefs($prefs) {
|
2012-05-25 20:39:37 +00:00
|
|
|
if (strstr($prefs, '\"')) {
|
|
|
|
return str_replace('\"', '"', $prefs);
|
|
|
|
}
|
2012-05-23 00:25:19 +00:00
|
|
|
$x = strstr($prefs, "</global_preferences>", true);
|
|
|
|
if (!$x) return null;
|
|
|
|
return "$x\n </venue>\n</global_preferences>\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
function process_set($users) {
|
|
|
|
foreach ($users as $user) {
|
|
|
|
if (!$user->global_prefs) {
|
|
|
|
//echo "$user->id: no prefs\n";
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$retval = @simplexml_load_string($user->global_prefs);
|
|
|
|
if ($retval) {
|
|
|
|
//echo "$user->id: good\n";
|
|
|
|
} else {
|
2012-05-25 20:39:37 +00:00
|
|
|
echo "repairing prefs for user $user->id\n";
|
2012-05-23 00:25:19 +00:00
|
|
|
$p = repair_prefs($user->global_prefs);
|
|
|
|
if ($p) {
|
|
|
|
$retval = @simplexml_load_string($p);
|
|
|
|
if ($retval) {
|
|
|
|
$user->update("global_prefs='$p'");
|
2012-05-25 20:39:37 +00:00
|
|
|
echo " repair succeeded\n";
|
2012-05-23 00:25:19 +00:00
|
|
|
} else {
|
2012-05-25 20:39:37 +00:00
|
|
|
echo " repair failed\n";
|
2012-05-23 00:25:19 +00:00
|
|
|
}
|
|
|
|
} else {
|
2012-05-25 20:39:37 +00:00
|
|
|
echo " prefs are missing end tag\n";
|
2012-05-23 00:25:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$n = 0;
|
2012-05-25 20:39:37 +00:00
|
|
|
$maxid = BoincUser::max("id");
|
|
|
|
while ($n <= $maxid) {
|
|
|
|
$m = $n + 1000;
|
|
|
|
$users = BoincUser::enum("id >= $n and id < $m");
|
|
|
|
//echo "processing from $n\n";
|
2012-05-23 00:25:19 +00:00
|
|
|
if (!$users) break;
|
|
|
|
process_set($users);
|
2012-05-25 20:39:37 +00:00
|
|
|
$n = $m;
|
2012-05-23 00:25:19 +00:00
|
|
|
}
|
|
|
|
?>
|