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' ) ) ) ) { Header( "Location: index.php" ); exit(); } $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 ) ) { Header( "Location: index.php?id=$node_id" ); exit(); } 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 '
This network interface has no additional setting
"; if( $is_admin || $is_pi ) // xxx check the destination page echo "\n"; } else { $interface_tags = $api->GetInterfaceTags($interface['interface_tag_ids']); sort_interface_tags ($interface_tags); print ""; print " | Name | Category | Description | Value | |
---|---|---|---|---|---|
"); echo plc_delete_link_button('setting_action.php?rem_id=' . $setting['interface_tag_id'], '\\n [ ' . $setting['tagname'] . ' = ' . $setting['value']); echo(" | "); } if ($is_admin || $is_pi) // xxx check the destination page printf ("%s | ",$setting['interface_tag_id'],$setting['tagname']); else printf ("%s | ",$setting['tagname']); printf ("%s | %s | %s |
Add a Network Setting | \n"; print "