source: newwww/finance/strom.php@ 3

Last change on this file since 3 was 3, checked in by george, 17 years ago

První pracovní verze nového webu.

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