--- alx-src/branches/alx-web-060/index.php 2011/05/09 16:31:38 2017 +++ alx-src/branches/alx-web-060/index.php 2011/06/07 13:12:26 2196 @@ -1,153 +1,152 @@ 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; + +include('include/basesql.php'); +session_start(); +session_register('alx_sort_krit'); session_register('alx_sort_onfirst'); session_register('alx_sort_loc'); + +$locations = sqlarr('SELECT location FROM client_locations', '', 'location'); +$locations[] = ''; + +if($_SESSION['alx_sort_krit']==null) +{ + $_SESSION['alx_sort_krit'] = 'serial'; + $_SESSION['alx_sort_onfirst'] = 1; + $_SESSION['alx_sort_loc'] = array('DEAD'=>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; + 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("/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']; + 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']; - } + $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; +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']; - } + { + 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 ''; } +function checkif($b) +{ + if($b) return ' checked'; + else return ''; +} - $comps = sqlarr("select client_serials.serial, client_serials.location, client_serials.mac, cfg_network.hostname, state_connected.mtime from client_serials left join cfg_network on client_serials.serial=cfg_network.serial left join state_connected on client_serials.serial=state_connected.serial", "serial"); +$comps = sqlarr("select client_serials.serial, client_serials.location, client_serials.mac, cfg_network.hostname, state_connected.mtime from client_serials left join cfg_network on client_serials.serial=cfg_network.serial left join state_connected on client_serials.serial=state_connected.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 ''; + echo 'ALX Config - Index'; + echo ''; +echo ''; +echo ''; +echo ''; +//echo ''; + +if($reload!='off') echo ''; + +/* +echo ''; +echo '[REFRESH]
'; + +echo 'SORT BYserial hostname'; +echo 'online clients on top
'; +*/ + +echo ''; +echo '
editserialhostnameiplast connectedversionup/down
'.substr($c['location'],0,1).''.strtoupper($pic).'#'.$c['serial'].''.$c['hostname'].'
'; +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 ''; + 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].''; @@ -156,23 +155,23 @@ } 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'].''; - if($c['online']) - { - echo ''; + if($c['online']) + { + echo ''; echo ''; echo ''; echo ''; } - else echo ''; + else echo ''; echo '

'; +} +echo '
'; - echo ''; +echo ''; ?> +$(document).ready(function(){ $("#mytab").tablesorter({ headers: { 0:{sorter: false}, 1:{sorter: false}, 5:{sorter: false}} } ); }); +