function merge_name($list) { // find the newest one // $newest_host = $list[0]; echo "<br><br>" . tra("Processing %1", $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) { echo "<br>" . tra("Merged %1 into %2", $host->id, $newest_host->id) . "\n"; } else { echo "<br>{$error}\n"; } // refresh from DB (otherwise credit increments get lost) $newest_host = BoincHost::lookup_id($newest_host->id); } }
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) { echo "<br>Merged {$host->id} into {$newest_host->id}\n"; } else { echo "<br>{$error}\n"; } } }
} $user = get_logged_in_user(); page_head("Merge computer records"); $nhosts = get_int("nhosts"); $hostid = get_int("id_0"); $latest_host = get_host($hostid, $user); for ($i = 1; $i < $nhosts; $i++) { $var = "id_{$i}"; $hostid = get_int($var, true); if (!$hostid) { continue; } $host = get_host($hostid, $user); if ($host->create_time > $latest_host->create_time) { $error = merge_hosts($latest_host, $host); if ($error) { echo "<br />{$error}\n"; continue; } $latest_host = $host; } else { merge_hosts($host, $latest_host); } // reread latest_host from database since we just // updated its credits // $latest_host = BoincHost::lookup_id($latest_host->id); } echo '<p><a href="hosts_user.php">Return to list of your computers</a></p>'; page_tail(); //Header("Location: show_host_detail.php?hostid=$latest_host->id");