File: 0.04.18a/server/base/screen.inc.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: $menu=array(); 24: $menu[0]="FreeNATS Homepage"; 25: $menu[1]="Monitor | Main | Settings | "; 26: $menu[1].="Help | Logout"; 27: $menu[2]=$menu[1]." | Admin"; 28: 29: $poplist=array(); 30: 31: function Screen_Header($title,$menuindex=0,$alertpane=0,$ah="") 32: { 33: global $menu,$NATS,$NATS_Session; 34: if ($NATS->Cfg->Get("site.enable.interactive")!=1) 35: { 36: echo "Sorry but FreeNATS interactive is disabled.
";
37: echo "site.enable.interactive != 1

";
38: $NATS->Stop(); 39: exit(); 40: } 41: if ($menuindex==1) $alertpane=1; // bodge 42: if ($NATS_Session->userlevel>9) $menuindex=2; // further bodge! 43: echo "FreeNATS: ".$title."\n"; 44: echo "\n"; 45: if ($ah!="") echo $ah; 46: echo "\n"; 47: echo "\n"; 48: echo ""; 49: 50: echo "\n"; 51: echo "\n"; 53: echo "
\n"; 52: echo "FreeNATS: ".$title."\n"; 54: echo $menu[$menuindex]; 55: echo "
\n";
56: 57: if ($alertpane==1) 58: { 59: $alerts=$NATS->GetAlerts(); 60: if (is_array($alerts)) 61: { 62: echo "
"; 63: echo "NATS Alerts

";
64: foreach($alerts as $alert) 65: { 66: echo " "; 67: echo "".$alert['nodeid']."
"; 68: } 69: echo "
";
70: echo "
";
71: } 72: } 73: 74: } 75: /* -- old table footer 76: function Screen_Footer() 77: { 78: global $NATS,$poplist; 79: echo "

\n";
80: //$NATS->Cfg->DumpToScreen(); 81: echo ""; 82: echo ""; 88: echo "
FreeNATS; © Copyright 2008 "; 83: echo "PurplePixie Systems"; 84: echo ""; 85: echo "Version: ".$NATS->Version; 86: if ($NATS->Release!="") echo "/".$NATS->Release; 87: echo "
";
89: echo "
"; 90: if (ini_get("freenats.rpath")==1) 91: { 92: echo "FreeNATS Virtual Server Powered By rPath LAMP Appliance
";
93: } 94: echo "This is alpha-test software - we would very much value your "; 95: echo "feedback
"; 96: 97: $t=$NATS->Cfg->Get("freenats.tracker"); 98: if ( ($t!="") && ($t>0) ) 99: { 100: $sn=explode("/",$_SERVER['SCRIPT_NAME']); 101: $script=$sn[count($sn)-1]; 102: echo "Version."+p=".$script."&type=ping\" width=1 height=1>\n"; 103: } 104: 105: if ($NATS->Cfg->Get("site.popupmessage")=="1") 106: { 107: if (count($poplist)>0) 108: { 109: echo "\n\n"; 117: } 118: } 119: echo "\n\n"; 120: } 121: */ 122: function Screen_Footer() 123: { 124: global $NATS,$poplist; 125: echo "

\n";
126: //$NATS->Cfg->DumpToScreen(); 127: echo "
"; 128: echo "
FreeNATS; © Copyright 2008 "; 129: echo "PurplePixie Systems"; 130: echo "
"; 131: echo "Version: ".$NATS->Version; 132: if ($NATS->Release!="") echo "/".$NATS->Release; 133: echo "  
";
134: echo "
";
135: if (ini_get("freenats.rpath")==1) 136: { 137: echo "FreeNATS Virtual Server Powered By rPath LAMP Appliance
";
138: } 139: //echo "This is alpha-test software - we would very much value your "; 140: //echo "feedback
"; 141: 142: $t=$NATS->Cfg->Get("freenats.tracker"); 143: if ( ($t!="") && ($t>0) ) 144: { 145: $sn=explode("/",$_SERVER['SCRIPT_NAME']); 146: $script=$sn[count($sn)-1]; 147: echo "Version."+p=".$script."&type=ping\" width=1 height=1>\n"; 148: } 149: 150: if ($NATS->Cfg->Get("site.popupmessage")=="1") 151: { 152: if (count($poplist)>0) 153: { 154: echo "\n\n"; 162: } 163: } 164: echo "\n\n"; 165: } 166: 167: function UL_Error($task="") 168: { 169: Screen_Header("Insufficient Access"); 170: echo "
Sorry but your user has insufficient access to perform task (".$task.").

";
171: echo "Please click here to continue.

";
172: Screen_Footer(); 173: exit(); 174: } 175: 176: function nicedt($ts) 177: { 178: global $NATS; 179: $form="H:i:s d/m/Y"; 180: if (isset($NATS)) $form=$NATS->Cfg->Get("site.dtformat","H:i:s d/m/Y"); 181: if ($ts<=0) return "never"; 182: return date($form,$ts); 183: } 184: 185: function enicedt($ts) 186: { 187: echo nicedt($ts); 188: } 189: 190: function nicediff($diff) 191: { 192: $hr=0; 193: $mn=0; 194: $se=0; 195: if ($diff>59) 196: { 197: $mn=round($diff/60,0); 198: $se=$diff%60; 199: if ($mn>59) 200: { 201: $hr=round($mn/60,0); 202: $mn=$mn%60; 203: } 204: } 205: else $se=$diff; 206: $s=""; 207: if ($hr<10) $s="0"; 208: $s.=$hr.":"; 209: if ($mn<10) $s.="0"; 210: $s.=$mn.":"; 211: if ($se<10) $s.="0"; 212: $s.=$se; 213: return $s; 214: } 215: 216: function dtago($ts,$sayago=true) 217: { 218: if ($ts<=0) return "never"; 219: $now=time(); 220: $diff=$now-$ts; 221: $s=nicediff($diff); 222: if ($sayago) $s.=" ago"; 223: return $s; 224: } 225: 226: function edtago($ts) 227: { 228: echo dtago($ts); 229: } 230: 231: $allowed="00123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz@_-.,:&/~%=+(){}[]#?"; 232: 233: function nices($s) 234: { 235: global $allowed; 236: $o=""; 237: for ($a=0; $a238: { 239: $c=$s[$a]; 240: if (strpos($allowed,$c)===false) 241: { 242: // skip it 243: } 244: else $o.=$c; 245: } 246: return $o; 247: } 248: 249: function ShowIcons() 250: { 251: global $fnIcons,$fnIcon_DefNode,$fnIcon_DefGroup; 252: $c=0; 253: echo ""; 254: $cc=0; 255: for ($a=0; $a256: { 257: if ($cc==0) echo ""; 258: echo ""; 262: $cc++; 263: if ($cc>=5) 264: { 265: echo ""; 266: $cc=0; 267: } 268: } 269: if ($cc>0) echo ""; 270: echo "

".$fnIcons[$a]."
"; 259: if ($a==$fnIcon_DefNode) echo "Node Default "; 260: if ($a==$fnIcon_DefGroup) echo "Group Default"; 261: echo "
";
271: } 272: 273: 274: function NodeIcon($nodeid) 275: { 276: global $NATS,$fnIcons,$fnIcon_DefNode; 277: $q="SELECT nodeicon FROM fnnode WHERE nodeid=\"".ss($nodeid)."\""; 278: $r=$NATS->DB->Query($q); 279: if ($row=$NATS->DB->Fetch_Array($r)) 280: { 281: if ($row['nodeicon']!="") return $row['nodeicon']; 282: } 283: return $fnIcons[$fnIcon_DefNode]; 284: } 285: 286: function GroupIcon($groupid) 287: { 288: global $NATS,$fnIcons,$fnIcon_DefGroup; 289: $q="SELECT groupicon FROM fngroup WHERE groupid=\"".ss($groupid)."\""; 290: $r=$NATS->DB->Query($q); 291: if ($row=$NATS->DB->Fetch_Array($r)) 292: { 293: if ($row['groupicon']!="") return $row['groupicon']; 294: } 295: return $fnIcons[$fnIcon_DefGroup]; 296: } 297: 298: function np_tiny($nodeid,$text=true,$nodename="") 299: { 300: global $NATS; 301: $al=$NATS->NodeAlertLevel($nodeid); 302: echo ""; 303: echo "
"; 304: echo ""; 305: echo ""; 306: echo ""; 307: if ($text) 308: { 309: if ($nodename=="") $nodename=$nodeid; 310: 311: //$words=explode(" ",$nodename); 312: 313: // messy but there you go... 314: 315: $max_on_line=7; 316: $max_lines=2; 317: $len=strlen($nodename); 318: $out=""; 319: $linecount=0; 320: $charcount=0; 321: for ($a=0; $a<$len; $a++) 322: { 323: 324: $char=$nodename[$a]; 325: 326: if ($char==" ") 327: { 328: $linecount++; 329: $charcount=0; 330: } 331: else $charcount++; 332: 333: if ($charcount>=$max_on_line) 334: { 335: $a=$len+10; 336: $out.=".."; 337: } 338: else if ($linecount>=$max_lines) 339: { 340: $a=$len+10; 341: $out.=".."; 342: } 343: else $out.=$char; 344: 345: } 346: //if ($a==($len+10)) $out.=".."; 347: $nodename=$out; 348: 349: $size=10; 350: 351: /* -- size-based 352: $len=strlen($nodename); 353: if ($len<9) $size=10; 354: else if ($len<15) $size=8; 355: else if ($len<20) $size=7; 356: else 357: { 358: $size=6; 359: $nodename=substr($nodename,0,18).".."; 360: } 361: */ 362: 363: echo "
".$nodename."";
364: } 365: echo "
";
366: } 367: 368: function ng_tiny($groupid,$groupname="",$text=true) 369: { 370: global $NATS; 371: // to do - get groupname if not sent but F--- it for now 372: $al=$NATS->GroupAlertLevel($groupid); 373: echo ""; 374: echo "
"; 375: echo ""; 376: echo ""; 377: echo ""; 378: if ($text) 379: { 380: echo "
".$groupname."";
381: } 382: echo "
";
383: } 384: 385: function ng_big($groupid,$groupname="",$groupdesc="",$groupicon="") 386: { 387: global $NATS; 388: if ($groupicon=="") $groupicon=GroupIcon($groupid); 389: $al=$NATS->GroupAlertLevel($groupid); 390: echo ""; 391: echo ""; 400: //echo ""; 403: echo ""; 404: echo "
"; 392: echo ""; 393: echo ""; 395: echo ""; 397: echo ""; 399: echo "
Group Name :"; 394: echo "".$groupname."
Description :"; 396: echo "".$groupdesc."
Status :"; 398: echo "".oText($al)."
"; 401: //echo ""; 402: //echo "
";
405: } 406: 407: function np_big($nodeid,$nodename="",$nodedesc="",$nodeicon="") 408: { 409: global $NATS; 410: if ($nodedesc=="") $nodedesc=" "; 411: if ($nodeicon=="") $nodeicon=NodeIcon($nodeid); 412: $al=$NATS->NodeAlertLevel($nodeid); 413: echo ""; 414: echo ""; 424: //echo ""; 427: echo ""; 428: echo "
"; 415: echo ""; 416: echo ""; 419: echo ""; 421: echo ""; 423: echo "
Node Name :"; 417: if ($nodename=="") $nodename=$nodeid; 418: echo "".$nodename."
Description :"; 420: echo "".$nodedesc."
Status :"; 422: echo "".oText($al)."
"; 425: //echo ""; 426: //echo "
";
429: } 430: 431: function GetAbsolute($filename="") 432: { // sooooooooo messy but looks like the ONLY FRICKIN' WAY! 433: if ((isset($_SERVER['HTTPS']))&&($_SERVER['HTTPS']!="")) $uri="https://"; 434: else $uri="http://"; 435: $uri.=$_SERVER['HTTP_HOST']; 436: $uri.=$_SERVER['REQUEST_URI']; 437: $pos=strripos($uri,"/"); 438: $rdir=substr($uri,0,$pos+1); 439: return $rdir.$filename; 440: } 441: 442: 443: ?>