Viewing File server/web/iphone.php of 1.19.1b
|
1: <?php 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: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 31: <html> 32: 33: <head> 34: <title>FreeNATS iPhone</title> 35: <meta http-equiv="content-type" content="text/html; charset=utf-8"> 36: <meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0"> 37: <!-- The browser.css file contain all information required to style the pages --> 38: <!-- <link rel="stylesheet" href="fnipbrowser.css"> --> 39: <link rel="stylesheet" href=css/iphone.css> 40: </head> 41: 42: <body> 43: <!-- this is the container for the whole content --> 44: <div id="browser"> 45: <!-- 46: this is the container for the header, the area at the top of the screen with the title and back button: 47: we keep two of buttons and titles so that we can transition a pair in and another pair out in transitions. 48: --> 49: <div id="header"> 50: <?php 51: if ($back!="") echo "<div id=\"first_button\" class=\"button\" onclick=\"javascipt:backbuttonclick('".$back."')\">Back</div>\n"; 52: ?> 53: <div id="first_title" class="title"><?php echo $title; ?></div> 54: 55: </div> 56: 57: <script src="js/iphone.js" type="text/javascript"></script> 58: 59: <?php 60: } 61: 62: function ipScreenFooter() 63: { 64: ?> 65: 66: <script type="text/javascript"> 67: function hide_address_bar () { 68: window.scrollTo(0, 1); 69: setTimeout(function () { 70: window.scrollTo(0, 0); 71: }, 0); 72: }; 73: 74: setTimeout(hide_address_bar, 200); 75: </script> 76: 77: 78: </body> 79: 80: </html> 81: <?php 82: } 83: 84: $lic=0; 85: 86: function li($text,$link="") 87: { 88: global $lic; 89: echo "<li id=\"pageli".$lic."\""; 90: if ($link!="") 91: { 92: echo " class=\"group\" onclick=\"javascript:liclick('pageli".$lic."','".$link."')\""; 93: } 94: echo ">".$text."</li>\n"; 95: $lic++; 96: } 97: 98: function lititled($text,$under) 99: { 100: echo "<li>".$text."<br>"; 101: echo "<i class=\"subtext\">".$under."</i></li>"; 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 "<ul>\n"; 120: 121: $alerts=$NATS->GetAlerts(); 122: if ($alerts===false) $alerts=array(); 123: 124: if (count($alerts)>0) 125: { 126: $alt="<b class=\"al2\">Alerts</b> (".count($alerts).")"; 127: $alt.="<br><i class=\"subtext\">"; 128: $first=true; 129: foreach($alerts as $alert) 130: { 131: if ($first) $first=false; 132: else $alt.=", "; 133: $alt.=$alert['nodeid']; 134: } 135: $alt.="</i>"; 136: } 137: else $alt="<b class=\"al0\">No Alerts</b>"; 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 "</ul>\n"; 144: 145: //echo "<div class=\"sectitle\">Stuff</div>\n"; 146: echo "<ul>\n"; 147: //echo "<li class=\"grouptitle\">Stuff</li>\n"; 148: li("Standard Interface","monitor.php"); 149: echo "</ul>\n"; 150: echo "<ul>\n"; 151: //li("Login","iphone.php?mode=login"); 152: li("Logoff","logout.php"); 153: echo "</ul>\n"; 154: break; 155: 156: case "alerts": 157: ipScreenHeader("FreeNATS Alerts","iphone.php"); 158: echo "<ul>\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="<b class=\"al".$alert['alertlevel']."\">".$alert['nodeid']."</b>"; 167: li($txt,$link); 168: } 169: } 170: echo "</ul>"; 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 "<ul>\n"; 178: while ($row=$NATS->DB->Fetch_Array($r)) 179: { 180: li($row['vtitle'],"view.php?viewid=".$row['viewid']); 181: } 182: echo "</ul>\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 "<ul>"; 190: while ($row=$NATS->DB->Fetch_Array($r)) 191: { 192: $lvl=$NATS->GroupAlertLevel($row['groupid']); 193: $txt="<b class=\"al".$lvl."\">".$groupname."</b>"; 194: $lnk=""; // for later 195: li($txt,$lnk); 196: } 197: echo "</ul>"; 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 "<ul>"; 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="<b class=\"al".$lvl."\">".$nodename."</b>"; 211: $lnk="iphone.php?mode=node&nodeid=".$row['nodeid']; 212: li($txt,$lnk); 213: } 214: echo "</ul>"; 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 "<ul><li>Invalid NodeID</li></ul>"; 226: else 227: { 228: echo "<ul>"; 229: li("Configuration"); 230: //lititled($node['nodeid'],"nodeid"); 231: //lititled($node['nodename'],"node name"); 232: //lititled($node['hostname'],"hostname"); 233: echo "<li><table border=0 style=\"font-size: 10pt; font-weight: normal;\">"; 234: echo "<tr><td>Node ID: </td><td align=left>".$node['nodeid']."</td></tr>"; 235: echo "<tr><td>Node Name: </td><td>".$node['nodename']."</td></tr>"; 236: echo "<tr><td>Hostname: </td><td>".$node['hostname']."</td></tr>"; 237: echo "</table></li>\n"; 238: echo "</ul>"; 239: 240: echo "<ul>\n"; 241: $t="Status: "; 242: $t.="<b class=\"al".$node['alertlevel']."\">"; 243: $t.=oText($node['alertlevel']); 244: $t.="</b>"; 245: li($t); 246: lititled($node['lastrunago']." ago",$node['lastrundt']); 247: 248: echo "</ul>"; 249: 250: echo "\n<ul>\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 "</ul>\n"; 256: 257: 258: 259: 260: } 261: break; 262: 263: case "login": 264: ipScreenHeader("FreeNATS"); 265: echo "<form action=\"login.php\" name=\"loginform\" method=post>"; 266: echo "<input type=hidden name=url value=iphone.php>"; 267: echo "<ul>\n"; 268: li("Username"); 269: echo "<li><input type=text name=naun size=20 maxlength=128 style=\"width: 250px; height: 28px; font-size: 14pt;\"></li>\n"; 270: echo "</ul><ul>\n"; 271: li("Password"); 272: echo "<li><input type=password name=napw size=20 maxlength=128 style=\"width: 250px; height: 28px; font-size: 14pt;\"></li>\n"; 273: echo "</ul><ul>\n"; 274: echo "<li class=\"group\" onclick=\"javascript:document.loginform.submit()\">"; 275: echo "Login to FreeNATS"; 276: echo "</li>\n"; 277: echo "</ul>"; 278: break; 279: 280: default: 281: ipScreenHeader("FreeNATS","iphone.php"); 282: echo "<ul>"; 283: li("Error Occured"); 284: echo "</ul>\n"; 285: echo "<script type=\"text/javascript\">\n"; 286: echo "setTimeout( function() { alert('Unknown Mode'); },700);\n"; 287: echo "</script>\n"; 288: break; 289: } 290: 291: 292: ipScreenFooter(); 293: $NATS->Stop(); 294: ?> 295: 296: