I'm just enquiring, i have a page full of functions in which would be alot of time and money to migrate to asp.net
I'm just wondering would i need to change anything about the following source code?
##############Code Start############
<%
function
k_f_getUserConfiguration(byVal strKey)dim aryAdminUserConfiguration
aryAdminUserConfiguration = session(
"aryAdminUserConfiguration")select
case strKeycase"kernel_userType_intCode"k_f_getUserConfiguration = aryAdminUserConfiguration(0)
case"kernel_user_intKernel_user_PK"k_f_getUserConfiguration = aryAdminUserConfiguration(1)
caseelsek_f_getAdminUserConfiguration =
nullend select
end
functionfunction
k_f_getPageConfiguration(byVal strKey)select
case strKeycase"intKernel_page_PK"k_f_getPageConfiguration = k_v_aryThisPageConfiguration(0)
case"kernel_page_nvcharFileName"k_f_getPageConfiguration = k_v_aryThisPageConfiguration(1)
case"intKernel_menuItem_PK"k_f_getPageConfiguration = k_v_aryThisPageConfiguration(2)
case"intKernel_menuItem_PK_parent"k_f_getPageConfiguration = k_v_aryThisPageConfiguration(3)
caseelsek_f_getPageConfiguration =
nullend select
end
function'retrieves values from the request
function
k_f_getRequest(byVal strVariableName)if lCase(request.serverVariables("request_method")) ="post" thenk_f_getRequest = trim(request.form(strVariableName))
elsek_f_getRequest = trim(request.queryString(strVariableName))
end
ifend
functionfunction
k_f_isEmail(byVal strValue)dim regEx
set regEx =new regExpregEx.ignoreCase =
trueregEx.pattern =
"^[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]@dotnet.itags.org.[a-zA-Z][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$"k_f_isEmail = regEx.test(strValue)
set regEx = nothingend
function'evaluates whether the input is an integer or not
function
k_f_isInteger(byVal value)dim intRoundedNumber
if isNumeric(value) thenintRoundedNumber = cLng(value)
if intRoundedNumber = cDbl(value) thenk_f_isInteger =
trueelsek_f_isInteger =
falseend
ifelsek_f_isInteger =
falseend
ifend
function'saves a client message in an array
sub k_f_saveClientMessage(byVal intMessageType, byVal strMessage)
session(
"aryClientMessage") = array(intMessageType, strMessage)end sub
'dumps any existing client message
sub k_f_dumpClientMessage(byVal intMessageType, byVal strMessage)
session(
"aryClientMessage") =nullend sub
'renders a message out to the client
sub k_f_renderClientMessage()
dim intMessageType, strMessage
dim aryClientMessage
aryClientMessage = session(
"aryClientMessage")if isArray(aryClientMessage) thenintMessageType = aryClientMessage(0)
strMessage = aryClientMessage(1)
select
case intMessageTypecase k_v_intInformationMessageresponse.write(
"<p class=""information"">" & strMessage &"</p>")case k_v_intErrorMessageresponse.write(
"<p class=""error"">" & strMessage &"</p>")end select
session(
"aryClientMessage") =nullelsesession(
"aryClientMessage") =nullend
ifend sub
sub k_f_renderHTMLOutput(byVal strText)
if not(isNull(strText)) thenresponse.write(server.htmlEncode(strText))
end
ifend sub
'sets the selected item in a check / select box
function
k_f_isSelected(byVal valueA, byVal valueB, byVal returnString)dim strTempValueA, strTempValueB
if isNull(valueA) thenstrTempValueA =
""elsestrTempValueA = lCase(cStr(valueA))
end
ifif isNull(valueB) thenstrTempValueB =
""elsestrTempValueB = lCase(cStr(valueB))
end
ifif strTempValueA = strTempValueB thenk_f_isSelected = returnString
elsek_f_isSelected =
""end
ifend
functionfunction
k_f_generatePassword()dim intCharacterNumber, strPassword, i
dim intFirstNumberLocation, intSecondNumberLocation
randomize
intFirstNumberLocation =
int((k_v_intPasswordLength - 1 + 1) * rnd + 1)randomize
intSecondNumberLocation =
int((k_v_intPasswordLength - 1 + 1) * rnd + 1)if (intSecondNumberLocation = intFirstNumberLocation) and (intFirstNumberLocation = k_v_intPasswordLength) thenintSecondNumberLocation = intSecondNumberLocation - 1
elseif (intSecondNumberLocation = intFirstNumberLocation) then
intSecondNumberLocation = intSecondNumberLocation + 1
end
iffor i = 1 to k_v_intPasswordLengthrandomize
if (i = intFirstNumberLocation) or (i = intSecondNumberLocation) thenstrPassword = strPassword & cstr(
int((9 - 0 + 1) * rnd + 0))elseintCharacterNumber =
int((122 - 97 + 1) * rnd + 97)'l as a strPassword character is causing confusion - prevent l from being accepted
if (intCharacterNumber = 108) thenintCharacterNumber = 109
end
ifstrPassword = strPassword & chr(intCharacterNumber)
end
ifnext
k_f_generatePassword = strPassword
end
functionsub k_f_renderDoubleURLOutput(byVal strText)
if not(isNull(strText)) thenresponse.write(server.urlEncode(server.urlEncode(strText)))
end
ifend sub
function
k_f_renderTextForSQL(byVal strText)if not(isNull(strText)) thenk_f_renderTextForSQL = replace(strText,
"'","''")elsek_f_renderTextForSQL =
""end
ifend
function'creates a recordset sorting string
function
k_f_createSortString(byVal strPrimarySortColumn, byVal strPrimarySortOrder, byVal strDefaultSort, byVal rst)dim objField, blnColumnExists, strSortOrder
if len(strPrimarySortColumn) > 0 and len(strPrimarySortOrder) > 0 thenblnColumnExists =
falsefor each objFieldin rst.fieldsif lCase(strPrimarySortColumn) = lCase(objField.name) thenblnColumnExists =
trueexit
forend
ifnext
if blnColumnExists thenif (len(strPrimarySortOrder) = 0) or ((lCase(strPrimarySortOrder) <>"asc") and (lCase(strPrimarySortOrder) <>"desc")) thenk_f_createSortString = strDefaultSort
elseif len(strDefaultSort) > 0 thenstrSortOrder = strPrimarySortColumn &
" " & strPrimarySortOrder &", " & strDefaultSortelsestrSortOrder = strPrimarySortColumn &
" " & strPrimarySortOrderend
ifk_f_createSortString = strSortOrder
end
ifelsek_f_createSortString = strDefaultSort
end
ifelsek_f_createSortString = strDefaultSort
end
ifend
function'returns the primary sort parameters of a given sort string
function
k_f_getPrimarySort(byVal strSort)dim strPrimaryColumn, strPrimaryOrder
dim strPrimarySort
if inStr(strSort,",") > 0 thenstrPrimarySort = trim(left(strSort, (inStr(strSort,
",")-1)))if inStr(strPrimarySort," ") > 0 thenstrPrimaryColumn = trim(left(strPrimarySort, inStr(strPrimarySort,
" ")))strPrimaryOrder = right(strPrimarySort, (len(strPrimarySort) - inStr(strPrimarySort,
" ")))elsestrPrimaryColumn = trim(strPrimarySort)
strPrimaryOrder =
"asc"end
ifelsestrPrimarySort = trim(strSort)
if inStr(strPrimarySort," ") > 0 thenstrPrimaryColumn = trim(left(strPrimarySort, inStr(strPrimarySort,
" ")))strPrimaryOrder = right(strPrimarySort, (len(strPrimarySort) - inStr(strPrimarySort,
" ")))elsestrPrimaryColumn = trim(strPrimarySort)
strPrimaryOrder =
"asc"end
ifend
ifk_f_getPrimarySort = array(strPrimaryColumn, strPrimaryOrder)
end
function'returns a valid scroll to page
function
k_f_createValidScrollToPage(byVal intScrollToPage, byVal rst)if len(intScrollToPage) > 0 thenif isNumeric(intScrollToPage) thenintScrollToPage = cInt(intScrollToPage)
if intScrollToPage < 1 thenk_f_createValidScrollToPage = 1
elseif intScrollToPage> rst.pageCount thenk_f_createValidScrollToPage = rst.pageCount
elsek_f_createValidScrollToPage = intScrollToPage
end
ifend
ifelsek_f_createValidScrollToPage = 1
end
ifelsek_f_createValidScrollToPage = 1
end
ifend
function'renders the header of a standard paging recordset
sub k_f_renderPagingRecordsetHeader(byVal rst)
if not(rst.bof and rst.eof) thenif rst.recordCount = 1 thenresponse.write(rst.recordCount &
" record found.")elseresponse.write(rst.recordCount &
" records found.")end
ifif rst.pageCount > 1 thenresponse.write(
" Showing page " & rst.absolutePage &" of " & rst.pageCount &".")end
ifend
ifend sub
'renders the footer of a standard paging recordset
sub k_f_renderPagingRecordsetFooter(byVal rst, byVal strPagingURL, byVal strThisPrimarySortColumn, byVal strThisPrimarySortOrder)
dim strRecordsetFooter, i
dim intPagesToDisplay, intCurrentPage
intPagesToDisplay = 4
'set the current page
if rst.absolutePosition = adPosEOF thenintCurrentPage = rst.pageCount
elseintCurrentPage = rst.absolutePage - 1
end
ifif not(rst.bof and rst.eof) thenif inStr(strPagingURL,"?") > 0 thenstrPagingURL = strPagingURL &
"&strPrimarySortColumn=" & strThisPrimarySortColumn &"&strPrimarySortOrder=" & strThisPrimarySortOrderelsestrPagingURL = strPagingURL &
"?strPrimarySortColumn=" & strThisPrimarySortColumn &"&strPrimarySortOrder=" & strThisPrimarySortOrderend
ifif rst.pageCount > 1 thenstrRecordsetFooter = strRecordsetFooter &
"<div class=""Paging-Recordset-Footer"">"if (intCurrentPage > 1) or (rst.absolutePage = adPosEOF) thenstrRecordsetFooter = strRecordsetFooter &
"<div class=""Paging-Recordset-Footer-Left"">"if rst.absolutePage = adPosEOF thenstrRecordsetFooter = strRecordsetFooter &
"<a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=1""> |« </a> <a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=" & (rst.pageCount - 1) &"""> « </a>"elsestrRecordsetFooter = strRecordsetFooter &
"<a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=1""> |« </a> <a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=" & (intCurrentPage - 1) &"""> « </a>"end
ifstrRecordsetFooter = strRecordsetFooter &
"</div>"end
ifstrRecordsetFooter = strRecordsetFooter &
"<div class=""Paging-Recordset-Footer-Pages"">"'count from below to current page
for i = 0 to intPagesToDisplayif ((intCurrentPage - (intPagesToDisplay - i)) > 0) and ((intCurrentPage - (intPagesToDisplay - i)) < intCurrentPage) thenstrRecordsetFooter = strRecordsetFooter &
"<a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=" & cStr(intCurrentPage - (intPagesToDisplay - i)) &"""> " & cStr(intCurrentPage - (intPagesToDisplay - i)) &" </a>"end
ifnext
'count current page
strRecordsetFooter = strRecordsetFooter &
"<span class=""list_nav_act""> " & cStr(intCurrentPage) &" </span>"'count to further page
for i = 1 to intPagesToDisplayif ((intCurrentPage + i) <= rst.pageCount) thenstrRecordsetFooter = strRecordsetFooter &
"<a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=" & cStr(intCurrentPage + i) &"""> " & cStr(intCurrentPage + i) &" </a>"end
ifnext
strRecordsetFooter = strRecordsetFooter &
"</div>"if (intCurrentPage < rst.pageCount) and (rst.absolutePage <> adPosEOF) thenstrRecordsetFooter = strRecordsetFooter &
"<div class=""Paging-Recordset-Footer-Right"">"strRecordsetFooter = strRecordsetFooter &
"<a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=" & (intCurrentPage + 1) &"""> » </a> <a href="http://links.10026.com/?link="" & strPagingURL &"&intScrollToPage=" & rst.pageCount &"""> »| </a>"strRecordsetFooter = strRecordsetFooter &
"</div>"end
ifstrRecordsetFooter = strRecordsetFooter &
"<br style=""clear: both;"" /></div>"response.write(strRecordsetFooter)
end
ifend
ifend sub
'renders the heading of a sortable column in standard paging recordset
sub k_f_renderColumnHeading(byVal strHeadingName, byVal strHeadingCode, byVal strHeadingURL, byVal strThisPrimarySortColumn, byVal strThisPrimarySortOrder)
dim strOrderToSort
if (strThisPrimarySortOrder ="asc") and (strThisPrimarySortColumn = strHeadingCode) thenstrOrderToSort =
"desc"elsestrOrderToSort =
"asc"end
ifif inStr(strHeadingURL,"?") > 0 thenstrHeadingURL = strHeadingURL &
"&strPrimarySortColumn=" & strHeadingCode &"&strPrimarySortOrder=" & strOrderToSortelsestrHeadingURL = strHeadingURL &
"?strPrimarySortColumn=" & strHeadingCode &"&strPrimarySortOrder=" & strOrderToSortend
ifif strThisPrimarySortColumn = strHeadingCode thenif strThisPrimarySortOrder ="asc" thenresponse.write(
"<a href="http://links.10026.com/?link="" & strHeadingURL &""">" & strHeadingName &"</a> <img src="http://pics.10026.com/?src="theme/list_asc.gif"" heigth=""7"" width=""12"" border=""0"">")elseresponse.write(
"<a href="http://links.10026.com/?link="" & strHeadingURL &""">" & strHeadingName &"</a> <img src="http://pics.10026.com/?src="theme/list_desc.gif"" heigth=""7"" width=""12"" border=""0"">")end
ifelseresponse.write(
"<a href="http://links.10026.com/?link="" & strHeadingURL &""">" & strHeadingName &"</a>")end
ifend sub
'returns an array of keywords from a list containing spaces and ""
function
k_f_getKeywords(byVal strKeywords)dim blnInReplaceZone, strMouldedSearchText, strSubString, i, aryKeywords
if len(strKeywords) > 0 thenaryKeywords = split(strKeywords,
" ")elsearyKeywords =
nullend
ifk_f_getKeywords = aryKeywords
end
functionfunction
k_f_prepareForADOParameter(byVal value, byVal intDataType, byVal lngLength)dim tempValue
tempValue = value
select
case intDataTypecase adIntegerif not(k_f_isInteger(tempValue)) thentempValue =
nullelsetempValue = cLng(tempValue)
end
ifcase adVarCharif not(isNull(tempValue)) thentempValue = cStr(tempValue)
if len(tempValue) = 0 thentempValue =
nullelsetempValue = left(tempValue, lngLength)
end
ifend
ifcase adBooleanif varType(tempValue) <> vbBoolean thentempValue = cBool(tempValue)
end
ifcase adDateif isDate(tempValue) thentempValue = cDate(tempValue)
elsetempValue =
nullend
ifcase adDoubleif isNumeric(tempValue) thentempValue = cDbl(tempValue)
elsetempValue =
nullend
ifcase adGUIDif len(tempValue) = 0 thentempValue =
nullend
ifend select
k_f_prepareForADOParameter = tempValue
end
function'returns an array of partnumbers from a list separated by vbCRLF
function
k_f_getPartnumbers(byVal strKeywords)dim aryPartnumbers, i
if len(strKeywords) > 0 thenaryPartnumbers = split(strKeywords, vbCRLF)
for i = 0 to uBound(aryPartnumbers)aryPartnumbers(i) = trim(aryPartnumbers(i))
next
elsearyPartnumbers =
nullend
ifk_f_getPartnumbers = aryPartnumbers
end
functionfunction
k_f_prepareForXMLOutput(value)dim strOutput
'there are 5 special characters that need to be replaced in any data represented by XML
'& with &
'< with <
'> with >
'" with "
''with 'if isNull(value) thenk_f_prepareForXMLOutput =
""elsestrOutput = cStr(value)
if len(strOutput) > 0 thenstrOutput = replace(strOutput,
"&","&")strOutput = replace(strOutput,
"<","<")strOutput = replace(strOutput,
">",">")strOutput = replace(strOutput,
"""",""")strOutput = replace(strOutput,
"'","'")end
ifk_f_prepareForXMLOutput = strOutput
end
ifend
functionfunction
k_f_prepareForXMLDateOutput(dtmValue)dim strYear, strMonth, strDay
if isDate(dtmValue) thenstrYear = cStr(datePart(
"yyyy", dtmValue))strMonth = cStr(datePart(
"m", dtmValue))strDay = cStr(datePart(
"d", dtmValue))if len(strMonth) = 1 thenstrMonth =
"0" & strMonthend
ifif len(strDay) = 1 thenstrDay =
"0" & strDayend
ifk_f_prepareForXMLDateOutput = strYear &
"-" & strMonth &"-" & strDayelsek_f_prepareForXMLDateOutput =
nullend
ifend
functionfunction
k_f_prepareForXMLDateTimeOutput(dtmValue)dim strYear, strMonth, strDay
dim strHour, strMinute, strSecond
if isDate(dtmValue) thenstrYear = cStr(datePart(
"yyyy", dtmValue))strMonth = cStr(datePart(
"m", dtmValue))strDay = cStr(datePart(
"d", dtmValue))strHour = cStr(datePart(
"h", dtmValue))strMinute = cStr(datePart(
"n", dtmValue))strSecond = cStr(datePart(
"s", dtmValue))if len(strMonth) = 1 thenstrMonth =
"0" & strMonthend
ifif len(strDay) = 1 thenstrDay =
"0" & strDayend
ifif len(strHour) = 1 thenstrHour =
"0" & strHourend
ifif len(strMinute) = 1 thenstrMinute =
"0" & strMinuteend
ifif len(strSecond) = 1 thenstrSecond =
"0" & strSecondend
ifk_f_prepareForXMLDateTimeOutput = strYear &
"-" & strMonth &"-" & strDay &"T" & strHour &":" & strMinute &":" & strSecondelsek_f_prepareForXMLDateTimeOutput =
nullend
ifend
functionfunction
k_f_prepareForXMLBooleanOutput(blnValue)if blnValue thenk_f_prepareForXMLBooleanOutput =
"true"elsek_f_prepareForXMLBooleanOutput =
"false"end
ifend
functionfunction
k_f_getXMLValueFromSingleNode(byVal objNode, byVal intDataType)if objNode is nothing thenk_f_getXMLValueFromSingleNode =
nullelseselect
case intDataTypecase adVarChark_f_getXMLValueFromSingleNode = replace(trim(objNode.text), vbLF, vbCRLF)
caseelsek_f_getXMLValueFromSingleNode = trim(objNode.text)
end select
end
ifend
functionfunction
k_f_renderIndent(byVal intSize, byVal intOffset)k_f_renderIndent = string(intSize - intOffset,
" ")end
functionfunction
k_f_RC4(ByRef pStrMessage, ByRef pStrKey)Dim lBytAsciiAry(255)
Dim lBytKeyAry(255)
Dim lLngIndex
Dim lBytJump
Dim lBytTemp
Dim lBytY
Dim lLngT
Dim lLngX
Dim lLngKeyLength
' Validate data
If Len(pStrKey) = 0 Then Exit Function
If Len(pStrMessage) = 0 Then Exit Function
' transfer repeated key to array
lLngKeyLength = Len(pStrKey)
For lLngIndex = 0 To 255
lBytKeyAry(lLngIndex) = Asc(Mid(pStrKey, ((lLngIndex) Mod (lLngKeyLength)) + 1, 1))
Next
' Initialize S
For lLngIndex = 0 To 255
lBytAsciiAry(lLngIndex) = lLngIndex
Next
' Switch values of S arround based off of index and Key value
lBytJump = 0
For lLngIndex = 0 To 255
' Figure index to switch
lBytJump = (lBytJump + lBytAsciiAry(lLngIndex) + lBytKeyAry(lLngIndex)) Mod 256
' Do the switch
lBytTemp = lBytAsciiAry(lLngIndex)
lBytAsciiAry(lLngIndex) = lBytAsciiAry(lBytJump)
lBytAsciiAry(lBytJump) = lBytTemp
Next
lLngIndex = 0
lBytJump = 0
For lLngX = 1 To Len(pStrMessage)
lLngIndex = (lLngIndex + 1) Mod 256 ' wrap index
lBytJump = (lBytJump + lBytAsciiAry(lLngIndex)) Mod 256 ' wrap J+S()
' Add/Wrap those two
lLngT = (lBytAsciiAry(lLngIndex) + lBytAsciiAry(lBytJump)) Mod 256
' Switcheroo
lBytTemp = lBytAsciiAry(lLngIndex)
lBytAsciiAry(lLngIndex) = lBytAsciiAry(lBytJump)
lBytAsciiAry(lBytJump) = lBytTemp
lBytY = lBytAsciiAry(lLngT)
' Character Encryption ...
k_f_RC4 = k_f_RC4 & Chr(Asc(Mid(pStrMessage, lLngX, 1)) Xor lBytY)
Next
end
function%>
########Code End###########
Would i have to change anything of the above source code? Or would i have to go through and re-do the entire thing?
I hope not :( only have about 7 days left to finish this project, and this file took about a week to code and debug
Cheers for the help
Looking at the code, I think its good idea to rewrite complete code in ASP.NET using existing logic from existing ASP code. If you decided to change in existing code, then you will lead to make modification in each and every line.
0 comments:
Post a Comment