<% Session("CurrentPage") = "AdminGallery" If Session( "LoginID" ) < "1" Then Response.Redirect( "adminlogin.asp" ) End If Dim dbConn, Rs Dim strX '------------- OPEN THE DATABASE & CREATE BLANK RECORDSET OBJECT dbConnection() Set dbConn = Session("dbConn") Set Rs = Server.CreateObject("adodb.recordset") Rs.Cursortype = adOpenDynamic Rs.LockType = adLockOptimistic '----------------------- PRE-PROCESSING STUFF If rqs("do") = "save" Then 'Submit the details back to the database IF rqf("id") < "1" Then cSQL = "INSERT INTO GalSections( Title,Description,CreatedOn ) " & _ "VALUES( " & strSQLField(rqf("title"),"c") & ", " & _ strSQLField(rqf("description"),"cn") & ", " & _ strSQLField(rqf("createdon"),"d") & " )" Else cSQL = "UPDATE GalSections SET " & _ "[Title] = " & strSQLField(rqf("title"),"c") & ", " & _ "[Description] = " & strSQLField(rqf("description"),"cn") & ", " & _ "[CreatedOn] = " & strSQLField(rqf("createdon"),"cn") & " " & _ "WHERE GalSectionID=" & rqf( "id" ) End If on error resume next dbConn.Execute(cSQL) If Err.Number = 0 Then response.redirect( Session("CurrentPage") & ".asp" ) Else rsw( strHeader ) WriteDBError "CANT UPDATE THE RECORD",err.Description,cSQL End If on error goto 0 ElseIf rqs("do") = "delpic" Then on error resume next dbConn.Execute( "DELETE * FROM GalPictures WHERE GalPictureID=" & rqs("id") ) If Err.Number = 0 Then Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject") Set myFile = ScriptObject.getFile( "dl\gallery\" & nID & ".jpg" ) myFile.Delete( true ) Set myFile = ScriptObject.getFile( "dl\gallery\" & nID & "b.jpg" ) myFile.Delete( true ) Else rsw( strHeader ) WriteDBError "CANT UPDATE THE RECORD",err.Description,cSQL response.End() End If on error goto 0 ElseIf rqs("do") = "savepic" Then Dim nID Dim byteCount, RequestBin, UploadRequest byteCount = Request.TotalBytes RequestBin = Request.BinaryRead(byteCount) Set UploadRequest = CreateObject("Scripting.Dictionary") BuildUploadRequest RequestBin '----------- GET THE FORM DETAILS Dim contentType, aSize, value contentType = UploadRequest.Item("full").Item("ContentType") aSize = Split( UploadRequest.Item("size").Item("Value"),"x" ) Dim uploadresult,ScriptObject,MyFile,i, strDestFileName If contentType = "image/pjpeg" Then '----------- GET THE DATABASE RECORD IF IT EXISTS nID = rqs("id") / 1 Rs.Open "SELECT * FROM GalPictures WHERE [GalPictureID] = " & nID, dbConn If Rs.Eof Then Rs.AddNew End If Rs("GalSectionID") = rqs("secid") Rs( "Width" ) = aSize( 0 ) Rs( "Height" ) = aSize( 1 ) Rs.Update Rs.MoveFirst nID = Rs("GalPictureID") Rs.Close '------------ WHAT IS THE FILE NAME WE WANT TO USE Set ScriptObject = Server.CreateObject("Scripting.FileSystemObject") '---- WRITE THE FULLSIZE IMAGE strDestFileName = CurrentFolder() & "\dl\gallery\" & nID & ".jpg" Set myFile = ScriptObject.CreateTextFile( strDestFileName ) value = UploadRequest.Item("full").Item("Value") For i = 1 to LenB(value) myFile.Write chr(AscB(MidB(value,i,1))) Next myFile.Close '---- WRITE THE THUMBNAIL IMAGE strDestFileName = CurrentFolder() & "\dl\gallery\" & nID & "b.jpg" Set myFile = ScriptObject.CreateTextFile( strDestFileName ) value = UploadRequest.Item("thumb").Item("Value") For i = 1 to LenB(value) myFile.Write chr(AscB(MidB(value,i,1))) Next myFile.Close End If ElseIf rqs("do") = "delete" Then 'delete the record' on error resume next If rqs("id") <> "" Then cSQL = "DELETE * FROM GalSections WHERE GalSectionID=" & rqs("id") dbConn.Execute(cSQL) End If If Err.Number = 0 Then response.redirect( Session("CurrentPage") & ".asp" ) Else rsw( strHeader ) WriteDBError "CANT DELETE THE RECORD",err.Description,cSQL End If on error goto 0 End If %>
Gallery
<% If rqs("do") = "edit" Then Rs.Open "SELECT * FROM GalSections WHERE GalSectionID=" & rqs("id"), dbConn %>
Title
Description
Date
  Submit  Back
<% Rs.Close ElseIf rqs("do") = "show" OR rqs("do") = "savepic" OR rqs("do") = "delpic" Then nCtr = 0 Rs.Open "SELECT * FROM GalPictures WHERE GalSectionID=" & rqs("secid"), dbConn Response.Write( "" ) Do While Not Rs.EOF If (nCtr mod 3) = 0 Then If nCtr > 0 Then Response.Write( "" ) End If Response.Write( "" ) End If Response.Write( _ "" ) Rs.MoveNext nCtr = nCtr + 1 Loop Response.Write( "
" & _ "
" & _ "del" & _ "
" ) Rs.Close Response.write( "

add picture

" ) ElseIf rqs("do") = "addpic" Then %>
Fullsize File Name
(600x450 or 450x600)
Thumbnail File Name
(120x90 or 90x120)
Size
  Submit  Back
<% End If %>
<% Response.Write( "" ) Rs.Open "SELECT * FROM GalSections ORDER BY CreatedOn DESC, Description", dbConn Do While Not Rs.EOF Response.Write( _ "" ) Rs.MoveNext Loop Response.Write( "" ) Response.Write( "" ) Response.Write( "
" & _ "" & Rs("Title") & " - " & Rs("CreatedOn") & "
" & _ "" & Rs("Description") & "
" & _ "show " & _ "edit " & _ "add picture" & _ "
Add Section
" ) Rs.Close %>