query($sql); $loc_db->next_record(); $node_lat = $loc_db->f("latitude"); $node_long = $loc_db->f("longitude"); $total_layers = count($opt_view_top_map_layers); for ($i = 0; $i < $total_layers; $i++) { $layers .= "&layer=" . $opt_view_top_map_layers[$i]; } return "http://" . $opt_mapserver_server . $opt_mapserver_path ."?map=" . $opt_mapserver_mapfile . "&imgext=" . ($node_long - 0.03936) . "+" . ($node_lat - 0.022078) . "+" . ($node_long + 0.03936) . "+" . ($node_lat + 0.022078) . "&mode=map&zoom=" . $zoom . "&imgxy=175+175" . $layers; } function get_node_link_map($node_id, $zoom) { GLOBAL $opt_mapserver_server; GLOBAL $opt_mapserver_path; GLOBAL $opt_mapserver_mapfile; GLOBAL $opt_view_bottom_map_layers; $loc_db = new locDatabase; $sql = "SELECT latitude, longitude FROM nodes WHERE id='$node_id'"; $loc_db->query($sql); $loc_db->next_record(); $node_lat = $loc_db->f("latitude"); $node_long = $loc_db->f("longitude"); $total_layers = count($opt_view_bottom_map_layers); for ($i = 0; $i < $total_layers; $i++) { $layers .= "&layer=" . $opt_view_bottom_map_layers[$i]; } return "http://" . $opt_mapserver_server . $opt_mapserver_path ."?map=" . $opt_mapserver_mapfile . "&imgext=" . ($node_long - 0.03936) . "+" . ($node_lat - 0.022078) . "+" . ($node_long + 0.03936) . "+" . ($node_lat + 0.022078) . "&mode=map&zoom=" . $zoom . "&imgxy=175+175" . $layers; } function get_area_map_url($area_id) { GLOBAL $opt_mapserver_server; GLOBAL $opt_mapserver_path; GLOBAL $opt_mapserver_mapfile; GLOBAL $opt_area; GLOBAL $opt_area_map_layers; $total_layers = count($opt_area_map_layers); for ($i = 0; $i < $total_layers; $i++) { $layers .= "&layer=" . $opt_area_map_layers[$i]; } return "http://" . $opt_mapserver_server . $opt_mapserver_path ."?map=" . $opt_mapserver_mapfile . "&imgext=" . $opt_area[$area_id]["min_long"] . "+" . $opt_area[$area_id]["min_lat"] . "+" . $opt_area[$area_id]["max_long"] . "+" . $opt_area[$area_id]["max_lat"] . "&mode=map&imgxy=175+175" . $layers . "&layer=area_boundary_" . $area_id; } function update_shp_nodes() { GLOBAL $opt_shp_path_full; $loc_db = new locDatabase; // the locations of the shp files // that store the node locations $shp_file = $opt_shp_path_full . "nodes.shp"; $shx_file = $opt_shp_path_full . "nodes.shx"; $dbf_file = $opt_shp_path_full . "nodes.dbf"; $lock_file = $opt_shp_path_full . "lock.tmp"; // select all nodes so we can totally rewrite the shp files $sql = "SELECT * FROM nodes ORDER BY id"; $loc_db->query( $sql ); // if the shp files are currently being updated // wait 2 secs and try again. while(file_exists($lock_file)) { sleep(2); } // create the lock file to stop anyone else // editing the shp files while we rewrite them touch($lock_file); // remove the old data files exec("rm " . $shp_file); exec("rm " . $shx_file); exec("rm " . $dbf_file); // create the empty files exec("shpcreate " . $shp_file . " POINT"); exec("dbfcreate " . $dbf_file . " -s \"id\" 4 -s \"status\" 13 -s \"ospf_mode\" 20 -s \"area\" 2"); // then, for each node add the data while ($loc_db->next_record()) { exec("shpadd " . $shp_file . " " . $loc_db->f("longitude") . " " . $loc_db->f("latitude")); exec("dbfadd " . $dbf_file . " " . "\"" . $loc_db->f("id") . "\" \"" . strtolower($loc_db->f("status")) . "\" \"" . strtolower($loc_db->f("ospf_mode")) . "\" \"" . $loc_db->f("area") . "\""); } // make the files readable by anyone exec("chmod 777 " . $shp_file); exec("chmod 777 " . $shx_file); exec("chmod 777 " . $dbf_file); // remove the lockfile exec("rm " . $lock_file); } function update_shp_links() { GLOBAL $opt_shp_path_full; $loc_db = new locDatabase; $loc_db_2 = new locDatabase; $link_shp = $opt_shp_path_full . "links.shp"; $link_shx = $opt_shp_path_full . "links.shx"; $link_dbf = $opt_shp_path_full . "links.dbf"; $lock_file = $opt_shp_path_full . "lock.tmp"; while(file_exists($lock_file)) { sleep(2); } touch($lock_file); exec("rm " . $link_shp); exec("rm " . $link_shx); exec("rm " . $link_dbf); exec("shpcreate " . $link_shp . " POLYGON"); exec("dbfcreate " . $link_dbf . " -s \"class\" 8 -s \"area_1\" 2 -s \"area_2\" 2"); $sql = "SELECT * FROM links ORDER BY id"; $loc_db->query( $sql ); while ($loc_db->next_record()) { $interface_1 = $loc_db->f("interface_1"); $interface_2 = $loc_db->f("interface_2"); $class = $loc_db->f("class"); $sql = "SELECT nodes.latitude, nodes.longitude, nodes.area FROM nodes, interfaces where ((interfaces.id = $interface_1) AND (interfaces.node = nodes.id))"; $loc_db_2->query( $sql ); $loc_db_2->next_record(); $interface_1_lat = $loc_db_2->f("latitude"); $interface_1_long = $loc_db_2->f("longitude"); $interface_1_area = $loc_db_2->f("area"); $sql = "SELECT nodes.latitude, nodes.longitude, nodes.area FROM nodes, interfaces where ((interfaces.id = $interface_2) AND (interfaces.node = nodes.id))"; $loc_db_2->query( $sql ); $loc_db_2->next_record(); $interface_2_lat = $loc_db_2->f("latitude"); $interface_2_long = $loc_db_2->f("longitude"); $interface_2_area = $loc_db_2->f("area"); exec("shpadd " . $link_shp . " " . $interface_1_long . " " . $interface_1_lat . " " . $interface_2_long . " " . $interface_2_lat); exec("dbfadd " . $link_dbf . " " . "\"" . $class . "\" \"" . $interface_1_area . "\" \"" . $interface_2_area . "\""); } exec("chmod 777 " . $link_shp); exec("chmod 777 " . $link_shx); exec("chmod 777 " . $link_dbf); exec("rm " . $lock_file); } } ?>