<%@ Language=VBScript %>
<% Response.Expires = 0 %> 


<!--#include file="includes/summaryheader.asp"-->
<!--#include file="includes/css.asp"-->
<% 
'***************************************************************************
'*                                summary.asp
'*                            -------------------
'*   begin                : Saturday, Sep 13, 2008
'*   copyright            : (C) 2008 AdamsLand Computers, DynDNSServices
'*   email                : sam@dyndnsservices.com
'*
'*   Id: summary.asp,v 1.0.0.0 9/13/08 01:54:11 Samuel Land 
'*   Function: Administration summary page.
'*
'***************************************************************************
On Error Resume next
Set Conn = CreateObject("ADODB.Connection")
Conn.Open Application("Connectit")

Userid = Request.Cookies("DDNSADMIN")("user")
Password = Request.Cookies("DDNSADMIN")("pass")

'Check admin user name and password
Set UserLook = Server.CreateObject("ADODB.Recordset")
 strSQL = "Admin_Lookup @UserID='" & Userid  & "', @Password='" & Password & "'"
Set UserLook = Conn.Execute(strSQL)
  If UserLook.EOF Then
    Response.Redirect "default.asp?error=Your session has expired. Please try again."
    Response.End
  End If
UserLook.Close



Set SumLook = Server.CreateObject("ADODB.Recordset")
 strSQL = "Summary_Display"
Set SumLook = Conn.Execute(strSQL)
  If SumLook.EOF Then
    Users = 0
    SysDomains = 0
    UserDomains = 0
    Records = 0
  Else
    TodayUpdates = "<font color=green>" & SumLook("TodayUpdates") & "</font>"
    TodayUsers = "<font color=green>" & SumLook("TodayUsers") & "</font>"
    TodayRecords = "<font color=green>" & SumLook("TodayRecords") & "</font>"
    
    If SumLook("TodayUpdates") = 0 Then TodayUpdates = "<font color=red>" & SumLook("TodayUpdates") & "</font>"
    If SumLook("TodayUsers") = 0 Then TodayUsers = "<font color=red>" & SumLook("TodayUsers") & "</font>"
    If SumLook("TodayRecords") = 0 Then TodayRecords = "<font color=red>" & SumLook("TodayRecords") & "</font>"
    
    Users = SumLook("UserCount")
    SysDomains = SumLook("SysDomainCount")
    UserDomains = SumLook("UserDomainCount")
    Records = SumLook("RecordCount")
  End If
SumLook.Close

AllDOms = UserDomains + SysDomains


DIM DNS_Array(2)
DIM DNSHeight(2)
Image = 1
Height_of_highest_bar = 100

DNS_Array(0) = Records
DNS_Array(1) = Users
DNS_Array(2) = AllDOms


If DNS_Array(0) >= DNS_Array(1) Then
Maximum = DNS_Array(0)
Else
Maximum = DNS_Array(1)
End If
'Calculate the height of each bar
FOR i=0 TO UBound(DNS_Array)
  DNSHeight(i) = DNS_Array(i) / Maximum * Height_of_highest_bar

    IF DNSHeight(i) < 1 THEN
    DNSHeight(i) = 1
    END IF
NEXT
%>
<p>&nbsp;</p>
<p style="text-align:center">
  <table id="summarytable" cellspacing="0">
  <caption style="width: 274px">DNS and Database Usage</caption>
  <tr>
  
  <th scope="col" colspan="3">
	System Usage Summary</th></tr>
	
	<th scope="row" class="spec" width="117">
  DNS Records:</th>
	<td class="rowb" style="text-align:center"><img src="images/green.gif" width="5" height="5"></td>
  <td class="rowb" align="center" rowspan="5" width="119" valign="bottom">
  <table id="Table1" cellspacing="0">
  <table id="Table2" cellspacing="0">
  <TR>
  <%
  
  FOR i=0 TO UBound(DNS_Array)
    If Image = 1 Then
    GifFil = "green.gif"
    End If
    If Image = 2 Then
    GifFil = "blue.gif"
    End If
    If Image = 3 Then
    GifFil = "red.gif"
    End If
    Image = Image + 1
    
  %>
  <td valign="bottom"><IMG SRC="images/<%=GifFil%>" width=20 HEIGHT="<%=DNSHeight(i)%>"></TD>
  <%NEXT%>
  <TR>
  <%FOR i=0 TO UBound(DNS_Array)%>
  <TD><font face="Arial" style="font-size: 9pt"><CENTER><%=DNS_Array(i)%></CENTER></FONT></TD>
  <%NEXT%>  
  </TABLE>
  </CENTER>

</td>
  
	<tr>
	<th scope="row" class="spec" align="left" width="117">
  Users:</th>
	<td class="rowb" style="text-align:center">
  <img src="images/blue.gif" width="5" height="5"/></td>
  </tr>
	<tr>
	<th scope="row" class="spec" align="left" width="117">
  Domains:</th>
	<td class="rowb" style="text-align:center">
  <img src="images/red.gif" width="5" height="5"></td>
  </tr>
	
	<tr>
	<th scope="col" class="nobg"  width="80" colspan="2" valign="top">
  Totals:</th>
  </tr>
  
</table>
</p>
<p style="text-align:center">
<table id="summarytable" cellspacing="0">
  <caption style="width: 274px">24 Hour Usage History</caption>
<th scope="col" colspan="2">Quick Stats</th>
<tr>
<th scope="row" class="spec" width="50%">DNS Updates:</th>
<td class="rowb" style="text-align:center;width:50px"><%=TodayUpdates %></td>
</tr>
<tr>
<th scope="row" class="spec" width="50%">New Users:</th>
<td class="rowb" style="text-align:center;width:50px"><%=TodayUsers %></td>
</tr>
<tr>
<th scope="row" class="spec" width="50%">New DNS Records:</th>
<td class="rowb" style="text-align:center;width:50px"><%=TodayRecords%></td>
</tr>
</table>
  </p>

<p>&nbsp;</p>


<%
'***************************************************************************
Conn.Close
Set Conn = Nothing
%>

<!--#include file="includes/summaryfooter.asp"-->