File: 0.02.68a/server/web/node.edit.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: FreeNATS is (C) Copyright 2008 PurplePixie Systems 6: 7: FreeNATS is free software: you can redistribute it and/or modify 8: it under the terms of the GNU General Public License as published by 9: the Free Software Foundation, either version 3 of the License, or 10: (at your option) any later version. 11: 12: FreeNATS is distributed in the hope that it will be useful, 13: but WITHOUT ANY WARRANTY; without even the implied warranty of 14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15: GNU General Public License for more details. 16: 17: You should have received a copy of the GNU General Public License 18: along with FreeNATS. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: ob_start(); 24: require("include.php"); 25: $NATS->Start(); 26: if (!$NATS_Session->Check($NATS->DB)) 27: { 28: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 29: exit(); 30: } 31: if ($NATS_Session->userlevel<5) UL_Error("Edit Node"); 32: ob_end_flush(); 33: Screen_Header("Node Editor",1); 34: echo "\n\n\n"; 43: ?> 44:
45: 46: if (isset($_REQUEST['action'])) 47: { 48: if ($_REQUEST['action']=="save_edit") 49: { 50: if (isset($_REQUEST['nodeenabled'])) $nodeenabled=1; 51: else $nodeenabled=0; 52: if (isset($_REQUEST['pingtest'])) $pingtest=1; 53: else $pingtest=0; 54: if (isset($_REQUEST['pingfatal'])) $pingfatal=1; 55: else $pingfatal=0; 56: if (isset($_REQUEST['nodealert'])) $nodealert=1; 57: else $nodealert=0; 58: 59: $q="UPDATE fnnode SET "; 60: $q.="nodename=\"".ss($_REQUEST['nodename'])."\","; 61: $q.="nodedesc=\"".ss($_REQUEST['nodedesc'])."\","; 62: $q.="nodeicon=\"".ss($_REQUEST['nodeicon'])."\","; 63: $q.="nodealert=".ss($nodealert).","; 64: $q.="nodeenabled=".ss($nodeenabled).",pingtest=".ss($pingtest).",pingfatal=".ss($pingfatal).","; 65: $q.="hostname=\"".ss($_REQUEST['hostname'])."\""; 66: 67: $q.=" WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\""; 68: 69: $NATS->DB->Query($q); 70: 71: if ($NATS->DB->Affected_Rows()<=0) 72: { 73: echo "Failed to Save Changes or Nothing Changed
";
74: $poplist[]="Failed to Save or Nothing Changed"; 75: } 76: else 77: { 78: echo "Saved Changes
";
79: $poplist[]="Saved Changes"; 80: } 81: } 82: else if ($_REQUEST['action']=="save_actions") 83: { 84: // build the two lists... 85: $cur=array(); 86: $cc=0; 87: $nl=array(); 88: $nc=0; 89: 90: if (isset($_REQUEST['links'])) 91: { 92: foreach($_REQUEST['links'] as $link) 93: { 94: $nl[$link]['proc']=false; // not processed or existing i.e. outstanding 95: $nl[$link]['aaid']=$link; 96: $nc++; 97: } 98: } 99: 100: $q="SELECT nalid,aaid FROM fnnalink WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\""; 101: $r=$NATS->DB->Query($q); 102: while ($row=$NATS->DB->Fetch_Array($r)) 103: { 104: //echo $row['aaid'].":"; 105: $cur[$row['aaid']]['proc']=false; 106: $cur[$row['aaid']]['nalid']=$row['nalid']; 107: $cur[$row['aaid']]['aaid']=$row['aaid']; 108: $cc++; 109: } 110: 111: // now we have the two lists lets process them 112: foreach($nl as $newone) 113: { 114: if (isset($cur[$newone['aaid']])) // exists - do nothing to both 115: { 116: //echo "
".$newone['aaid'].":";
117: $cur[$newone['aaid']]['proc']=true; 118: $nl[$newone['aaid']]['proc']=true; 119: } 120: // otherwise news are left false to insert and curs false to delete 121: } 122: 123: // so lets do that 124: foreach($nl as $newone) 125: { 126: if ($newone['proc']==false) 127: { 128: //echo $q; 129: $q="INSERT INTO fnnalink(aaid,nodeid) VALUES(".ss($newone['aaid']).",\"".ss($_REQUEST['nodeid'])."\")"; 130: $NATS->DB->Query($q); 131: } 132: } 133: foreach($cur as $curone) 134: { 135: if ($curone['proc']==false) 136: { 137: $q="DELETE FROM fnnalink WHERE nalid=".$curone['nalid']; 138: $NATS->DB->Query($q); 139: //echo $q; 140: } 141: } 142: 143: echo "Saved Alert List Preferences
";
144: $poplist[]="Saved Alert List Preferences"; 145: 146: 147: } 148: 149: } 150: 151: 152: 153: echo "Editing Node: ".$_REQUEST['nodeid']."

";
154: 155: $q="SELECT * FROM fnnode WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" LIMIT 0,1"; 156: $r=$NATS->DB->Query($q); 157: if (!$row=$NATS->DB->Fetch_Array($r)) 158: { 159: echo "No such node.

";
160: Screen_Footer(); 161: exit(); 162: } 163: $NATS->DB->Free($r); 164: 165: echo ""; 166: echo "
";
167: echo ""; 168: echo ""; 169: echo ""; 170: 171: echo ""; 176: 177: echo ""; 182: 183: echo ""; 188: 189: echo ""; 194: 195: echo ""; 206: 207: echo ""; 215: 216: echo ""; 224: 225: echo ""; 233: 234: echo ""; 242: 243: echo ""; 247: echo ""; 248: 249: if (isset($_REQUEST['show_icons'])) 250: { 251: echo ""; 254: } 255: 256: echo ""; 257: 258: 259: echo ""; 260: 261: $q="SELECT * FROM fnlocaltest WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND testtype!=\"ICMP\""; 262: $r=$NATS->DB->Query($q); 263: while ($row=$NATS->DB->Fetch_Array($r)) 264: { 265: echo ""; 274: 275: echo ""; 280: } 281: 282: echo "
";
283: echo "\n"; 284: echo ""; 285: echo ""; 286: echo ""; 293: 294: 295: echo "
Node Settings

172: NodeID 173: :"; 174: echo $row['nodeid']; 175: echo "
178: Node Name 179: :"; 180: echo ""; 181: echo "
184: Hostname 185: :"; 186: echo ""; 187: echo "
190: Description 191: :"; 192: echo ""; 193: echo "
196: Node Icon 197: :"; 198: echo " [ Show Icons ]"; 204: echo " [ Show Icons ]"; 205: echo "
208: Enabled 209: :"; 210: if ($row['nodeenabled']==1) $s=" checked"; 211: else $s=""; 212: echo ""; 213: echo " ".hlink("Node:Enabled"); 214: echo "
217: Alerts Active 218: :"; 219: if ($row['nodealert']==1) $s=" checked"; 220: else $s=""; 221: echo ""; 222: echo " ".hlink("Node:AlertActive"); 223: echo "
226: Ping Test 227: :"; 228: if ($row['pingtest']==1) $s=" checked"; 229: else $s=""; 230: echo ""; 231: echo " ".hlink("Node:PingTest"); 232: echo "
235: Require Ping 236: :"; 237: if ($row['pingfatal']==1) $s=" checked"; 238: else $s=""; 239: echo ""; 240: echo " ".hlink("Node:RequirePing"); 241: echo "
"; 244: echo " Cancel Changes"; 245: echo "

";
246: echo "


"; 252: ShowIcons(); 253: echo "


Node Tests

"; 266: 267: echo ""; 268: if (strlen($row['testparam'])>10) $tp=substr($row['testparam'],0,8).".."; 269: else $tp=$row['testparam']; 270: if ($row['testname']=="") echo lText($row['testtype'])." (".$tp.")"; 271: else echo $row['testname']; 272: echo ""; 273: echo "Edit | "; 276: echo "Delete"; 277: 278: echo "  Last Tested: ".dtago($row['lastrunx']).""; 279: echo "
 
Add Test : "; 291: echo ""; 292: echo "
";
296: 297: echo "

Alert Actions

";
298: echo ""; 299: echo ""; 300: echo ""; 301: $q="SELECT aaid,aname FROM fnalertaction"; 302: $r=$NATS->DB->Query($q); 303: $c=0; 304: while ($row=$NATS->DB->Fetch_Array($r)) 305: { 306: // has link? 307: $lq="SELECT nalid FROM fnnalink WHERE nodeid=\"".ss($_REQUEST['nodeid'])."\" AND aaid=".ss($row['aaid'])." LIMIT 0,1"; 308: $lr=$NATS->DB->Query($lq); 309: if ($NATS->DB->Num_Rows($lr)>0) $s=" checked"; 310: else $s=""; 311: $NATS->DB->Free($lr); 312: echo ""; 314: } 315: $NATS->DB->Free($r); 316: echo ""; 317: echo "
"; 313: echo "".$row['aaid']." - ".$row['aname']."
";
318: ?> 319: 320: 321: 322: Screen_Footer(); 323: ?> 324: