Viewing File server/base/screen.inc.php of 0.02.18a
|
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>; © Copyright 2008 "; 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 "</table>"; 86: echo "</div>"; 87: if (ini_get("freenats.rpath")==1) 88: { 89: echo "<i>FreeNATS Virtual Server Powered By <a href=http://www.rpath.org/>rPath</a> LAMP Appliance</i><br>"; 90: } 91: echo "<i>This is alpha-test software - we would very much value your "; 92: echo "<a href=http://www.purplepixie.org/freenats/feedback.php>feedback</a></i><br>"; 93: echo "\n</body></html>\n"; 94: } 95: 96: function UL_Error($task="") 97: { 98: Screen_Header("Insufficient Access"); 99: echo "<br>Sorry but your user has insufficient access to perform task (".$task.").<br><br>"; 100: echo "<a href=main.php>Please click here to continue.</a><br><br>"; 101: Screen_Footer(); 102: exit(); 103: } 104: 105: function nicedt($ts) 106: { 107: if ($ts<=0) return "never"; 108: return date("H:i:s d/m/Y",$ts); 109: } 110: 111: function enicedt($ts) 112: { 113: echo nicedt($ts); 114: } 115: 116: function nicediff($diff) 117: { 118: $hr=0; 119: $mn=0; 120: $se=0; 121: if ($diff>59) 122: { 123: $mn=round($diff/60,0); 124: $se=$diff%60; 125: if ($mn>59) 126: { 127: $hr=round($mn/60,0); 128: $mn=$mn%60; 129: } 130: } 131: else $se=$diff; 132: $s=""; 133: if ($hr<10) $s="0"; 134: $s.=$hr.":"; 135: if ($mn<10) $s.="0"; 136: $s.=$mn.":"; 137: if ($se<10) $s.="0"; 138: $s.=$se; 139: return $s; 140: } 141: 142: function dtago($ts) 143: { 144: if ($ts<=0) return "never"; 145: $now=time(); 146: $diff=$now-$ts; 147: $s=nicediff($diff); 148: $s.=" ago"; 149: return $s; 150: } 151: 152: function edtago($ts) 153: { 154: echo dtago($ts); 155: } 156: 157: $allowed="00123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@_-.,"; 158: 159: function nices($s) 160: { 161: global $allowed; 162: $o=""; 163: for ($a=0; $a<strlen($s); $a++) 164: { 165: $c=$s[$a]; 166: if (strpos($allowed,$c)===false) 167: { 168: // skip it 169: } 170: else $o.=$c; 171: } 172: return $o; 173: } 174: 175: function ShowIcons() 176: { 177: global $fnIcons,$fnIcon_DefNode,$fnIcon_DefGroup; 178: $c=0; 179: echo "<table border=0>"; 180: $cc=0; 181: for ($a=0; $a<count($fnIcons); $a++) 182: { 183: if ($cc==0) echo "<tr>"; 184: echo "<td valign=top align=center><img src=icons/".$fnIcons[$a]."><br>".$fnIcons[$a]."<br>"; 185: if ($a==$fnIcon_DefNode) echo "<i>Node Default</i> "; 186: if ($a==$fnIcon_DefGroup) echo "<i>Group Default</i>"; 187: echo "</td>"; 188: $cc++; 189: if ($cc>=5) 190: { 191: echo "</tr>"; 192: $cc=0; 193: } 194: } 195: if ($cc>0) echo "</tr>"; 196: echo "</table>"; 197: } 198: 199: 200: function NodeIcon($nodeid) 201: { 202: global $NATS,$fnIcons,$fnIcon_DefNode; 203: $q="SELECT nodeicon FROM fnnode WHERE nodeid=\"".ss($nodeid)."\""; 204: $r=$NATS->DB->Query($q); 205: if ($row=$NATS->DB->Fetch_Array($r)) 206: { 207: if ($row['nodeicon']!="") return $row['nodeicon']; 208: } 209: return $fnIcons[$fnIcon_DefNode]; 210: } 211: 212: function GroupIcon($groupid) 213: { 214: global $NATS,$fnIcons,$fnIcon_DefGroup; 215: $q="SELECT groupicon FROM fngroup WHERE groupid=\"".ss($groupid)."\""; 216: $r=$NATS->DB->Query($q); 217: if ($row=$NATS->DB->Fetch_Array($r)) 218: { 219: if ($row['groupicon']!="") return $row['groupicon']; 220: } 221: return $fnIcons[$fnIcon_DefGroup]; 222: } 223: 224: function np_tiny($nodeid,$text=true) 225: { 226: global $NATS; 227: $al=$NATS->NodeAlertLevel($nodeid); 228: echo "<table class=\"nptiny-al".$al."\">"; 229: echo "<tr><td valign=center align=center>"; 230: echo "<a href=node.php?nodeid=".$nodeid.">"; 231: echo "<img src=\"icons/".NodeIcon($nodeid)."\" border=0>"; 232: echo "</a>"; 233: if ($text) 234: { 235: echo "<br><b class=\"al".$al."\">".$nodeid."</b>"; 236: } 237: echo "</td></tr></table>"; 238: } 239: 240: function ng_tiny($groupid,$groupname="",$text=true) 241: { 242: global $NATS; 243: // to do - get groupname if not sent but F--- it for now 244: $al=$NATS->GroupAlertLevel($groupid); 245: echo "<table class=\"nptiny-al".$al."\">"; 246: echo "<tr><td valign=center align=center>"; 247: echo "<a href=group.php?groupid=".$groupid.">"; 248: echo "<img src=\"icons/".GroupIcon($groupid)."\" border=0>"; 249: echo "</a>"; 250: if ($text) 251: { 252: echo "<br><b class=\"al".$al."\">".$groupname."</b>"; 253: } 254: echo "</td></tr></table>"; 255: } 256: 257: function ng_big($groupid,$groupname="",$groupdesc="",$groupicon="") 258: { 259: global $NATS; 260: if ($groupicon=="") $groupicon=GroupIcon($groupid); 261: $al=$NATS->GroupAlertLevel($groupid); 262: echo "<table class=\"npbig-al".$al."\">"; 263: echo "<tr><td align=left valign=top>"; 264: echo "<table class=\"nicetable\" width=300>"; 265: echo "<tr><td align=right>Group Name :"; 266: echo "</td><td align=left><a href=group.php?groupid=".$groupid.">".$groupname."</a></td></tr>"; 267: echo "<tr><td align=right>Description :"; 268: echo "</td><td align=left>".$groupdesc."</td></tr>"; 269: echo "<tr><td align=right>Status :</td><td align=left>"; 270: echo "<b class=\"al".$al."\">".oText($al)."</b></td></tr>"; 271: echo "</table></td>"; 272: //echo "<td align=left valign=top align=right width=60>"; 273: //echo "<img src=icons/".GroupIcon($groupid).">"; 274: //echo "</td>"; 275: echo "</tr>"; 276: echo "</table>"; 277: } 278: 279: 280: 281: 282: ?>