source: trunk/hostlist.php@ 358

Last change on this file since 358 was 358, checked in by chronos, 13 years ago
  • Opraveno: Generovalo se na výstup chybně odřádkování před začátek dokumentu díky nadbytečnému odřádkování za ukončením php v souboru Meals.php. Pak nebylo možné generovat dynamicky obrázky.
  • Upraveno: Generování topologie přesunuto do systémového modulu NetworkTopology.
  • Property svn:executable set to *
File size: 3.1 KB
Line 
1<?php
2include_once('global.php');
3
4class HostListPage extends Page
5{
6 var $FullTitle = 'Seznam registrovaných počítačů';
7 var $ShortTitle = 'Seznam počítačů';
8
9 function Show()
10 {
11 if(array_key_exists('admin', $_GET)) $Where = 'AND NetworkDevice.Type IN (1,4,5) ';
12 else $Where = '';
13 $Output = '<div align="center" style="font-size: small;"><table class="WideTable">';
14 $Output .= '<tr><th>Jméno počítače</th><th>IP adresa</th><th>Typ</th><th>Naposledy online</th><th>Správce</th></tr>';
15 $DbResult = $this->Database->query('SELECT NetworkDevice.*, User.Name as UserName, NetworkDeviceType.Name AS HostType FROM NetworkDevice LEFT JOIN Member ON Member.Id = NetworkDevice.Member LEFT JOIN User ON Member.ResponsibleUser = User.Id LEFT JOIN NetworkDeviceType ON NetworkDeviceType.Id = NetworkDevice.Type WHERE NetworkDevice.Used = 1 '.$Where.'ORDER BY NetworkDevice.Name');
16 while($Device = $DbResult->fetch_assoc())
17 {
18 if($Device['Online'] == 1) $Style = 'color: blue;'; else $Style = '';
19 $DbResult2 = $this->Database->query('SELECT COUNT(*) FROM NetworkInterface WHERE Device = '.$Device['Id']);
20 $DbRow = $DbResult2->fetch_row();
21 if($DbRow[0] == 1)
22 {
23 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
24 $Interface = $DbResult2->fetch_assoc();
25 if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
26 if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
27 $InterfaceName = $Device['Name'];
28 if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
29 $Output .= '<tr><td style="text-align: left; '.$Style.'">'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
30 } else
31 {
32 $Output .= '<tr><td colspan="2" style="text-align: left; font-weight: bold; '.$Style.'">'.$Device['Name'].'</td><td>'.$Device['HostType'].'</td><td style="text-align: right;">'.HumanDate($Device['LastOnline']).'</td><td style="text-align: right;">'.$Device['UserName'].'</td></tr>';
33 $DbResult2 = $this->Database->query('SELECT * FROM NetworkInterface WHERE Device = '.$Device['Id']);
34 while($Interface = $DbResult2->fetch_assoc())
35 {
36 if($Interface['LocalIP'] == '') $Interface['LocalIP'] = '&nbsp;';
37 if($Interface['Online'] == 1) $Style = 'font-weight: bold; color: blue;'; else $Style = '';
38 $InterfaceName = $Device['Name'];
39 if($Interface['Name'] != '') $InterfaceName .= '-'.$Interface['Name'];
40 $Output .= '<tr><td style="text-align: left; '.$Style.'">&nbsp;&nbsp;'.$InterfaceName.'</td><td>'.$Interface['LocalIP'].'</td><td>&nbsp;</td><td>&nbsp;</td><td>&nbsp;</td></tr>';
41 }
42 }
43 }
44 $Output .= '</table></div>';
45 return($Output);
46 }
47}
48
49$System->AddModule(new HostListPage());
50$System->Modules['HostListPage']->GetOutput();
51
52?>
Note: See TracBrowser for help on using the repository browser.