Changeset 192 for trunk/is/topologie-img.php
- Timestamp:
- Apr 26, 2009, 11:30:31 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/is/topologie-img.php
r129 r192 112 112 $count[$level]++; 113 113 // --- Zjisti existenci potomků ---------------------------------------------- 114 $DbResult = $Database->query( "SELECT COUNT(*) FROM hosts WHERE used=1 AND parent = ".$curr);114 $DbResult = $Database->query('SELECT COUNT(*) FROM hosts WHERE used=1 AND parent = '.$curr); 115 115 $childcnt = $DbResult->fetch_array(); 116 116 if ($childcnt[0] > 0) … … 164 164 $data = gentree(1); 165 165 $datawidth = $data['width']; 166 for($i =0; $i <= $maxindex; $i++)166 for($i = 0; $i <= $maxindex; $i++) 167 167 { 168 168 if(!array_key_exists($i, $vleft)) $vleft[$i] = 0; … … 175 175 $halfx = $spacex / 2; 176 176 $halfy = $spacey / 2; 177 // === Načtení pomocných obrázků =============================================== 178 $im_comp = imagecreatefrompng('images/comp.png'); 179 $im_dev = imagecreatefrompng('images/device.png'); 177 178 // Preload icon images 179 $IconList = array(); 180 $DbResult = $Database->query('SELECT * FROM HostType'); 181 while($HostType = $DbResult->fetch_assoc()) 182 $IconList[$HostType['Id']] = imagecreatefrompng('images/'.$HostType['IconName'].'.png'); 183 180 184 // === Generování obrázku ====================================================== 181 $im = imagecreate(($datawidth +$width+3.2) * $halfx, ($height + 1) * $spacey);185 $im = imagecreate(($datawidth + $width + 3.2) * $halfx, ($height + 1) * $spacey); 182 186 $background_color = imagecolorallocate($im, 255, 255, 255); 183 187 $black = imagecolorallocate($im, 0, 0, 0); … … 193 197 } 194 198 195 $DbResult = $Database->query( "SELECT * FROM hosts WHERE used=1");199 $DbResult = $Database->query('SELECT * FROM hosts JOIN HostType ON HostType.Id = hosts.type WHERE hosts.used=1'); 196 200 while($item = $DbResult->fetch_array()) 197 201 { … … 207 211 imageline($im, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey - 10, xpos($id) + $halfx, ($vtop[$id] + 1) * $spacey, $black); 208 212 } 209 $ip = explode('.',$item['IP']); 210 if(!array_key_exists(3, $ip)) $ip[3] = ''; 211 if($ip[3] < 100) 212 { 213 $image = $im_comp; 214 } else $image = $im_dev; 215 if(($ip[0] != 192) and ($ip[0] != 168)) 216 { 217 $image = $im_dev; 218 } 219 if($item['IP'] == '') 220 { 213 214 $image = $IconList[$item['type']]; 215 if($item['IP'] == '') 216 { 221 217 $color = $gray; 222 $image = $im_dev; 223 } else 224 { 225 if((($ip[0] != 192) and ($ip[0] != 168)) or ($ip[3] >= 100) or ($ip[3] == 1)) 226 { 227 if($item['online'] == 1) { $color = $green; } else $color = $red; 228 } else 229 { 230 if($item['online'] == 1) { $color = $green; } else $color = $black; 231 } 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; 232 225 } 233 226 // $text='IP: '.$ip[0]; 234 227 // imagestring($im,2,xpos($id)+($spacex-strlen($text)*imagefontwidth(2))/2,$vtop[$id]*$spacey+24+imagefontheight(2),$text,$black); 235 imagecopy($im, $image, xpos($id) +$halfx-15,$vtop[$id]*$spacey+12, 0, 0, 30, 30);228 imagecopy($im, $image, xpos($id) + $halfx - 15, $vtop[$id] * $spacey + 12, 0, 0, 30, 30); 236 229 // imagerectangle($im,xpos($id)+$halfx-6,$vtop[$id]*$spacey+16,xpos($id)+$halfx+6,$vtop[$id]*$spacey+28,$color); 237 if ($debug) { 230 if($debug) 231 { 238 232 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['id']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), $item['id'], $color); 239 } else imagestring($im, 2, xpos($id) + ($spacex - strlen($item['name']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), strtoupper($item['name']), $color); 233 } else 234 imagestring($im, 2, xpos($id) + ($spacex - strlen($item['name']) * imagefontwidth(2)) / 2, $vtop[$id] * $spacey + 31 + imagefontheight(2), strtoupper($item['name']), $color); 240 235 } 241 236 } … … 244 239 if(!($debug > 1)) 245 240 { 246 header( "Content-type: image/png");247 header( "Cache-Control: no-cache"); // Dynamický graf, nekešovat241 header('Content-type: image/png'); 242 header('Cache-Control: no-cache'); 248 243 imagepng($im); 249 244 imagedestroy($im); 250 imagedestroy($im_comp); 251 imagedestroy($im_dev); 252 } 245 } 246 253 247 ?>
Note:
See TracChangeset
for help on using the changeset viewer.