2007-05-30 20:30:28 +00:00
|
|
|
<?php
|
|
|
|
|
2007-05-30 21:35:14 +00:00
|
|
|
require_once("../inc/util.inc");
|
2007-05-30 20:30:28 +00:00
|
|
|
require_once("../inc/host.inc");
|
2007-10-28 15:03:14 +00:00
|
|
|
require_once("../inc/boinc_db.inc");
|
2007-05-30 20:30:28 +00:00
|
|
|
|
|
|
|
db_init();
|
|
|
|
|
|
|
|
function merge_name($list) {
|
|
|
|
// find the newest one
|
|
|
|
//
|
|
|
|
$newest_host = $list[0];
|
|
|
|
echo "<br><br>Processing $newest_host->domain_name\n";
|
|
|
|
foreach ($list as $host) {
|
|
|
|
if ($host->create_time > $newest_host->create_time) {
|
|
|
|
$newest_host = $host;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
foreach ($list as $host) {
|
|
|
|
if ($host->id == $newest_host->id) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$error = merge_hosts($host, $newest_host);
|
|
|
|
if (!$error) {
|
2007-10-24 17:35:28 +00:00
|
|
|
echo "<br>Merged $host->id into $newest_host->id\n";
|
2007-05-30 20:30:28 +00:00
|
|
|
} else {
|
|
|
|
echo "<br>$error\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function merge_by_name($userid) {
|
|
|
|
$hosts = array();
|
2007-10-28 15:03:14 +00:00
|
|
|
$host_list = BoincHost::enum("userid=$userid");
|
|
|
|
foreach($host_list as $host) {
|
2007-05-30 20:30:28 +00:00
|
|
|
$hosts[$host->domain_name][] = $host;
|
|
|
|
}
|
|
|
|
foreach($hosts as $hlist) {
|
|
|
|
merge_name($hlist);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$user = get_logged_in_user();
|
|
|
|
|
|
|
|
page_head("Merge computers by name");
|
|
|
|
|
|
|
|
if ($_GET['confirmed']) {
|
2007-05-30 21:35:14 +00:00
|
|
|
check_tokens($user->authenticator);
|
2007-05-30 20:30:28 +00:00
|
|
|
merge_by_name($user->id);
|
|
|
|
echo "
|
|
|
|
<p><a href=hosts_user.php>
|
|
|
|
Return to the list of your computers</a>.
|
|
|
|
";
|
|
|
|
} else {
|
2007-05-30 21:35:14 +00:00
|
|
|
$tokens = url_tokens($user->authenticator);
|
2007-05-30 20:30:28 +00:00
|
|
|
echo "
|
2007-10-24 17:35:28 +00:00
|
|
|
This operation merges computers based on their domain name.
|
2007-05-30 20:30:28 +00:00
|
|
|
<p>
|
2007-10-24 17:35:28 +00:00
|
|
|
For each domain name, it will merge all older computers
|
2007-05-30 20:30:28 +00:00
|
|
|
having that name with the newest computer having that name.
|
|
|
|
Incompatible computers will not be merged.
|
|
|
|
<p>
|
2007-10-24 17:35:28 +00:00
|
|
|
<a href=merge_by_name.php?confirmed=1&$tokens>Go ahead and do this</a>.
|
|
|
|
<p><a href=hosts_user.php>Return to the list of computers</a>.
|
2007-05-30 20:30:28 +00:00
|
|
|
";
|
|
|
|
}
|
|
|
|
page_tail();
|
|
|
|
?>
|