?? lbbs_pic.asp
字號:
<%
'**********************************************************
'** 文 件 名:LBBS_pic.asp (可以改名)
'**
'** 文件說明:樂學LBBS無限級目錄圖片直讀系統V1.09.20080719修正版(ASP)
'** 創建日期:2008-04-30
'** 修改日期:2008-07-19
'** 網站支持:http://www.learn365.cn/(樂學365)
'** 問題討論:http://www.learn365.cn/context.asp?id=19002
'** 技術支持:learn365
'** 作 者:cyc
'**********************************************************
'系統變量
Option Explicit '變量定義后可用
Dim c_admin_name,c_admin_password,c_HomeName,c_HomeUrl,c_title,c_UploadDirg,c_PicType
Dim c_filelb,c_cook,con_MaxPerPage,con_Page,con_picwidth,con_picheight,c_shownane,c_TxtType
dim picurl,c_picurl,Action,totalPut,picPage,TotalPages,FileExt,picbgclass,search_path,c_showscope
dim UploadDir,TruePath,fso,theFolder,theFile,thisfile,FileCount,TotalSize,TotalSize_Page
dim strFileType,sqlup,rsup,strFiles,iij,strDirName,admin_login,delpic,c_PicPaixutime,c_showallpic
dim forder,upforder,action_cook,c_MaxPerPage,cook_MaxPerPage,c_showmouseover
dim c_Page,cook_Page,c_picwidth,cook_picwidth,c_URLEncode,c_search,c_PicPaixu,c_orderBy
dim c_picheight,cook_picheight,cook_picheight01,con_pic_small_w,con_pic_small_h,con_filelbtablew
dim action_search,search_key,search_scope,c_homeshowpic,c_logo,c_logotxt,c_banner,c_showtop,c_Copyright
dim starttime:starttime = timer()
dim c_poweredby:c_poweredby ="v1.09.20080719修正版" '系統版本號
'============參數設置(等號“=”前后不要留空)===================
c_admin_name="admin" '管理員名稱
c_admin_password="7a57a5a743894a0e" '管理密碼(用MD5加密,如果忘記,請改為“7a57a5a743894a0e”,密碼即是“admin”)
c_HomeName="樂學首頁" '網站首頁鏈接名稱(空值則不顯示)
c_HomeUrl="http://www.learn365.cn/" '網站首頁鏈接地址
c_title="樂學LBBS圖片庫" '標題名
c_showtop="是" '是否顯示頭部LOGO(是:顯示,否則不顯示)
c_logo="images/logo.gif" '網站LOGO地址
c_logotxt="<BR><font color=#CC6600><B>www.learn365.cn</B><br>簡約而不簡單-[樂學迷你BBS]</font>" 'LOGO傍注
c_banner="<BR>少而好學,如日出之陽;壯而好學,如日中之光;老而好學,如炳燭之光。" 'Banner內容
c_Copyright="Copyright 2008 <a target=_blank href=http://www.learn365.cn/>樂學365®</a>" '底部Copyright信息
c_UploadDirg="lbbs_pic" '圖片所在文件夾,如“lbbs_pic/pic”,開頭與結尾不能帶“/”
c_PicType="jpg|gif|png|bmp" '圖片類型 (可使用|將圖片格式分開)
c_TxtType="doc|xls|txt|rar|ppt" '非圖片文件類型 (可使用|將文件格式分開)
c_shownane="是" '是否在圖片下顯示圖片文件名。(是:顯示,否則不顯示)
c_showallpic="所有" '圖片列表顯示層次(所有:顯示當前目錄及子目錄所有圖片,否則只顯示當前目錄的圖片)
c_homeshowpic="不分類" '首頁最新圖片顯示形式(分類:按目錄分類列最新圖,不分類:不分類列最新圖,當前:只列當前目錄新圖)
c_showmouseover="是" '是否顯示鼠標懸停在鏈接上的JS提示信息。(是:顯示,否則不顯示)
c_URLEncode="是" '是否用Server.URLEncode編碼圖片路徑,以便顯示特殊文件名的圖片。(是:編碼,否則不編碼)
c_PicPaixu="時間" '圖片列表排序方式。(默認:由系統自動排序,時間:按時間排序,大小:按文件大小排序)
c_PicPaixutime="建立" '圖片列表按什么時間排序。(建立:按建立時間排序,修改:按修改時間排序)
c_orderBy="降序" '列表圖片排序。(升序:ASC,降序,DESC)
c_cook="是" '是否顯示并允許使用自定義顯示功能。(是:開啟,否則關閉)
c_search="是" '是否顯示搜索功能。(是:開啟,否則關閉)
c_filelb="是" '左則是否顯示當前目錄下文件。(是:顯示,否則不顯示)
con_filelbtablew=140 '左則目錄欄至少寬度
con_MaxPerPage=20 '列表每頁顯示圖片數
con_Page=5 '列表每行顯示圖片數
con_picwidth=130 '列表圖片寬度
con_picheight=120 '列表圖片高度
con_pic_small_w=150 '生成的縮略圖寬度
con_pic_small_h=150 '生成的縮略圖高度
'=============================================================
If c_UploadDirg="" Then
Response.write "未設置圖片所在文件夾,程序停止執行。"
Response.End
End If
'轉換參數,以便后臺管理設置
c_showtop = Replace(c_showtop,"是","YES")
c_filelb = Replace(c_filelb,"是","YES")
c_cook = Replace(c_cook,"是","YES")
c_search = Replace(c_search,"是","YES")
c_shownane = Replace(c_shownane,"是","YES")
c_showallpic=Replace(c_showallpic,"所有","ALL")
c_homeshowpic=Replace(Replace(Replace(c_homeshowpic,"分類","FENLEI"),"不分類","NOFENLEI"),"當前","ONE")
c_showmouseover=Replace(c_showmouseover,"是","YES")
c_URLEncode=Replace(c_URLEncode,"是","YES")
c_PicPaixu=Replace(Replace(Replace(c_PicPaixu,"時間","TIME"),"默認","NAME"),"大小","SIZE")
c_PicPaixutime=Replace(Replace(Replace(c_PicPaixutime,"建立","CR"),"存取","LA"),"修改","LM")
c_orderBy=Replace(Replace(c_orderBy,"升序","ASC"),"降序","DESC")
Action=LCase(trim(Request("Action")))
action_search=LCase(trim(Request("action_search")))
search_key=LCase(trim(Request("search_key")))
search_path=trim(Request("search_path"))
search_scope=trim(Request("search_scope"))
If search_scope="one" Then
c_showallpic="one"
end If
If action_search="search" Then
c_homeshowpic="NOFENLEI"
c_showallpic="ALL"
c_shownane="YES"
c_filelb="YES"
End if
'取文件夾路徑/目錄
forder=request("forder")
forder=Replace(forder,"\","/") '轉換\為/,保證彈窗跳轉路徑正確
If forder="" Then forder=c_UploadDirg
if inStr(forder,"//")<>0 Then forder = Replace( forder ,"//","/" )
If instr(forder,"../")>0 Or instr(forder,"./")>0 Or forder="/" Or forder="." Then
Response.write "<script language='javascript'>alert('文件夾路徑有誤!');history.go(-1);</script>"
Response.End
End If
If Left(forder,1)="/" Then forder=right(forder,len(forder)-1)
If right(forder,1)="/" Then forder=left(forder,len(forder)-1)
'取上層文件夾/目錄
if instr(forder,"/")>0 then
upforder=left(forder,instrrev(forder,"/")-1) 'upforder當前目錄去末尾的/
end If
If search_path=LCase(c_UploadDirg) Then '搜索所有目錄的文件
forder=c_UploadDirg
End If
'取目錄實際路徑
TruePath=Server.MapPath(forder)
'取當前文件路徑/文件名
picurl=Request.ServerVariables("script_name")
If forder = "" Then
c_picurl = picurl
Else
c_picurl = picurl &"?forder="&forder&""
End If
'管理員登錄檢查
admin_login=false
If Session("lbbs_pic_UserName")=c_admin_name And Session("lbbs_pic_password")=c_admin_password Then
admin_login=True
end if
'-----------------------------------
'自定義每頁圖片數、行數、寬度、高度
If c_cook = "YES" then
action_cook = request("action_cook")
Select Case action_cook
Case "cookies"
cook_MaxPerPage = trim(replace(request("cook_MaxPerPage")," ",""))
cook_Page = trim(replace(request("cook_Page")," ",""))
cook_picwidth = trim(replace(request("cook_picwidth")," ",""))
cook_picheight = trim(replace(request("cook_picheight")," ",""))
if not(IsNumeric(cook_MaxPerPage)) then
Response.write "<script language='javascript'>alert('第頁圖片數:你輸入的不是純數字,請輸入1-100之間的數字!');history.go(-1);</script>"
Response.end
elseif cook_MaxPerPage<1 or cook_MaxPerPage>100 then
Response.write "<script language='javascript'>alert('第頁圖片數:請輸入1-100之間的數字!');history.go(-1);</script>"
Response.end
end if
if not(IsNumeric(cook_Page)) then
Response.write "<script language='javascript'>alert('每行圖片數:你輸入的不是純數字,請輸入正確數字!');history.go(-1);</script>"
Response.end
elseif cook_Page<1 or cook_Page>20 then
Response.write "<script language='javascript'>alert('每行圖片數:請輸入1-20之間的數字!');history.go(-1);</script>"
Response.end
end if
if not(IsNumeric(cook_picwidth)) then
Response.write "<script language='javascript'>alert('圖片寬度:你輸入的不是純數字,請輸入正確數字!');history.go(-1);</script>"
Response.end
elseif cook_picwidth<20 or cook_Page>800 then
Response.write "<script language='javascript'>alert('圖片寬度:請輸入20-800之間的數字!');history.go(-1);</script>"
Response.end
end if
if not(IsNumeric(cook_picheight)) then
Response.write "<script language='javascript'>alert('圖片高度:你輸入的不是純數字,請輸入正確數字!');history.go(-1);</script>"
Response.end
elseif cook_picheight<20 or cook_picheight>800 then
Response.write "<script language='javascript'>alert('圖片高度:請輸入20-800之間的數字!');history.go(-1);</script>"
Response.end
end If
Response.cookies("cycpic")("cook_MaxPerPage") = cook_MaxPerPage
Response.cookies("cycpic")("cook_Page") = cook_Page
Response.cookies("cycpic")("cook_picwidth") = cook_picwidth
Response.cookies("cycpic")("cook_picheight") = cook_picheight
if cook_MaxPerPage<>"" and cook_Page<>"" and cook_picwidth<>"" and cook_picheight<>"" then
Select Case Request.Form("CookieTime")
Case 1
Response.cookies("cycpic").Expires=Date+1
Case 2
Response.cookies("cycpic").Expires=Date+7
Case 3
Response.cookies("cycpic").Expires=Date+31
Case 4
Response.cookies("cycpic").Expires=Date+365
End Select
end If
Case "con"
Response.cookies("cycpic")("cook_MaxPerPage") = con_MaxPerPage
Response.cookies("cycpic")("cook_Page") = con_Page
Response.cookies("cycpic")("cook_picwidth") = con_picwidth
Response.cookies("cycpic")("cook_picheight") = con_picheight
End Select
End If
'---------------------------------
cook_MaxPerPage = Request.cookies("cycpic")("cook_MaxPerPage")
cook_Page = Request.cookies("cycpic")("cook_Page")
cook_picwidth = Request.cookies("cycpic")("cook_picwidth")
cook_picheight = Request.cookies("cycpic")("cook_picheight")
if cook_MaxPerPage="" then c_MaxPerPage = con_MaxPerPage else c_MaxPerPage = cook_MaxPerPage
if cook_Page="" then c_Page = con_Page else c_Page = cook_Page
if cook_picwidth="" then c_picwidth = con_picwidth else c_picwidth = cook_picwidth
if cook_picheight="" then c_picheight = con_picheight else c_picheight = cook_picheight
'------------------------------------------------
'函數名:IsObjInstalled 檢查組件是否已經安裝(參 數:strClassString ----組件名)
'返回值:True ----已經安裝 False ----沒有安裝
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
Sub ShowObjectInstalled(strObjName)
If IsObjInstalled(strObjName) Then
Response.Write "<b><font color='#0094D8'>√</font></b>"
Else
Response.Write "<font color='red'><b>×</b>(無)</font>"
End If
End Sub
'------------------------------------------------
'函數名:JoinChar
'作 用:向地址中加入 ? 或 &
'參 數:strUrl ----網址
'返回值:加了 ? 或 & 的網址
function JoinChar(strUrl)
if strUrl="" then
JoinChar=""
exit function
end if
if InStr(strUrl,"?")<len(strUrl) then
if InStr(strUrl,"?")>1 then
if InStr(strUrl,"&")<len(strUrl) then
JoinChar=strUrl & "&"
else
JoinChar=strUrl
end if
else
JoinChar=strUrl & "?"
end if
else
JoinChar=strUrl
end if
end Function
'------------------------------------------------
'------------------------------------------
'目錄存在時顯示此目錄下的所有子目錄
Function ShowFolderList(folderspec)
On Error Resume Next
Dim f,f1,f2,fc,fc2,s,fs,jj,Filenames,FileSize,i,pj,pj2,picFile,picExt
Set f = fso.GetFolder(folderspec)
Set fc = f.SubFolders
jj=1
For Each f1 in fc
pj=0
pj2=0
For Each picFile In f1.Files
picExt=LCase(Right(Trim(picFile.name),3))
If instr(LCase(c_PicType),picExt)>0 And instr(LCase(picFile.name),"_[small]")=0 and instr(LCase(picFile.name),search_key)>0 Then
pj=pj+1
ElseIf instr(LCase(c_TxtType),picExt)>0 And Session("lbbs_pic_show")<>"smallpic" and instr(LCase(picFile.name),search_key)>0 then
pj2=pj2+1
End If
Next
If CInt(pj)>0 Then pj=" "&pj&"P" Else pj=""
If CInt(pj2)>0 Then pj2=" "&pj2&"F" Else pj2=""
s = s & "<a title='"&f1.name&"' href='?forder="&forder&"/"&f1.name&"&search_path="&forder&"/"&f1.name&"&search_key="&search_key&"'><img border='0' src='images/folder.gif' width='16' height='16'>"
s = s &"<font color='#0066FF'>"&jj&"."& f1.name&"</font>"& pj & pj2 &""
If search_key<>"" then
s = s &"<font color=#FF9900>查["&search_key&"]</font>"
End If
s = s &"</a><br>"
jj=jj+1
Next
If jj-1=0 then s = s &"<font color=#0066FF>(當前目錄無下層文件夾)</font><BR>"
If c_filelb = "YES" then
'讀取該文件夾下所有文件
s = s &"<hr color='#FFFFFF' size='1' width='100%'>"
s = s &"<IMG SRC='images/file.gif' WIDTH='16' HEIGHT='16' BORDER='0'>當前目錄文件:<BR>"
Set fc2 = f.Files
i=1
For Each f2 in fc2
Filenames= f2.name
FileSize= f2.Size
FileExt = fso.GetExtensionName(Filenames) '獲得文件的擴展名
if FileExt<>"" then
FileExt = Lcase(FileExt)
end if
If Len(Filenames)>20 Then Filenames=Left(Filenames,20)&".."
If ((instr(LCase(c_PicType),FileExt)>0 And instr(LCase(f2.name),"_[small]")=0) or (instr(LCase(c_TxtType),FileExt)>0) And Session("lbbs_pic_show")<>"smallpic") and instr(LCase(f2.Name),search_key)>0 Then
s = s &"<a href='"&Server.URLEncode(forder &"\"& f2.Name)&"' target='_blank' title='[文件]"&f2.name &Chr(10)&"[大小]"&SizeTo(FileSize)&"'>"
s = s &"<img src='images/" & FileExt & ".gif' border='0' onerror=""this.src='images/Unknown.gif';"" HEIGHT='17'>"
s = s &"<font color='#0066FF'>"&i&".</font><font color=#0066FF>"&Replace(Filenames,search_key,"<font color=#FF9900>"&search_key&"</font>")&"</font></a><BR>"
Else
i=i-1
End If
i=i+1
Next
If i-1=0 then s = s &"<font color=#0066FF>(當前目錄無文件)</font><BR>"
End if
ShowFolderList = s
End Function
'===========================================
'===========================================
'轉換文件大小轉換
Function SizeTo(PFSize)
SizeTo=0
IF PFSize>(1024*1024*1024) And (PFSize/1024/1024/1024)>0 Then
'GB轉換
SizeTo=FormatNumber(PFSize/1024/1024/1024,2)&" GB"
ElseIF PFSize>(1024*1024) And (PFSize/1024/1024)>0 Then
'MB轉換
SizeTo=FormatNumber(PFSize/1024/1024,2)&" MB"
ElseIF PFSize>1024 And (PFSize/1024)>0 Then
'KB轉換
SizeTo=FormatNumber(PFSize/1024,2)&" KB"
ElseIF PFSize>0 Then
'byte轉換
SizeTo="0"&FormatNumber(PFSize/1024,3)&" KB"
'SizeTo=PFsize&" Byte(字節)"
Else
SizeTo=0&" Byte(字節)"
End IF
End Function
'===========================================
'===========================================
'過修改目錄、創建目錄時不能使用的濾特殊字符(/\:*?"<>|)與空格
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -