File: 0.02.73a/server/web/main.php (View as HTML)

  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: ob_end_flush();
 32: Screen_Header("Monitoring Interface",1);
 33: 
 34: if (isset($_REQUEST['message'])) 
 35: 	{
 36: 	echo "<b>".$_REQUEST['message']."</b><br>";
 37: 	$poplist[]=$_REQUEST['message'];
 38: 	}
 39: 	
 40: if (isset($_REQUEST['nodemove'])) $nm=true;
 41: else $nm=false;
 42: 
 43: ?>
 44: <br>
 45: <?php
 46: if (isset($_REQUEST['check_updates']))
 47: 	{
 48: 	// check for updates
 49: 	$dq="?CheckVersion=".$NATS->Version."&JSMode=1";
 50: 	$dl="http://www.purplepixie.org/freenats/download.php";
 51: 	$du=$dl.$dq;
 52: 	echo "<b>Checking for Updates: ";
 53: 	echo "<script type=\"text/javascript\" src=\"".$du."\"></script>\n";
 54: 	echo "</b><br>";
 55: 	echo "If this test fails you can check on the <a href=http://www.purplepixie.org/freenats/>website</a>.<br>";
 56: 	echo "You are currently running version ";
 57: 	echo $NATS->Version.$NATS->Release.".";
 58: 	echo "<br><i>You can check regularly via the top-right admin link</i><br><br>";
 59: 	}
 60: 
 61: if ($nm)
 62: {
 63: $q="SELECT nodeid,weight FROM fnnode ORDER BY weight ASC";
 64: $r=$NATS->DB->Query($q);
 65: $nml="Move Before <select name=move_before>";
 66: while ($row=$NATS->DB->Fetch_Array($r))
 67: 	{
 68: 	$nml.="<option value=".$row['weight'].">".$row['nodeid']."</option>";
 69: 	}
 70: $nml.="</select>";
 71: $NATS->DB->Free($r);	
 72: }
 73: 
 74: echo "<b class=\"subtitle\">Nodes</b> ".hlink("Node")."<br><br>";
 75: $q="SELECT nodeid,nodename,alertlevel,weight FROM fnnode ORDER BY weight ASC";
 76: $r=$NATS->DB->Query($q);
 77: 
 78: echo "<table class=\"nicetable\">";
 79: echo "<tr><td><b>Node</b></td><td><b>Options</b></td><td><a href=main.php?nodemove=1><b>Move</a></b></td></tr>";
 80: $f=0;
 81: $l=$NATS->DB->Num_Rows($r);
 82: while ($row=$NATS->DB->Fetch_Array($r))
 83: 	{
 84: 	echo "<tr><td align=left>";
 85: 	echo "<a href=node.php?nodeid=".$row['nodeid'].">";
 86: 	
 87: 	echo "<b class=\"al".$row['alertlevel']."\">";
 88: 	echo $row['nodename'];
 89: 	echo "</b>";
 90: 	
 91: 	echo "</a> ";
 92: 	echo "(".$row['nodeid'].")";
 93: 	echo "</td><td align=left>";
 94: 	echo "<a href=node.edit.php?nodeid=".$row['nodeid'].">Edit</a> | ";
 95: 	echo "<a href=node.action.php?action=delete&nodeid=".$row['nodeid'].">Delete"."</a> ";
 96: 	echo "</td>";
 97: 	
 98: 	if ($nm) 
 99: 		{
100: 		echo "<form action=node.action.php method=post>";
101: 		echo "<input type=hidden name=nodeid value=".$row['nodeid'].">";
102: 		echo "<input type=hidden name=action value=move_before>";
103: 		}
104: 	
105: 	echo "<td>";
106: 	if ($f==0) echo "<img src=images/arrows/off/arrow_top.png>";
107: 	else 
108: 		{
109: 		echo "<a href=node.action.php?nodeid=".$row['nodeid']."&action=move&dir=up>";
110: 		echo "<img src=\"images/arrows/on/arrow_top.png\" border=0>";
111: 		echo "</a>";
112: 		}
113: 	
114: 	if ($f>=($l-1)) echo "<img src=images/arrows/off/arrow_down.png>";
115: 	else 
116: 		{
117: 		echo "<a href=node.action.php?nodeid=".$row['nodeid']."&action=move&dir=down>";
118: 		echo "<img src=\"images/arrows/on/arrow_down.png\" border=0>";
119: 		echo "</a>";
120: 		}
121: 	
122: 	if ($nm)
123: 		{
124: 		echo "&nbsp;[".$row['weight']."]&nbsp;";
125: 		echo $nml;
126: 		echo " <input type=submit value=\"Go\">";
127: 		}
128: 		
129: 	echo "</td>";
130: 	
131: 	if ($nm) echo "</form>"; 
132: 	$f++;
133: 	
134: 	echo "</tr>";
135: 	}
136: echo "<form action=node.action.php><input type=hidden name=action value=create>";
137: echo "<tr><td><input type=text name=nodeid size=20 maxlenth=32></td><td><input type=submit value=\"Create Node\"></td>";
138: echo "<td>".hlink("Node:Create");
139: if ($nm) echo " <a href=node.action.php?action=reorderweight>Refresh Weighting</a>";
140: echo "</td></tr></form>";
141: 
142: $fx=time();
143: $sx=$fx-(60*60*24);
144: echo "<tr><td colspan=2><b>Summary: </b><a href=summary.test.php?nodeid=*>Today</a> | ";
145: echo "<a href=summary.test.php?nodeid=*&startx=".$sx."&finishx=".$fx.">Last 24 Hrs</a>";
146: echo "</td></tr>";
147: 
148: echo "</table>";
149: 
150: echo "<br><br>";
151: echo "<b class=\"subtitle\">Node Groups</b> ".hlink("Group")."<br><br>";
152: 
153: $q="SELECT groupid,groupname FROM fngroup ORDER BY weight ASC";
154: $r=$NATS->DB->Query($q);
155: $f=0;
156: echo "<table class=\"nicetable\">";
157: $l=$NATS->DB->Num_Rows($r);
158: while ($row=$NATS->DB->Fetch_Array($r))
159: 	{
160: 	echo "<tr><td><a href=group.php?groupid=".$row['groupid']."><b class=\"al".$NATS->GroupAlertLevel($row['groupid'])."\">".$row['groupname']."</b></a></td>";
161: 	echo "<td><a href=group.edit.php?groupid=".$row['groupid'].">Edit</a> | <a href=group.action.php?action=delete&groupid=".$row['groupid'].">Delete</a></td>";
162: 	echo "<td>";
163: 	
164: 	if ($f==0) echo "<img src=images/arrows/off/arrow_top.png>";
165: 	else 
166: 		{
167: 		echo "<a href=group.action.php?groupid=".$row['groupid']."&action=move&dir=up>";
168: 		echo "<img src=\"images/arrows/on/arrow_top.png\" border=0>";
169: 		echo "</a>";
170: 		}
171: 	
172: 	if ($f>=($l-1)) echo "<img src=images/arrows/off/arrow_down.png>";
173: 	else 
174: 		{
175: 		echo "<a href=group.action.php?groupid=".$row['groupid']."&action=move&dir=down>";
176: 		echo "<img src=\"images/arrows/on/arrow_down.png\" border=0>";
177: 		echo "</a>";
178: 		}
179: 		
180: 	echo "</td>";
181: 	$f++;
182: 	
183: 	echo "</tr>";
184: 	}
185: echo "<form action=group.action.php method=post>";
186: echo "<input type=hidden name=action value=create>";
187: echo "<tr><td><input type=text size=20 name=groupname maxlength=120></td><td><input type=submit value=\"Create Group\">";
188: echo "</td><td>".hlink("Group:Create")."</td></tr></form>";
189: echo "</table>";
190: 
191: 
192: echo "<br><br>";
193: echo "<b class=\"subtitle\">Views</b> ".hlink("View")."<br><br>";
194: echo "<table class=\"nicetable\">";
195: // get views...
196: $q="SELECT viewid,vtitle FROM fnview";
197: $r=$NATS->DB->Query($q);
198: while ($row=$NATS->DB->Fetch_Array($r))
199: 	{
200: 	echo "<tr><td>";
201: 	echo "<a href=view.php?viewid=".$row['viewid'].">".$row['vtitle']."</a>";
202: 	echo "</td><td>";
203: 	echo "<a href=view.edit.php?viewid=".$row['viewid'].">Edit</a> | <a href=view.edit.php?viewid=".$row['viewid']."&action=delete>Delete</a>";
204: 	echo "</td></tr>";
205: 	}
206: 
207: 
208: echo "<form action=view.edit.php method=post><input type=hidden name=action value=create>";
209: echo "<tr><td><input type=text name=vtitle size=20 maxlength=64></td><td><input type=submit value=\"Create View\"> ";
210: echo hlink("View:Create")."</td></tr></form>";
211: echo "</table>";
212: 
213: ?>
214: 
215: 
216: <?php
217: Screen_Footer();
218: /* old PhoneHome Ping Tracker - now in screen as a png
219: $t=$NATS->Cfg->Get("freenats.tracker");
220: if ( ($t!="") && ($t>0) )
221: 	$NATS->PhoneHome();
222: */
223: ?>
224: