person; $_roles= $_person['role_ids']; $interface = array(); // If interface_id is specified, load data if( isset( $_GET['id'] ) ) { $id= intval( $_GET['id'] ); $interfaces= $api->GetInterfaces( array( $id ) ); if( $interfaces ) { $interface= $interfaces[0]; $node_id= $interface['node_id']; } } if( $_GET['node_id'] ) $node_id= $_GET['node_id']; // Override fields with specified data foreach( array( 'method', 'type', 'ip', 'gateway', 'network', 'broadcast', 'netmask', 'dns1', 'dns2', 'hostname', 'mac', 'bwlimit', 'node_id' ) as $field ) { if( isset( $_POST[$field] ) ) { if( $_POST[$field] == "" ) { $interface[$field]= NULL; } else { $interface[$field]= $_POST[$field]; if( in_array( $field, array( 'bwlimit', 'node_id' ) ) ) { $interface[$field]= intval( $interface[$field] ); } } } if( isset( $interface[$field] ) ) { // E.g., $method = $interface['method']; $$field= $interface[$field]; } } // Either interface_id or node_id must be specified in URL if( !isset( $_GET['node_id'] ) && !( $nodes= $api->GetNodes( array( intval($node_id) ), array( 'node_id', 'hostname', 'site_id' ) ) ) ) { drupal_set_error ("Malformed URL"); plc_redirect(l_nodes()); } $nodes= $api->GetNodes( array( intval($node_id) ), array( 'node_id', 'hostname', 'site_id' ) ); $node= $nodes[0]; $can_update= True; if( !in_array( 10, $_roles ) ) { if ( !( in_array( 20, $_roles ) || in_array( 40, $_roles ) ) || !in_array( $node['site_id'], $_person['site_ids'] ) ) { $can_update= False; } } if( $can_update && (isset( $_POST['submitted'] ) || isset ($_GET['submitted'])) ) { if( isset( $_POST['add'] ) ) { $api->AddInterface( intval( $node_id ), $interface ); } elseif ( isset( $_POST['delete'] ) || isset( $_GET['delete']) || isset( $_POST['update'] ) ) { // interface_id must be specified in URL if( !isset( $id ) ) { plc_redirect(l_node($node_id)); } if( isset( $_POST['delete'] ) || isset ($_GET['delete']) ) { $api->DeleteInterface( $id ); } elseif( isset( $_POST['update'] ) ) { $api->UpdateInterface( $id, $interface ); } } $error= $api->error(); if( !empty( $error ) ) { echo '
' . $error . '.
'; } else { plc_redirect(l_node($node_id)); } } // Print header require_once 'plc_drupal.php'; drupal_set_title($node['hostname']); include 'plc_header.php'; // Start form $action= "interface.php"; if( isset( $id ) ) { $action.= "?id=" . $interface['interface_id']; } elseif( isset($node_id)) { $action.= "?node_id=" . $node_id; } foreach( array( 'static', 'dhcp', 'proxy', 'tap', 'ipmi' ) as $option ) { ${$option . "_selected"} = ( $method == $option ) ? 'selected="selected"' : ''; } // XXX Query methods and types echo << function updateStaticFields() { var is_static= document.fm.method.options[document.fm.method.selectedIndex].text == 'Static'; var is_tap= document.fm.method.options[document.fm.method.selectedIndex].text == 'TUN/TAP'; document.fm.netmask.disabled= !is_static; document.fm.network.disabled= !is_static; document.fm.gateway.disabled= !is_static && !is_tap; document.fm.broadcast.disabled= !is_static; document.fm.dns1.disabled= !is_static; document.fm.dns2.disabled= !is_static; }
EOF; if ($can_update) { echo ''; } echo <<
Method:
Type:
IP:
BW Limit:

Gateway:
Network:
Broadcast:
Netmask:
DNS 1:
DNS 2:
Hostname:
MAC Address:
BW Limit (bps):
'; echo ''; if (isset($id)) { echo ''; echo ''; } echo ''; echo '
EOF; $is_admin=in_array( 10, $_roles ); $is_pi=in_array( 20, $_roles ); print "
"; if (empty ($interface['interface_tag_ids'])) { print "

This network interface has no additional setting

"; if( $is_admin || $is_pi ) // xxx check the destination page echo "

Add an Interface Setting

\n"; } else { $interface_tags = $api->GetInterfaceTags($interface['interface_tag_ids']); sort_interface_tags ($interface_tags); print ""; print ""; // the column for the delete button if( $is_admin ) print ""; print ""; foreach ($interface_tags as $setting) { echo ""; if ($is_admin) { echo(""); } if ($is_admin || $is_pi) // xxx check the destination page printf ("",$setting['interface_tag_id'],$setting['tagname']); else printf ("",$setting['tagname']); printf ("", $setting['category'], $setting['description'], $setting['value']); } if( $is_admin || $is_pi ) // xxx check the destination page echo "
Additional Settings
NameCategoryDescriptionValue
"); echo plc_delete_link_button('setting_action.php?rem_id=' . $setting['interface_tag_id'], '\\n [ ' . $setting['tagname'] . ' = ' . $setting['value']); echo(" %s %s %s %s %s
Add a Network Setting\n"; print "
"; } echo <<Back to Node EOF; // Print footer include 'plc_footer.php'; ?>