CLASSIC ASP QUERY - asp-classic

do until rs1.eof
elseif year(tDate) = year(now) then
elseif rs1("leavetype") = 1 and (rs1("statusLev1") = "z" and rs1("statusLev2") = "z") then
childcare = childcare + rs1("totaldays")
elseif rs1("leavetype") = 28 and (rs1("statusLev1") = "P" and rs1("statusLev2") = "P") then
%>
<script>alert("You are...")
history.go(-1)</script>
<%**
end if
end if
rs1.movenext
loop
rs1.movefirst
After submitting leavetype = 28 ,i can't apply any other leave as the message box is showing.I want to show the message box only if i applied for leave type 28 and status level is p.Otherwise i don't need to the message box for leave 1 or 2.How can i modify..?
Thanks

ASP is executed on the server side, the <script>.... is executed on the client site.
What you are looking for is ( I think )
Response.Write("<script>alert(""You are...""); history.go(-1)<script>")
withgout the %> and <%. So writing the javascript code so that it appears in the client side html .

Related

How to check if form is an input file field? Asp Classic

I have some code that checks input values before I insert it into the db. And it works as it should, it checks all form inputs, but I would like it to exclude all the file upload inputs, so it doesn´t check the values of file inputs when I upload an image. But I don´t know how to make it work, so any input really appreciated. Thanks.
This is what I have now.
Dim BlackList, ErrorPage
BlackList = Array("#","$","%","^","&","|",_
"<",">","'","""","(",")",_
"--", "/*", "*/", "##",_
"cursor","exec","execute",_
"nchar", "varchar", "nvarchar", "iframe", "char", "alter", "begin", "cast", "create", "insert","delete", "drop", "table"_
)
Function CheckStringForSQL(str,varType)
On Error Resume Next
Dim lstr
' If the string is empty, return false that means pass
If ( IsEmpty(str) ) Then
CheckStringForSQL = false
Exit Function
ElseIf ( StrComp(str, "") = 0 ) Then
CheckStringForSQL = false
Exit Function
End If
lstr = LCase(str)
' Check if the string contains any patterns in our black list
For Each s in BlackList
If(IsExceptionList(s,varType)=False) then
If ( InStr (lstr, s) <> 0 ) Then
CheckStringForSQL = true
Exit Function
End If
End If
Next
CheckStringForSQL = false
End Function
CookieExceptionList = Array("""","(",")","!")
Function IsExceptionList(str,varType)
If(varType="cookie") then
For Each item in CookieExceptionList
If(item=str) then
IsExceptionList=True
Exit Function
End If
Next
End If
IsExceptionList=False
End Function
--SO HERE I NEED TO CHECK IF IT IS A FILE INPUT, AND IF SO, NOT RUN THE BELOW--
For Each s in Request.form
If ( CheckStringForSQL(Request.form(s),"form") ) Then
feltext="Fel"
End If
Next

Get the name and value of all cookies

I'm trying to get all cookies and so far found nothing using Google and other topics.
What I have tried so far:
If (Request.Cookies().Count > 0) Then
sss.Visible = True
sss.InnerHtml = Request.Cookies().Count
End If
I can get the Cookies().Count and return a number, but my goal is get the name and value of all cookies. I have no idea what I should use. I'm good in PHP but forced to do this via .NET and can't find something like var_dump($_COOKIE); in VB.NET. Any ideas?
If (Request.Cookies.Count > 0) Then
sss.Visible = True
Dim i as Ingeter
For i = 0 To (Request.Cookies.Count - 1)
sss.InnerHtml = sss.InnerHtml + Request.Cookies.Get(i).Name + " = " + Request.Cookies.Get(i).Value + vbCrLf
Next
End If

Decompiling a lua String(text) Compiled into ASCII

I am trying to decrypt an encrypted lua code, because:
First: I don't want to create it from the begging.
Second: It sounds fun!
I've created a simple program at Visual Basic 2013 that executes lua functions from a file, the files as you guys can see below contains the encrypted code defined as 'code' in ASCII bytes and my lua code translate it back to the original form.
The problem is: I can translate some words and sign but it still pretty mess, since this is a lua code and contains numbers, signs and words.
The files of the program, as the code encrypted and the code to decrypt can be found at my Gist: https://gist.github.com/DarkShinz/e9aeca7dd1ac1035cf6e ; so you guys can reproduce my so far progress.
I need advices to improve my following code, because, so far, it decrypts some words but others are still just numbers and some signs. Still a mess to the eye.
function tablelength(T)
local count = 0
for _ in pairs(T) do count = count + 1 end
return count
end
local code = {SOME COMPILED LUA CODE} //Mine is too extensive to be added here
local finalString = "Yay! :"
local codeLength = tablelength(code)
local text = nil
for i = 1, codeLength do
local letter = string.char(code[i])
if (letter:match("%w")) then
elseif (letter:match("%d")) then
elseif (letter:match("%s")) then
elseif (letter:match("%p")) then
elseif (letter:match("%(")) then
elseif (letter:match("%)")) then
elseif (letter:match("%.")) then
elseif (letter:match("%+")) then
elseif (letter:match("%*")) then
elseif (letter:match("%#")) then
elseif (letter:match("%?")) then
elseif (letter:match("%^")) then
elseif (letter:match("%$")) then
elseif (letter:match("%-")) then
elseif (letter:match("%=")) then
elseif (letter:match("%_")) then
elseif (letter:match("%[")) then
elseif (letter:match("%]")) then
elseif (letter:match("%:")) then
elseif (letter:match("%,")) then
elseif (letter:match("%#")) then
elseif (letter:match("%&")) then
else
letra = string.byte(letter)
end
finalString = finalString .. letra
end
print(finalString)
This is my output
I wish I had a full clean lua source code.

Detect HTTP_USER_AGENT in asp

I need in an asp site, detect if the device used is a tablet.
i'd like to know which user agent is use for this one
for now i do this
agent = Request.ServerVariables("HTTP_USER_AGENT")
Set reg = New RegExp
With reg
.Pattern = "(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|windows ce|pda|mobile|mini|palm)"
.IgnoreCase = True
.Global = True
End With
match = reg.Test(agent)
If match Then
session("IsMobileBrowser") = 1
Else
session("IsMobileBrowser") = 0
End If
Thanks
We are using this API to dectect mobile devices on our classic asp website and it works great.
https://code.google.com/p/mobileesp/source/browse/#svn/JavaScript
Use DetectTierTablet function to detect tablets.
Also with very few changes to the code we were able to include it server side. Just had to replace:
if (navigator && navigator.userAgent)
this.uagent = navigator.userAgent.toLowerCase();
with
if (Request.ServerVariables("HTTP_USER_AGENT").Item != null)
this.uagent = Request.ServerVariables("HTTP_USER_AGENT").Item.toLowerCase();

Classic ASP xmlhhtp between < head> < /head> tags only

With classic ASP, i retrieve data from an another webpage with XMLHTTP, and save it to database.
private function gethttp(url)
Set strhttp=server.createobject("MSXML2.ServerXMLHTTP.6.0")
strhttp.Open "get",url,false
strhttp.send
gethttp=strhttp.responsetext
Set strhttp=Nothing
End function
url="http://www.noktadomains.com/buydomains/BodyBalance#BodyBalancing.com"
text=gethttp(url)
response.write(text)
is it possible only call source between < head>...< /head> tags?
Because the whole page is very large and takes too long to load, and i do not need the < html>...< /html> part of it !!
Thanks
Do you want to just extract the HEAD section out, like this?
(Add this code to the end of your function)
intStart = InStr(text, "<head>)
If intStart <> 0 Then
intStart = intStart + 6
intEnd = InStr(intStart, text, "</head>")
If intEnd <> 0 Then
text = Mid(text, intStart, intEnd - intStart)
End If
End If

Resources