当前位置: 移动技术网 > IT编程>开发语言>Asp > Wrance的图片系统目录直读版1.0

Wrance的图片系统目录直读版1.0

2017年12月12日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

<%@language=vbscript codepage=936 %>
<% 
'++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
'++++++wrance的图片系统目录直读版1.0+++++++++++++++++++++++
'++++++演示:http://www.cnecg.com/pic.asp++++++++++++++++++
'++++++此为免费程序,您可以任意修改,欢迎发表建议++++++++++
'++++++email:cnecg@yahoo.com.cn,qq:74028+++++++++++++++++++

'以下为修改内容
const uploaddir="/ecg/upload/news/"        '存放文件的目录
const maxperpage=30                      '每页显示数量
const title="+++__wrance的图片系统目录直读版_ "   '标题


'检查组件是否已经安装
function isobjinstalled(strclassstring)    
    isobjinstalled = false
    err = 0
    dim xtestobj
    set xtestobj = server.createobject(strclassstring)
    if 0 = err then isobjinstalled = true
    set xtestobj = nothing
    err = 0
end function
dim strfilename
dim totalput,currentpage,totalpages
dim truepath,fso,thefolder,thefile,whichfile,thisfile,filecount,totlesize
strfilename="?"

if request("page")<>"" then
    currentpage=cint(request("page"))
else
    currentpage=1
end if

truepath=server.mappath(uploaddir)
if not isobjinstalled("scripting.filesystemobject") then
    response.write "<b><font color=red>你的服务器不支持 fso(scripting.filesystemobject)! 不能使用本功能</font></b>"
else
    set fso=createobject("scripting.filesystemobject")    

%>
<html>
<head>
<title><%=title%></title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
<style type="text/css">
<!--
.font {
    font-size: 12px;
    color: #000000;
    text-decoration: none;
    text-align: center;
    vertical-align: middle;
    line-height: 140%;
}
a:link {
    font-size: 12px;
    color: #000000;
    text-decoration: underline;
}
a:hover {
    font-size: 12px;
    color: #999999;
    text-decoration: none;
}
a:visited {
    font-size: 12px;
    color: #0088b5;
    text-decoration: underline;
}
-->
</style>
</head>
<body>
<div align=center>
<%=title%><br>
  <table width="100%" height="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>      
      <td width="100%" align="center" valign="top">      

      <%
  if fso.folderexists(truepath)then
    filecount=0
    totlesize=0
    set thefolder=fso.getfolder(truepath)
    for each thefile in thefolder.files
        filecount=filecount+1
        totlesize=totlesize+thefile.size
    next
    totalput=filecount
    if currentpage<1 then
           currentpage=1
       end if
       if (currentpage-1)*maxperpage>totalput then
        if (totalput mod maxperpage)=0 then
              currentpage= totalput \ maxperpage
          else
              currentpage= totalput \ maxperpage + 1
        end if

    end if
    if currentpage=1 then
        showcontent         
        showpage2 strfilename,totalput,maxperpage
        response.write "<br><div align='center'>本页共显示 <b>" & filecount-1 & "</b> 个文件,占用 <b>" & totlesize\1024 & "</b> k</div>"
       else
              if (currentpage-1)*maxperpage<totalput then
            showcontent         
            showpage2 strfilename,totalput,maxperpage
            response.write "<br><div align='center'>本页共显示 <b>" & filecount-1 & "</b> 个文件,占用 <b>" & totlesize\1024 & "</b> k</div>"
           else
            currentpage=1
            showcontent         
            showpage2 strfilename,totalput,maxperpage
            response.write "<br><div align='center'>本页共显示 <b>" & filecount-1 & "</b> 个文件,占用 <b>" & totlesize\1024 & "</b> k</div>"
        end if
    end if
  else
    response.write "找不到文件夹!可能是配置有误!"
  end if
end if

sub showcontent()
       dim c
    filecount=1
    totlesize=0
%>
      <table width="100%" border="0" align="center" cellpadding="5" cellspacing="5">
                  <tr class="tdbg"> 
        <% for each thefile in thefolder.files
    c=c+1
    if filecount>maxperpage then
        exit for
    elseif c>maxperpage*(currentpage-1) then %>
          <td><a href="<%=(uploaddir & thefile.name)%>" target="_blank">
<img src=<%=(uploaddir & thefile.name)%> border=0 width=120 height=150></a></td>
<% if filecount mod 5 =0 then%>
              </tr>
              <tr> 
                <%end if%>
        <%    filecount=filecount+1
        totlesize=totlesize+thefile.size
    end if
next
%>                </tr>
      </table>
      <%
end sub
%>
    </td>
  </tr>
</table>
<%
sub showpage2(sfilename,totalnumber,maxperpage)
    dim n, i,strtemp
    if totalnumber mod maxperpage=0 then
        n= totalnumber \ maxperpage
      else
        n= totalnumber \ maxperpage+1
      end if
      strtemp= "<table align='center'><form name='showpages' method='post' action='" & sfilename & "'><tr><td>"
    strtemp=strtemp & "共 <b>" & totalnumber & "</b> 个文件  "
      if currentpage<2 then
            strtemp=strtemp & "首页 上一页 "
      else
            strtemp=strtemp & "<a href='" & sfilename & "page=1'>首页</a> "
            strtemp=strtemp & "<a href='" & sfilename & "page=" & (currentpage-1) & "'>上一页</a> "
      end if

      if n-currentpage<1 then
            strtemp=strtemp & "下一页 尾页"
      else
            strtemp=strtemp & "<a href='" & sfilename & "page=" & (currentpage+1) & "'>下一页</a> "
            strtemp=strtemp & "<a href='" & sfilename & "page=" & n & "'>尾页</a>"
      end if
       strtemp=strtemp & " 页次:<strong><font color=red>" & currentpage & "</font>/" & n & "</strong>页 "
    strtemp=strtemp & " <b>" & maxperpage & "</b>" & "个文件/页"
    strtemp=strtemp & " 转到:<select name='page' size='1' onchange='javascript:submit()'>"   
    for i = 1 to n   
           strtemp=strtemp & "<option value='" & i & "'"
        if cint(currentpage)=cint(i) then strtemp=strtemp & " selected "
        strtemp=strtemp & ">第" & i & "页</option>"   
    next
    strtemp=strtemp & "</select>"
    strtemp=strtemp & "</td></tr></form></table>"
    strtemp=strtemp & "<font color='#0083ae'> "
    strtemp=strtemp & "copyright 2004 cnecg.com all rights reserved 版权所有 +++__wrance的图片系统目录直读版_  1.0<br>"
    strtemp=strtemp & "设计制作:wrance email:cnecg@yahoo.com.cn qq:74028</font>"
    response.write strtemp
end sub
%>

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网