2009-09-07 11:07:59 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								< ? php  
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-07-28 19:43:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								### FIXME : remove link when port/host is not in the database (things /seen/ but not *discovered*)
  
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								###         No, that should be there... I like to see that stuff :> (adama)
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#  ini_set('display_errors', 1);
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#  ini_set('display_startup_errors', 1);
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#  ini_set('log_errors', 1);
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								#  ini_set('error_reporting', E_ALL);
  
						 
					
						
							
								
									
										
										
										
											2010-07-28 19:43:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-08-14 20:20:35 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								$links  =  1 ;  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								include_once ( " ../includes/defaults.inc.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								include_once ( " ../config.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								include_once ( " ../includes/functions.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								include_once ( " ../includes/dbFacile.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								include_once ( " includes/functions.inc.php " );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								include_once ( " includes/authenticate.inc.php " );  
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-17 11:48:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( is_array ( $config [ 'branding' ]))  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( $config [ 'branding' ][ $_SERVER [ 'SERVER_NAME' ]]) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    foreach  ( $config [ 'branding' ][ $_SERVER [ 'SERVER_NAME' ]]  as  $confitem  =>  $confval ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-17 11:48:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      eval ( " \$ config[' "  .  $confitem  .  " '] =  \$ confval; " ); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    foreach  ( $config [ 'branding' ][ 'default' ]  as  $confitem  =>  $confval ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      eval ( " \$ config[' "  .  $confitem  .  " '] =  \$ confval; " ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-17 11:48:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-17 11:48:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2010-07-04 13:33:38 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( isset ( $_GET [ 'device' ]))  {  $where  =  " WHERE device_id =  " . mres ( $_GET [ 'device' ]);  }  else  {  $where  =  " " ;  }  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								## FIXME this shit probably needs tidied up.
  
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2010-01-17 21:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								if  ( isset ( $_GET [ 'format' ])  &&  preg_match ( " /^[a-z]* $ / " ,  $_GET [ 'format' ]))  
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:23:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  $map  =  " digraph G  {  sep=0.01; size= \" 12,5.5 \" ; pack=100; bgcolor=transparent; splines=true; overlap=scale; concentrate=0; epsilon=0.001; rankdir=0;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     node  [  fontname = \ " helvetica \" , fontstyle=bold, style=filled, color=white, fillcolor=lightgrey, overlap=false;];
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     edge  [  bgcolor = white ;  fontname = \ " helvetica \" ; fontstyle=bold; arrowhead=dot; arrowtail=dot];
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								     graph  [ bgcolor = transparent ;]; \n\n " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  if  ( ! $_SESSION [ 'authenticated' ]) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    $map  .=  " \" Not authenticated \"  [fontsize=20 fillcolor= \" lightblue \"  URL= \" / \"  shape=box3d] \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  else 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    foreach  ( dbFetch ( " SELECT * from devices  " . $where )  as  $device ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-22 20:27:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    { 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      if  ( $device ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      { 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $links  =  dbFetch ( " SELECT * from ports AS I, links AS L WHERE I.device_id = ? AND L.local_interface_id = I.interface_id ORDER BY L.remote_hostname " ,  array ( $device [ 'device_id' ])); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        if  ( count ( $links )) 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:23:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          $map  .=  " \" " . $device [ 'hostname' ] . " \"  [fontsize=20 fillcolor= \" lightblue \"  URL= \" { $config [ 'base_url' ] } /device/ " . $device [ 'device_id' ] . " /map/ \"  shape=box3d] \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        foreach   ( $links  as  $link ) 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          $local_interface_id  =  $link [ 'local_interface_id' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          $remote_interface_id  =  $link [ 'remote_interface_id' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          $i  =  0 ;  $done  =  0 ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								          if  ( $linkdone [ $remote_interface_id ][ $local_interface_id ])  {  $done  =  1 ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          if  ( ! $done ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          { 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $linkdone [ $local_interface_id ][ $remote_interface_id ]  =  TRUE ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 14:37:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $links ++ ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $link [ 'ifSpeed' ]  >=  " 10000000000 " ) 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:28:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $info  =  " color=red3 style= \" setlinewidth(6) \" " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  elseif  ( $link [ 'ifSpeed' ]  >=  " 1000000000 " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $info  =  " color=lightblue style= \" setlinewidth(4) \" " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  elseif  ( $link [ 'ifSpeed' ]  >=  " 100000000 " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $info  =  " color=lightgrey style= \" setlinewidth(2) \" " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  elseif  ( $link [ 'ifSpeed' ]  >=  " 10000000 " )  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $info  =  " style= \" setlinewidth(1) \" " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $info  =  " style= \" setlinewidth(1) \" " ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:28:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $src  =  $device [ 'hostname' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( $remote_interface_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $dst  =  dbFetchCell ( " SELECT `hostname` FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ? AND D.device_id = I.device_id " ,  array ( $remote_interface_id )); 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $dst_host  =  dbFetchCell ( " SELECT D.device_id FROM `devices` AS D, `ports` AS I WHERE I.interface_id = ?  AND D.device_id = I.device_id " ,  array ( $remote_interface_id )); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 14:37:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              unset ( $dst_host ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $dst  =  $link [ 'remote_hostname' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $sif  =  ifNameDescr ( dbFetchRow ( " SELECT * FROM ports WHERE `interface_id` = ? " ,  array ( $link [ 'local_interface_id' ])), $device ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $remote_interface_id ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2011-05-12 19:09:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $dif  =  ifNameDescr ( dbFetchRow ( " SELECT * FROM ports WHERE `interface_id` = ? " ,  array ( $link [ 'remote_interface_id' ])),  $device ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $dif [ 'label' ]  =  $link [ 'remote_port' ]; 
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 14:37:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $dif [ 'interface_id' ]  =  $link [ 'remote_hostname' ]  .  $link [ 'remote_port' ]; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-04-09 16:08:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            $map  .=  " \" "  .  $sif [ 'interface_id' ]  .  " \"  [label= \" "  .  $sif [ 'label' ]  .  " \" , fontsize=12, fillcolor=lightblue URL= \" { $config [ 'base_url' ] } /device/ " . $device [ 'device_id' ] . " /port/ $local_interface_id / \" ] \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( ! $ifdone [ $src ][ $sif [ 'interface_id' ]]) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $map  .=  " \" $src\ "  ->  \ " "  .  $sif [ 'interface_id' ]  .  " \"  [weight=500000, arrowsize=0, len=0]; \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $ifdone [ $src ][ $sif [ 'interface_id' ]]  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 14:37:54 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $dst_host )  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-20 11:19:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $map  .=  " \" $dst\ "  [ URL = \ " { $config [ 'base_url' ] } /device/ $dst_host /map/ \"  fontsize=20 shape=box3d] \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $map  .=  " \" $dst\ "  [  fontsize = 20  shape = box3d ] \n " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-27 10:21:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            if  ( $dst_host  ==  $device [ 'device_id' ]  ||  $where  ==  '' ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-09 16:08:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $map  .=  " \" "  .  $dif [ 'interface_id' ]  .  " \"  [label= \" "  .  $dif [ 'label' ]  .  " \" , fontsize=12, fillcolor=lightblue, URL= \" { $config [ 'base_url' ] } /device/ $dst_host /port/ $remote_interface_id / \" ] \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-09 16:08:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								              $map  .=  " \" "  .  $dif [ 'interface_id' ]  .  " \"  [label= \" "  .  $dif [ 'label' ]  .  "   \" , fontsize=12, fillcolor=lightgray, URL= \" { $config [ 'base_url' ] } /device/ $dst_host /port/ $remote_interface_id / \" ] \n " ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            if  ( ! $ifdone [ $dst ][ $dif [ 'interface_id' ]]) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $map  .=  " \" "  .  $dif [ 'interface_id' ]  .  " \"  ->  \" $dst\ "  [ weight = 500000 ,  arrowsize = 0 ,  len = 0 ]; \n " ;
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								              $ifdone [ $dst ][ $dif [ 'interface_id' ]]  =  1 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								            $map  .=  " \" "  .  $sif [ 'interface_id' ]  .  " \"  ->  \" "  .  $dif [ 'interface_id' ]  .  " \"  [weight=1, arrowhead=normal, arrowtail=normal, len=2,  $info ]  \n " ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								          } 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:23:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								        $done  =  0 ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								      } 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:23:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    } 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  $map  .=  " 
 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}; " ;
  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( $_GET [ 'debug' ]  ==  1 )  {  echo ( " <pre> $map </pre> " ); exit ();  } 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  switch  ( $_GET [ 'format' ]) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    case  'svg' : 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-18 17:29:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    case  'png' : 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      break ; 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-19 13:29:47 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    default : 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								      $_GET [ 'format' ]  =  'png' ; 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2010-06-18 17:29:02 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( $links  >  10 )  ### Unflatten if there are more than 10 links. beyond that it gets messy
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-27 13:51:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $maptool  =  'unflatten -f -l 5 | dot' ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }  else  { 
							 
						 
					
						
							
								
									
										
										
										
											2011-04-27 13:51:30 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $maptool  =  'dot' ; 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2010-08-05 23:21:57 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-09-20 15:59:51 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( $where  ==  '' )  {  $maptool  =  'sfdp -Gpack -Gcharset=latin1 -Gsize=200,200' ;  } 
							 
						 
					
						
							
								
									
										
										
										
											2010-07-30 15:04:44 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  $img  =  shell_exec ( " echo  \" " . addslashes ( $map ) . " \"  |  $maptool  -T " . $_GET [ 'format' ] . " " ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-27 10:21:19 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( $_GET [ 'format' ]  ==  " png " ) 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:23:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    header ( " Content-type: image/ " . $_GET [ 'format' ]); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  }  elseif  ( $_GET [ 'format' ]  ==  " svg " )  { 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-09 18:23:39 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    header ( " Content-type: image/svg+xml " ); 
							 
						 
					
						
							
								
									
										
										
										
											2010-11-19 22:46:24 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								    $img  =  str_replace ( " <a  " ,  '<a target="_parent" ' ,  $img ); 
							 
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  echo ( " $img " ); 
							 
						 
					
						
							
								
									
										
										
										
											2009-03-11 14:54:13 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2010-01-17 21:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								else  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								{  
						 
					
						
							
								
									
										
										
										
											2011-03-23 09:54:56 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								  if  ( $_SESSION [ 'authenticated' ])  ## FIXME level 10 only?
 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  { 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    echo ( ' < center > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    < object  data = " '.  $config['base_url']  . '/map.php?format=svg "  type = " image/svg+xml " > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								    </ object > 
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								</ center > ' );  
						 
					
						
							
								
							 
							
								
							 
							
								 
							
							
								  } 
							 
						 
					
						
							
								
									
										
										
										
											2010-01-17 21:30:12 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								}  
						 
					
						
							
								
									
										
										
										
											2011-03-17 11:48:03 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-04-20 11:19:46 +00:00 
										
									 
								 
							 
							
								
									
										 
								
							 
							
								 
							
							
								?>