<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> Picture Galleries - Castle Manor Academy
<% 'on error resume next Rootfold = "\Media\Galleries\" If Request.QueryString("Gallery") = "" Then Process = "ReturnList" Fold = "\Media\Galleries\" Else Process = "ReturnPics" Fold = RootFold & Request.QueryString("Gallery") & "\" End If 'Response.Write(process) DispFold = Right(Fold,Len(Fold)-1) Dim FSObj Set FSObj = Server.CreateObject("Scripting.FileSystemObject") Set Folder = FSObj.GetFolder(Server.MapPath(Fold)) If Process = "ReturnList" Then 'Do the following if you are not given a folder and therefore want to list available galleries. Response.Write("

Picture Galleries

" & vbcrlf) Response.Write("

Below is a selection of picture galleries.

" & vbcrlf) Response.Write("
    ") fileCount = folder.subfolders.count dim fNames() redim fNames(fileCount) cFcount = 0 for each file in folder.subfolders cFcount = cFcount + 1 fNames(cFcount) = file.name 'lcase(file.name) If UCase(file.Name) = "TITLE.TXT" Then Set CurTitle = FSObj.OpenTextFile(file.path, 1) strTitle = CurTitle.ReadLine CurTitle.Close End If next for tName = 1 to fileCount for nName = (tName + 1) to fileCount if strComp(fNames(tName),fNames(nName),0)=1 then buffer = fNames(nName) fNames(nName) = fNames(tName) fNames(tName) = buffer end if next next for i = fileCount to 1 step -1 'For Each DocFold in Folder.SubFolders 'Get gallery title from folder contents 'Dim FSObj2 'Set FSObj2 = Server.CreateObject("Scripting.FileSystemObject") Set SubFolder = FSObj.GetFolder(Server.MapPath(Fold & fnames(i) & "\")) For Each SubFoldDoc in SubFolder.Files If UCase(SubFoldDoc.Name) = "TITLE.TXT" Then 'Response.Write(SubFoldDoc.path) 'Response.Write(Server.MapPath(Fold & DocFold.Name & "\")) Set CurTitle = FSObj.OpenTextFile(SubFoldDoc.path, 1) strTitle = CurTitle.ReadLine 'Response.Write(strTitle) CurTitle.Close 'This section builds the URLs for each folder Gallery Response.Write("
  • " & vbcrlf) Response.Write("" & vbcrlf) For Each DocFile in Subfolder.Files If UCase(Right(DocFile.Name,3)) = "JPG" Then Response.Write("" & vbcrlf) Exit For End If Next Response.Write("" & vbcrlf) Response.Write("
  • " & vbcrlf) strTitle = "" End If Next Next Response.Write("
" & vbcrlf) End If 'Do the following if you are given a folder variable (and therefore want to show pictures. If Process = "ReturnPics" Then fileCount = folder.files.count 'redim fNames() redim fNames(fileCount) cFcount = 0 for each file in folder.files cFcount = cFcount + 1 fNames(cFcount) = file.name 'lcase(file.name) If UCase(file.Name) = "TITLE.TXT" Then Set CurTitle = FSObj.OpenTextFile(file.path, 1) strTitle = CurTitle.ReadLine CurTitle.Close End If next for tName = 1 to fileCount for nName = (tName + 1) to fileCount if strComp(fNames(tName),fNames(nName),0)=1 then buffer = fNames(nName) fNames(nName) = fNames(tName) fNames(tName) = buffer end if next next Response.Write("

Picture Gallery - ") Response.Write(strTitle & "

" & vbcrlf) Response.Write("
") Response.Write("
    ") for i = fileCount to 1 step -1 If UCase(Right(fnames(i),3)) = "JPG" Then 'For Each DocFile in Folder.Files ' If UCase(Right(DocFile.Name,3)) = "JPG" Then Response.Write("
  • " & vbcrlf) Response.Write("" & vbcrlf) Response.Write("" & vbcrlf) Response.Write("" & vbcrlf) Response.Write("
  • " & vbcrlf) End If Next Response.Write("
" & vbcrlf) End If %>

<% If Process = "ReturnPics" Then Response.Write("

Return to gallery list

") End If %>