- <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
5 I0 H: X* G U - <% . _ }9 K8 }/ M/ Y/ x; t4 O2 f7 e
- Function AllPath()
) s* N* c5 t: ] - Dim Domain,GFilePath
& H4 i+ `6 [$ _- x: G. P0 { - Domain = Request.ServerVariables("SERVER_NAME") % p" g! N8 ^& a9 Y6 N B; R
- GFilePath = Request.ServerVariables("PATH_INFO") P) T! U+ A! m! V
- GFilePath = lcase(left(GFilePath,instrRev(GFilePath,"/")))
" ^+ N/ _7 Z q8 t5 n - AllPath = "http://www.w16888.com/" //唯一需要修改的地方,你的圖片目錄如果是在http://xxxx/myfile/angie/pic,這裡就寫http://xxx.com/myfile/angie/ ;
; }' }; z [8 Q5 s1 Y: {0 @( Z - End Function ' M$ u# o2 ?5 u& f4 A6 `! ]
- Function ShowFileList(folderspec)
2 |" n1 c6 y. G: h - Dim Path,objFSO,objFolder,count,objFile,nume,S
' e$ V0 ?- A) b# p) w) Q4 J- {, Y - Path = Server.MapPath(folderspec)
: e+ j6 v: K+ F5 x - Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
3 O/ r4 }7 I* T/ a/ c - If objFSO.FolderExists(Path) Then ' _8 s# c3 c. C2 R, y5 W
- Set objFolder = objFSO.GetFolder(Path)
# S( G0 w# H1 Y( T - count = 0 6 H8 Z. ~0 o+ L+ U
- For Each objFile in objFolder.Files
) `8 p; Y# u- n: j - count = count+1
* C) c0 o! E3 S0 S& w - Next 6 l* S/ c7 M+ c) T2 r0 j* w: s3 [$ ~7 A
- randomize
3 @- F7 y, _* @ - nume = Int((count*rnd)+1) 9 U/ J" T. I8 K
- S = 0 * U& n1 G! w7 _9 V5 S% }' f3 s- w7 e
- ShowFileList = "" ( Q p g4 E+ `
- For Each objFile in objFolder.Files 2 y& z% E4 y7 w7 M2 g; [
- S = S + 1
+ M. f7 W6 V' k x9 @/ H - If S = nume Then
. s- G; k% r2 Q( N - ShowFileList = objFile.Name
+ t/ } R! e2 D( d9 s- j( A& I - Exit For 9 d& I: b/ g' r6 j
- End If 6 n* B; H4 ?+ H3 d1 _/ ^
- Next
; P8 l: y+ I4 {6 q0 ^# { - Set objFolder = Nothing
: H) R$ }9 c3 O - Else
1 J$ F: P& ~# M( I u, V$ } - ShowFileList = "NO" & i9 @; o/ S: I) W
- End If
/ u6 K5 N5 ]6 E4 a% [. M - Set objFSO = Nothing , h$ v5 z! z& W* P/ m, C
- End Function 3 c( s+ _$ ^, w" B! O" A2 G3 `8 s
- Dim list,filename,address,str
7 A& Z0 [/ w1 |6 k - list = trim(Request.QueryString("list")) 0 U! b& N: v5 U
- if list = "" then
: Q8 P) W! X) V2 O6 e0 n - Response.write "本頁需要正確參數引入,您缺少相關的參數!正確格式如下:"&AllPath&"xxxxxx.asp?list=xxxxxx.jpg"
/ I, [0 A- B- J* n - Response.End() % t; p: F9 T9 Z% s! a2 ~
- end if ( h" c7 ?$ u& U5 [
- filename = ShowFileList("./"&list&"/") % O; s* t: @) t) E" U4 n
- if filename = "NO" then ) l# z7 a G2 N2 `' e' [( n2 q
- Response.write "您指定的目錄<b>"&list&"</b>不存在,請重新指定!" . w: j$ b$ Z3 d: o
- Response.End() , Z& c* [0 w5 j! r! E- D4 i
- end if
' c# @; R: x2 d7 q# i7 h - if filename = "" then
5 H2 i6 M6 H2 x, M" w - Response.write "您指定的目錄<b>"&list&"</b>沒有相關的圖片文件存在,請重新指定!" % { N% b, @. `) |9 g
- Response.End()
$ E; N, ~% p0 k8 A5 d& ?! @0 f - end if . }) b: V' X* ]. ~) p( \& u
- str = right(filename,3) % K2 N3 g9 m$ @; p
- if str<>"jpg" and str<>"gif" then
5 a& h$ ~& M, B8 z" j; M% u - filename = "erro.gif" " V1 a4 M9 J, k& Z: u
- end if
( t& u2 S4 [5 D. H7 H3 E; V( i/ G W2 q - address = AllPath&list&"/" - i3 {; d* V# R0 O- Y, @' q
- address = address&filename
) V5 x- P! _! L4 J+ f8 a - %>
% }4 b" V( d9 G9 d6 Y, ]5 t - <%Response.redirect(address)%>
5 ~7 l3 e) ]% \' k: V - 把這段代碼保存為im.asp
* a) F, G. x2 J; m4 a- { - 把美女圖片放在pic文件夾下,把pic文件夾和im.asp放在網站根目錄下,在瀏覽器裡打開演
複製代碼
, O; i% n0 r& t3 a[ 本帖最後由 tcbxh2008 於 2007-6-3 16:47 編輯 ] |
|