- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> ; h1 Y" y" { o9 z: l% o
- <% . ^4 d L) j8 F8 }& ~5 G. E
- Function AllPath()
3 @+ v! Z% T8 c$ c8 D# X* V2 C - Dim Domain,GFilePath ) s+ D4 V- ]& c! Q- r; H N" [8 a
- Domain = Request.ServerVariables("SERVER_NAME")
& u [/ W0 y4 h; v - GFilePath = Request.ServerVariables("PATH_INFO") ! V/ J' x+ h' w- D/ ^/ E- ~
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
. S% c' d6 y0 r- G7 q - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; . p( g; A+ z2 h8 }& r2 B
- End Function
* G' A D" V( ]2 F r8 v - Function ShowFileList(folderspec) - L8 @! D5 Z0 [# ~9 l
- Dim Path,objFSO,objFolder,count,objFile,nume,S
+ Z2 ~" ^: i/ Z5 h - Path = Server.MapPath(folderspec) * t& C. O1 u2 g2 r* P$ E
- Set objFSO = Server.CreateObject("Scripting.FileSystemObject") & u" {; `" [( \2 Q
- If objFSO.FolderExists(Path) Then
( @8 i4 @& c; P% o( q - Set objFolder = objFSO.GetFolder(Path) ) U+ j, Z/ I, o; Z* L
- count = 0 " Q' ^9 C8 B9 e: a; @/ U
- For Each objFile in objFolder.Files
! R( j$ x m+ [" C - count = count+1 ' V B/ B4 E4 [
- Next 3 N% Q# y$ B, u6 Y
- randomize
$ ^+ A+ P6 U+ {/ Y" p" ^* y; U - nume = Int((count*rnd)+1) # ]) X6 N) [2 y* P
- S = 0 ! c# W9 O! n5 _7 Q/ i! s
- ShowFileList = ""
3 S6 o) @: l2 J - For Each objFile in objFolder.Files t" X: O% x; K. r. i5 E4 y
- S = S + 1
4 D5 A* A3 i# K$ o - If S = nume Then
0 I* W, x2 ~' ?& p+ b9 R0 P8 V - ShowFileList = objFile.Name % ~9 {! l& H* d8 q; W( [
- Exit For
" K5 ^" }/ z6 [% Z& v3 W - End If
% B( u" K4 ?" s+ G - Next
) E* P) W' e$ u6 m' g% F3 V - Set objFolder = Nothing
0 `% o2 A# [0 y, C0 U. ~4 O - Else " a- ~5 C+ g2 q" x Y( `
- ShowFileList = "NO"
: S8 l; O, f5 ~, B2 \) [, R - End If
" n! [3 N; g6 ~; j& Y - Set objFSO = Nothing 7 \9 ?4 G1 R2 g" Q
- End Function
8 T* Q4 Q5 D) C - Dim list,filename,address,str
# g3 N7 T, Y+ ~/ T* p* M2 ` - list = trim(Request.QueryString("list"))
$ V% s5 \% F: L$ @, H7 H - if list = "" then % Q9 r" Q( f; S( v* _) n6 I/ F6 a
- Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
5 K4 X, k9 ^% [; D - Response.End()
6 `0 v5 A0 A5 M" S) }2 K! i' l0 [ - end if ; i. I& S* O- G! }. l
- filename = ShowFileList("./"&list&"/") ' ]$ C9 Q# s4 F- i& r! V6 D
- if filename = "NO" then 3 c8 U) [! [) M8 w
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!"
, d, Y1 {* @7 \$ g+ l, g - Response.End() 1 ^& @( `1 a& r) d
- end if
$ L1 s$ I: C# w' |* V: u* o - if filename = "" then
9 F) Y. P( |9 b4 C) B - Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" * i9 g1 A7 I# B1 r0 N, h% v2 q
- Response.End() : W7 C# |$ h& P) O% @+ i" L8 c. F
- end if
' b. v; p3 N1 F% J$ `, O! M2 Q - str = right(filename,3)
3 j% M _2 E+ A - if str<>"jpg" and str<>"gif" then ' m( Y4 E$ Q5 _0 H. R" W" d3 T
- filename = "erro.gif" 2 K) P3 K4 |; L6 v$ N
- end if ' }' _: A$ `- n5 T, N3 O" g' o
- address = AllPath&list&"/" 6 v; Y# |" x6 r% N" ^
- address = address&filename 4 H; O- w; k) Q
- %> + R! J) \$ g8 P8 C" z! }4 c* t' M* I
- <%Response.redirect(address)%>
$ g6 p; _8 f9 \8 G - 把這段代碼保存為im.asp" a3 \# a; i1 ~$ k @4 @4 a# h
- 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
+ R7 p' C! {0 q8 L6 H2 ][ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|