Damon Alverson's profile

Database Driven Secure Client Access User Interface

PROJECT: POST MONTHLY FINANCIAL DATA TO THE WEB
PROBLEMS: LEGACY ACCOUNTING SOFTWARE, MANUAL PROCESSES, SECURITY ISSUES, SITE ADMINISTRATION.  

SOLUTION: Integrate existing technologies, human resources, and procedures with a system capable of handling the limitations of legacy accounting software still in use until a better back-office solution can be selected, purchased, tested, and implemented.
This was my pride and joy when I worked for Bernard / Allison and I hand coded it using VBSript and a few Active Server Pages that communicated directly with our corporate database using ADO and .... well I could explain it all day or just let you check out the source code and see what I got going on. Since all the user authentication is handled using Microsoft Windows 2003 Active Directory Users and Computers (ADUC), and managed at the server level, I feel safe posting the code I wrote for the User Interface (UI) without compromising the security of this application. Developed in 2002 as a temporary solution to an immediate problem, I assume my Secure Client Access pages have been replaced with a more integrated, web-based, back-office solution. Hopefully. Yet I am still very proud of the work that went into producing this Frankenstein :-)
The Technology I've been involved in: Intranets , Extranets, Blogs (Wordpress, TypePad, b2evolution), E-commerce, Authentication Systems, SharePoint Services, and Internet Protocols: (FTP, Telnet, SMTP, SNMP, DNS, TCP/IP). Document Object Models (DOM), Full Macromedia Suite (ver. 4 & MX): Dreamweaver, Fireworks, Freehand, Flash & Action Scripting, Adobe Creative Suite (CS2) including Illustrator, Photoshop, and Acrobat.

The Source Code:

<!--
****************************************************************************************************************
*    HOW TO ADMINISTER THE SECURE CLIENT AREA OF WWW.BAMSI.COM
*
*    ADD NEW USER:
*    STEP 1:
*        Configure new user in ADUC
*    STEP 2:
*        Open any user query in the "lists" database
*        Go to Design View
*        Set Criteria of userID = to user's logon name in ADUC
*        Save the query with the same name as the user's logon name in ADUC
*        Copy the query and paste as same name but add FR to the end for the Financial Reporting Section
*        You now have 2 queries that look like this:
*        user
*        userFR
*    STEP 3:
*        Run the copydatabase.bat file in My Docs on the Exchange box to upload changes
*       
*    Designed 12/19/2002 by -Damon Alverson
*    BAMSI Web Based Financial Reporting System v2.0
****************************************************************************************************************
****************************************************************************************************************
Documentation:
There are 2 things going on here, displaying morning reports to our owners and displaying Financial Reports.
Admin is responsible for MR's, Accounting is responsible for FS's
Admin and Accounting have custom spreadsheets built for them. All these do in terms of this application is save
an .XLS to the proper location. This program then displays the spreadsheet if it was saved to the right location.

This program solves 2 issues:
Authentication
Redirection (based on user authentication)


Limitations:
The database Admin administers controls the relationships (what owner sees what). This program will not work on the Web if the database is open, so we simply copy the database to the webserver via a batch file nightly, and maintain 2 databases.

Dependencies:
Lists Database (lists.mdb)
MS Active Directory (ADUC)
MS 2000 Server built in variables (for user authentication).

-->

<%
    'Because we might be redirecting, we must use buffering.
    Response.Buffer = True
%>

<%
    'Force Authentication if the LOGON_USER Server Variable is blank
    'by sending the Response.Status of 401 Access Denied.
   
    'Finish the Page by issuing a Response.End so that a user
    'cannot cancel through the dialog box.

    If Request.ServerVariables("LOGON_USER") = "" Then
        Response.Status = "401 Access Denied"
        Response.End
    'If Request.ServerVariables("LOGON_USER") = "sample" Then
        'Response.Redirect "http://www.bamsi.com"       
    End If
    Response.Flush
%>

<%
Dim var, SCuser
' Here we get the user's logon name from the server
var=request.servervariables("LOGON_USER")
' Here we convert the string to ALL CAPS, therefore our case statement must reflect this.
' usernames are not case sensitive. this is in case an owner has the Caps Lock key on.
SCuser=LCase(var)
%>

<%
'Declare Variables
Dim MR_ROLLING12, FS_ROLLING12
DIM PROPERTY, MR_REPORT, FS_REPORT
DIM ArrayMonths, arraysize, myMonths, myStartYear, myPriorYear, myMonthDiff, arrayTemp
DIM counter, myMonth, myYear, myMonthNum, newdate, curYear, getDaysInMonth

'VBscript array numbering starts at 0, therefore ArrayMonths(0) will return "January".

ArrayMonths = Array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December")
'myYearToday = year(now())    ' THIS YEAR CALCULATED
   
'This is used to concatenate a string
'This piece of magic tells the Property Name dropdown what to pull from our Access database (Lists.mdb)

sql = "exec"
sql = sql & " " & SCuser
%>

<html>
<head>
<title>Bernard/Allison Secure Client Area</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>

<body bgcolor="#FFFFFF" text="#000000">


<table width="601" border="0" cellpadding="0" cellspacing="0" align="center">
  <tr>
    <td valign="top" height="112" colspan="4"><b><img src="images/scTopBanner.gif" width="600" height="71"><br>
      <font size="2" face="Geneva, Arial, Helvetica, san-serif">
      <script language="JavaScript">
//CN Insert Greeting Ver 1.0.2 - CEA CrystalNet
CN_Now = new Date();
localtime = CN_Now.toString();
CN_Hours = CN_Now.getHours();
if (CN_Hours < 12) {
    document.write("Good Morning");
} else {
    if (CN_Hours >= 12 && CN_Hours < 18)  {
            document.write("Good Afternoon");
    } else {
        if (CN_Hours >= 18) {
            document.write("Good Evening");
            } else {
              document.write("Good Day");
        }
    }
}
</script>
      <i><br>
      The Following Summarizes the Status of Your Site:</i></font></b>
  </tr>
  <tr>
    <td valign="top" height="166" colspan="4">
      <table width="100%" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="300" height="166" valign="top">
            <form method="Get" action="MR_parser.asp">
              <div align="left">
                <p><b><u><img src="images/MRselector.gif" width="300" height="25"><br>
                  </u></b><img src="images/Property.gif" width="65" height="18">
                  <select name="PROPERTY">
                    <%                 
' Construct path to database
sPath = Request.ServerVariables("Path_Translated")
sPath = Left(sPath,InStrRev(sPath,"\")) & "../lists/lists.mdb"
'
' Open Connection & Recordset
set dbLists = Server.CreateObject("ADODB.Connection")
dbLists.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=TRUE;" & _
"Data Source=" & sPath, "Admin", ""
'
' Check for default...
PROPERTY = Trim(Request("SiteName"))
'
' Create the List using an Access stored proc -based on the user's logon

Set oRS=dbLists.Execute(sql)

DO WHILE NOT oRS.EOF
 mSelected = ""
 IF PROPERTY=trim(oRS("SiteName")) then mSelected=" SELECTED"
 %>
                    <option<%=mSelected%>><%=oRS("SiteName")%></option>
                    <%
 oRS.MoveNext
Loop
%>
                  </select>
                  <br>
                  <img src="images/Report.gif" width="65" height="18">
                  <select name="MR_REPORT">
                    <option value="Excel">Morning Reports in Excel</option>
                  </select>
                  <br>
                  <img src="images/Period.gif" width="65" height="18">
                  <%
response.write "<Select name='MR_ROLLING12'>"   

'SETTING UP THE DATE VARIABLES
mrDate=Date()
myMonthNum = DATEPART("M", mrDate)
myMonth = ArrayMonths(myMonthNum - 1)
myYear = DATEPART("YYYY", mrDate)
arraytemp = myMonth
arraytemp = arraytemp & " " & myYear

    For i=0 to 12
                   
                response.write "<OPTION value='"&arrayTemp&"'>"&arrayTemp&"</OPTION>"
                arraytemp=DateAdd("m", -1, arraytemp)
                myMonthNum = DATEPART("M", arraytemp)
                myYear = DATEPART("YYYY", arraytemp)
                myMonth = ArrayMonths(myMonthNum - 1)
                arraytemp = myMonth
                arraytemp = arraytemp & " " & myYear
               
    next
    response.write "</Select>"
   
%>
                  <br>
                  <BR>
                  <input value="Get Monthly Morning Reports">
              </div>
            </form>
          </td>
          <td width="301" valign="top">            <form method="post" action="FS_parser.asp">
              <p><b><u><img src="images/FRselector.gif" width="300" height="25"><br>
                </u></b><img src="images/Property.gif" width="65" height="18">
                <select name="PROPERTY">
                  <%                 
' Construct path to database
sPath = Request.ServerVariables("Path_Translated")
sPath = Left(sPath,InStrRev(sPath,"\")) & "../lists/lists.mdb"
'
' Open Connection & Recordset
set dbLists = Server.CreateObject("ADODB.Connection")
dbLists.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=TRUE;" & _
"Data Source=" & sPath, "Admin", ""
'
' Check for default...
PROPERTY = Trim(Request("SiteName"))
'
' Create the List using an Access stored proc -this executes the query based on the user's logon
Set oRS=dbLists.Execute(sql + "FR")

DO WHILE NOT oRS.EOF
 mSelected = ""
 IF PROPERTY=trim(oRS("SiteName")) then mSelected=" SELECTED"
 %>
                  <option<%=mSelected%>><%=oRS("SiteName")%></option>
                  <%
 oRS.MoveNext
Loop
%>
                </select>
                <b><u> <br>
                </u></b><img src="images/Report.gif" width="65" height="18">
                <select name="FS_REPORT">
                  <option value="financial">Financial Statements</option>
                  <option value="glc">General Ledger - Current Month</option>
                  <option value="gly">General Ledger - Year-to-Date</option>
                </select>
                <br>
                <img src="images/Period.gif" width="65" height="18">
                <%
response.write "<Select name='FS_ROLLING12'>"   

'SETTING UP THE DATE VARIABLES
mrDate=Date()
myMonthNum = DATEPART("M", mrDate)
myMonth = ArrayMonths(myMonthNum - 1)
myYear = DATEPART("YYYY", mrDate)
arraytemp = myMonth
arraytemp = arraytemp & " " & myYear

    For i=0 to 12
                   
                response.write "<OPTION value='"&arrayTemp&"'>"&arrayTemp&"</OPTION>"
                arraytemp=DateAdd("m", -1, arraytemp)
                myMonthNum = DATEPART("M", arraytemp)
                myYear = DATEPART("YYYY", arraytemp)
                myMonth = ArrayMonths(myMonthNum - 1)
                arraytemp = myMonth
                arraytemp = arraytemp & " " & myYear
               
    next
    response.write "</Select>"
   
%>
                &nbsp;<br>
                <br>
                <input value="Get Monthly Financial Statements">
              </p>
            </form></td>
        </tr>
      </table>
   
    </tr>
  <tr>
    <td height="14" width="1">
    <td colspan="3" valign="top">
      <p><img src="images/scBottomBanner.gif" width="600" height="14"></p>
  </tr>
  <tr>
    <td height="120">
    <td valign="middle" width="268" align="center">
      <p><b>Note:</b>
        <%
' 12 Column countdown
mrDate=Date()
myMonthNum = DATEPART("M", mrDate)
myMonth = ArrayMonths(myMonthNum - 1)
myYear = DATEPART("YYYY", mrDate)
curYear = DATEPART("YYYY", mrDate)
myYear = myYear - 1
arraytemp = myMonth
arraytemp = arraytemp & " " & myYear

' Countdown days of month  

        Select Case (myMonthNum)
            Case 4,6,9,11
                getDaysInMonth = 30
            Case 2
                If (curYear Mod 4 = 0 And curYear Mod 100 <> 0) Or curYear Mod 400 = 0 Then
            getDaysInMonth = 29
            Else
            getDaysInMonth = 28
            End If
            Case Else
                getDaysInMonth = 31
        End Select

counter = getDaysInMonth - Datepart("d", mrDate)

response.write "<font color=""#400080"" & size=""4"">" & arraytemp & "</font><font size=""4""> </font> "
response.write " reports no longer available in "
response.write "<font color=""#400080"" & size=""4"">" & counter & "</font><font size=""4""> </font> "
response.write "day(s)."

%>
      </p>
    <td width="31" valign="top"> 
    <td valign="middle" align="left" width="301">
      <form method="post" action="YearEnd_redirect.asp">
        <img src="images/YearEndSelector.gif" width="300" height="25"><br>
        <img src="images/Property.gif" width="65" height="18">
        <select name="Property">
          <%                 
' Construct path to database
sPath = Request.ServerVariables("Path_Translated")
sPath = Left(sPath,InStrRev(sPath,"\")) & "../lists/lists.mdb"
'
' Open Connection & Recordset
set dbLists = Server.CreateObject("ADODB.Connection")
dbLists.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Persist Security Info=TRUE;" & _
"Data Source=" & sPath, "Admin", ""
'
' Check for default...
PROPERTY = Trim(Request("SiteName"))
'
' Create the List using an Access stored proc -based on the user's logon

Set oRS=dbLists.Execute(sql)

DO WHILE NOT oRS.EOF
 mSelected = ""
 IF PROPERTY=trim(oRS("SiteName")) then mSelected=" SELECTED"
 %>
          <option<%=mSelected%>><%=oRS("SiteName")%></option>
          <%
 oRS.MoveNext
Loop
%>
        </select>
        <br>
        <img src="images/Period.gif" width="65" height="18">
        <%     ' SETUP VARIABLES
    'THIS CODE WILL NEED TO BE MODIFIED TO PROVIDE THE "ROLLING" 12 PERIOD CYCLE

        mrDate=Date()
        myYear = DATEPART("YYYY", mrDate)
        myStartYear = 2003        ' YEAR To START COUNT FROM
        respyear = myStartYear        ' SETTING EQUAL To TEMP VARIABLE SO WE DON'T TRASH OUR STARTING VALUE
    ' CALCULATE THE DIFFERENCE IN YEARS AND
    '     SET TO A TEMP VARIABLE
    yearDiff = myYear - myStartYear
    response.write "<Select name='year'>"
    For i=0 To yearDiff
        response.write "<OPTION value='"&respYear&"'>"&respYear&"</OPTION>"
        respYear = respYear + 1
    next
    response.write "</Select>"
%>
        <input name="Submit2" value="Get Year End">
      </form>
  </tr>
  <tr>
    <td height="33" colspan="4" valign="top"><img src="images/scBottomBanner.gif" width="600" height="14"><br>
      [<font color="#4D4D4D"><a href="http://secure.bamsi.com/help/help.htm">Help
      &amp; Downloads</a></font>]
  </tr>
  <tr>
    <td height="21" colspan="4" valign="top" align="center"><font size="2" face="Geneva, Arial, Helvetica, san-serif"><b>Copyright
      2002 &copy; Bernard/Allison</b></font>
  </tr>
</table>
</body>
</html>




 
Database Driven Secure Client Access User Interface
Published:

Database Driven Secure Client Access User Interface

Cascading Style Sheets or CSS, AJAX, JavaScript, C Programming Language, HTML (of course), XHTML, Active Server Pages or ASP, Macromedia (buildin Read More

Published: