%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%> <% Option Explicit Const Version="2.6" %> <% '-------- '############## 'CONFIGURATION. Const cPageTitle="Model gallery" 'Page title. Change it at your will. Const cVirtualPath="images/" 'IMPORTANT: Set the images virtual folder (with the last "/") Const cAdminEmail="info@aztecmodels.com" 'in order to notify administrator about new comments. Dim cWritableXMLCommentsFile 'Physical folder where the xml comment files are going to be written. cWritableXMLCommentsFile=Server.Mappath(cVirtualPath) & "\comments.xml" 'Value: a valid physical folder. Must end with "\" 'cosmetic Const cMaxThumbnailsSize=100 ' Thumbnail's width. Values: a valid integer Const cNumberPicturesPerRowDefault=2 'set the default number of thumbails per row. Const cimgPlus="plus.gif" Const cimgChildNode="child.gif" Const cimgMinus="minus.gif" Const cNumberRecentComments=7 'language 'I had took language configuration out, to make easier multilingual support %> <% 'funcionality Const cShowEmptyFolders=true 'If a folder doesn't contain files inside, would it be displayed? Const cImageExtensions=".jpg,.gif,.png" 'the system would considerar files with that extension as images Const cAllowUserChangePicturePerRow=true 'allow visitor to change the number of pictures he visualize per row Const cAllowUserEnterComments=true 'allow visitor to add comments to the pics. You will need write access permit to comments file! Const cHideFoldersPattern="_vti_cnf" 'thumbnail generator Const cUseThumbnailFile=false 'Values: true or false. Set to true if you are using a server page to create the thumbnail (if your server has .NET Framework installed) Const cUseThumbnailFilePath="thumbnail.aspx" 'path to server page that will generate the thumbnail 'set here available sizes to display the big picture, separate by coma. Const cAvailableThumbnailSizes="original,200,300,500,600" ' "original" is a reserved word Const cDefaultThumbnailSize="original" 'set value that would appear as 'default' 'Main page text sub WriteMainText() 'write here whatever HTML you would like to add to the main page %> <% end sub 'Image Copyright text(apply to every picture) sub WriteCopyRightText() %> <% end sub 'Parse here the picture name as you wish, to take certain characters out of the display name, for example function ParsePictureName(filepath) Const maxPicNamesize=10 Dim output output=fs.GetBaseName(filepath) output=replace(replace(output,"_"," "),"-"," ") 'change "_" for " ", "-" for " " if len(output)>maxPicNamesize then output=left(output,maxPicNamesize) + ".." ParsePictureName=output end Function 'Do whatever you want then a visitor write a comment (send and email to the admin, for example) sub OnCommentAdded(author,email,text,picturelink) 'lets send an email using CDONTS (be sure you have installed it in your server) Dim objCDO Set objCDO = Server.CreateObject("CDONTS.NewMail") objCDO.To = cAdminEmail objCDO.From = cAdminEmail objCDO.Subject = "Simple online photo catalogue comment" objCDO.Body = "Author: " & author & vbcrlf & _ "Email: " & email & vbcrlf & _ "Comments: " & text & vbcrlf & _ "Picture: " & vbcrlf & picturelink objCDO.Send Set objCDO = Nothing end sub 'END CONFIGURATION '################# 'FUNCTIONS 'function to write formated output to response object. sub prt(strValue) response.write(strValue) & Vbcrlf end Sub 'get XML document from file or create a new one if it doesn't exist function GetXmlObj() Dim objXML Set objXML = Server.CreateObject("Microsoft.XMLDOM") If objXML.load(cWritableXMLCommentsFile) = False Then objXML.appendChild(objXML.createProcessingInstruction("xml","version=""1.0"" encoding=""utf-8""")) objXML.appendChild(objXML.createElement("comments")) End If set GetXmlObj=objXML end function 'BEGIN SEARCH ENGINE 'Show search engine form sub DisplaySearch() prt cSearchPictures prt "
" End sub 'Do search Sub DoSearch() if len(request("search")) then dim result,i result=split(searchPictures(cVirtualPath,request("search")),";") for i=0 to ubound(result) -1 ShowResultSearchPicture(result(i)) next if ubound(result)=-1 then prt cNoResultsFoundFor & " " & request("search") & "" end if End Sub 'search engine function searchPictures(Item, filter) Dim folder,subfolder,file set folder = fs.GetFolder(Server.MapPath(Item)) For each subfolder in folder.SubFolders searchPictures= searchPictures & searchPictures(Item & subfolder.Name & "/",filter) next for each file in folder.Files if (len(filter)=0 or instr(1,file.Name,filter,1)>0) then searchPictures=searchPictures & Item & file.Name & ";" next end function 'END SEARCH ENGINE 'Display recent comments 'IDEA: Eliram Haklay Sub displayRecentComments () Dim commentsList,objXML,comment,objXMLcomment,i,startPos,tempWriter Set objXML = GetXmlObj() set commentsList=objXML.selectNodes("/comments/comment") 'we could be using xPath with position()< cNumberRecentComments if we were using MSXML2.DOMDocument.4.0 If commentsList.length > 0 Then startPos=commentsList.length - cNumberRecentComments If startPos<0 Then startPos=0 For i = commentsList.length-1 to startPos step -1 Set comment=objXML.childnodes(1).childnodes(i) Prt "" & cFileName & " " & comment.childnodes(4).text & "| "
output=output & ""
tempWriter=""
if cUseThumbnailFile then tempWriter=cUseThumbnailFilePath & "?ForceAspect=false&Height=" & cMaxThumbnailsSize & "&Width="& cMaxThumbnailsSize & "&image="
output=output & " " & ParsePictureName(File.path) & " " if (fs.FileExists(replace(File.path, fs.GetExtensionName(File.path),"txt")))=true Then output=output & "" & cAComments & "" For each cA in cArray If cA=File.Name Then output=output & "" & cVComments & "" Exit For End If Next output=output & " | "
If cint(iRow)=cint(session("picsperrow")-1) then
iRow=0
output=output & "
" & cThisFolderHasNoImages & "
" else Prt output end if Set folder=nothing End Sub 'get subfolders from folder (recursive) Sub DisplaySubFolders(Item) Dim subfolder,folder, parentfolder,linktext, preHtml, nImages, File set folder = fs.GetFolder(Server.MapPath(Item)) If folder.subfolders.count > 0 then Prt "| " thePrev=FindThePrev (request("item")) If len(thePrev) Then Prt "" & cPrevPicText & "" Prt " | " Prt cFileName & "" & fs.GetFilename(request("item")) & "" Prt " | " theNext=FindTheNext (request("item")) If len(theNext) Then Prt "" & cNextPicText & "" Prt " |
Error: " & err.description + ".
" end if %>
" & cVisitorComments & "
" Prt "" & cErrorMessage & " " & err.Description & "
" FormatCommentsToDisplay(comment) prt "
" Next 'write form prt "