source: www/finance/strom.php@ 8

Last change on this file since 8 was 4, checked in by george, 18 years ago

Upraveno: Změna přístupu k databázi na třídu rozšířenou mysqli.
Upraveno: Sjednocení
Upraveno: Změna kódování všech stránek na UTF-8.
Odstraňeno: Staré nepotřebné soubory.

  • Property svn:executable set to *
File size: 3.7 KB
Line 
1<?php
2include('../global.php');
3include('../style.php');
4ShowHeader('Zařízení sítě', 'Zařízení');
5
6// Seznam segmentů a zařízení
7echo('Stromový výpis struktury sítě:<br>');
8$DbResult = $Database->query("SELECT * FROM network_segments WHERE parent = 0");
9$root = $DbResult->fetch_array();
10echo '<img src="../images/strom/server.png" width="16" height="16"/>&nbsp;'.$root['name'].'<br/>';
11$level = 0;
12$parent = array($root['id']);
13$position = array(0);
14$count = array(0);
15$DbResult = $Database->query("SELECT * FROM users WHERE network_segment = ".$parent[$level]);
16$count[0] += $DbResult->fetch_array();
17$DbResult = $Database->query("SELECT * FROM network_devices WHERE segment = ".$parent[$level]);
18$count[0] += $DbResult->fetch_array();
19$DbResult = $Database->query("SELECT * FROM network_segments WHERE parent = ".$parent[$level]);
20$count[0] += $DbResult->fetch_array();
21
22
23function showlines($type)
24{
25 global $count, $position, $level, $Database;
26
27 $i = 0;
28 while ($i < $level)
29 {
30 if ($position[$i]<$count[$i])
31 {
32 echo '<img src="../images/strom/line.gif" width="16" height="16"/>';
33 } else
34 {
35 echo '<img src="../images/strom/null.gif" width="16" height="16"/>';
36 }
37 $i++;
38 }
39 if ($type==0)
40 {
41 if ($position[$i]<$count[$i])
42 {
43 echo '<img src="../images/strom/sub.gif" width="16" height="16"/>';
44 } else
45 {
46 echo '<img src="../images/strom/sub_.gif" width="16" height="16"/>';
47 }
48 } else
49 {
50 if ($position[$i]<$count[$i])
51 {
52 echo '<img src="../images/strom/plus.gif" width="16" height="16"/>';
53 } else {
54 echo '<img src="../images/strom/plus_.gif" width="16" height="16"/>';
55 }
56 }
57 return 0;
58}
59
60do
61{
62 if ($position[$level]==0)
63 {
64 $DbResult = $Database->query("SELECT * FROM users WHERE network_segment = ".$parent[$level]);
65 $devs = 0;
66 while ($item = $DbResult->fetch_array)
67 {
68 $position[$level]++;
69 $devs++;
70 showlines(0);
71 echo '<img src="../images/strom/comp.png" width="16" height="16"/>&nbsp;'.$item['fullname'].'<br/>';
72 }
73 $position[$level] = 0;
74 $count[$level] -= $devs;
75 }
76 if ($position[$level]==0)
77 {
78 $DbResult = $Database->query("SELECT * FROM network_devices WHERE segment = ".$parent[$level]);
79 $devs = 0;
80 while ($item = $DbResult->fetch_array())
81 {
82 $position[$level]++;
83 $devs++;
84 if ($item['used']==1)
85 {
86 showlines(0);
87 echo '<img src="../images/strom/device.png" width="16" height="16"/>&nbsp;'.$item['name'].'<br/>';
88 } else {
89// showlines(0);
90// echo '<img src="../images/strom/device_.png" width="16" height="16"/>&nbsp;'.$item['name'].'<br/>';
91 }
92 }
93 $position[$level] = 0;
94 $count[$level] -= $devs;
95 }
96 if ($position[$level]<$count[$level])
97 {
98 $DbResult = $Database->query("SELECT * FROM network_segments WHERE parent = ".$parent[$level].' LIMIT '.$position[$level].',1');
99 $item = $DbResult->fetch_array;
100 if (!$item)
101 {
102 echo '<br/>Došlo k chybě!!</br>';
103 break;
104 }
105 $position[$level]++;
106 showlines(1);
107 echo '<img src="../images/strom/volume.png" width="16" height="16"/>&nbsp;'.$item['name'].'<br/>';
108 $level++;
109 $parent[$level]=$item['id'];
110 $position[$level] = 0;
111 $count[$level] = 0;
112 $DbResult = $Database->query("SELECT * FROM users WHERE network_segment = ".$parent[$level]);
113 $count[$level] += $DbResult->fetch_array;
114 $DbResult = $Database->query("SELECT * FROM network_devices WHERE segment = ".$parent[$level]);
115 $count[$level] += $DbResult->fetch_array;
116 $DbResult = $Database->query("SELECT * FROM network_segments WHERE parent = ".$parent[$level]);
117 $count[$level] += $DbResult->fetch_array;
118 } else
119 {
120 $level--;
121 }
122} while($level >= 0);
123
124ShowFooter();
125?>
Note: See TracBrowser for help on using the repository browser.