Changeset 873 for trunk/Modules/NetworkTopology/topologie-img.php
- Timestamp:
- Apr 6, 2020, 11:17:40 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Modules/NetworkTopology/topologie-img.php
r738 r873 3 3 include('../global.php'); 4 4 5 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug'];5 if (array_key_exists('debug', $_GET)) $debug = $_GET['debug']; 6 6 else $debug = 0; 7 7 $TopHostName = 'nix-router'; … … 13 13 global $debug, $bbound; 14 14 15 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;16 if ($i = $vfirst[$id])15 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 16 if ($i = $vfirst[$id]) 17 17 { 18 18 //if ($debug==2) echo $id.':'.@$i.','.@$vpred[$i].'-'.@$vleft[@$vpred[$i]]."\n"; … … 37 37 $vleft[$i]+=$diff; 38 38 $limit = balance($i,$level+1, $vlast,$vleft,$vpred, $vfirst,$vnext,$tbound, $width, $limit) + 2; 39 if (!array_key_exists($i, $vnext)) $vnext[$i] = 0;39 if (!array_key_exists($i, $vnext)) $vnext[$i] = 0; 40 40 $i = $vnext[$i]; 41 41 } … … 91 91 $item = $DbResult->fetch_array(); 92 92 //print_r($item); 93 if ($item)93 if ($item) 94 94 { 95 95 // --- Zpracování položky z DB ----------------------------------------------- 96 if ($position[$level] > 0)96 if ($position[$level] > 0) 97 97 { 98 98 $vnext[$curr] = $item['id']; // Neprvní položka, nastav předchozí … … 103 103 $vlast[$parent[$level]] = $curr; 104 104 $vtop[$curr] = $level; 105 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;105 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0; 106 106 $vleft[$curr] = $tbound[$level]; 107 if (!array_key_exists($level, $tranger)) $tranger[$level] = 0;107 if (!array_key_exists($level, $tranger)) $tranger[$level] = 0; 108 108 $vpred[$curr] = $tranger[$level]; 109 109 $tranger[$level] = $curr; … … 117 117 { 118 118 // Uzelový vrchol 119 if (array_key_exists($level + 1, $tbound))120 if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1];119 if (array_key_exists($level + 1, $tbound)) 120 if ($tbound[$level + 1] > $vleft[$curr]) $vleft[$curr] = $tbound[$level + 1]; 121 121 } 122 122 $tbound[$level] = $vleft[$curr] + 2; … … 133 133 { 134 134 // --- Zarovnávání prvků kvůli vzhledu 135 if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0;136 if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0;135 if (!array_key_exists($vfirst[$parent[$level]], $vleft)) $vleft[$vfirst[$parent[$level]]] = 0; 136 if (!array_key_exists($parent[$level], $vleft)) $vleft[$parent[$level]] = 0; 137 137 if ($vleft[$vfirst[$parent[$level]]] > $vleft[$parent[$level]]) 138 138 { … … 146 146 } 147 147 $level--; 148 if (!array_key_exists($level, $parent)) $parent[$level] = 0;149 if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0;148 if (!array_key_exists($level, $parent)) $parent[$level] = 0; 149 if (!array_key_exists($parent[$level], $vlast)) $vlast[$parent[$level]] = 0; 150 150 $curr = $vlast[$parent[$level]]; 151 151 152 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0;153 if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0;154 if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level];155 } 156 } while ($level >= 0);152 if (!array_key_exists($level, $tbound)) $tbound[$level] = 0; 153 if (!array_key_exists($level + 1, $tbound)) $tbound[$level + 1] = 0; 154 if ($tbound[$level] > $tbound[$level + 1]) $tbound[$level + 1] = $tbound[$level]; 155 } 156 } while ($level >= 0); 157 157 $data = compact('tbound', 'count', 'tbound', 'vfirst', 'vlast', 'vtop', 'vleft', 'height', 'width', 'index', 'maxindex'); 158 return ($data);158 return ($data); 159 159 }; 160 160 … … 164 164 $data = gentree(1); 165 165 $datawidth = $data['width']; 166 for ($i = 0; $i <= $maxindex; $i++)167 { 168 if (!array_key_exists($i, $vleft)) $vleft[$i] = 0;169 if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0;166 for ($i = 0; $i <= $maxindex; $i++) 167 { 168 if (!array_key_exists($i, $vleft)) $vleft[$i] = 0; 169 if (!array_key_exists($i, $data['vleft'])) $data['vleft'][$i] = 0; 170 170 $vleft[$i] = .2 + ($vleft[$i] + ($datawidth - $data['vleft'][$i])) / 2; 171 171 } … … 179 179 $IconList = array(); 180 180 $DbResult = $Database->query('SELECT * FROM HostType'); 181 while ($HostType = $DbResult->fetch_assoc())181 while ($HostType = $DbResult->fetch_assoc()) 182 182 $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png'); 183 183 … … 194 194 { 195 195 global $vleft, $spacex; 196 return ($vleft[$id] * $spacex);196 return ($vleft[$id] * $spacex); 197 197 } 198 198 199 199 $DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1'); 200 while ($item = $DbResult->fetch_array())200 while ($item = $DbResult->fetch_array()) 201 201 { 202 202 $id = $item['id']; 203 if (!array_key_exists($id, $vtop)) $vtop[$id] = 0;204 if (($vtop[$id] > 0) || ($item['name'] == $TopHostName))203 if (!array_key_exists($id, $vtop)) $vtop[$id] = 0; 204 if (($vtop[$id] > 0) || ($item['name'] == $TopHostName)) 205 205 { 206 if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black);207 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0;208 if ($vfirst[$id] > 0)206 if ($vtop[$id] > 0) imageline($im, xpos($id) + $halfx, $vtop[$id] * $spacey, xpos($id) + $halfx, $vtop[$id] * $spacey + 8, $black); 207 if (!array_key_exists($id, $vfirst)) $vfirst[$id] = 0; 208 if ($vfirst[$id] > 0) 209 209 { 210 210 imageline($im, xpos($vfirst[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, xpos($vlast[$id]) + $halfx, $vtop[$id] * $spacey + $spacey, $black); … … 213 213 214 214 $image = $IconList[$item['type']]; 215 if ($item['IP'] == '')215 if ($item['IP'] == '') 216 216 { 217 217 $color = $gray; 218 218 } else 219 if ($item['ShowOnline'] == 1)220 { 221 if ($item['online'] == 1) $color = $green; else $color = $black;222 } else 223 { 224 if ($item['online'] == 1) $color = $green; else $color = $red;219 if ($item['ShowOnline'] == 1) 220 { 221 if ($item['online'] == 1) $color = $green; else $color = $black; 222 } else 223 { 224 if ($item['online'] == 1) $color = $green; else $color = $red; 225 225 } 226 226 // $text='IP: '.$ip[0]; … … 228 228 imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30); 229 229 // imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color); 230 if ($debug)230 if ($debug) 231 231 { 232 232 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color); … … 237 237 238 238 // === Sestavení výsledného souboru ============================================ 239 if (!($debug > 1))239 if (!($debug > 1)) 240 240 { 241 241 header('Content-type: image/png');
Note:
See TracChangeset
for help on using the changeset viewer.