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/>.
2003-03-21 04:38:55 +00:00
2007-10-28 15:03:14 +00:00
require_once ( " ../inc/boinc_db.inc " );
2004-02-02 23:34:39 +00:00
require_once ( " ../inc/util.inc " );
require_once ( " ../inc/host.inc " );
2003-03-21 04:38:55 +00:00
2011-02-09 22:11:34 +00:00
check_get_args ( array ( " hostid " , " detail " ));
2003-03-21 04:38:55 +00:00
$user = get_logged_in_user ();
2005-02-15 22:29:32 +00:00
$hostid = get_int ( " hostid " );
2007-10-28 15:03:14 +00:00
$host = BoincHost :: lookup_id ( $hostid );
2003-03-21 04:38:55 +00:00
if ( ! $host || $host -> userid != $user -> id ) {
2005-02-15 22:29:32 +00:00
error_page ( " We have no record of that computer " );
2003-03-21 04:38:55 +00:00
}
2008-01-12 00:15:24 +00:00
$detail = get_int ( 'detail' , true );
2011-08-25 22:12:48 +00:00
page_head ( tra ( " Merge computers " ));
2005-02-15 22:29:32 +00:00
2003-03-21 21:45:34 +00:00
$t = time_str ( $host -> create_time );
2011-08-25 22:12:48 +00:00
echo tra ( " Sometimes BOINC assigns separate identities to the same computer by mistake. You can correct this by merging old identities with the newest one. " ) . "
< form name = host_list action = host_edit_action . php >
2004-01-08 00:09:26 +00:00
< input type = hidden name = id_0 value = $hostid >
< p >
2003-03-21 04:38:55 +00:00
" ;
2007-10-28 15:03:14 +00:00
$all_hosts = BoincHost :: enum ( " userid= $user->id " );
2007-05-29 04:38:54 +00:00
2004-01-08 00:09:26 +00:00
$nhosts = 1 ;
2007-05-29 04:38:54 +00:00
$hosts = array ();
2007-10-28 15:03:14 +00:00
foreach ( $all_hosts as $host2 ) {
2003-03-21 21:45:34 +00:00
if ( $host -> id == $host2 -> id ) continue ;
2008-01-12 00:15:24 +00:00
if ( ! hosts_compatible ( $host , $host2 , $detail )) continue ;
2007-05-29 04:38:54 +00:00
$hosts [] = $host2 ;
$nhosts ++ ;
if ( $nhosts == 500 ) break ;
}
if ( $nhosts == 1 ) {
2011-08-25 22:12:48 +00:00
echo " <br> " . tra ( " No hosts are eligible for merging with this one. " );
2008-01-12 00:15:24 +00:00
if ( ! $detail ) {
2011-08-25 22:12:48 +00:00
echo " <p><a href=host_edit_form.php?hostid= $hostid &detail=1> " . tra ( " Show details " ) . " </a>
2008-01-12 00:15:24 +00:00
" ;
}
2007-05-29 04:38:54 +00:00
page_tail ();
exit ();
}
echo "
2011-08-25 22:12:48 +00:00
< p > "
. tra ( " Check the computers that are the same as %1 (created %2, computer ID %3): " , $host -> domain_name , $t , $host -> id ) . "
2007-05-29 04:38:54 +00:00
< p >
" ;
start_table ();
2011-08-25 22:12:48 +00:00
row_heading_array ( array ( " " , tra ( " name " ), tra ( " created " ), tra ( " computer ID " )));
2007-05-30 17:25:51 +00:00
$i = 1 ;
2007-05-29 04:38:54 +00:00
foreach ( $hosts as $host2 ) {
2003-03-21 21:45:34 +00:00
$t = time_str ( $host2 -> create_time );
2004-03-20 01:35:37 +00:00
$x = $host2 -> domain_name ;
if ( $x == " " ) {
2011-08-25 22:12:48 +00:00
$x = " [ " . tra ( " no hostname " ) . " ] " ;
2004-03-20 01:35:37 +00:00
}
2005-04-08 00:06:52 +00:00
row_array ( array (
2007-05-30 17:25:51 +00:00
" <input type=checkbox name=id_ $i value= $host2->id > " ,
2005-04-07 20:46:25 +00:00
$x ,
" $t " ,
" $host2->id "
2007-05-30 17:25:51 +00:00
));
$i ++ ;
2004-01-08 00:09:26 +00:00
}
2005-04-07 20:46:25 +00:00
end_table ();
2004-01-08 00:09:26 +00:00
echo "
< br >
< script >
function set_all () {
" ;
for ( $i = 1 ; $i < $nhosts ; $i ++ ) {
2011-08-25 22:12:48 +00:00
echo " document.host_list.id_ $i .checked=1; \n " ;
2004-01-08 00:09:26 +00:00
}
echo "
}
function clear_all () {
" ;
for ( $i = 1 ; $i < $nhosts ; $i ++ ) {
2011-08-25 22:12:48 +00:00
echo " document.host_list.id_ $i .checked=0; \n " ;
2003-03-21 04:38:55 +00:00
}
echo "
2004-01-08 00:09:26 +00:00
}
</ script >
< p >< a href = javascript : set_all () > Select all </ a >
< p >< a href = javascript : clear_all () > Unselect all </ a >
< input type = hidden name = nhosts value = $nhosts >
2011-08-25 22:12:48 +00:00
< p >< input type = submit value = '".tra("Merge hosts")."' >
2003-03-21 04:38:55 +00:00
</ form >
" ;
2008-01-12 00:15:24 +00:00
if ( ! $detail ) {
2011-08-25 22:12:48 +00:00
echo " <p><a href=host_edit_form.php?hostid= $hostid &detail=1> " . tra ( " Show details " ) . " </a>
2008-01-12 00:15:24 +00:00
" ;
}
2003-03-21 04:38:55 +00:00
page_tail ();
?>