%
'###
'# this file does NOT have error checking - if bad values are submitted the kaos news script may break
'# it is intended to be used alongside ui_scriptstructure.asp by the script admin only
'#
'# this file simply takes the script options given and generates the appropriate files for use by the kaos news script
'###
zobjConn.Close
Set zobjConn = Nothing
If z1_AccessLevel <> 3 Then
Response.Redirect "ui_index.asp?msg=You naughty monkey, you shouldnt be trying to use that page"
End If
'# scriptStructure.xml generation #
Function prepare(formvar)
Dim i
i = Request.Form(formvar)
i = Replace(i,vbcrlf,"")
prepare = i
End Function
Dim zobjXml,zobjXmlNode
Set zobjXml = Server.CreateObject("Microsoft.XMLDOM")
zobjXml.Load(Server.MapPath("scriptStructure.xml"))
Set zobjXmlNode = zobjXml.documentElement
'-- set the chosen attribute for date/format styles --
zobjXmlNode.childNodes(0).attributes(0).text = Request.Form("newsdate")
zobjXmlNode.childNodes(1).attributes(0).text = Request.Form("newscomments")
zobjXmlNode.childNodes(2).attributes(0).text = Request.Form("newsform")
zobjXmlNode.childNodes(3).attributes(0).text = Request.Form("commentsdate")
zobjXmlNode.childNodes(4).attributes(0).text = Request.Form("commentsform")
zobjXmlNode.childNodes(5).attributes(0).text = Request.Form("indexowndate")
zobjXmlNode.childNodes(6).attributes(0).text = Request.Form("indexownform")
zobjXmlNode.childNodes(7).attributes(0).text = Request.Form("indexremotedate")
zobjXmlNode.childNodes(8).attributes(0).text = Request.Form("indexremoteform")
zobjXmlNode.childNodes(9).attributes(0).text = Request.Form("searchform")
'-- set custom styles --
zobjXmlNode.childNodes(0).childNodes(2).text = prepare("newsdate1")
zobjXmlNode.childNodes(1).childNodes(2).text = prepare("newscomments1")
zobjXmlNode.childNodes(2).childNodes(1).text = prepare("newsform1")
zobjXmlNode.childNodes(3).childNodes(2).text = prepare("commentsdate1")
zobjXmlNode.childNodes(4).childNodes(1).text = prepare("commentsform1")
zobjXmlNode.childNodes(5).childNodes(2).text = prepare("indexowndate1")
zobjXmlNode.childNodes(6).childNodes(1).text = prepare("indexownform1")
zobjXmlNode.childNodes(7).childNodes(2).text = prepare("indexremotedate1")
zobjXmlNode.childNodes(8).childNodes(1).text = prepare("indexremoteform1")
zobjXmlNode.childNodes(9).childNodes(1).text = prepare("searchform1")
'-- save xml file --
zobjXml.Save(Server.MapPath("scriptStructure.xml"))
'# zWrite.asp generation #
Function make_newsStructure()
Dim structure,date1,email1
email1 = """ & zobjRS(6,arrayid) & """
date1 = """ & zDate(""" & zobjXmlNode.childNodes(0).childNodes((CInt(Request.Form("newsdate"))-1)).text & """,zobjRS(2,arrayid)) & """
structure = " & """ & Replace(zobjXmlNode.childNodes(2).childNodes((CInt(Request.Form("newsform"))-1)).text,"""","""""") & """ & "
structure = Replace(structure,"[title]",""" & zobjRS(1,arrayid) & """,1,-1,1)
structure = Replace(structure,"[count]",""" & arrayid & """,1,-1,1)
structure = Replace(structure,"[category]",""" & zobjRS(5,arrayid) & """,1,-1,1)
structure = Replace(structure,"[content]",""" & zobjRS(3,arrayid) & """,1,-1,1)
structure = Replace(structure,"[comments_link]",""" & zTmpComments & """,1,-1,1)
structure = Replace(structure,"[user]",email1,1,-1,1)
structure = Replace(structure,"[date]",date1,1,-1,1)
structure = Replace(structure," & """" & "," & ") 'removes unneccessary stuff - ' & "" & ' to ' & '
structure = Mid(structure,4,(Len(structure) - 6))
make_newsStructure = structure
End Function
Function make_commentsLink()
Dim structure
structure = """ & """ & Replace(zobjXmlNode.childNodes(1).childNodes((CInt(Request.Form("newscomments"))-1)).text,"""","""""") & """ & """
structure = Replace(structure,"[comments]",""" & zobjRS(4,arrayid) & """,1,-1,1)
structure = Replace(structure,"[count]",""" & arrayid & """,1,-1,1)
'-- optimise - makes sure that there is no occurence of ' & "" & ' or '"text" & "text"' --
structure = Replace(structure," & """" & "," & ")
If Left(structure,5) = """ & """ Then
structure = Right(structure,(Len(structure) - 5))
End If
If Right(structure,5) = """ & """ Then
structure = Left(structure,(Len(structure) - 5))
End If
make_commentsLink = structure
End Function
Function make_commentsStructure()
Dim structure,date1
structure = " & """ & Replace(zobjXmlNode.childNodes(4).childNodes((CInt(Request.Form("commentsform"))-1)).text,"""","""""") & """ & "
date1 = """ & zDate(""" & zobjXmlNode.childNodes(3).childNodes((CInt(Request.Form("commentsdate"))-1)).text & """,zobjRS1(""PostedDate"")) & """
structure = Replace(structure,"[by]",""" & zobjRS1(""PostedBy"") & """,1,-1,1)
structure = Replace(structure,"[date]",date1,1,-1,1)
structure = Replace(structure,"[comment]",""" & zobjRS1(""Comment"") & """,1,-1,1)
structure = Replace(structure,"[count]",""" & count & """,1,-1,1)
structure = Replace(structure," & """" & "," & ") 'changes them to ' & '
structure = Mid(structure,4,(Len(structure) - 6))
make_commentsStructure = structure
End Function
Function make_indexStructure()
Dim structure,date1,title1
structure = " & """ & Replace(zobjXmlNode.childNodes(6).childNodes((CInt(Request.Form("indexownform"))-1)).text,"""","""""") & """ & "
date1 = """ & zDate(""" & zobjXmlNode.childNodes(5).childNodes((CInt(Request.Form("indexowndate"))-1)).text & """,zobjRS(2,arrayid)) & """
title1 = """ & zobjRS(1,arrayid) & """
structure = Replace(structure,"[title]",title1,1,-1,1)
structure = Replace(structure,"[date]",date1,1,-1,1)
structure = Replace(structure,"[category]",""" & zobjRS(4,arrayid) & """,1,-1,1)
structure = Replace(structure,"[user]",""" & zobjRS(3,arrayid) & """,1,-1,1)
structure = Replace(structure," & """" & "," & ") 'changes them to ' & '
structure = Mid(structure,4,(Len(structure) - 6))
make_indexStructure = structure
End Function
'-- write file --
Dim zobjFSO,zobjTS
Set zobjFSO = CreateObject("Scripting.FileSystemObject")
Set zobjTS = zobjFSO.CreateTextFile(Server.MapPath("zWrite.asp"))
'-- news template --
zobjTS.WriteLine chr(60) & chr(37) & vbcrlf & "Function zWrite_News(arrayid,comments)" & vbcrlf & "If arrayid > UBound(zobjRS) Then" & vbcrlf & " zWrite_News = ""Error.""" & vbcrlf & " Exit Function" & vbcrlf & "End If" & vbcrlf & "Dim zTmpPost,zTmpComments" & vbcrlf & "zTmpComments = """ & make_commentsLink() & """"
zobjTS.WriteLine "zTmpPost = " & make_newsStructure() & vbcrlf & "zWrite_News = zTmpPost" & vbcrlf & "End Function" & vbcrlf
'-- comments template --
zobjTS.WriteLine "Function zWrite_Comments(count)" & vbcrlf & "Dim zTmpComment" & vbcrlf & "If Not zobjRS1.EOF Then"
zobjTS.WriteLine "zTmpComment = " & make_commentsStructure() & vbcrlf & "Else" & vbcrlf & " zTmpComment = ""Error.""" & vbcrlf & "End If" & vbcrlf & "zWrite_Comments = zTmpComment" & vbcrlf & "End Function" & vbcrlf
'-- index template --
zobjTS.WriteLine "Function zWrite_Index(arrayid)" & vbcrlf & "Dim zTmpIndex"
zobjTS.Write "zTmpIndex = " & make_indexStructure() & vbcrlf & "zWrite_Index = zTmpIndex" & vbcrlf & "End Function" & vbcrlf & chr(37) & chr(62)
zobjTS.Close
'# displayRemote.asp generation #
Function make_remoteIndexStructure()
Dim structure,date1,title1
structure = " & """ & Replace(zobjXmlNode.childNodes(8).childNodes((CInt(Request.Form("indexremoteform"))-1)).text,"""","""""") & """ & "
date1 = """ & zDate(""" & zobjXmlNode.childNodes(7).childNodes((CInt(Request.Form("indexremotedate"))-1)).text & """,zobjXmlNode.childNodes(1).text) & """
title1 = """ & zobjXmlNode.childNodes(0).text & """
structure = Replace(structure,"[title]",title1,1,-1,1)
structure = Replace(structure,"[date]",date1,1,-1,1)
structure = Replace(structure,"[user]",""" & zobjXmlNode.childNodes(2).text & """,1,-1,1)
structure = Replace(structure," & """" & "," & ") 'changes them to ' & '
structure = Mid(structure,4,(Len(structure) - 6))
make_remoteIndexStructure = structure
End Function
Set zobjXml1 = Server.CreateObject("Microsoft.XMLDOM")
zobjXml1.Load(Server.MapPath("scriptComponents.xml"))
Set zobjTS = zobjFSO.CreateTextFile(Server.MapPath("displayRemote.asp"))
zobjTS.WriteLine Replace(zobjXml1.documentElement.childNodes(0).text,vbLf,vbCrLf)
zobjTS.WriteLine " Response.Write " & make_remoteIndexStructure()
zobjTS.Write Replace(zobjXml1.documentElement.childNodes(1).text,vbLf,vbCrLf)
zobjTS.Close
'xml closedown
Set zobjXmlNode = Nothing
Set zobjXml = Nothing
Set zobjXml1 = Nothing
'fso closedown
Set zobjTS = Nothing
Set zobjFSO = Nothing
Response.Redirect "ui_index.asp?msg=script structure set"
%>