<%@ Language=VBScript %> <% Option Explicit %> <% Response.Buffer = True %> <% ' ----------------------------------------------------------------- ' -- THERE SHOULD BE NO NEED TO EDIT ANYTHING BELOW THIS LINE ' -- APART FROM POSSIBLY THE openDB() FUNCTION TO OPEN THE DATABASE ' ----------------------------------------------------------------- ' -- START ERROR HANDLING ' -- UNCOMMENT IF REQUIRED BUT I RECOMMEND LEAVING IT COMMENTED OUT FOR BETTER ERROR REPORTING WHILE DEVELOPING ' On Error Resume Next ' -- DEFINE DATABASE FUNCTIONS ' -- SET SOME BASIC VARIABLES Dim DSN_Name ' Application DB Connection Dim objConn ' Connection Object Dim strSQL ' SQL String Dim objRs ' Recordset Object Dim DB_CONNECTIONSTRING Dim timeDiff timeDiff = 15 ' -- FUNCTION TO OPEN THE DATABASE CONNECTION. USAGE = Call openDB () ' -- COMMENT-OUT OR UNCOMMENT-IN TO USE ANOTHER CONNECTION TYPE Function openDB DB_CONNECTIONSTRING = "DRIVER={MySQL ODBC 3.51 Driver}; SERVER=h41mysql57.secureserver.net; PORT=3306; DATABASE=bisaas; USER=bisaas; PASSWORD=JMNH9.wn@!; OPTION=0;" CONST DB_TYPE="MySQL" Set objConn = Server.CreateObject("ADODB.Connection") objConn.Open DB_CONNECTIONSTRING End Function ' -- FUNCTION TO CREATE A RECORDSET. USAGE = Call createRS (objRs) Function createRS (objRs) Set objRS = Server.CreateObject("ADODB.Recordset") objRS.LockType = 3 objRS.CursorLocation = 3 objRS.CursorType = 0 Set objRS = objConn.Execute (strSQL) End Function ' -- FUNCTION TO CLOSE CONNECTION AND RELEASE OBJECTS. USAGE = Call closeConnRS (objRs, objConn) Function closeConnRS (objRs, objConn) If isObject (objRs) Then If LCase(TypeName(objRS)) = "recordset" Then If objRs.State = 1 Then objRs.Close End If End If Set objRs = Nothing End If If isObject (objConn) Then If LCase(TypeName(objConn)) = "connection" Then If objConn.State = 1 Then objConn.Close End If End If Set objConn = Nothing End If End Function ' -- END DATABASE FUNCTIONS ' -- DEFINE RECORD FUNCTION Function recordStandClicks(hall, stand) strSQL = "INSERT INTO record_stand (mem_id, hall, stand, login_date) VALUES ('" + cStr(Request.Cookies("uid")) + "','" + hall + "','" + stand + "',curDate())" objConn.Execute (strSQL) End Function Function recordHallClicks(hall) strSQL = "INSERT INTO record_hall (mem_id, hall, login_date) VALUES ('" + cStr(Request.Cookies("uid")) + "','" + hall + "',curDate())" objConn.Execute (strSQL) End Function Function recordKeynoteClicks(keynote) strSQL = "INSERT INTO record_keynote (mem_id, keynote, login_date) VALUES ('" + cStr(Request.Cookies("uid")) + "','" + keynote + "',curDate())" objConn.Execute (strSQL) End Function ' -- END RECORD FUNCTIONS ' -- DEFINE ARRAY FUNCTIONS ' -- SET ARRAY VARIABLES Dim intpage ' For Request.QueryString Page Number Dim arrayData ' Array for objRs.GetRows Dim arrayDataCount ' For Total Number of Records in Array Dim i ' For Looping Through Array Dim rowbgcolor ' For Alternate Rowcolour rowbgcolor = "#F3F3F3" Dim intRecordsPerPage ' Number of Records to be displayed per page Dim intTotalPages ' Total number of Array Records Dim intFirstRecord ' First record in Array Dim intLastRecord ' Last record in Array Dim totalRecords ' -- FUNCTION TO STORE objRS RECORDSET RESULTS IN ARRAY. USAGE = Call arrayGetRows () Function arrayGetRows If not objRs.EOF Then arrayData = objRs.GetRows arrayDataCount = UBound (arrayData, 2) + 1 End If End Function ' -- FUNCTION FOR ARRAY RECORDSET PAGING. USAGE = Call arrayPaging () Function arrayPaging intRecordsPerPage = 20 totalRecords = ubound(arrayData, 2)+1 intTotalpages = int((ubound(arrayData, 2)/intRecordsPerPage)+1) intFirstRecord = (intPage - 1) * intRecordsPerPage If intFirstRecord + (intRecordsPerPage - 1) >= ubound(arrayData,2) then intLastRecord = ubound(arrayData, 2) Else intLastRecord = intFirstRecord + (intRecordsPerPage - 1) End If End Function ' -- FUNCTION TO ALTERNATE ROW COLOURS. USAGE = Call rowColor () Function rowColor If rowbgcolor = "#F3F3F3" Then rowbgcolor = "#FFFFFF" Else rowbgcolor = "#F3F3F3" End If End Function ' -- END ARRAY FUNCTIONS function chkEmail(theAddress) ' checks for a vaild email ' returns 1 for invalid addresses ' returns 1 for invalid addresses dim atCnt chkEmail = 0 ' chk length if len(theAddress) < 5 then ' a@b.c should be the shortest an ' address could be chkEmail = 1 ' chk format ' has at least one "@" elseif instr(theAddress,"@") = 0 then chkEmail = 1 ' has at least one letter before "@" elseif instrrev(theAddress,"@") = 1 then chkEmail = 1 ' has at least one "." elseif instr(theAddress,".") = 0 then chkEmail = 1 ' has no more than 3 chars after last "." elseif len(theAddress) - instrrev(theAddress,".") > 3 then chkEmail = 1 ' has less than 2 chars after last "." elseif len(theAddress) - instrrev(theAddress,".") < 2 then chkEmail = 1 ' has no "_" after the "@" elseif instr(theAddress,"_") <> 0 and _ instrrev(theAddress,"_") > instrrev(theAddress,"@") then chkEmail = 1 else ' has only one "@" atCnt = 0 for i = 1 to len(theAddress) if mid(theAddress,i,1) = "@" then atCnt = atCnt + 1 end if next if atCnt > 1 then chkEmail = 1 end if ' chk each char for validity for i = 1 to len(theAddress) if not isnumeric(mid(theAddress,i,1)) and _ (lcase(mid(theAddress,i,1)) < "a" or _ lcase(mid(theAddress,i,1)) > "z") and _ mid(theAddress,i,1) <> "_" and _ mid(theAddress,i,1) <> "." and _ mid(theAddress,i,1) <> "@" and _ mid(theAddress,i,1) <> "-" then chkEmail = 1 end if next end if end function %> <% Dim arrayNews Dim arrayNewsSize ' -- CHECK IF REQUEST.QUERYSTRING EXISTS FOR RECORD PAGING If Request.QueryString ("page") <> "" Then intPage = cint(Request.QueryString("page")) Else intPage = 1 End If ' -- OPEN DATABASE CONNECTION Call openDB () ' -- GET NEWS strSQL = "SELECT id, newstitle FROM news ORDER BY newsdate DESC" Call createRS (objRs) ' -- ASSIGN objRS TO ARRAY Call arrayGetRows () arrayNews = arrayData ' -- get number of items in array for loop to display If isArray (arrayNews) Then arrayNewsSize = UBound (arrayNews, 2) End If ' -- CLOSE THE CONNECTION AND OBJECTS Call closeConnRS (objRs, objConn) ' -- SET UP ARRAY PAGING If isArray (arrayNews) Then intRecordsPerPage = 10 intTotalpages = int((ubound(arrayNews, 2)/intRecordsPerPage)+1) intFirstRecord = (intPage - 1) * intRecordsPerPage If intFirstRecord + (intRecordsPerPage - 1) >= ubound(arrayNews,2) then intLastRecord = ubound(arrayNews, 2) Else intLastRecord = intFirstRecord + (intRecordsPerPage - 1) End If End If %> Business Intelligence Software as a Service (BI SAAS)
<% If isArray (arrayNews) Then For i = intFirstRecord to intLastRecord %> <%= arrayNews (1,i) %>

<% Next End If %>


ADVERTISEMENT