<% Sub nwAdminMain() on error resume next Set Uploader = New FileUploader Uploader.Upload() Dim CurAction CurAction = Request.QueryString("nwadmact") if ( Uploader.form("nwadmact") <> "" ) then CurAction = Uploader.form("nwadmact") end if if CurAction="logout" then Session("nwpassword")="" end if dim fieldsarray dim contentarray dim arrayaux dim cont dim mLanguage if ( Uploader.form("nwadmact") = "adminlogin" ) then Session("nwpassword") = Uploader.form("nwpassword") end if if Trim(Session("nwpassword")) <> Trim(passw) then '//display the login form Response.Write "
" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & "" if Uploader.form("nwpassword")<>"" then Response.Write "" end if Response.Write "
" & nwGetLocaleString("nw.Admin.Text.WrongPassword", null) & "
" & vbCrlf & "
" else '//already logged in Dim XMLDoc, propFile propFile = nof_sitePath & nof_scriptDir & "\" & nof_scriptInterfaceFile set XMLDoc = nwOpenXMLFile(propFile) Dim ComponentNode if XMLDoc is nothing then call Err.Raise ( 601, "nw_admin.nwAdminMain", nwGetLocaleString("Error.601", Array(propFile)) ) Call nwRaiseFatalError(err, nof_debug) exit sub end if set ComponentNode = nwGetNode(XMLDoc,,"Component", Array("name","id"), Array("admin", nof_componentId), -1) set XMLDoc = nothing if ComponentNode is Nothing then call Err.Raise ( 400, "nw_admin.nwAdminMain", nwGetLocaleString("Error.400", Array(nof_componentId)) ) Call nwRaiseFatalError(err, nof_debug) exit sub end if Dim id id = Request.QueryString("id").Item if Uploader.Form("id") <> "" then id = Uploader.Form("id") end if Dim fields fields = nwGetLabels(ComponentNode) Dim titleLabel, showTitle, titleReq titleLabel = fields(0)(0) showTitle = fields(0)(1) titleReq = fields(0)(2) Dim shortMessageLabel, shortMessageShow, shortmessageReq shortMessageLabel = fields(1)(0) shortMessageShow = fields(1)(1) shortmessageReq = fields(1)(2) Dim fullMessageLabel, fullMessageShow, fullmessageReq fullMessageLabel = fields(2)(0) fullMessageShow = fields(2)(1) fullmessageReq = fields(2)(2) Dim authorLabel, authorShow, authorReq authorLabel = fields(3)(0) authorShow = fields(3)(1) authorReq = fields(3)(2) Dim imageLabel, imageShow, imageReq imageLabel = fields(4)(0) imageShow = fields(4)(1) imageReq = fields(4)(2) Dim language language = nwGetProperty(ComponentNode, "language") Dim datemask, timemask, timezone datemask = nwGetProperty(ComponentNode, "dateFormat") timemask = nwGetProperty(ComponentNode, "timeFormat") timezone = nwGetProperty(ComponentNode, "timeZone") if ( Clng(timezone) = 24 ) then timezone = -1 * nof_gmtDiff/60 end if Dim imageRequireNote imageRequireNote = nwGetProperty(ComponentNode, "imageRequire") Dim pageSize pageSize = nwGetProperty(ComponentNode, "pageSize") Dim msg msg = "" DBPath = nwGetProperty(ComponentNode, "dbPath") if dbPath = "" then 'the db path was not set call Err.Raise ( 526, "nw_admin.nwAdminMain", nwGetLocaleString("Error.526", null) ) call nwRaiseFatalError(err, nof_debug) exit sub end if Dim relPath, absPath if not inStr(1, dbPath, "\", 1) > 0 then set relPath = nothing set relPath = nwReFind(dbPath, "\.\./") absPath = nof_sitePath & nof_scriptDir if not relPath is nothing then if relPath.count > 0 then for i=1 to relPath.count absPath = Left(absPath, inStrRev(absPath,"\") - 1) dbPath = Replace(dbPath, "../", "", 1, 1) next else if inStr(1, dbPath, "./") > 0 then dbPath = Replace(dbPath, "./", "", 1, 1) end if end if set relPath = nothing end if dbPath = absPath & "\" & Replace(dbPath, "/", "\") end if contentarray = nwGetDB(dbPath, 0) if Err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if '//get the db fields redim fieldsArray(Ubound(contentarray,2)) For k = 0 To Ubound(contentarray,2) fieldsArray(k) = contentarray(0,k) next Dim offset offset=1 if Uploader.Form("nwoffset")<>"" then offset=Uploader.Form("nwoffset") end if if Request.QueryString("nwoffset")<>"" then offset=Request.QueryString("nwoffset") end if if IsArray(fieldsarray) then for k=0 to ubound(fieldsarray) if trim(fieldsarray(k))="title" then title_pos=k end if if trim(fieldsarray(k))="shortmessage" then shortmessage_pos=k end if if trim(fieldsarray(k))="fullmessage" then fullmessage_pos=k end if if trim(fieldsarray(k))="author" then author_pos=k end if if trim(fieldsarray(k))="date" then date_pos=k end if if trim(fieldsarray(k))="image" then image_pos=k end if if trim(fieldsarray(k))="validation" then validation_pos=k end if next end if '//datagrid action If (CurAction = "delete") Then dim imageToDel If IsArray(contentarray) Then For t = 1 To Ubound(contentarray,1) If Cint(contentarray(t,0))= Cint(id) Then contentarray(t,0)="" imageToDel = contentarray(t,image_pos) End If Next End If Call nwUpdateDB(contentarray, dbPath) if Err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if 'delete the image if it had one if ( imageToDel <> "" ) then imageToDel = nof_sitePath & nof_scriptDir & "\images\" & imageToDel dim dFSO set dFSO = Server.CreateObject("Scripting.FileSystemObject") if ( dFSO.FileExists(imageToDel) ) then call dFSO.DeleteFile(imageToDel, true) end if if err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if end if contentarray = nwGetDB(dbPath, 0) if Err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if End If '//datagrid action if Uploader.Form("nwadmact") = "save" then For k = 0 To Ubound(fieldsArray) If trim(fieldsArray(k)) = "validation" Then validation_pos = k End If Next For i=0 To 10 If Uploader.Form("v" & i) <> "" Then For c = 1 To Ubound(ContentArray) If cInt(ContentArray(c,0)) = cInt(Uploader.Form("v"&i)) Then If Trim(cstr(Uploader.Form("c"&i))) = "true" Then ContentArray(c, validation_pos) = "true" Else ContentArray(c, validation_pos) = "false" End If End If Next End If next Call nwUpdateDB(contentarray, dbPath) if Err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if end if '//view item action if CurAction = "validation" then for k=0 to ubound(fieldsarray) if trim(fieldsarray(k)) = "validation" then validation_pos=k end if next for c=1 to ubound(contentarray) if cint(contentarray(c,0))=cint(id) then if trim(contentarray(c,validation_pos))="true" then contentarray(c,validation_pos)="false" else contentarray(c,validation_pos)="true" end if end if next Call nwUpdateDB(contentarray, dbPath) if Err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if end if '//edit form action if Uploader.Form("nwadmact") = "saveedit" then if ( id = "" ) then msg = AddNewsItem(Uploader, ComponentNode, nof_gmtDiff) else msg = SaveNewsItem(contentarray, Uploader, ComponentNode) end if if err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if if ( msg <> "" ) then CurAction = "edit" end if contentarray = nwGetDB(dbPath, 0) if Err.number <> 0 then call nwRaiseFatalError(err, nof_debug) exit sub end if end if '//datagrid action if CurAction = "edit" OR CurAction = "add" then '//show the add/edit form if ( CurAction = "add" ) then id = "" call nwShowEditForm(Uploader, contentarray, fields, language, id, msg, imageRequireNote) exit sub end if if UBound(contentarray) > 0 then cont = UBound(contentarray) else contentarray = empty end if if cont > 0 then redim arrayaux(ubound(contentarray)-1,ubound(fieldsarray)) iterator=0 for i=ubound(contentarray) to 1 step -1 for s=0 to ubound(fieldsarray) arrayaux(iterator,s)=contentarray(i,s) next iterator = iterator + 1 next contentarray=arrayaux end if numberoflines=0 if IsArray(contentarray) then for t=0 to ubound(contentarray) numberoflines = numberoflines+1 next end if dim dateform, timeform if CurAction="view" then redim viewline(0,ubound(fieldsarray)) for t=0 to ubound(contentarray) if cint(contentarray(t,0))=cint(id) then for h=0 to ubound(fieldsarray) viewline(0,h)=contentarray(t,h) next end if next Response.Write "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf if ( authorShow = "true" ) then Response.Write "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf end if if ( imageShow = "true" ) then Response.Write "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & "" & vbCrLf end if Response.Write "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf Response.Write "" & vbCrLf & _ " " & vbCrLf & "" & vbCrlf & "
" & nwGetLocaleString("nw.Admin.ViewPage.Title", null) & "
" & titleLabel & "" & nwHtmlSpecialChars(viewline(0,title_pos), true) & " 
" & shortMessageLabel & "" & nwHtmlSpecialChars(viewline(0,shortmessage_pos), true) & " 
" & fullMessageLabel & "" & nwHtmlSpecialChars(viewline(0,fullMessage_pos), true) & " 
" & authorLabel & "" & nwHtmlSpecialChars(viewline(0,author_pos), true) & " 
" & imageLabel & "" if ( trim(viewline(0,image_pos)) = "" ) then Response.Write nwGetLocaleString("nw.Admin.Picture.Empty", null) else Response.Write "" end if Response.Write "
" & nwGetLocaleString("nw.Admin.Text.Status", null) & "" if ( trim(viewline(0,validation_pos)) = "true" ) then Response.Write "" & nwGetLocaleString("nw.Admin.Text.ApprovedNews", null) & "!" else Response.Write "" & nwGetLocaleString("nw.Admin.Text.NotApprovedNews", null) & "!" end if Response.Write " 
" & nwGetLocaleString("nw.PostedDate.Label", null) & "" & dateFormat(viewline(0,date_pos), dateMask, timeMask, timeZone) & " 
" & vbCrLf & _ "" & _ nwGetLocaleString("nw.Admin.Link.Back", null) & " " & _ "- " & nwGetLocaleString("nw.Admin.Link.Edit", null) & _ " - " & _ nwGetLocaleString("nw.Admin.Link.Delete", null) & " - " & vbCrLf str="" if trim(viewline(0,validation_pos))<>"true" then str = nwGetLocaleString("nw.Admin.Link.Validate", null) else str = nwGetLocaleString("nw.Admin.Link.Invalidate", null) end if Response.Write " " & str & _ "
" & vbCrLf else Response.Write "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & "" & vbCrLf & "" & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ "" & vbCrLf & _ "
" & nwGetLocaleString("nw.Admin.Link.Logout", null) & "" & vbCrLf if numberoflines>0 then call nwDisplayPages(offset, numberoflines, pageSize, 5, "") end if Response.Write "
" & vbCrLf & _ "
" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf start = offset-1 inc=1 do while Cint(start)>=0 and Cint(start)" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf inc=inc+1 start=start+1 loop if cint(numberoflines=0) then Response.Write " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf end if Response.Write " " & vbCrLf & _ "
" & nwGetLocaleString("nw.Admin.Text.Title", null) & "" & nwGetLocaleString("nw.Admin.Text.Date", null) & "" & nwGetLocaleString("nw.Admin.Text.Name", null) & " 
" & _ "" & _ nwHtmlSpecialChars(contentarray(start,title_pos), true) & " " & _ dateFormat(contentarray(start,date_pos), dateMask, timeMask, timeZone) & "" & _ nwHtmlSpecialChars(contentarray(start,author_pos), true) & "" & _ "
" & _ nwGetLocaleString("nw.Text.NoNews", null) & "
" & vbCrLf & _ " " & vbCrLf Response.Write "   " & vbCrLf Response.Write "   " & vbCrLf Response.Write "   " & vbCrLf if cint(numberoflines<>0) then Response.Write "" end if Response.Write "
" & vbCrLf & _ "
" & vbCrLf & _ "
 
" & vbCrLf end if end if end sub sub nwShowEditForm(ByRef Uploader, contentarray, fields, language, id, msg, imageRequireNote) Dim titleLabel, titleShow, titleReq titleLabel = fields(0)(0) titleShow = fields(0)(1) titleReq = fields(0)(2) Dim shortMessageLabel, shortMessageShow, shortmessageReq shortMessageLabel = fields(1)(0) shortMessageShow = fields(1)(1) shortmessageReq = fields(1)(2) Dim fullMessageLabel, fullMessageShow, fullmessageReq fullMessageLabel = fields(2)(0) fullMessageShow = fields(2)(1) fullmessageReq = fields(2)(2) Dim authorLabel, authorShow, authorReq authorLabel = fields(3)(0) authorShow = fields(3)(1) authorReq = fields(3)(2) Dim imageLabel, imageShow, imageReq imageLabel = fields(4)(0) imageShow = fields(4)(1) imageReq = fields(4)(2) Dim TitleText if ( id <> "" ) then TitleText = nwGetLocaleString("nw.EditForm.Title", null) else TitleText = nwGetLocaleString("nw.AddForm.Title", null) end if dim sTitle, sShortMessage, sFullMessage, sAuthor, sImage, sDate, sStatus sTitle = Uploader.Form("title") sShortMessage = Uploader.Form("shortmessage") sFullMessage = Uploader.Form("fullmessage") sAuthor = Uploader.Form("author") sImage = Uploader.Form("image") sStatus = Uploader.Form("status") for i=0 to Ubound(contentarray,1) if contentarray(i,0) = id then sTitle = formEscape(contentarray(i,1)) sShortMessage = formEscape(contentarray(i,2)) sFullMessage = formEscape(contentarray(i,3)) sAuthor = formEscape(contentarray(i,4)) sImage = formEscape(contentarray(i,5)) sDate = formEscape(contentarray(i,6)) sStatus = formEscape(contentarray(i,7)) end if next 'display the edit form Response.Write "" & vbCrLf Response.Write "
" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ "" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ "
" & TitleText & "* " & _ nwGetLocaleString("nw.AddForm.Required.Message", null) & "
" & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf& _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf Response.Write " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf Response.Write " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf & _ " " & vbCrLf Response.Write " " & vbCrLf & _ "
" & msg & "
" & titleLabel & _ "" if ( titleShow = "true" and titleReq = "true" ) then Response.Write "*" end if Response.Write "
" & _ shortMessageLabel & "" if ( titleShow = "true" and shortmessageReq = "true" ) then Response.Write "*" end if Response.Write "
" & _ fullMessageLabel & "" if ( fullmessageShow = "true" and fullmessageReq = "true" ) then Response.Write "*" end if Response.Write "
" & authorLabel & "" if ( authorShow = "true" and authorReq = "true" ) then Response.Write "*" end if Response.Write "
" & imageLabel & "" if ( imageShow = "true" and imageReq = "true" ) then Response.Write "*" end if Response.Write "" if ( sImage <> "" ) then dim popupLink popupLink = "javascript:window.open('" & nof_rootDir & nof_scriptDir & _ "/nw_showImage.html?img=images/" & sImage & "','popupimage','left=' + window.screen.availWidth*20/100 + ',top=' + window.screen.availHeight*5/100 + ',toolbar=0,resizable=0,scrollbars=0,location=0');" Response.Write "" & nwGetLocaleString("nw.Admin.Link.ViewImage", null) & "
" end if Response.Write "
" & vbCrLf & _ "" & imageRequireNote & "

" & vbCrLf & _ "
" & nwGetLocaleString("nw.Admin.Text.Status", null) & ": " & vbCrLf & _ "
 
 " & vbCrLf & _ "     " & vbCrLf & _ "
" & vbCrLf & _ "
" & vbCrLf end sub %>