false); foreach($locations as $l) $_SESSION['alx_sort_loc'][$l]=true; } if(isset($_GET['s_krit'])) { $_SESSION['alx_sort_krit']=$_GET['s_krit']; $_SESSION['alx_sort_onfirst']=0+$_GET['s_on']; $_SESSION['alx_sort_loc']['DEAD']=$_GET['s_dead']; foreach($locations as $l) $_SESSION['alx_sort_loc'][$l]=$_GET['s_'.$l]; } function check_online($dat, $bla) { global $comps; global $pingcmd; if(!isset($comps[$dat['serial']])) return false; //passthru("/bin/ping -I eth0 -c 1 -W 1 -q ".$dat['ip']." &> /dev/null && exit 0 || exit 1",$retval); passthru($pingcmd." ".$dat['ip']." &> /dev/null && exit 0 || exit 1",$retval); if($retval==0) { $comps[$dat['serial']]['online'] = true; $comps[$dat['serial']]['ip'] = $dat['ip']; } else $comps[$dat['serial']]['ip'] = ''.$dat['ip'].' (no ping)'; $comps[$dat['serial']]['hostname'] = $dat['hostname']; $comps[$dat['serial']]['mac'] = $dat['mac']; } function sortcomp($a,$b) { if($a['serial']<0 && $b['serial']>0) return -1; if($a['serial']>0 && $b['serial']<0) return 1; if($_SESSION['alx_sort_onfirst']) { if($a['online'] && !$b['online']) return -1; if($b['online'] && !$a['online']) return 1; } if($_SESSION['alx_sort_krit']=='hostname') { if(strtoupper($a['hostname'])strtoupper($b['hostname'])) return 1; } return $a['serial']-$b['serial']; } function checkif($b) { if($b) return ' checked'; else return ''; } $comps = sqlarr("SELECT s.serial, s.location, s.mac, n.hostname, t.mtime FROM cfg_network n,client_serials s,state_connected t WHERE n.serial=s.serial OR t.serial=s.serial", "serial"); sqlforeach('SELECT serial, ip, hostname, mac FROM state_connected', 'check_online', null); usort($comps, 'sortcomp'); echo ''; echo ''; echo 'ALX Config - Index'; echo ''; echo ''; echo ''; echo ''; //echo ''; if($reload!='off') echo ''; /* echo ''; echo '[REFRESH]
'; echo '
SORT BY serial hostname'; echo 'online clients on top

'; */ echo '
'; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo '
[REFRESH]
SORT BY serial hostname
'; echo 'online clients on top
'; foreach($locations as $l) echo ''.($l=='' ? '?' : $l).''; echo '
'; echo 'DEACTIVATED'; echo '

'; echo '
'; echo ''; echo ''; if($showversion=='on') echo ''; echo ''; foreach($comps as $c) { if(!$_SESSION['alx_sort_loc'][$c['location']]) Continue; if($c['serial']<0 && !$_SESSION['alx_sort_loc']['DEAD']) Continue; if($c['online']) $pic='online'; else $pic='offline'; if($c['serial']<0) { echo ''; $pic = 'deact'; } else echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; echo ''; if($c['mtime']) { echo ''; } //if($c['mtime']) { echo ''; } else echo ''; if($c['online']) { if($showversion=='on') { $pubkey = mysql_query('select public_key from ssh_auth_clients where serial='.$c['serial'].''); while ($row = mysql_fetch_row ($pubkey)) { # schreiben der .ssh/known_hosts file mit dem public rsa key des client, # um die "yes" abfrage zu vermeiden $hostfile = fopen ($home."/.ssh/known_hosts","w"); fwrite($hostfile,$c['ip']." ".$row[0],strlen($row[0])+strlen($c['ip'])+1); fclose($hostfile); $osver = exec($sshcmd.' '.$c['ip'].' \'os_ver=$('.$osver[0].''; echo ''; } } echo ''; echo ''; } echo '
editserialhostnameiplast connectedversionup/down
'.substr($c['location'],0,1).''.strtoupper($pic).'#'.$c['serial'].''.$c['hostname'].''.$c['ip'].''.date('Y-m-d, H:i:s',$c['mtime']).''.$c['mtime'].''.$osver[1].''; if($c['online']) { echo ''; echo ''; echo ''; echo ''; } else echo ''; echo '

'; echo ''; ?>