📄 myphotoup.asp
字号:
<!--#include file="conn.asp"-->
<!--#include file="const.asp"-->
<!--#include file="css.asp"-->
<!--#include file="top.asp"-->
<!--#include file="upfile.inc"-->
<%
dim flag,errormsg,classtitle
errormsg="● 你是否阅读了 <a href='help_photo.asp'>帮助文件</a><br>"
mark=8045
state=sessionuser&"的图片-本地上传图片"
classtitle=sitename&"-我的图片-本地上传图片"
if sessionuser="" then
flag="true"
state="本地上传图片错误"
classtitle=sitename&"-本地上传图片出错"
errormsg=errormsg&"● 本地上传图片前必须先 <a href='login.asp'>登陆</a><br>"
end if
%>
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title><%=classtitle%></title>
</head>
<body class=body <%=sitecolor(13)%>>
<table align="center" <%=sitecolor(0)%> <%=sitecolor(7)%>>
<tr>
<td width="100%" height="20">本地上传图片在线用户 | <a href="javascript:history.go(-1)">返回</a></td>
</tr>
<tr>
<td width="100%">
<%
'***列出论坛在线用户和客人***
if sitefunction(6)=0 then
call online()
sql="select oid,user,state,intime,activetime,fromip,address,myhead from online where hidden=0 and mark=8045 order by intime desc"
rs.open sql,conn,1,1
do while not rs.eof
response.write" <img src='"&rs("myhead")&"'><a href='user.asp?user="&rs("user")&"&id="&rs("oid")&"' title='来自: "&rs("address")&" 进站: "&rs("intime")&" 活动: "&rs("activetime")&" 方位: "&rs("state")&" '>"
if rs("fromip")=myip then
response.write"<font color='"&sitecolor(19)&"'>"&rs("user")&"</font></a>"
elseif rs("user")="客人" then
response.write"客人</a>"
else
response.write"<font color='"&sitecolor(20)&"'>"&rs("user")&"</font></a>"
end if
rs.movenext
loop
rs.close
else
response.write"<font color='"&sitecolor(21)&"'>×在线用户关闭</font>"
end if
%>
</td>
</tr>
</table>
<%
if flag="true" then
response.write"<p><table align='center' height='150' width='60%' "&sitecolor(1)&"><tr><td width='100%' height='20' align='center' class=heart>温 馨 提 示</td></tr><tr><td width='80%'>"&errormsg&"● <a href='javascript:history.go(-1)'>返回上一页</a></td></tr></table>"
else
dim photoclassid,ptitle,pinfo,filesplit,i,picname,flagin,psize,findpeople,photoclasshide,photoclasspeople
dim upfile,formPath,ServerPath,FSPath,formName,FileName,oFile
set upfile=new upfile_class '建立上传对象
upfile.GetData (sitefunction(20)) '取得上传数据,限制最大上传sitefunction(20)K
%>
<table align="center" <%=sitecolor(0)%> border="0" cellspacing="0">
<tr>
<td width="100%" height="20" align="center" class=hh>
<b>控制面板:</b> <a href="setmain.asp">个性化设置</a> | <a href="editreg.asp">资料修改</a> | <a href="note.asp">我的记事</a> | <a href="myfriend.asp">我的好友</a> | <a href="myinfo.asp">分类信息</a> | <a href="myarticle.asp">我的文章</a> | <a href="myphoto.asp">我的图片</a>
</td>
</tr>
</table>
<table align="center" <%=sitecolor(0)%> <%=sitecolor(1)%>>
<tr>
<td width="100%" height="20" class=hh><a href="myphoto.asp?">图片列表</a> <a href="myphoto.asp?action=addphoto">添加图片</a> <a href="myphoto.asp?action=upphoto">上传图片</a>
</td>
</tr>
</table>
<%
FSPath=GetFilePath(Server.mappath("upfile.asp"),"\") '取得当前文件在服务器路径
FSPath=FSPath&"upfile\"
ServerPath=GetFilePath(Request.ServerVariables("HTTP_REFERER"),"/") '取得在网站上的位置
ServerPath=ServerPath&"upfile/"
for each formName in upfile.file '列出所有上传了的文件
set ofile=upfile.file(formname)
'FileName=upfile.form(formName) '取得文本域的值
psize=ofile.FileSize '取得文件大小
photoclassid=upfile.form("photoclassid")
ptitle=upfile.form("ptitle")
pinfo=upfile.form("pinfo")
if photoclassid="" then
flag="true"
errormsg=errormsg&"● 请选择一个图片分类<br>"
else
'*若是认证分类检测是否已通过认证
sql="select photoclasshide,photoclasspeople from photoclass where photoclassid="&photoclassid&""
rs.open sql,conn,1,1
photoclasshide=rs("photoclasshide")
photoclasspeople=rs("photoclasspeople")
rs.close
if photoclasshide=1 and photoclasspeople="" then '分类认证
findpeople="false"
elseif photoclasshide=1 and photoclasspeople<>"" then
findpeople="false"
photoclasspeople=split(photoclasspeople,",")
for i=0 to ubound(photoclasspeople) '寻找是否有匹配用户得到认证
if sessionuser=photoclasspeople(i) then
findpeople="true"
exit for
end if
next
end if
if mygrade<14 and findpeople="false" then
flag="true"
errormsg=errormsg&"● 你所选择的是认证分类,你还没有通过认证,请选择其他分类<br>"
end if
end if
if psize<1 then '如果没有数据
flag="true"
errormsg=errormsg&"● 请选择需要上传的图片<br>"
elseif psize>cint(sitefunction(20))*1024 then '如果数据太大
flag="true"
errormsg=errormsg&"● 上传图片太大,只允许上传 <font color=""#ff0000"">"&sitefunction(20)&"</font> K 之内的图片,你的图片 "&psize\1024&" K<br>"
end if
if ptitle="" or len(ptitle)>30 then
flag="true"
errormsg=errormsg&"● 图片标题不能为空,且在30个字符以内<br>"
end if
if pinfo="" or len(pinfo)>cint(nclass(22)) then
flag="true"
errormsg=errormsg&"● 图片介绍不能为空,且在"&nclass(22)&"个字符以内<br>"
end if
flagin="true"
filesplit=split(upfiles,"/")
for i=0 to ubound(filesplit)
if lcase(right(ofile.filename,4))=filesplit(i) then
flagin=""
exit for
end if
next
if flagin="true" then
flag="true"
errormsg=errormsg&"● 只能上传以下文件 "&upfiles&"<br>"
end if
if flag="true" then
response.write"<p><table align='center' height='150' width='60%' "&sitecolor(1)&"><tr><td width='100%' height='20' align='center' class=heart>温 馨 提 示</td></tr><tr><td width='80%'>"&errormsg&"● <a href='javascript:history.go(-1)'>返回上一页</a></td></tr></table>"
else
dim nowdate
randomize '初始化随机数
nowdate=dateadd("h",changetime,now())
picname=year(nowdate)&month(nowdate)&day(nowdate)&hour(nowdate)&minute(nowdate)&second(nowdate)&left(10000*rnd,3)&lcase(right(ofile.FileName,4)) '将上传的文件名转化为时间
ofile.SaveToFile FSPath&picname '保存上传文件至目录upfile
sql="insert into photo(photoclassid,photo,user,ptitle,pinfo,psize,psay,preview,phit,ptype,pdate) values("&photoclassid&",'upfile/"&picname&"','"&sessionuser&"','"&ptitle&"','"&pinfo&"',"&psize&",'没有评论',0,0,1,'"&dateadd("h",changetime,now())&"')"
conn.execute(sql) '插入图片数据库
sql="update photoclass set photoclassnum=photoclassnum+1,photoclasstoday=photoclasstoday+1 where photoclassid="&photoclassid&""
conn.execute(sql) '更新分类数据
sql="update count set totalphoto=totalphoto+1"
conn.execute(sql) '更新总数据
response.write"<meta HTTP-EQUIV=REFRESH CONTENT='"&myfunction(14)&"; URL=myphoto.asp'>"&_
"<p><table align='center' height='150' width='60%' "&sitecolor(1)&"><tr><td width='100%' height='20' align='center' class=heart>温 馨 提 示</td></tr><tr><td width='80%'>"&_
"● 上传一张图片成功,文件大小 "&psize\1024&" K<br>● <a href='myphoto.asp'>"&myfunction(14)&"秒后自动跳转到我的图片列表</a><br>● <a href='myphoto.asp?action=upphoto'>继续上传一张图片</a><br>● <a href='myphoto.asp?action=addphoto'>添加一张图片</a></td></tr></table>"
end if
next
end if
set ofile=nothing
set upfile=nothing '删除此对象
set rs=nothing
conn.close
set conn=nothing
function GetFilePath(FullPath,str)
If FullPath <> "" Then
GetFilePath = left(FullPath,InStrRev(FullPath, str))
Else
GetFilePath = ""
End If
End function
%>
<!--#include file="footer.asp"-->
</body>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -