2003-03-21 04:38:55 +00:00
|
|
|
<?php
|
2008-08-05 22:43:14 +00:00
|
|
|
// This file is part of BOINC.
|
|
|
|
// http://boinc.berkeley.edu
|
|
|
|
// Copyright (C) 2008 University of California
|
|
|
|
//
|
|
|
|
// BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
// under the terms of the GNU Lesser General Public License
|
|
|
|
// as published by the Free Software Foundation,
|
|
|
|
// either version 3 of the License, or (at your option) any later version.
|
|
|
|
//
|
|
|
|
// BOINC is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
// See the GNU Lesser General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU Lesser General Public License
|
|
|
|
// along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
2007-10-28 15:03:14 +00:00
|
|
|
|
|
|
|
require_once("../inc/boinc_db.inc");
|
|
|
|
require_once("../inc/util.inc");
|
|
|
|
require_once("../inc/host.inc");
|
2003-03-21 04:38:55 +00:00
|
|
|
|
2003-12-01 06:08:22 +00:00
|
|
|
function fail($msg) {
|
2004-01-08 00:09:26 +00:00
|
|
|
echo "Error: $msg";
|
2003-12-01 06:08:22 +00:00
|
|
|
page_tail();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2004-01-08 00:09:26 +00:00
|
|
|
function get_host($hostid, $user) {
|
2007-10-28 15:03:14 +00:00
|
|
|
$host = BoincHost::lookup_id($hostid);
|
2004-01-08 00:09:26 +00:00
|
|
|
if (!$host || $host->userid != $user->id) {
|
2004-05-30 21:47:11 +00:00
|
|
|
fail("We have no record of that computer");
|
2003-03-21 04:38:55 +00:00
|
|
|
}
|
2004-01-08 00:09:26 +00:00
|
|
|
return $host;
|
|
|
|
}
|
2003-12-01 06:08:22 +00:00
|
|
|
|
2005-10-23 07:11:23 +00:00
|
|
|
$user = get_logged_in_user();
|
2004-01-08 00:09:26 +00:00
|
|
|
|
2011-08-25 22:12:48 +00:00
|
|
|
page_head(tra("Merge computer records"));
|
2004-01-08 00:09:26 +00:00
|
|
|
|
2005-11-23 01:54:18 +00:00
|
|
|
$nhosts = get_int("nhosts");
|
|
|
|
$hostid = get_int("id_0");
|
2005-10-23 07:11:23 +00:00
|
|
|
$latest_host = get_host($hostid, $user);
|
|
|
|
for ($i=1; $i<$nhosts; $i++) {
|
2010-11-04 18:20:57 +00:00
|
|
|
$var = "id_$i";
|
|
|
|
$hostid = get_int($var, true);
|
2005-12-10 02:21:06 +00:00
|
|
|
if (!$hostid) continue;
|
2010-11-04 18:20:57 +00:00
|
|
|
$host = get_host($hostid, $user);
|
|
|
|
if ($host->create_time > $latest_host->create_time) {
|
|
|
|
$error = merge_hosts($latest_host, $host);
|
2007-05-30 20:30:28 +00:00
|
|
|
if ($error) {
|
2009-02-19 04:36:56 +00:00
|
|
|
echo "<br>$error\n";
|
|
|
|
continue;
|
2007-05-30 20:30:28 +00:00
|
|
|
}
|
2010-11-04 18:20:57 +00:00
|
|
|
$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);
|
2005-10-23 07:11:23 +00:00
|
|
|
}
|
|
|
|
echo "
|
2011-08-25 22:12:48 +00:00
|
|
|
<p><a href=hosts_user.php>".tra("Return to list of your computers")."</a>
|
2005-10-23 07:11:23 +00:00
|
|
|
";
|
|
|
|
page_tail();
|
2004-01-08 00:09:26 +00:00
|
|
|
|
2005-10-23 07:11:23 +00:00
|
|
|
//Header("Location: show_host_detail.php?hostid=$latest_host->id");
|
2003-03-21 04:38:55 +00:00
|
|
|
|
|
|
|
?>
|