- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%> ' i' f$ D- o- s% Z* |- N
- <% 2 K, V. n0 X1 U2 ?" y: N
- Function AllPath()
& [/ |* c' |0 ]' S0 Y q3 [ - Dim Domain,GFilePath 9 P, c0 o4 [( o# m/ |! L
- Domain = Request.ServerVariables("SERVER_NAME")
* ` o' N9 Y6 T; L) b - GFilePath = Request.ServerVariables("PATH_INFO") . ?1 i; L k8 z, x: S! H
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
/ Q- u/ E3 F3 |' K ?4 Q - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ; ! z4 h% Z) r/ D, X9 F Y
- End Function
2 a: u! a: N( l& w - Function ShowFileList(folderspec) . U' O1 X/ b0 }$ \! p9 v- W2 f
- Dim Path,objFSO,objFolder,count,objFile,nume,S
6 i- t0 y& ]( G: ~ - Path = Server.MapPath(folderspec)
* F+ w: p9 U9 z7 e - Set objFSO = Server.CreateObject("Scripting.FileSystemObject") * h) s- ~4 j0 h& v5 ^
- If objFSO.FolderExists(Path) Then
+ Y3 r# v! Z: u! ?6 G - Set objFolder = objFSO.GetFolder(Path) 7 T. D' @2 v& p7 _% ~
- count = 0 1 u3 n3 A* p2 C/ H
- For Each objFile in objFolder.Files 6 ]/ e4 `& p }# h$ J5 \: ^
- count = count+1 , k2 b) G8 T: m. U, _. M3 L6 r
- Next
+ ^9 _% y4 V8 a* ?% w - randomize " h% M# i: m4 ~( Y* D; _. ]$ e
- nume = Int((count*rnd)+1) $ S) t. b% h( I" w% t( @$ V) w
- S = 0
4 j6 _" a3 H: C7 k+ L9 V - ShowFileList = ""
( w5 u/ N8 x5 F0 V, W7 I - For Each objFile in objFolder.Files
9 q: A: h" j. p7 O9 E - S = S + 1 ; }. P5 c* w5 V g& Z) H
- If S = nume Then * U9 i: } e J. Z6 s/ t
- ShowFileList = objFile.Name
" p0 ^+ G: `3 T - Exit For
2 d* A+ `; [) n% I - End If 2 J4 @4 A/ \6 x. j: m& M
- Next * D( X: b: d- W, T
- Set objFolder = Nothing ) H' b q4 o: Y7 x: | r% g8 A' x3 }
- Else ( A( m2 [' ~" `, [
- ShowFileList = "NO"
% e" P& \0 w4 d6 x# `8 X - End If
; y i/ U: h/ F! a t - Set objFSO = Nothing
+ g5 [( J8 @% O9 D% T; }& v2 {& \ - End Function 8 _9 W' [5 c5 q7 E
- Dim list,filename,address,str
: I1 m- L0 x& J1 K( F' ]( [& H - list = trim(Request.QueryString("list")) 2 D6 I" \2 ^ R- _
- if list = "" then
3 {- \ i! g/ g) G& o6 A - Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
A3 T% a8 x! i) Y3 Q - Response.End() 1 l/ N0 U; [$ _; q
- end if ' n; _0 [; ^& L1 \- A" e
- filename = ShowFileList("./"&list&"/")
1 O% e% G1 \7 o, H2 i, J. @0 _; g. y - if filename = "NO" then 0 S+ @" ~2 |2 w5 ]$ g
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" " y$ @" U3 N/ T5 C+ K
- Response.End() # F- G1 ?- c3 p# s- S4 f
- end if
* N2 T, f5 O- a Q9 Y' n+ x8 q2 X - if filename = "" then 8 X+ v+ h! j- v
- Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" . M2 ~ d+ A. p7 Y5 T2 i
- Response.End()
5 ?% ?* b# N, t5 K# x% a' q - end if # v' t* e0 b% P& Q
- str = right(filename,3)
5 N# \6 S h, C; R' c - if str<>"jpg" and str<>"gif" then : w7 a+ I M$ U) o v6 _8 q9 Z
- filename = "erro.gif"
; F3 b6 E* z) T# Q, s8 \ - end if
) L# g- @- W% ?6 [- \* t" Q3 X - address = AllPath&list&"/"
+ t- F3 V0 j8 m( T - address = address&filename
6 o; E9 {8 x: l- v% u - %> * L4 t' D B9 L, b
- <%Response.redirect(address)%>
0 i# a4 c. d) {3 L# P - 把這段代碼保存為im.asp3 g1 M; O2 V) ]' w3 n8 c2 E
- 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼 $ v" z! m- I6 h
[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|