USUÁRIO:      SENHA:        SALVAR LOGIN ?    Adicione o VBWEB na sua lista de favoritos   Fale conosco 

 

  Dicas

  ASP - Active Server Page    (Miscelâneas)

Título da Dica:  Exibe Imagens - Codigo Simples
Postada em 3/10/2003 por ^HEAVY-METAL^            
gallery.asp

<%Option Explicit%>
<%Response.Buffer = "True"%>
<HTML>
<HEAD>
<TITLE>Galeria</TITLE>
<STYLE TYPE="text/css">
body, table, td, h1 {font-family: arial; font-size: 8pt; color: #000000; background-color: transparent;}
h1 {font-size: 9pt; font-weight: bold; color: #000000; background-color: transparent; display: inline;}
</STYLE>
</HEAD>
<BODY>
<%
'***********************************************************************************
'*  Gallery System: (gallery.asp) - Tuesday October 31, 2002 - By dobbs.           *
'***********************************************************************************

'Dim all the variables required here
Dim objFSO               'Creates an instance of the file system object
Dim objFolder          'Gets the current folder
Dim objFile               'Gets the current file
Dim Path               'Where the images are storeed ie. "images"
Dim Series               'The location of the pics, and the prefix of the files ie. "anime"
Dim ImageCount          'Counts how many images in the series
Dim ImageNumber          'Number of the image to be displayed
Dim NextImage          'Next image link
Dim PreviousImage     'Previous image link
Dim FileExtention     'Grabs the file extention (".jpg")
Dim ErrorPage          'In the case of an error redirect the user here

'Set the counter to zero
ImageCount = 0

'You can change this to a custom error page, but REMEMBER to copy the code from "index.asp"
ErrorPage = "index.asp?GalleryError=True"

'Set the location of the images, and redirect the user if no path or series is given
Set Path = Request.QueryString("Path")
Set Series = Request.QueryString("Series")
If Path = "" OR Series = "" Then
     Response.Redirect(ErrorPage)
End If

'If series of images are ".jpg" files, and have not been counted, count them
If ImageCount = 0 Then
     Set objFSO = CreateObject("Scripting.FileSystemObject")
     Set objFolder = objFSO.GetFolder(Server.MapPath(Path & "/" & Series))
          For Each objFile In objFolder.Files
               FileExtention = LCase(Right((objFile.Name), 4))
                    If FileExtention = ".jpg" Then
                         ImageCount = Cint(ImageCount) + 1
                    End If
          Next
     
     'Destroy the objects
     Set objFSO = Nothing
     Set objFolder = Nothing
     Set objFile = Nothing
End If

'Get the number of the image to be displayed and check/fix impossible numbers
ImageNumber = Cint(Request.QueryString("ImageNumber"))
     If ImageNumber < 1 Then
          ImageNumber = 1
     ElseIf ImageNumber > ImageCount Then
          ImageNumber = ImageCount
     End If

'This function generates the "previous" & "next" buttons
Function Buttons(ImageCount, ImageNumber)
     If ImageNumber = 1 Then
          NextImage = "<A HREF=""gallery.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber + 1) & """>Next</A>"
          PreviousImage = "Previous"
     ElseIf ImageNumber > 1 AND ImageNumber < ImageCount Then
          NextImage = "<A HREF=""gallery.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber + 1) & """>Next</A>"
          PreviousImage = "<A HREF=""gallery.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber - 1) & """>Previous</A>"
     Else
          NextImage = "Next"
          PreviousImage = "<A HREF=""gallery.asp?Path=" & Path & "&Series=" & Series & "&ImageNumber=" & (ImageNumber - 1) & """>Previous</A>"
     End If
     Buttons = PreviousImage & " | " & NextImage
End Function
%>
<!-- Start Gallery Table -->
<TABLE WIDTH="300">
  <TR>
    <TD WIDTH="300" ALIGN="Right">
      <%
      'Displays the current image number, and total number of images
      Response.Write("<H1>Imagem " & ImageNumber & " de " & ImageCount & "</H1><BR>")
      %>
    </TD>
  </TR>
  <TR>
    <TD WIDTH="300" ALIGN="Right">
      <%
      'Displays the current image.  Note this code is only for 1 type of image extention ".jpg"
      Response.Write("<IMG SRC=""" & Path & "/" & Series & "/" & Series & "_" & ImageNumber & ".jpg" & """>")
      %>
    </TD>
  </TR>
  <TR>
    <TD WIDTH="300" ALIGN="Right">
      <%=Buttons(ImageCount, ImageNumber)%>
    </TD>
  </TR>
  <TR>
    <TD WIDTH="300" ALIGN="Right"> © SuperASP - 2003 </TD>
  </TR>
</TABLE>
<!-- End Gallery Table -->
</BODY>
</HTML>

index.asp

<%Option Explicit%>
<HTML>
<HEAD>
<TITLE>Gallery Home</TITLE>
<STYLE TYPE="text/css">
body, table, td, h1 {font-family: arial; font-size: 8pt; color: #000000; background-color: transparent;}
h1 {font-size: 9pt; font-weight: bold; color: #FF0000; background-color: transparent; display: inline;}
</STYLE>
</HEAD>
<BODY>
<%
'***********************************************************************************
'*  Gallery System: (index.asp) - Tuesday October 31, 2002 - By dobbs.             *
'***********************************************************************************

'Dim all the variables required here
Dim GalleryError     'Checks for an error

'If there was an error, display a warning
Set GalleryError = Request.QueryString("GalleryError")
     If GalleryError = "True" Then
          Response.Write("<H1>An error occured please make sure the link is correct</H1><HR>")
     End If
%>
<TABLE WIDTH="400">
  <TR>
    <TD WIDTH="400">
      Feel free to use this code for your website,
      edit it to fit your needs, but please leave the link to my site.<BR>
      Thank you.<BR>
      <A HREF="gallery.asp?Path=images&Series=anime&ImageNumber=1">Gallery Example</A><BR><BR>
      <H1>Instructions:</H1><BR>
      For this code to work correctly you must have your folders and images set-up as follows:<BR>
      [root folder]<BR>
      &nbsp;&nbsp;gallery.asp<BR>
      &nbsp;&nbsp;index.asp<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;[images]<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[series]<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;series_1.jpg<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;series_2.jpg<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;series_3.jpg<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;[anotherseries]<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anotherseries_1.jpg<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anotherseries_2.jpg<BR>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;anotherseries_3.jpg<BR>
      <BR>Replace "series" with the name of your picture series eg. "cars" or "comic" etc.
      Make sure the images have the same name as the folder they reside in, then an underscore "_" and the number
      of the image (determines order to be displayed), and the ".jpg" extension.<BR>
      (as shown above)<BR>
      <BR>Creating the link:<BR>
      To make a link to your gallery, simply edit this:<BR><BR>
      &lt;A HREF="gallery.asp?Path=<FONT COLOR="#008000">images</FONT>&amp;Series=<FONT COLOR="#008000">seriesname</FONT>&amp;ImageNumber=1"><FONT COLOR="#008000">name of link</FONT>&lt;/A&gt;
      <BR><BR>Simply edit the green parts.  Where "images" enter your images foldes,
      where "seriesname" enter the name of the series folder you want to access, and the last is just the link name.
      <BR><BR>Note: this code only works for ".jpg" extension images, because that was all i wanted it for,
      if you need it to work with a variety of files, feel free to edit the code.

      <BR><BR><A TARGET="_blank" HREF="http://www24.brinkster.com/dobbs3/">ASP Image Gallery v1.0</A> | © dobbs 2002 - 2003
    </TD>
  </TR>
</TABLE>
</BODY>
</HTML>

T+,
 


CyberWEB Network Ltda.    © Copyright 2000-2024   -   Todos os direitos reservados.
Powered by HostingZone - A melhor hospedagem para seu site
Topo da página