Viewing File server/web/admin.php of 1.01.2a
|
1: <?php 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: ob_start(); 24: require("include.php"); 25: $NATS->Start(); 26: if (!$NATS_Session->Check($NATS->DB)) 27: { 28: header("Location: ./?login_msg=Invalid+Or+Expired+Session"); 29: exit(); 30: } 31: if ($NATS_Session->userlevel<9) UL_Error("Admin Interface"); 32: 33: if (isset($_REQUEST['action'])) 34: { 35: switch($_REQUEST['action']) 36: { 37: case "save_user": 38: $q="UPDATE fnuser SET realname=\"".ss($_REQUEST['realname'])."\",userlevel=".ss($_REQUEST['userlevel']); 39: if ((isset($_REQUEST['pword']))&&($_REQUEST['pword']!="_NOTTHIS_")) $q.=",password=MD5(\"".ss($_REQUEST['pword'])."\")"; 40: $q.=" WHERE username=\"".ss($_REQUEST['username'])."\""; 41: $NATS->DB->Query($q); 42: if ($NATS->DB->Affected_Rows()<=0) $amsg="Save User Failed or Nothing Changed"; 43: else $amsg="Save User ".$_REQUEST['username']." Succeeded"; 44: break; 45: 46: case "create_user": 47: $q="INSERT INTO fnuser(username,password,realname,userlevel) VALUES(\"".ss($_REQUEST['username'])."\","; 48: $q.="MD5(\"".ss($_REQUEST['pword'])."\"),\"".ss($_REQUEST['realname'])."\",".ss($_REQUEST['userlevel']).")"; 49: $NATS->DB->Query($q); 50: //echo $q; 51: if ($NATS->DB->Affected_Rows()<=0) $amsg="Create User Failed"; 52: else $amsg="User ".$_REQUEST['username']." Created"; 53: break; 54: 55: case "delete_user": 56: /* - disabled for 0.02.44 to allow duplicate deletion 57: if ($_REQUEST['username']=="admin") 58: { 59: $amsg="Can't delete the admin user"; 60: break; 61: } 62: */ 63: if (!isset($_REQUEST['confirmed'])) 64: { 65: $back=urlencode("admin.php?action=delete_user&mode=users&username=".$_REQUEST['username']."&confirmed=1"); 66: $url="confirm.php?action=Delete+User+".$_REQUEST['username']."&back=".$back; 67: header("Location: ".$url); 68: exit(); 69: } 70: $q="DELETE FROM fnuser WHERE username=\"".ss($_REQUEST['username'])."\""; 71: $NATS->DB->Query($q); 72: $amsg="User ".$_REQUEST['username']." Deleted"; 73: break; 74: 75: case "var_save": 76: if ($_REQUEST['new_var']=="") // delete 77: { 78: $q="DELETE FROM fnconfig WHERE fnc_var=\"".ss($_REQUEST['orig_var'])."\""; 79: } 80: else // update 81: { 82: $q="UPDATE fnconfig SET fnc_var=\"".ss($_REQUEST['new_var'])."\",fnc_val=\"".ss($_REQUEST['new_val'])."\" "; 83: $q.="WHERE fnc_var=\"".ss($_REQUEST['orig_var'])."\""; 84: } 85: $NATS->DB->Query($q); 86: if ($NATS->DB->Affected_Rows()<=0) $amsg="Update/Delete Variable Failed"; 87: else $amsg="Updated/Deleted Variable"; 88: break; 89: case "var_new": 90: $q="INSERT INTO fnconfig(fnc_var,fnc_val) VALUES(\"".ss($_REQUEST['new_var'])."\",\"".ss($_REQUEST['new_val'])."\")"; 91: //echo $q; 92: $NATS->DB->Query($q); 93: if ($NATS->DB->Affected_Rows()<=0) $amsg="Create Variable Failed"; 94: else $amsg="Created Variable"; 95: break; 96: 97: case "save_aa": 98: $q="UPDATE fnalertaction SET "; 99: $q.="atype=\"".ss($_REQUEST['atype'])."\","; 100: $q.="ctrlimit=".ss($_REQUEST['ctrlimit']).","; 101: $q.="ctrtoday=".ss($_REQUEST['ctrtoday']).","; 102: $q.="aname=\"".ss($_REQUEST['aname'])."\","; 103: $q.="scheduleid=".ss($_REQUEST['scheduleid']).","; 104: if (isset($_REQUEST['efrom'])) $q.="efrom=\"".ss($_REQUEST['efrom'])."\","; 105: $q.="etolist=\"".ss($_REQUEST['etolist'])."\","; 106: if (isset($_REQUEST['esubject'])) $q.="esubject=".ss($_REQUEST['esubject']).","; 107: $q.="etype=".ss($_REQUEST['etype']); 108: if (isset($_REQUEST['awarnings'])) $q.=",awarnings=".ss($_REQUEST['awarnings']); 109: else $q.=",awarnings=0"; 110: if (isset($_REQUEST['adecrease'])) $q.=",adecrease=".ss($_REQUEST['adecrease']); 111: else $q.=",adecrease=0"; 112: $q.=" WHERE aaid=".ss($_REQUEST['aaid']); 113: //echo $q; 114: $NATS->DB->Query($q); 115: if ($NATS->DB->Affected_Rows()<=0) $amsg="Action Update Failed or Nothing Changed"; 116: else $amsg="Action Updated"; 117: break; 118: 119: case "action_test": 120: $q="SELECT mdata FROM fnalertaction WHERE aaid=".ss($_REQUEST['aaid'])." LIMIT 0,1"; 121: $r=$NATS->DB->Query($q); 122: $row=$NATS->DB->Fetch_Array($r); 123: $oldm=$row['mdata']; 124: $q="UPDATE fnalertaction SET mdata=\"** ACTION TEST **\" WHERE aaid=".ss($_REQUEST['aaid']); 125: $NATS->DB->Query($q); 126: $NATS->ActionFlush(); 127: $q="UPDATE fnalertaction SET mdata=\"".ss($oldm)."\" WHERE aaid=".ss($_REQUEST['aaid']); 128: $NATS->DB->Query($q); 129: $amsg="Alert Action Tested & Flushed"; 130: break; 131: 132: case "action_create": 133: $q="INSERT INTO fnalertaction(atype) VALUES(\"\")"; 134: $NATS->DB->Query($q); 135: $amsg="Created New Alert Action"; 136: $_REQUEST['aaid']=$NATS->DB->Insert_Id(); 137: break; 138: 139: case "action_delete": 140: if (!isset($_REQUEST['confirmed'])) 141: { 142: $back=urlencode("admin.php?mode=alertactions&aaid_del=".$_REQUEST['aaid_del']."&action=action_delete&confirmed=1"); 143: $url="confirm.php?action=Delete+alert+action&back=".$back; 144: header("Location: ".$url); 145: exit(); 146: } 147: // otherwise confirmed 148: $q="DELETE FROM fnalertaction WHERE aaid=".ss($_REQUEST['aaid_del']); 149: $NATS->DB->Query($q); 150: if ($NATS->DB->Affected_Rows()>0) $amsg="Alert Action Deleted"; 151: else $amsg="Alert Action Delete Failed"; 152: $q="DELETE FROM fnnalink WHERE aaid=".ss($_REQUEST['aaid_del']); 153: $NATS->DB->Query($q); 154: break; 155: 156: case "optimize": 157: $q="OPTIMIZE TABLE ".ss($_REQUEST['table']); 158: $NATS->DB->Query($q); 159: $msg="Optimised Table ".$_REQUEST['table']; 160: break; 161: 162: } 163: } 164: 165: ob_end_flush(); 166: Screen_Header("Administration Interface",1,1,"","main","admin"); 167: 168: if (isset($_REQUEST['mode'])) $mode=$_REQUEST['mode']; 169: else $mode=""; 170: 171: if (isset($_REQUEST['message'])) echo "<br><b>".$_REQUEST['message']."</b><br>"; 172: if (isset($amsg)) echo "<br><b>".$amsg."</b><br>"; 173: 174: echo "<br>"; 175: if (isset($_REQUEST['updatecheck'])) 176: { 177: // check for updates 178: $dq="?CheckVersion=".$NATS->Version."&JSMode=1"; 179: $dl="http://www.purplepixie.org/freenats/download.php"; 180: $du=$dl.$dq; 181: /* old method 182: $cp=@fopen($du,"r"); 183: if ($cp>0) 184: { 185: $cs=@fgets($cp,128); 186: @fclose($cp); 187: if ($cs=="0") echo "System Up to Date<br>"; 188: else echo "Update Available: <a href=http://www.purplepixie.org/freenats>".$cs."</a><br>"; 189: } 190: else echo "Error Checking for Updates<br>"; 191: */ 192: echo "Checking Version: "; 193: echo "<script type=\"text/javascript\" src=\"".$du."\"></script>\n"; 194: echo "<br><br>"; 195: } 196: else if ($mode=="") 197: { 198: echo "<a href=admin.php?updatecheck=1><b>Check for FreeNATS Updates</b></a><br><br>"; 199: } 200: 201: function tul($l) 202: { 203: if ($l>9) return "Administrator"; 204: if ($l>4) return "Power User"; 205: if ($l>0) return "Normal User"; 206: return "Disabled"; 207: } 208: 209: function aat_etype($type) 210: { 211: switch ($type) 212: { 213: case 0: return "Short"; 214: case 1: return "Long"; 215: default: return "Unknown"; 216: } 217: } 218: 219: function aat_esub($type) 220: { 221: switch ($type) 222: { 223: case 0: return "Blank"; 224: case 1: return "Short"; 225: case 2: return "Long"; 226: default: return "Unknown"; 227: } 228: } 229: 230: function aat_atype($type) 231: { 232: switch($type) 233: { 234: case "": case "Disabled": return "Disabled"; 235: case "email": return "EMail"; 236: case "url": return "URL"; 237: case "mqueue": return "Message Queue"; 238: default: return "Unknown (".$type.")"; 239: } 240: } 241: 242: if ($mode=="users") 243: { 244: echo "<b class=\"subtitle\">Users</b><br><br>"; 245: 246: 247: 248: 249: $q="SELECT username,realname,userlevel FROM fnuser"; 250: $r=$NATS->DB->Query($q); 251: echo "<table border=0>"; 252: echo "<tr><td><b>Username </b></td>"; 253: echo "<td><b>Real Name</b></td><td><b>User Level</b></td><td><b>Password</b></td><td><b>Options</b></td></tr>"; 254: while ($row=$NATS->DB->Fetch_Array($r)) 255: { 256: echo "<form action=admin.php method=post>"; 257: echo "<input type=hidden name=action value=save_user>"; 258: echo "<input type=hidden name=mode value=users>"; 259: echo "<input type=hidden name=username value=\"".$row['username']."\">"; 260: echo "<tr><td>".$row['username']."</td>"; 261: echo "<td><input type=text name=realname value=\"".$row['realname']."\" size=20 maxlength=120></td>"; 262: echo "<td><select name=userlevel>"; 263: echo "<option value=".$row['userlevel'].">".tul($row['userlevel'])."</option>"; 264: echo "<option value=0>".tul(0)."</option>"; 265: echo "<option value=1>".tul(1)."</option>"; 266: echo "<option value=5>".tul(5)."</option>"; 267: echo "<option value=10>".tul(10)."</option>"; 268: echo "</select>"; 269: echo "</td>"; 270: echo "<td><input type=password name=pword value=\"_NOTTHIS_\" size=10 maxlength=128></td>"; 271: echo "<td><input type=submit value=\"Save\"> <a href=admin.php?action=delete_user&username=".$row['username'].">Delete</a></td>"; 272: echo "</tr>"; 273: echo "</form>"; 274: } 275: echo "<form action=admin.php method=post>"; 276: echo "<input type=hidden name=action value=create_user>"; 277: echo "<input type=hidden name=mode value=users>"; 278: echo "<tr><td><input type=text name=username size=20 maxlength=60></td>"; 279: echo "<td><input type=text name=realname size=20 maxlength=120></td>"; 280: echo "<td><select name=userlevel>"; 281: echo "<option value=1>".tul(1)."</option>"; 282: echo "<option value=0>".tul(0)."</option>"; 283: echo "<option value=5>".tul(5)."</option>"; 284: echo "<option value=10>".tul(10)."</option>"; 285: echo "</select></td>"; 286: echo "<td><input type=password name=pword size=10 maxlength=60></td>"; 287: echo "<td><input type=submit value=\"Create User\"></td>"; 288: echo "</tr></form>"; 289: echo "</table><br>"; 290: echo "<br>"; 291: $NATS->DB->Free($r); 292: } 293: else if ($mode=="nodetestsessions") 294: { 295: echo "<b class=\"subtitle\">Test Sessions for ".$_REQUEST['nodeid']."</b><br><br>"; 296: echo "<b>Running Sessions for ".$_REQUEST['nodeid']."</b><br>"; 297: $q="SELECT * FROM fntestrun WHERE fnode=\"".ss($_REQUEST['nodeid'])."\" AND finishx=0 ORDER BY trid DESC"; 298: $r=$NATS->DB->Query($q); 299: if ($NATS->DB->Num_Rows($r)==0) echo "<i>No running test sessions</i><br>"; 300: echo "<table border=0>"; 301: while ($row=$NATS->DB->Fetch_Array($r)) 302: { 303: echo "<tr><td><a href=testrun.php?trid=".$row['trid'].">run/".$row['trid']."</a></td>"; 304: echo "<td>".nicedt($row['startx'])." - "; 305: if ($row['finishx']>0) echo nicedt($row['finishx']); 306: else echo "Still Running"; 307: echo " (<a href=log.php?f_entry=Tester+".$row['trid'].">System Logs</a>)"; 308: echo "</td></tr>"; 309: } 310: echo "</table>"; 311: $NATS->DB->Free($r); 312: echo "<br>"; 313: echo "<br>"; 314: 315: echo "<b>Last 100 Previous Sessions for ".$_REQUEST['nodeid']."</b><br>"; 316: $q="SELECT * FROM fntestrun WHERE fnode=\"".ss($_REQUEST['nodeid'])."\" ORDER BY trid DESC LIMIT 0,100"; 317: $r=$NATS->DB->Query($q); 318: if ($NATS->DB->Num_Rows($r)==0) echo "<i>No previous test sessions</i><br>"; 319: echo "<table border=0>"; 320: while ($row=$NATS->DB->Fetch_Array($r)) 321: { 322: echo "<tr><td><a href=testrun.php?trid=".$row['trid'].">run/".$row['trid']."</a></td>"; 323: echo "<td>".nicedt($row['startx'])." - "; 324: if ($row['finishx']>0) echo nicedt($row['finishx']); 325: else echo "Still Running"; 326: echo " (<a href=log.php?f_entry=Tester+".$row['trid'].">System Logs</a>)"; 327: echo "</td></tr>"; 328: } 329: echo "</table>"; 330: $NATS->DB->Free($r); 331: echo "<br>"; 332: echo "<br>"; 333: 334: } 335: else if ($mode=="testsessions") 336: { 337: echo "<b class=\"subtitle\">Running Test Sessions</b><br><br>"; 338: $q="SELECT * FROM fntestrun WHERE finishx=0 ORDER BY trid DESC"; 339: $r=$NATS->DB->Query($q); 340: if ($NATS->DB->Num_Rows($r)==0) echo "<i>No running test sessions</i><br>"; 341: echo "<table border=0>"; 342: while ($row=$NATS->DB->Fetch_Array($r)) 343: { 344: echo "<tr><td><a href=testrun.php?trid=".$row['trid'].">run/".$row['trid']."</a></td>"; 345: echo "<td>".nicedt($row['startx'])." - "; 346: if ($row['finishx']>0) echo nicedt($row['finishx']); 347: else echo "Still Running"; 348: echo " (<a href=log.php?f_entry=Tester+".$row['trid'].">System Logs</a>)"; 349: echo "</td></tr>"; 350: } 351: echo "</table>"; 352: $NATS->DB->Free($r); 353: echo "<br>"; 354: echo "<form action=admin.php method=post>"; 355: echo "<input type=hidden name=mode value=nodetestsessions>"; 356: echo "<b>Last 100 Test Sessions for </b>"; 357: $q="SELECT nodeid,nodename FROM fnnode ORDER BY weight ASC"; 358: $r=$NATS->DB->Query($q); 359: echo "<select name=nodeid>"; 360: while ($row=$NATS->DB->Fetch_Array($r)) 361: { 362: echo "<option value=".$row['nodeid'].">".$row['nodename']." (".$row['nodeid'].")</option>"; 363: } 364: echo "</select> <input type=submit value=Go></form><br>"; 365: } 366: else if ($mode=="alertactions") 367: { 368: echo "<b class=\"subtitle\">Alert Actions</b><br><br>"; 369: 370: if (isset($_REQUEST['aaid'])) 371: { // view/edit aaid 372: $q="SELECT * FROM fnalertaction WHERE aaid=".ss($_REQUEST['aaid']); 373: $r=$NATS->DB->Query($q); 374: if (!$row=$NATS->DB->Fetch_Array($r)) 375: { 376: echo "<b>Error Fetching AAID</b><br><br>"; 377: Screen_Footer(); 378: exit(); 379: } 380: echo "<table border=0>"; 381: echo "<form action=admin.php method=post>"; 382: echo "<input type=hidden name=action value=save_aa>"; 383: echo "<input type=hidden name=mode value=alertactions>"; 384: echo "<input type=hidden name=aaid value=".$_REQUEST['aaid'].">"; 385: echo "<tr><td>ID : </td><td>action/".$_REQUEST['aaid']."</td></tr>"; 386: 387: echo "<tr><td>Action Name : </td>"; 388: echo "<td>"; 389: echo "<input type=text name=aname size=30 maxlength=120 value=\"".$row['aname']."\">"; 390: echo "</td></tr>"; 391: 392: echo "<tr><td>Type : </td><td>"; 393: echo "<select name=atype>"; 394: echo "<option value=".$row['atype'].">".aat_atype($row['atype'])."</option>"; 395: echo "<option value=Disabled>Disabled</option>"; 396: echo "<option value=email>EMail</option>"; 397: echo "<option value=url>URL</option>"; 398: echo "<option value=mqueue>Message Queue</option>"; 399: echo "</select>"; 400: echo "</td></tr>"; 401: 402: echo "<tr><td>Schedule : </td><td>"; 403: echo "<select name=scheduleid>"; 404: echo "<option value=0>At All Times</option>"; 405: $sq="SELECT scheduleid,schedulename FROM fnschedule"; 406: $sr=$NATS->DB->Query($sq); 407: while ($sched=$NATS->DB->Fetch_Array($sr)) 408: { 409: if ($sched['scheduleid']==$row['scheduleid']) $s.=" selected"; 410: else $s=""; 411: echo "<option value=".$sched['scheduleid'].$s.">".$sched['schedulename']."</option>"; 412: } 413: echo "</select>"; 414: $NATS->DB->Free($sr); 415: echo " ".hlink("AlertSchedule"); 416: echo "</td></tr>"; 417: 418: 419: echo "<tr><td>Warnings : </td>"; 420: if ($row['awarnings']==1) $s=" checked"; 421: else $s=""; 422: echo "<td><input type=checkbox name=awarnings value=1".$s."> ".hlink("AAction:Warnings")."</td></tr>"; 423: 424: echo "<tr><td>Decreases : </td>"; 425: if ($row['adecrease']==1) $s=" checked"; 426: else $s=""; 427: echo "<td><input type=checkbox name=adecrease value=1".$s."> ".hlink("AAction:Decreases")."</td></tr>"; 428: 429: echo "<tr><td>Action Limit : </td>"; 430: echo "<td>"; 431: echo "<input type=text name=ctrlimit size=3 maxlength=6 value=\"".$row['ctrlimit']."\"> "; 432: echo hlink("AAction:Limit"); 433: echo "</td></tr>"; 434: 435: echo "<tr><td>Action Counter : </td>"; 436: echo "<td>"; 437: echo "<input type=text name=ctrtoday size=3 maxlength=6 value=\"".$row['ctrtoday']."\"> "; 438: echo hlink("AAction:Counter"); 439: echo " (for "; 440: if ($row['ctrdate']=="") echo "<i>unknown</i>"; 441: else echo substr($row['ctrdate'],6,2)."/".substr($row['ctrdate'],4,2)."/".substr($row['ctrdate'],0,4); 442: echo ")"; 443: echo "</td></tr>"; 444: 445: if ($row['atype']!="url") 446: { 447: 448: echo "<tr><td>Email From : </td>"; 449: echo "<td>"; 450: echo "<input type=text name=efrom size=30 maxlength=120 value=\"".$row['efrom']."\">"; 451: echo "</td></tr>"; 452: 453: echo "<tr><td>Email Subject : </td><td>"; 454: echo "<select name=esubject>"; 455: echo "<option value=".$row['esubject'].">".aat_esub($row['esubject'])."</option>"; 456: echo "<option value=0>Blank</option>"; 457: echo "<option value=1>Short</option>"; 458: echo "<option value=2>Long</option>"; 459: echo "</select>"; 460: echo "</td></tr>"; 461: 462: } 463: 464: echo "<tr><td>Msg Type : </td><td>"; 465: echo "<select name=etype>"; 466: echo "<option value=".$row['etype'].">".aat_etype($row['etype'])."</option>"; 467: echo "<option value=0>Short</option>"; 468: echo "<option value=1>Long</option>"; 469: echo "</select>"; 470: echo "</td></tr>"; 471: 472: echo "<tr><td valign=top>Email To<br>or URL : </td><td>"; 473: echo "<textarea name=etolist cols=40 rows=6>".$row['etolist']."</textarea>"; 474: echo "</td></tr>"; 475: 476: echo "<tr><td colspan=2><input type=submit value=\"Update Action\"> <a href=admin.php>Cancel Update</a> | "; 477: echo "<a href=admin.php?aaid=".$_REQUEST['aaid']."&mode=alertactions&action=action_test>Test Action</a> | "; 478: echo "<a href=admin.php?aaid_del=".$_REQUEST['aaid']."&mode=alertactions&action=action_delete>Delete Action</a>"; 479: echo "</td></tr>"; 480: 481: echo "</form></table><br><br>"; 482: $NATS->DB->Free($r); 483: } 484: 485: $q="SELECT aaid,atype,aname FROM fnalertaction"; 486: $r=$NATS->DB->Query($q); 487: echo "<table class=\"nicetable\"><tr>"; 488: echo "<td><b>ID</b></td><td><b>Action Name</b></td><td><b>Action Type</b></td></tr>"; 489: while ($row=$NATS->DB->Fetch_Array($r)) 490: { 491: echo "<tr><td>"; 492: echo "<a href=admin.php?mode=alertactions&aaid=".$row['aaid'].">".$row['aaid']."</a></td>"; 493: echo "<td><a href=admin.php?mode=alertactions&aaid=".$row['aaid'].">".$row['aname']."</a></td><td>"; 494: echo aat_atype($row['atype']); 495: echo "</td></tr>"; 496: } 497: echo "</table>"; 498: 499: echo "<br><a href=admin.php?mode=alertactions&action=action_create><b>Create New Alert Action</b></a><br>"; 500: echo "<br><br>"; 501: } 502: else if ($mode=="logs") 503: { 504: echo "<b class=\"subtitle\">System Logs</b><br><br>"; 505: echo "<a href=log.php>System Event Log</a><br><br>"; 506: 507: echo "<br><br>"; 508: } 509: else if ($mode=="status") 510: { 511: // system healthcheck 512: 513: // usage data 514: //$q="SELECT COUNT(fnnode.nodeid),COUNT(fngroup.groupid),COUNT( FROM fnnode,fngroup"; 515: $q="SHOW TABLE STATUS LIKE \"fn%\""; 516: $r=$NATS->DB->Query($q); 517: 518: echo "<b class=\"maintitle\">FreeNATS System Status</b><br><br>"; 519: 520: $tinfo=array(); 521: 522: echo "<b class=\"subtitle\">Table Sizes</b><br><br>"; 523: 524: echo "<table class=\"nicetable\">"; 525: echo "<tr><td><b>Table Name</b></td><td><b>Size (Rows)</b></td><td><b>Size (kb)</b></td><td><b>Other Information</b></td></tr>"; 526: while ($row=$NATS->DB->Fetch_Array($r)) 527: { 528: echo "<tr><td>".$row['Name']."</td><td>".$row['Rows']."</td>"; 529: echo "<td>".round($row['Data_length']/1024,0)."</td><td>"; 530: if (isset($tinfo[$row['Name']])) echo $tinfo[$row['Name']]; 531: else echo " "; 532: if ($row['Data_free']>0) 533: { 534: echo " [".round($row['Data_free']/1024,0)."kb Free - <a href=admin.php?mode=status&action=optimize&table=".$row['Name'].">Optimise</a>]"; 535: } 536: echo "</td></tr>"; 537: } 538: echo "</table>"; 539: $NATS->DB->Free($r); 540: echo "<br><br>"; 541: 542: echo "<b class=\"subtitle\">Test Sessions</b><br><br>"; 543: $q="SELECT * FROM fntestrun WHERE finishx=0"; 544: $r=$NATS->DB->Query($q); 545: echo "<b>".$NATS->DB->Num_Rows($r)." Open/Running Test Sessions</b><br><br>"; 546: if ($NATS->DB->Num_Rows($r)>0) 547: { 548: echo "<table class=\"nicetable\">"; 549: echo "<tr><td><b>ID</b></td><td><b>Node</b></td><td><b>Started</b></td><td><b>Notes</b></td></tr>"; 550: $nowx=time(); 551: $fifteenx=$nowx-(15*60); 552: $hourx=$nowx-(60*60); 553: while ($row=$NATS->DB->Fetch_Array($r)) 554: { 555: echo "<tr><td><a href=testrun.php?trid=".$row['trid'].">"; 556: echo $row['trid']."</a></td>"; 557: echo "<td><a href=node.php?nodeid=".$row['fnode']."</a></td>"; 558: echo "<td>".nicedt($row['startx'])." - ".dtago($row['startx'])."</td>"; 559: echo "<td>"; 560: if ($row['startx']<$hourx) echo "Error: Over an hour old"; 561: else if($row['startx']<$fifteenx) echo "Warning: Over fifteen minutes old"; 562: else echo " "; 563: echo "</td></tr>"; 564: } 565: echo "</table>"; 566: } 567: $NATS->DB->Free($r); 568: echo "<br><br>"; 569: 570: echo "<b class=\"subtitle\">Environment</b><br><br>"; 571: 572: function test_funcs($funcs) 573: { 574: if (!is_array($funcs)) $funcs=array($funcs); 575: $out=""; 576: for($a=0; $a<count($funcs); $a++) 577: { 578: if (!function_exists($funcs[$a])) 579: { 580: $out.=$funcs[$a]." "; 581: } 582: } 583: if ($out!="") $out.="functions required"; 584: return $out; 585: } 586: 587: function test_mod($mod,$funcs) 588: { 589: $text=test_funcs($funcs); 590: if ($text=="") 591: { 592: echo "<b style=\"color: green;\">".$mod."</b> - Ok<br>"; 593: return true; 594: } 595: else 596: { 597: echo "<b style=\"color: red;\">".$mod."</b> - ".$text."<br>"; 598: return false; 599: } 600: } 601: 602: if (!test_mod("IMAP","imap_open")) 603: { 604: echo "IMAP is not supported - don't configure IMAP tests or your environment will hang<br>"; 605: } 606: echo "<br>"; 607: if (!test_mod("Sockets","fsockopen")) 608: { 609: echo "Sockets are not supported - fatal error<br>"; 610: } 611: echo "<br>"; 612: if (!test_mod("Streams","fopen")) 613: { 614: echo "Streams are not supported - fatal error<br>"; 615: } 616: echo "<br>"; 617: if (!test_mod("MySQL","mysql_connect")) 618: { 619: echo "MySQL are not supported - fatal error<br>"; 620: } 621: echo "<br>"; 622: if (!test_mod("Mail","mail")) 623: { 624: echo "mail() not supported, may have to use direct SMTP or maybe no mail will work!<br>"; 625: } 626: echo "<br>"; 627: if (!test_mod("PHP5","str_split")) 628: { 629: echo "Don't appear to be running PHP5 - this may not work on PHP4<br>"; 630: } 631: echo "<br>"; 632: 633: echo "<br><br>"; 634: 635: echo "Please note this merely displays FreeNATS software status - not<br>the status of "; 636: echo "the underlying Virtual Machine (if applicable).<br><br> You should monitor disk space and "; 637: echo "performance for the VM via<br>the relevant system (such as the rPath interface).<br><br>"; 638: 639: } 640: else if ($mode=="variables") 641: { 642: echo "<b class=\"subtitle\">Variables</b> ".hlink("Variable")."<br><br>"; 643: $q="SELECT * FROM fnconfig ORDER BY fnc_var ASC"; 644: $r=$NATS->DB->Query($q); 645: echo "<table border=0>"; 646: while ($row=$NATS->DB->Fetch_Array($r)) 647: { 648: echo "<form action=admin.php method=post>"; 649: echo "<input type=hidden name=action value=var_save>"; 650: echo "<input type=hidden name=mode value=variables>"; 651: echo "<input type=hidden name=orig_var value=\"".$row['fnc_var']."\">"; 652: echo "<input type=hidden name=orig_val value=\"".$row['fnc_val']."\">"; 653: echo "<tr><td><input type=text size=20 maxlength=60 name=new_var value=\"".$row['fnc_var']."\"> "; 654: echo "</td>"; 655: echo "<td>=</td>"; 656: echo "<td><input type=text size=20 maxlength=60 name=new_val value=\"".$row['fnc_val']."\"></td>"; 657: echo "<td><input type=submit value=\"Save\"> "; 658: echo hlink("Var:".$row['fnc_var']); 659: echo "</td>"; 660: echo "</tr>"; 661: echo "</form>"; 662: } 663: echo "<form action=admin.php method=post>"; 664: echo "<input type=hidden name=action value=var_new>"; 665: echo "<input type=hidden name=mode value=variables>"; 666: echo "<tr><td><input type=text size=20 maxlength=60 name=new_var value=\"\"></td>"; 667: echo "<td>=</td>"; 668: echo "<td><input type=text size=20 maxlength=60 name=new_val value=\"\"></td>"; 669: echo "<td><input type=submit value=\"Create\"></td>"; 670: echo "</tr>"; 671: echo "</form>"; 672: echo "</table>"; 673: } 674: else if ($mode=="sysinfo") 675: { 676: echo "<b class=\"subtitle\">FreeNATS System Information</b><br><br>"; 677: 678: echo "<b>Version Information</b><br><br>"; 679: echo "<table border=0>"; 680: echo "<tr><td>Version:</td><td>".$NATS->Version."</td></tr>"; 681: echo "<tr><td>Release:</td><td>".$NATS->Release."</td></tr>"; 682: echo "<tr><td>Compound:</td><td>".$NATS->Version.$NATS->Release."</td></tr>"; 683: echo "</table><br><br>"; 684: 685: echo "<b>Registered Test Modules</b><br><br>"; 686: echo "<table class=\"nicetable\" width=600>"; 687: echo "<tr><td><b>Name</b></td><td><b>Provides</b></td><td><b>Revision</b></td><td><b>Additional</b></td></tr>"; 688: foreach($NATS->Tests->QuickList as $key => $val) 689: { 690: echo "<tr><td>"; 691: echo $NATS->Tests->Tests[$key]->name; 692: echo "</td><td>"; 693: echo $NATS->Tests->Tests[$key]->type; 694: echo "</td><td>"; 695: echo $NATS->Tests->Tests[$key]->revision; 696: echo "</td><td>"; 697: echo $NATS->Tests->Tests[$key]->additional; 698: echo "</td></tr>"; 699: } 700: echo "</table><br><br>"; 701: 702: echo "<b>Registered Event Handlers</b><br><br>"; 703: echo "<table class=\"nicetable\" width=600>"; 704: echo "<tr><td><b>Event</b></td><td><b>Handler(s)</b></td></tr>"; 705: foreach($NATS->EventHandlers as $key => $val) 706: { 707: echo "<tr><td valign=top>".$key."</td><td>"; 708: foreach($NATS->EventHandlers[$key] as $handler) 709: echo $handler."<br>"; 710: echo "</td></tr>"; 711: } 712: echo "</table><br><br>"; 713: } 714: else // catch-all 715: { 716: echo "<img src=images/options/user.png style=\"vertical-align: bottom;\"> "; 717: echo "<a href=admin.php?mode=users>User Administration</a><br><br>"; 718: echo "<img src=images/options/application.png style=\"vertical-align: bottom;\"> "; 719: echo "<a href=log.php>System Event Log</a><br><br>"; 720: echo "<img src=images/options/letter_open.png style=\"vertical-align: bottom;\"> "; 721: echo "<a href=admin.php?mode=alertactions>Alert Actions</a><br><br>"; 722: echo "<img src=images/options/action_add.png style=\"vertical-align: bottom;\"> "; 723: echo "<a href=admin.php?mode=variables>System Variables</a><br><br>"; 724: echo "<img src=images/options/file.png style=\"vertical-align: bottom;\"> "; 725: echo "<a href=admin.php?mode=testsessions>Test Sessions</a><br><br>"; 726: echo "<img src=images/options/time.png style=\"vertical-align: bottom;\"> "; 727: echo "<a href=schedule.php>Test and Alert Schedules</a><br><br>"; 728: echo "<img src=images/options/folder_open.png style=\"vertical-align: bottom;\"> "; 729: echo "<a href=filemanager.php>File Manager</a><br><br>"; 730: 731: if ($NATS->Cfg->Get("site.enable.adminsql",0)==1) 732: { 733: echo "<img src=images/options/folder_files.png style=\"vertical-align: bottom;\"> "; 734: echo "<a href=admin.sql.php>SQL Console</a><br><br>"; 735: } 736: echo "<img src=images/options/search.png style=\"vertical-align: bottom;\"> "; 737: echo "<a href=admin.dns.php>DNS Query Console</a><br><br>"; 738: echo "<img src=images/options/save.png style=\"vertical-align: bottom;\"> "; 739: echo "<a href=admin.backup.php>Backup and Restore</a><br><br>"; 740: echo "<img src=images/options/reply.png style=\"vertical-align: bottom;\"> "; 741: echo "<a href=admin.php?mode=status>System Status Report</a><br><br>"; 742: echo "<img src=images/help16.png style=\"vertical-align: bottom;\"> "; 743: echo "<a href=admin.php?mode=sysinfo>System Information</a><br><br>"; 744: } 745: 746: if ($mode!="") echo "<a href=admin.php>Back to Main Admin Menu</a><br><br>"; 747: ?> 748: 749: 750: <?php 751: Screen_Footer(); 752: ?> 753: