Viewing File server/base/screen.inc.php of 0.02.16a
|
1: <?php // screen.inc.php -- web page screen library 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 Foobar. If not, see www.gnu.org/licenses 19: 20: For more information see www.purplepixie.org/freenats 21: -------------------------------------------------------------- */ 22: 23: $menu=array(); 24: $menu[0]="<a href=http://www.purplepixie.org/freenats/>FreeNATS Homepage</a>"; 25: $menu[1]="<a href=monitor.php>Monitor</a> | <a href=main.php>Main</a> | <a href=pref.php>Settings</a> | <a href=logout.php>Logout</a>"; 26: $menu[2]=$menu[1]." | <a href=admin.php>Administrator</a>"; 27: 28: function Screen_Header($title,$menuindex=0,$alertpane=0,$ah="") 29: { 30: global $menu,$NATS,$NATS_Session; 31: if ($NATS->Cfg->Get("site.enable.interactive")!=1) 32: { 33: echo "Sorry but FreeNATS interactive is disabled.<br>"; 34: echo "<i>site.enable.interactive</i> != 1<br><br>"; 35: $NATS->Stop(); 36: exit(); 37: } 38: if ($menuindex==1) $alertpane=1; // bodge 39: if ($NATS_Session->userlevel>9) $menuindex=2; // further bodge! 40: echo "<html><head><title>FreeNATS: ".$title."</title>\n"; 41: echo "<link rel=\"stylesheet\" type=\"text/css\" href=\"css/main.css\">\n"; 42: if ($ah!="") echo $ah; 43: echo "</head>\n"; 44: echo "<script type=\"text/javascript\" src=\"js/freenats.js\">\n"; 45: echo "<body>"; 46: 47: echo "<table width=100% class=\"maintitle\">\n"; 48: echo "<tr><td align=left valign=center>\n"; 49: echo "<b class=\"maintitle\">FreeNATS: ".$title."</b></td>\n"; 50: echo "<td class=\"titlelink\" align=right valign=center>\n"; 51: echo $menu[$menuindex]; 52: echo "</td></tr></table>\n"; 53: 54: if ($alertpane==1) 55: { 56: $alerts=$NATS->GetAlerts(); 57: if (is_array($alerts)) 58: { 59: echo "<div class=\"alertpane\" id=\"fn_alertpane\">"; 60: echo "<b><u>NATS Alerts</u></b><br><br>"; 61: foreach($alerts as $alert) 62: { 63: echo " <a href=node.php?nodeid=".$alert['nodeid'].">"; 64: echo "<b class=\"al".$alert['alertlevel']."\">".$alert['nodeid']."</b></a><br>"; 65: } 66: echo "<br>"; 67: echo "</div>"; 68: } 69: } 70: 71: } 72: 73: function Screen_Footer() 74: { 75: global $NATS; 76: echo "<br><br>\n"; 77: //$NATS->Cfg->DumpToScreen(); 78: echo "<table class=\"nfooter\" width=100%>"; 79: echo "<tr><td align=left><a href=http://www.purplepixie.org/freenats/>FreeNATS</a> from "; 80: echo "<a href=http://www.purplepixie.org/>PurplePixie Systems</a>"; 81: echo "</td><td align=right>"; 82: echo "Version: ".$NATS->Version; 83: if ($NATS->Release!="") echo "/".$NATS->Release; 84: echo "</td></tr>"; 85: echo "</div>"; 86: if (ini_get("freenats.rpath")==1) 87: { 88: echo "<i>FreeNATS Virtual Server Powered By <a href=http://www.rpath.org/>rPath</a> LAMP Appliance</i>"; 89: } 90: echo "\n</body></html>\n"; 91: } 92: 93: function UL_Error($task="") 94: { 95: Screen_Header("Insufficient Access"); 96: echo "<br>Sorry but your user has insufficient access to perform task (".$task.").<br><br>"; 97: echo "<a href=main.php>Please click here to continue.</a><br><br>"; 98: Screen_Footer(); 99: exit(); 100: } 101: 102: function nicedt($ts) 103: { 104: if ($ts<=0) return "never"; 105: return date("H:i:s d/m/Y",$ts); 106: } 107: 108: function enicedt($ts) 109: { 110: echo nicedt($ts); 111: } 112: 113: function nicediff($diff) 114: { 115: $hr=0; 116: $mn=0; 117: $se=0; 118: if ($diff>59) 119: { 120: $mn=round($diff/60,0); 121: $se=$diff%60; 122: if ($mn>59) 123: { 124: $hr=round($mn/60,0); 125: $mn=$mn%60; 126: } 127: } 128: else $se=$diff; 129: $s=""; 130: if ($hr<10) $s="0"; 131: $s.=$hr.":"; 132: if ($mn<10) $s.="0"; 133: $s.=$mn.":"; 134: if ($se<10) $s.="0"; 135: $s.=$se; 136: return $s; 137: } 138: 139: function dtago($ts) 140: { 141: if ($ts<=0) return "never"; 142: $now=time(); 143: $diff=$now-$ts; 144: $s=nicediff($diff); 145: $s.=" ago"; 146: return $s; 147: } 148: 149: function edtago($ts) 150: { 151: echo dtago($ts); 152: } 153: 154: $allowed="00123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@_-.,"; 155: 156: function nices($s) 157: { 158: global $allowed; 159: $o=""; 160: for ($a=0; $a<strlen($s); $a++) 161: { 162: $c=$s[$a]; 163: if (strpos($allowed,$c)===false) 164: { 165: // skip it 166: } 167: else $o.=$c; 168: } 169: return $o; 170: } 171: 172: function ShowIcons() 173: { 174: global $fnIcons,$fnIcon_DefNode,$fnIcon_DefGroup; 175: $c=0; 176: echo "<table border=0>"; 177: $cc=0; 178: for ($a=0; $a<count($fnIcons); $a++) 179: { 180: if ($cc==0) echo "<tr>"; 181: echo "<td valign=top align=center><img src=icons/".$fnIcons[$a]."><br>".$fnIcons[$a]."<br>"; 182: if ($a==$fnIcon_DefNode) echo "<i>Node Default</i> "; 183: if ($a==$fnIcon_DefGroup) echo "<i>Group Default</i>"; 184: echo "</td>"; 185: $cc++; 186: if ($cc>=5) 187: { 188: echo "</tr>"; 189: $cc=0; 190: } 191: } 192: if ($cc>0) echo "</tr>"; 193: echo "</table>"; 194: } 195: 196: 197: function NodeIcon($nodeid) 198: { 199: global $NATS,$fnIcons,$fnIcon_DefNode; 200: $q="SELECT nodeicon FROM fnnode WHERE nodeid=\"".ss($nodeid)."\""; 201: $r=$NATS->DB->Query($q); 202: if ($row=$NATS->DB->Fetch_Array($r)) 203: { 204: if ($row['nodeicon']!="") return $row['nodeicon']; 205: } 206: return $fnIcons[$fnIcon_DefNode]; 207: } 208: 209: function GroupIcon($groupid) 210: { 211: global $NATS,$fnIcons,$fnIcon_DefGroup; 212: $q="SELECT groupicon FROM fngroup WHERE groupid=\"".ss($groupid)."\""; 213: $r=$NATS->DB->Query($q); 214: if ($row=$NATS->DB->Fetch_Array($r)) 215: { 216: if ($row['groupicon']!="") return $row['groupicon']; 217: } 218: return $fnIcons[$fnIcon_DefGroup]; 219: } 220: 221: function np_tiny($nodeid,$text=true) 222: { 223: global $NATS; 224: $al=$NATS->NodeAlertLevel($nodeid); 225: echo "<table class=\"nptiny-al".$al."\">"; 226: echo "<tr><td valign=center align=center>"; 227: echo "<a href=node.php?nodeid=".$nodeid.">"; 228: echo "<img src=\"icons/".NodeIcon($nodeid)."\" border=0>"; 229: echo "</a>"; 230: if ($text) 231: { 232: echo "<br><b class=\"al".$al."\">".$nodeid."</b>"; 233: } 234: echo "</td></tr></table>"; 235: } 236: 237: function ng_tiny($groupid,$groupname="",$text=true) 238: { 239: global $NATS; 240: // to do - get groupname if not sent but F--- it for now 241: $al=$NATS->GroupAlertLevel($groupid); 242: echo "<table class=\"nptiny-al".$al."\">"; 243: echo "<tr><td valign=center align=center>"; 244: echo "<a href=group.php?groupid=".$groupid.">"; 245: echo "<img src=\"icons/".GroupIcon($groupid)."\" border=0>"; 246: echo "</a>"; 247: if ($text) 248: { 249: echo "<br><b class=\"al".$al."\">".$groupname."</b>"; 250: } 251: echo "</td></tr></table>"; 252: } 253: 254: function ng_big($groupid,$groupname="",$groupdesc="",$groupicon="") 255: { 256: global $NATS; 257: if ($groupicon=="") $groupicon=GroupIcon($groupid); 258: $al=$NATS->GroupAlertLevel($groupid); 259: echo "<table class=\"npbig-al".$al."\">"; 260: echo "<tr><td align=left valign=top>"; 261: echo "<table class=\"nicetable\" width=300>"; 262: echo "<tr><td align=right>Group Name :"; 263: echo "</td><td align=left><a href=group.php?groupid=".$groupid.">".$groupname."</a></td></tr>"; 264: echo "<tr><td align=right>Description :"; 265: echo "</td><td align=left>".$groupdesc."</td></tr>"; 266: echo "<tr><td align=right>Status :</td><td align=left>"; 267: echo "<b class=\"al".$al."\">".oText($al)."</b></td></tr>"; 268: echo "</table></td>"; 269: //echo "<td align=left valign=top align=right width=60>"; 270: //echo "<img src=icons/".GroupIcon($groupid).">"; 271: //echo "</td>"; 272: echo "</tr>"; 273: echo "</table>"; 274: } 275: 276: 277: 278: 279: ?>