%
dim error, error_msg, all_done
function ProcessPK3data
'Adding a new pk3, so lets make sure they have a cookie!
'this will also make sure they are coming from this server
'and not some shit head spamming us
if trim(Request.Form("old_pk3")) = "" then
error = true
error_msg = error_msg & "
You must enter the old pk3 file name"
end if
if trim(Request.Form("new_pk3")) = "" then
error = true
error_msg = error_msg & "You must enter the new pk3 file name"
end if
if trim(Request.Form("bugfix")) = "" then
error = true
error_msg = error_msg & "Its a good idea to let people know what has changed between the releases"
else
'trim and make sure the text is not too long without a space
dim bugfix
bugfix = SafeLength(Trim(Request.Form("bugfix")))
'Response.Write("bugfix=[" & bugfix & "]
")
'strip all html tags that are not welcomed
bugfix = striphtml(bugfix)
'check for links and insert a hrefs
'bugfix = InsertHyperlinks(bugfix)
'does an auto (
insert) line return
'bugfix = Replace(bugfix,chr(13),"
")
if len(Request.Form("bugfix")) > 450 then
error = true
error_msg = error_msg & "Your description of what has changed is too long and has been cut short at the limit. (450 characters)"
end if
end if
if trim(Request.Form("download")) = "" then
error = true
error_msg = error_msg & "You really should let people know where they can download the new file from"
end if
'and one more check
if (Request.QueryString("add") = "y") and not error then
set con = Server.CreateObject("ADODB.Connection")
con.Open(DSN)
'open the connection to the DSN (SQL server)
query = "SELECT old_pk3, new_pk3, bugfix from q3a_bug_fix " & _
"WHERE " & _
" old_pk3 = '" & SQLSafe(Request.Form("old_pk3")) & "' and " & _
" new_pk3 = '" & SQLSafe(Request.Form("new_pk3")) & "' and " & _
" bugfix = '" & SQLSafe(bugfix) & "'"
'for a quick debug of the query
'Response.Write("query = [" & query & "]
")
set RS = con.Execute(query)
if not RS.eof then
'this pk3 is already listed :[
error = true
error_msg = error_msg & "The pk3 you are trying to add is already listed, sorry"
end if
con.close
end if
'===========================
'done checking form data, onto the submission
if (Request.QueryString("add") = "y") and not error then
'its an new entry
'Response.Write("inserting new record")
set con = Server.CreateObject("ADODB.Connection")
con.Open(DSN)
'open the connection to the DSN (SQL server)
query = "INSERT INTO q3a_bug_fix " & _
"(old_pk3, new_pk3, bugfix, download, added_by) " & _
"VALUES (" & _
" '" & SQLSafe(Request.Form("old_pk3")) & "'," & _
" '" & SQLSafe(Request.Form("new_pk3")) & "'," & _
" '" & SQLSafe(bugfix) & "'," & _
" '" & SQLSafe(Request.Form("download")) & "'," & _
" '" & Request.Cookies("lvl")("forumid") & "'" & _
")"
'for a quick debug of the query
'Response.Write("query = [" & query & "]
")
con.Execute(query)
con.close
all_done = true
elseif (Request.QueryString("upd") = "y") and not error then
'we can guess its update :]
'Response.Write("updating an old record")
set con = Server.CreateObject("ADODB.Connection")
con.Open(DSN)
'open the connection to the DSN (SQL server)
query = "UPDATE q3a_bug_fix " & _
"SET old_pk3 = '" & SQLSafe(Request.Form("old_pk3")) & "', " & _
" new_pk3 = '" & SQLSafe(Request.Form("new_pk3")) & "', " & _
" bugfix = '" & SQLSafe(bugfix) & "', " & _
" download = '" & SQLSafe(Request.Form("download")) & "' " & _
"WHERE id = " & Request.QueryString("pk3") & " and " & _
" added_by = '" & Request.Cookies("lvl")("forumid") & "'"
'for a quick debug of the query
'Response.Write("query = [" & query & "]
")
con.Execute(query)
con.close
all_done = true
end if
'===========
'write the XML file for left nav
set tigCON = Server.CreateObject("ADODB.Connection")
tigCON.Open(DSN)
' set up the query to list the news by date Desc
query = "SELECT top 6 old_pk3 " & _
"FROM q3a_bug_fix " & _
"where hide_it = 0 " & _
"ORDER BY date_added DESC"
'Response.Write("Query = [" & query & "]
")
set tigRS = tigCON.Execute(query)
'======================
'writing the XML format map list
const ForReading = 1, ForWriting = 2
dim f
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(current_ROOT & "xml\recentPK3update.xml", ForWriting, True)
f.Writeline ""
' make sure we have see if there is no records
if (tigRS.EOF) Then
f.Writeline " No PK3's atm"
end if
do while not (tigRS.EOF)
f.Writeline " "
f.Writeline " " & tigRS("old_pk3") & ""
f.Writeline " "
tigRS.MoveNext
loop
f.Writeline ""
tigRS.close
tigCON.close
'end writing the XML file for left nav
'===========
end function
%>