Avatar billede zaar Nybegynder
20. juli 2006 - 17:21 Der er 7 kommentarer og
1 løsning

BBC Webgallery

Er der nogen der ved om jeg kan få dette script til at hente billeder fra andet sted på min server?

f.eks

c:\billeder\

Eller kan dette script kun anvendes til at vise billeder der ligger i c:\inetpub\wwwroot\?

Jeg har nemlig ikke haft held til at ændre dette til andet udenfor mappen wwwroot.

Scriptet kan hentes og ses i funktion her her:
http://www.brinch.it/webgal.asp

script:
-----------------------------------------------------------------

<%
' This is BBC Webgallery V4.0. The script is freeware for private usage.
' For COMMERCIAL USE, please contact me on brian@brinch.it. Any commercial use without contacting me will be billed
' without any notice!!
'
' To use this script, it's recommended to have the AspImage component installed on the server.
' But no matter what, the script will work, because it will check if AspImage is installed or
' not. If not then thumbnails are just created, using width/height on the IMG tag, but the performance on this is poor.
'
' To use this script on your own server, you have to change a few statements. All statements
' that have to be changed, is marked in the section below these comments
'
' I can not give any support on this script (you know, it's freeware, bla. bla.) But however
' you can try to ask in any ASP forums. The script is pretty easy and self documentated.
'
' Good luck with the script and if you need to see any examples where the script is used,
' take a look at http://www.brinch.it/webgalleryv4/webgalleryv4.asp
' The script is by default shipped with the following files: webgalleryv4.asp, webgalleryv4.css, crttmb.asp
'
'
' ***** New things in this version *****
'
' - Only 4 lines of constants to be changed to make it work.
' - Few errors from other version are corrected
' - .CSS file to make it easy to individualize the design
' - Easy control of subfolders
' - All texts have been put into constants to make it easy to change
' - Source is cleaned, more comments and better structure
' - Script is now validating strict HTML 4
' - Script is tested in IE 6.0, FireFox and Opera
'
'
'
'
'
' ****Updates****
' 29-03-2006 Txt12 variable added.
' 29-03-2006 Force a 800x600 in the popup window


' *********************************************************************
' * Below is all the constants that you can change to individualize
' * Your own album
' *********************************************************************
ImageDir        = "c:/billeder/"         ' ImageDir must be entered with / and NOT \ !!!!!!
AlbumTitle        = "BBC Webgallery - demo gallery"    '  Title of the album
Columns            = 4                    ' How many Columns with pictures?           
Rows            = 4                    ' How many Rows with pictures?
TmbSize            = 80                    ' This is the size of the generated thumbnail


' *********************************************************************
' * Text constants for all texts in the gallery
' *********************************************************************

Txt1            = "[Prev. Album]"
Txt2            = "[Next Picture]"
Txt3            = "[Prev. Picture]"
Txt4            = "Number of pictures in this album"
Txt5            = "This is picture"
Txt6            = "of"
Txt7            = "Close Window"
Txt8            = "[Next Page]"
Txt9            = "[Prev Page]"
Txt10            = "This is page"           
Txt11            = "Return to"       
Txt12            = "No pictures found in this album!"

' *********************************************************************
' * Initiate all the vars that can be calculated/constants
' *********************************************************************
' Replace all / with \ to use with FSO
ImageDirBack        = Replace(ImageDir, "/", "\", 1, -1, 1)
strScriptName = Request.Servervariables("script_name")
OrgDir            = ImageDirBack
PicturesOnPage    = Columns * Rows
PageNumber        = request.Querystring("Page")
If isNumeric(PageNumber) = False Or PageNumber < 1 Then
  PageNumber = 1
End If
PicID            = request.Querystring("PicID")
Album            = request.Querystring("Album")
If Album <> "" THEN
    ImageDir = ImageDir & Album & "/"
End If
FirstPicture    = ((PageNumber-1) * PicturesOnPage)
LastPicture        = (FirstPicture + PicturesOnPage) - 1
ImageDirJS        = Replace(ImageDir, "\", "/", 1, -1, 1)

' ******************************************************************
' This function is checking if AspImage is installed or not.
' ******************************************************************
Function IsComponentInstalled(ProgId)
    Dim tmpObject
    On Error Resume Next
    Set tmpObject = Server.CreateObject(ProgId)
    If Err.Number = 0 Then
        IsComponentInstalled = True
    Else
        IsComponentInstalled = False
    End If
    Set tmpObject = Nothing
End Function

Response.Write "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0//EN' 'http://www.w3.org/TR/html4/loose.dtd'>"
Response.Write "<HTML>"
Response.Write "<HEAD>"
Response.Write "<TITLE>" & AlbumTitle & "</TITLE>"
Response.Write "<meta name='Generator' content='BBC'>"
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'>"
Response.Write "<link rel='stylesheet' type='text/css' href='webgalleryv4.css'>"

%>
<script type="text/javascript">
function openwindow(photoname, thewidth, theheight) {
    thewidth=thewidth+50
    theheight=theheight+50
    winleft = (screen.width - thewidth) / 2;
    i = open("", "displayWindow","top=10,left="+winleft+",width="+thewidth+",height="+theheight+",status=no,toolbar=no,menubar=no,resize=no,dependent=yes");
    i.focus();
    i.document.open();
    i.document.write('<html>')
    i.document.write('<head>')
    i.document.write('<title>BBC Webgallery<\/title>')
    i.document.write('<\/head>')   
    i.document.write('<body>')
    i.document.write('<A href="java script:window.close();"><%response.write Txt7%><\/A><BR>')
    i.document.write('<img src="<%response.write ImageDirJS%>'+photoname+'" width="800" height="600" ALT="">')
    i.document.write('<\/body>')
    i.document.write('<\/html>')
}
</script>
<%
Response.Write "</HEAD>"
Response.Write "<body>"
Response.Write "<H1>" & AlbumTitle & "</H1>"

' *********************************************************************
' * This part will find all existing subfolders and if any exists   
' * then show them all as a link.
' *********************************************************************
NumberOfFolders    = 0
DIM FolderArray
directpath = lcase(server.mappath("\") & ImageDir)
orgdirect = lcase(server.mappath("\") & OrgDir)
Set fso            = CreateObject("Scripting.FileSystemObject")
Set folder        = fso.GetFolder(directpath)
IF    Album <> "" THEN
    ParentFolder    = lcase(folder.ParentFolder & "\")
    IF ParentFolder = orgdirect THEN
        ParentAlbum = ""
    ELSE   
        Pos                = CINT(LEN(ParentFolder)-LEN(orgdirect))-1
        ParentAlbum        = MID(ParentFolder, CINT(LEN(ParentFolder)-Pos), Pos)
    END IF
END IF   
Set subFolders    = folder.SubFolders
For Each folderObject in SubFolders
    NumberOfFolders = NumberOfFolders + 1
    FolderList = FolderList & folderObject.Name & ","   
Next
FolderArray = Split(FolderList,",")
Set subFolders    = Nothing
Set folder        = Nothing
Set fso            = Nothing
Response.Write "<DIV id='Folders'>"
IF Album <> "" THEN
' *****************************************************************************************************************   
' If user is watching a picture, we give a link back to the album and page where the picture was located
' *****************************************************************************************************************   
    IF PicID <> "" THEN
        ToPage = (CINT(PicID)+1)/PicturesOnPage
        IF ToPage > int(ToPage) THEN
            ToPage= int(ToPage) + 1
        END IF
        IF ToPage = 0 THEN
            ToPage = 1
        END IF
        Response.Write "<A href='"&strScriptName&"?Album="&Album&"&amp;Page="&ToPage&"'>"&Txt11&" "&Album&"</A><BR>"
    ELSE
' *****************************************************************************************************************   
' If we are deeper than the root album, we give a link to the parent album
' *****************************************************************************************************************   
        IF ParentAlbum <> "" THEN
            Response.Write "<A href='"&strScriptName&"?Album="&ParentAlbum& "'>"&Txt1&"</A><BR>"
        ELSE
            Response.Write "<A href='"&strScriptName&"'>"&Txt1&"</A><BR>"           
        END IF
    END IF
END IF   
IF NumberOfFolders > 0 THEN
    FOR FCount=0 TO NumberOfFolders-1
' *****************************************************************************************************************   
'We have to check if current directory is a subfolder. Then Add the actual subfolder to the path
' *****************************************************************************************************************   
        IF Album <> "" THEN
            AlbumPath = Album & "/" & FolderArray(FCount)
        ELSE
            AlbumPath = FolderArray(FCount)
        END IF   
        Response.Write "<A href='"&strScriptName&"?Album="&AlbumPath& "'>"&FolderArray(FCount)&"</A><BR>"
    Next
END IF       
Response.Write "</DIV>"
' *************************************************************************
' * This part will find all pictures in the folder and show them as links
' *************************************************************************
DIM PictureArray
Set objFS = CreateObject("Scripting.FileSystemObject")
Set objFolder = objFS.GetFolder(Server.MapPath(ImageDir))
Set objFiles = objFolder.Files

TotalPics = objFiles.Count

For Each Image In objFiles
    NumberOfPics    = NumberOfPics + 1
    PictureList        = PictureList & Image.Name & ","
Next
PictureArray = Split(PictureList,",")
Set objFS        = Nothing
Set objFolder    = Nothing
Set objFiles    = Nothing
' *****************************************************************************************************************
' * Now we calculate how many pages we have in the current album (directory)
' *****************************************************************************************************************
NumberOfPages = -Int(-(NumberOfPics/PicturesOnPage))
Response.Write "<DIV id='Pics'>"
IF NumberOfPics > 0 THEN
    Response.Write "<TABLE style='margin:auto;'>"
    Response.Write "<TR>"
    Response.Write "<TD>"&Txt4&" " & NumberOfPics & "</TD></TR><TR>"
    IF PicID = "" THEN
        Response.Write "<TD>"&Txt10&" "&PageNumber&" "&Txt6&" " & NumberOfPages&"</TD>"
    ELSE
        Response.Write "<TD>"&Txt5&" "&PicID+1&" "&Txt6&" " & NumberOfPics&"</TD>"
        PageNumber = (CINT(PicID)+1)/PicturesOnPage
        IF PageNumber > int(PageNumber) THEN
            PageNumber = int(PageNumber) + 1
        END IF
        IF PageNumber = 0 THEN
            PageNumber = 1
        END IF

    END IF
    Response.Write "</TR>"
    Response.Write "</TABLE>"
    Response.Write "<TABLE style='margin:auto;'>"
    Response.Write "<TR>"
' *****************************************************************************************************************
' * This check is if a Picture-ID was sent as a parameter. Then we will show that picture instead of thumbs
' *****************************************************************************************************************
    IF PicID <> "" THEN
        IF IsComponentInstalled("AspImage.Image") Then
            Set Image = Server.CreateObject("AspImage.Image")
            Image.LoadImage directpath & PictureArray(PicID)
            thewidth= Image.MaxX
            theheight = Image.MaxY
            Set objImg = Nothing
        ELSE
            thewidth  = 800
            theheight = 600
        END IF
        IF CINT(PicID) = 0 THEN
            PrevPic = CINT(NumberOfPics-1)
        ELSE
            PrevPic = CINT(PicID-1)
        END IF   
        IF CINT(PicID) = CINT(NumberOfPics-1) THEN
            NextPic = 0
        ELSE
            NextPic = CINT(PicID+1)
        END IF   
' *****************************************************************************************************************   
' Build the string that will show Prev. And Next Picture. We have to difference if it's a subfolder or not :-(
' *****************************************************************************************************************   
        IF Album <> "" THEN
            PrevString = "<TD><A HREF='"&strScriptName&"?PicID="&PrevPic&"&amp;Album="&Album&"'>"&Txt3&"</A>&nbsp<A HREF='"&strScriptName&"?PicID="&NextPic& "&amp;Album="&Album& "'>"&Txt2&"</A></TD></TR><TR>"
        ELSE
            PrevString = "<TD><A HREF='"&strScriptName&"?PicID="&PrevPic& "'>"&Txt3&"</A>&nbsp<A HREF='"&strScriptName&"?PicID="&NextPic&"'>"&Txt2&"</A></TD></TR><TR>"
        END IF
        Response.Write PrevString
        Scrstring = "java script:openwindow('"&PictureArray(PicID)&"',"&thewidth&","&theheight&")"
        Response.write "<TD><A HREF="""&Scrstring&""" class='fotolnk'><IMG src='"&ImageDir&PictureArray(PicID)&"' width='450px' alt=''></A></TD>"
    ELSE
' *****************************************************************************************************************
' * If the calculated last picture number is greater than the number of pictures, then only show until the last one
' *****************************************************************************************************************
        IF LastPicture > NumberOfPics THEN
            LastPicture = NumberOfPics - 1
        END IF   
        CountTDS = 1
        FOR PCount=FirstPicture TO LastPicture
' *****************************************************************************************************************           
' Build the string that will show the thumbnails. We have to difference if it's a subfolder or not :-(
' *****************************************************************************************************************   
            If IsComponentInstalled("AspImage.Image") Then
                IF Album <> "" THEN
                    PicString = "<TD><A href='"&strScriptName&"?Album="&Album&"&amp;PicID="&PCount&"' class='fotolnk'><img src='crttmb.asp?Size=" & TmbSize & "&amp;Path=" & ImageDir & "&amp;File=" & PictureArray(PCount) & "' alt=''  style='border-style:none;'></A></TD>"&vbCrLf
                ELSE
                    PicString = "<TD><A href='"&strScriptName&"?PicID="&PCount&"' class='fotolnk'><img src='crttmb.asp?Size=" & TmbSize & "&amp;Path=" & ImageDir & "&amp;File=" & PictureArray(PCount) & "' style='width:"&TmbSize&"px;height:"&TmbSize&"px; border-style:none;' alt=''></A></TD>"&vbCrLf
                END IF
            ELSE
                IF Album <> "" THEN
                    PicString = "<TD><A href='"&strScriptName&"?Album="&Album&"&amp;PicID="&PCount&"' class='fotolnk'><img src='"&ImageDir&PictureArray(PCount)&"' style='width:"&TmbSize&"px;height:"&TmbSize&"px; border-style:none; width='"&TmbSize&"'; height='"&TmbSize&";' alt=''></A></TD>"&vbCrLf
                ELSE
                    PicString = "<TD><A href='"&strScriptName&"?PicID="&PCount&"' class='fotolnk'><img src='"&ImageDir&PictureArray(PCount)&"' width='"&TmbSize&"' height='"&TmbSize&"' alt='''></A></TD>"&vbCrLf
                END IF                       
            END IF   
            Response.Write PicString
            CountTDS = CountTDS + 1
            IF CountTDS > Columns THEN
                CountTDS = 1
                Response.Write "</TR>"&vbCrLf&"<TR>"
            END IF
        Next
        Response.Write "<TD></TD>"
    END IF
    Response.Write "</TR>"
    Response.Write "</TABLE>"
    Response.Write "</DIV>"
ELSE
    Response.Write Txt12
END IF
' *****************************************************************************************************************   
' * Then we setup what pagenumbers we want to show if we have more that 9 pages
' *****************************************************************************************************************
IF NumberOfPages > 1 THEN
    IF NumberOfPages <= 9 THEN
        FirstPage = 1
        LastPage  = NumberOfPages
    END IF
    IF NumberOfPages > 9 THEN
        FirstPage = INT(PageNumber-4)
        IF FirstPage < 1 THEN
            FirstPage = 1
        END IF
        LastPage  = INT(FirstPage+8)
        IF LastPage > NumberOfPages THEN
            LastPage = NumberOfPages
            FirstPage = INT(NumberOfPages-8)
        END IF
    END IF
' *****************************************************************************************************************   
' * Setup the bottom-box with the pages. But only if we have more tham 1 page   
' *****************************************************************************************************************
    Response.Write "<DIV id='Pages'>"
' *****************************************************************************************************************   
' If current page is greater than 1, then we show the prev. button.
' *****************************************************************************************************************   
    IF CINT(PageNumber) > 1 THEN
' *****************************************************************************************************************       
' And again we have to check if the current folder is a subfolder....
' *****************************************************************************************************************   
        IF Album <> "" THEN
            Response.Write "<A Href='"&strScriptName&"?Album="&Album&"&amp;Page="&int(PageNumber-1)&"'>"&Txt9&"</A>"   
        ELSE       
            Response.Write "<A Href='"&strScriptName&"?Page="&int(PageNumber-1)&"'>"&Txt9&"</A>"
        END IF       
    END IF
    FOR PageCounter = FirstPage TO LastPage
' *****************************************************************************************************************   
' And one more time we will check if the current folder is a subfolder....
' *****************************************************************************************************************   
        IF Album <> "" THEN
            Response.Write "<a HREF='"&strScriptName&"?Album="&Album&"&amp;Page="&PageCounter&"'>"&PageCounter&"&nbsp</A>&nbsp"   
        ELSE   
            Response.Write "<a HREF='"&strScriptName&"?Page="&PageCounter&"'>"&PageCounter&"&nbsp</A>&nbsp"   
        END IF   
    Next
' *****************************************************************************************************************       
' * If we have more than 1 page and current page is not the last page, then show the next button
' *****************************************************************************************************************
    IF CINT(PageNumber) < CINT(NumberOfPages) THEN
' *****************************************************************************************************************       
' And guess what... We check the subfolder again!
' *****************************************************************************************************************   
        IF Album <> "" THEN
            Response.Write "<A Href='"&strScriptName&"?Album="&Album&"&amp;Page="&int(PageNumber+1)&"'>"&Txt8&"</A>"                   
        ELSE   
            Response.Write "<A Href='"&strScriptName&"?Page="&int(PageNumber+1)&"'>"&Txt8&"</A>"       
        END IF   
    END IF
    Response.Write "</DIV>"
END IF   
%>
</BODY>
</HTML>
Avatar billede lund_dk Praktikant
20. juli 2006 - 20:04 #1
Hvor vil du hente fra da..?
Avatar billede zaar Nybegynder
20. juli 2006 - 20:14 #2
Som jeg har skrevet i mit spg. så ville jeg gerne at jeg kunne vise billederne som jeg har liggende her c:\billeder\, men scriptet ser ikke ud til at ville arbejde med andet end hvad der ligger i c:\intepub\wwwroot\*
Avatar billede fennec Nybegynder
21. juli 2006 - 08:36 #3
AF sikkerheds mæssige årsager kan HTML ikke vise noget der ligger uden for www roden. Forstil dig f.eks at man kunne gøre dette:
<a href="../../../windows/syetem32/systemfil.dll">

Ikke så smart...

Det kan dog godt lade sig gøre at vise billeder, som ligger uden for www roden. Men det skal gøres via ASP, som så skal streame billederne til HTML koden (binarywrite). Der ligger et par eks her på E, og jeg kan sikkert godt finde et frem til dig. Det er nemlig den kode som bruges til at passwordbeskytte billeder.
Avatar billede zaar Nybegynder
21. juli 2006 - 10:17 #4
Ja ok, det er jo klart nok.
Det kunne jeg jo have sagt mig selv.

Jeg må leve med denne løsning g så have nogle billeder liggende dobbelt, det er der så bare ikke noget at gøre ved.
Avatar billede fennec Nybegynder
21. juli 2006 - 10:29 #5
Ikke medmindre du vil over i stream løsningen.
Hvis jeg husker ret skal du ikke ændre så meget i denne kode, da det fungere ved at billeder bliver vist via en ASP fil. F.eks noget i denne stil:

<img src="visBilled.asp?fil=filNavn.gif">

visBilled.asp skal så bare laves, men den ligger også her på E, så det er bare at finde den, også lave et par små tilrettelser.
Avatar billede zaar Nybegynder
21. juli 2006 - 10:39 #6
Jeg prøver at kigge lidt mere på din løsning.
Hvis du evt. har link liggende til "visbillede.asp" ville det være fint, hvis ikke finder jeg den bare selv.
Avatar billede fennec Nybegynder
21. juli 2006 - 10:49 #7
Taget her fra: http://www.eksperten.dk/spm/217905

<img src="show_pic.asp?pic=billed.gif">

[show_pic.asp]
<%
FileName = Request.QueryString("pic")
Response.ContentType = "image/jpeg"
Set Stream = server.CreateObject("ADODB.Stream")
Stream.Open
Stream.LoadFromFile Server.MapPath(FileName)
Contents = Stream.ReadText
Response.BinaryWrite Contents
Stream.Close
Set Stream = Nothing
%>

Du kan så ændre:
Stream.LoadFromFile Server.MapPath(FileName)

til:
Stream.LoadFromFile "c:\mappe\"& FileName
Avatar billede fennec Nybegynder
21. juli 2006 - 10:54 #8
Skal nok også have ændret "image/jpeg" til "image/gif" hvis du bruger gif filer. Jeg vil dog tro det virker, lige meget om det er gif eller jpg, men er ikke sikker.

Vi kan altid lave et tjek for filtype også sætte den rigtige ContentType, hvis du både har gif og jpg filer.
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester