File: 1.09.2b/server/web/iphone.php (View as Code)

1: 2: /* ------------------------------------------------------------- 3: This file is part of FreeNATS 4: 5: Portions of the iPhone interface code are derived from the Apple 6: development tools. Where applicable - their notices and licence 7: are kept intact and apply. 8: 9: FreeNATS is (C) Copyright 2008 PurplePixie Systems 10: 11: FreeNATS is free software: you can redistribute it and/or modify 12: it under the terms of the GNU General Public License as published by 13: the Free Software Foundation, either version 3 of the License, or 14: (at your option) any later version. 15: 16: FreeNATS is distributed in the hope that it will be useful, 17: but WITHOUT ANY WARRANTY; without even the implied warranty of 18: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 19: GNU General Public License for more details. 20: 21: You should have received a copy of the GNU General Public License 22: along with FreeNATS. If not, see www.gnu.org/licenses 23: 24: For more information see www.purplepixie.org/freenats 25: -------------------------------------------------------------- */ 26: 27: function ipScreenHeader($title,$back="",$maintitle="FreeNATS") 28: { 29: ?> 30: 31: 32: 33: 34: FreeNATS iPhone 35: 36: 37: 38: 39: 40: 41: 42: 43: 44:
45: 49: 56: 57: 58: 59: 60: } 61: 62: function ipScreenFooter() 63: { 64: ?> 65: 66: 76: 77: 78: 79: 80: 81: 82: } 83: 84: $lic=0; 85: 86: function li($text,$link="") 87: { 88: global $lic; 89: echo "
  • 90: if ($link!="") 91: { 92: echo " class=\"group\" onclick=\"javascript:liclick('pageli".$lic."','".$link."')\""; 93: } 94: echo ">".$text."
  • \n";
    95: $lic++; 96: } 97: 98: function lititled($text,$under) 99: { 100: echo "
  • ".$text."
    "; 101: echo "".$under."
  • ";
    102: } 103: 104: // Actual FreeNATS Interface... 105: 106: require("include.php"); 107: $NATS->Start(); 108: if (!$NATS_Session->Check($NATS->DB)) 109: { 110: $mode="login"; 111: } 112: else if (isset($_REQUEST['mode'])) $mode=$_REQUEST['mode']; 113: else $mode="main"; 114: 115: switch($mode) 116: { 117: case "main": 118: ipScreenHeader("FreeNATS"); 119: echo "
      \n"; 120: 121: $alerts=$NATS->GetAlerts(); 122: if ($alerts===false) $alerts=array(); 123: 124: if (count($alerts)>0) 125: { 126: $alt="Alerts (".count($alerts).")"; 127: $alt.="
      ";
      128: $first=true; 129: foreach($alerts as $alert) 130: { 131: if ($first) $first=false; 132: else $alt.=", "; 133: $alt.=$alert['nodeid']; 134: } 135: $alt.=""; 136: } 137: else $alt="No Alerts"; 138: 139: li($alt,"iphone.php?mode=alerts"); 140: li("Groups","iphone.php?mode=groups"); 141: li("Nodes","iphone.php?mode=nodes"); 142: li("Views","iphone.php?mode=views"); 143: echo "
    \n";
    144: 145: //echo "
    Stuff
    \n";
    146: echo "
      \n"; 147: //echo "
    • Stuff
    • \n";
      148: li("Standard Interface","monitor.php"); 149: echo "
    \n";
    150: echo "
      \n"; 151: //li("Login","iphone.php?mode=login"); 152: li("Logoff","logout.php"); 153: echo "
    \n";
    154: break; 155: 156: case "alerts": 157: ipScreenHeader("FreeNATS Alerts","iphone.php"); 158: echo "
      \n"; 159: $alerts=$NATS->GetAlerts(); 160: if ($alerts===false) li("No Alerts"); 161: else 162: { 163: foreach($alerts as $alert) 164: { 165: $link="iphone.php?mode=node&nodeid=".$alert['nodeid']."&back=".urlencode("iphone.php?mode=alerts"); 166: $txt="".$alert['nodeid'].""; 167: li($txt,$link); 168: } 169: } 170: echo "
    ";
    171: break; 172: 173: case "views": 174: ipScreenHeader("Views","iphone.php"); 175: $q="SELECT viewid,vtitle FROM fnview"; 176: $r=$NATS->DB->Query($q); 177: echo "
      \n"; 178: while ($row=$NATS->DB->Fetch_Array($r)) 179: { 180: li($row['vtitle'],"view.php?viewid=".$row['viewid']); 181: } 182: echo "
    \n";
    183: break; 184: 185: case "groups": 186: ipScreenHeader("Groups","iphone.php"); 187: $q="SELECT groupname,groupid FROM fngroup ORDER BY weight ASC"; 188: $r=$NATS->DB->Query($q); 189: echo "
      "; 190: while ($row=$NATS->DB->Fetch_Array($r)) 191: { 192: $lvl=$NATS->GroupAlertLevel($row['groupid']); 193: $txt="".$groupname.""; 194: $lnk=""; // for later 195: li($txt,$lnk); 196: } 197: echo "
    ";
    198: break; 199: 200: case "nodes": 201: ipScreenHeader("Nodes","iphone.php"); 202: $q="SELECT nodeid,nodename,alertlevel FROM fnnode WHERE nodeenabled=1 ORDER BY alertlevel DESC,weight ASC"; 203: $r=$NATS->DB->Query($q); 204: echo "
      "; 205: while ($row=$NATS->DB->Fetch_Array($r)) 206: { 207: if ($row['nodename']=="") $nodename=$row['nodeid']; 208: else $nodename=$row['nodename']; 209: $lvl=$row['alertlevel']; 210: $txt="".$nodename.""; 211: $lnk="iphone.php?mode=node&nodeid=".$row['nodeid']; 212: li($txt,$lnk); 213: } 214: echo "
    ";
    215: break; 216: 217: case "node": 218: if (isset($_REQUEST['nodeid'])) $nodeid=$_REQUEST['nodeid']; 219: else $nodeid=""; 220: if (isset($_REQUEST['back'])) $back=$_REQUEST['back']; 221: else $back="iphone.php?mode=nodes"; 222: ipScreenHeader($nodeid,$back); 223: 224: $node=$NATS->GetNode($nodeid); 225: if ($node===false) echo "
    • Invalid NodeID
    ";
    226: else 227: { 228: echo "
      "; 229: li("Configuration"); 230: //lititled($node['nodeid'],"nodeid"); 231: //lititled($node['nodename'],"node name"); 232: //lititled($node['hostname'],"hostname"); 233: echo "
    • "; 234: echo ""; 235: echo ""; 236: echo ""; 237: echo "
      Node ID: ".$node['nodeid']."
      Node Name: ".$node['nodename']."
      Hostname: ".$node['hostname']."
    • \n";
      238: echo "
    ";
    239: 240: echo "
      \n"; 241: $t="Status: "; 242: $t.=""; 243: $t.=oText($node['alertlevel']); 244: $t.=""; 245: li($t); 246: lititled($node['lastrunago']." ago",$node['lastrundt']); 247: 248: echo "
    ";
    249: 250: echo "\n
      \n"; 251: li("Standard Interface"); 252: li("Node View","node.php?nodeid=".$node['nodeid']); 253: li("Todays Summary","summary.test.php?nodeid=".$node['nodeid']); 254: li("Node Edit","node.edit.php?nodeid=".$node['nodeid']); 255: echo "
    \n";
    256: 257: 258: 259: 260: } 261: break; 262: 263: case "login": 264: ipScreenHeader("FreeNATS"); 265: echo "
    "; 266: echo ""; 267: echo "
      \n"; 268: li("Username"); 269: echo "
    • \n";
      270: echo "
      \n"; 271: li("Password"); 272: echo "
    • \n";
      273: echo "
      \n"; 274: echo "
    • "; 275: echo "Login to FreeNATS"; 276: echo "
    • \n";
      277: echo "
    ";
    278: break; 279: 280: default: 281: ipScreenHeader("FreeNATS","iphone.php"); 282: echo "
      "; 283: li("Error Occured"); 284: echo "
    \n";
    285: echo "\n"; 288: break; 289: } 290: 291: 292: ipScreenFooter(); 293: $NATS->Stop(); 294: ?> 295: 296: