📄 pic.asp
字号:
<!--#include file="i_login.asp"-->
<!--#include FILE="../inc/upload.inc"-->
<%
mode=trim(request("mode"))
id=trim(request("id"))
select case mode
case "add"
call add_sub()
case "save"
call save_sub()
case "del"
call del_sub()
case "order"
call order_sub()
end select
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>链接管理</title>
<script language="javascript" src="../inc/functions.js"></script>
<LINK href="images/style.css" type=text/css rel=stylesheet>
<script>
function chk(form)
{
if(form.name.value==""){
alert(" 请填写名称!");
form.name.focus();
return false;
}
else
{
return true;
}
}
</script>
</head>
<body >
<table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td height="26" class="gray"> CMS >> 链接管理</td>
</tr>
</table>
<%if mode="edit" then
set rs=conn.execute("select * from data_pic where id="&id&"")
%>
<table border="1" align="center" cellpadding="5" cellspacing="0">
<form name="form1" method="post" action="?mode=save&id=<%=id%>" enctype="multipart/form-data" onSubmit="return chk(this);">
<tr>
<td align="center" >名称</td>
<td align="left" ><input name="name" type="text" class="input" id="name" value="<%=rs("name")%>" size="45"></td>
</tr>
<tr>
<td align="center" >网址</td>
<td align="left" ><input name="url" type="text" class="input" id="url" value="<%=rs("url")%>" size="45"></td>
</tr>
<tr>
<td align="center" > 图片</td>
<td align="left" ><input name="file1" type="file" id="file1" /></td>
</tr>
<tr>
<td colspan="2" align="center" ><input name="Submit" type="submit" id="Submit" value=" 保 存 "></td>
</tr>
</form>
</table>
<%
rs.close
set rs=nothing
else%>
<table border="1" align="center" cellpadding="5" cellspacing="0">
<form name="form2" method="post" action="?mode=add" enctype="multipart/form-data" onSubmit="return chk(this);">
<tr>
<td align="center" >名称</td>
<td align="left" ><input name="name" type="text" class="input" id="name" size="45"></td>
</tr>
<tr>
<td align="center" >网址</td>
<td align="left" ><input name="url" type="text" class="input" id="url" value="http://" size="45"></td>
</tr>
<tr>
<td align="center" >图片</td>
<td align="left" ><input name="file2" type="file" id="file2" /></td>
</tr>
<tr>
<td colspan="2" align="center" ><input type="submit" name="Submit" value=" 添 加 "></td>
</tr>
</form>
</table>
<%end if%>
<hr/>
<table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#C2BDBD">
<tr>
<td width="20%" align="center" bgcolor="#CCCCCC"
>图片</td>
<td width="26%" height="32" align="center" bgcolor="#CCCCCC"
>名称</td>
<td width="43%" align="center" bgcolor="#CCCCCC"
>网址</td>
<td width="11%" align="center" bgcolor="#CCCCCC"
>操作</td>
</tr><%
set rs=server.CreateObject("adodb.recordset")
rs.open "select * from data_pic order by orderby,id",conn,1,1
m=rs.RecordCount
i=0
while not rs.eof
i=i+1
%>
<tr>
<td align="center" bgcolor="#FFFFFF"
onmouseover="this.bgColor = '#f0f0f0'" onmouseout="this.bgColor = '#FFFFFF'">
<%
'排列
if i>1 then
response.Write("<a href=""?id="&rs("id")&"&mode=order&flag=up"">↑</a>")
else
response.Write("<font color=""#999999"">↑</font>")
end if
if i<m then
response.Write("<a href=""?id="&rs("id")&"&mode=order&flag=down"">↓</a>")
else
response.Write("<font color=""#999999"">↓</font>")
end if
response.Write(" ")
if trim(rs("img_s"))<>"" then
response.Write("<a href="""&rs("img")&""" target=""_blank"" ><img src="""&rs("img_s")&"?"&getkey(6)&""" border=""0"" align=""absmiddle"" width="""&c_pic_width_s&""" height="""&c_pic_height_s&""" onload=""ResizeImage(this, "&c_pic_width_s&", "&c_pic_height_s&");""></a> ")
end if
%></td>
<td height="33" align="center" bgcolor="#FFFFFF"
onmouseover="this.bgColor = '#f0f0f0'" onmouseout="this.bgColor = '#FFFFFF'"><a href="?mode=edit&id=<%=rs("id")%>" class="Af"><%=rs("name")%><br/>
</a></td>
<td align="center" bgcolor="#FFFFFF"
onmouseover="this.bgColor = '#f0f0f0'" onmouseout="this.bgColor = '#FFFFFF'"><a href="?mode=edit&id=<%=rs("id")%>" class="Af"><%=rs("url")%><br/>
</a></td>
<td align="center" bgcolor="#FFFFFF"
onmouseover="this.bgColor = '#f0f0f0'" onmouseout="this.bgColor = '#FFFFFF'"><a href="?mode=edit&id=<%=rs("id")%>" class="Af">编辑</a> <a href="?mode=del&id=<%=rs("id")%>" class="Af"
onclick="javascript:if(confirm('确定删除吗?')){return true;}else{return false;}">删除</a></td>
</tr>
<%
rs.movenext
wend
rs.close
set rs=nothing
%>
</table>
</body>
</html>
<%
conn.close
set conn=nothing
%>
<%
sub order_sub()
dim request_id,request_flag,i,temp_orderby
request_flag=request("flag")
request_id=cint(trim(request("id")))
'初始化
set rs=server.CreateObject("adodb.recordset")
rs.open "select orderby from data_pic order by orderby,id",conn,1,2
i=0
while not rs.eof
i=i+1
rs("orderby")=i
rs.update
rs.movenext
wend
rs.close
'排列
rs.open "select orderby from data_pic where id="&request_id&" ",conn,1,2
if not rs.eof then
temp_orderby=rs("orderby")
if request_flag="up" then
conn.execute("update data_pic set orderby=orderby+1 where orderby="&temp_orderby-1&" ")
rs("orderby")=rs("orderby")-1
elseif request_flag="down" then
conn.execute("update data_pic set orderby=orderby-1 where orderby="&temp_orderby+1&" ")
rs("orderby")=rs("orderby")+1
end if
rs.update
end if
rs.close
set rs=nothing
end sub
sub add_sub()
dim file,upload,fileExt,ranNum,picname,formName,filename,picname_s,filename_s
dim myfile(),i
dim name,url,name_en,url_en
set upload=new upload_bird ''建立上传对象
name=trim(upload.form("name"))
url=trim(upload.form("url"))
if name="" then
call msg("未填写完整!","-1")
end if
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open "data_pic", Conn, 1,2
rs.addnew
rs("name")=name
rs("url")=url
rs("orderby")=1000
rs.update
'------------------上传图片
i=0
for each formName in upload.file ''列出所有上传了的文件
Set file=upload.file(formName) ''生成一个文件对象
If file.filesize>1 Then
'说明有文件数据
If file.filesize>c_size*1024 Then
set file=nothing
set upload=nothing
call msg("Please choose picture (must be within "&c_size&"KB size)。","product_edit.asp?id="&rs("id")&"")
End If
fileExt=lcase(right(file.filename,4))
if fileEXT <>"" and fileEXT<>".gif" and fileEXT<>".jpg" then
call msg("Wrong file format (only for .Gif, or .Jpg file), please check.","product_edit.asp?id="&rs("id")&"")
end if
ReDim Preserve myfile(i)
set myfile(i)=file
i=i+1
End If
set file=nothing
Next
i=0
for each file in myfile
i=i+1
picname=year(now)&month(now)&"/pic_"&rs("id")&lcase(right(file.filename,4))
picname_s=year(now)&month(now)&"/pic_"&rs("id")&"_s"&lcase(right(file.filename,4))
filename=c_pic&picname
filename_s=c_pic&picname_s
call myfind(filename)
file.SaveAs Server.mappath(filename)'保存文件
rs("img")=get_img_s(filename,filename,c_pic_width,c_pic_height)
rs("img_s")=get_img_s2(filename,filename_s,c_pic_width_s,c_pic_height_s)
set file=nothing
Next
rs.update
'--------------------------
rs.close
set rs=nothing
end sub
sub save_sub()
dim file,upload,fileExt,ranNum,picname,formName,filename,picname_s,filename_s
dim myfile(),i
dim name,url
set upload=new upload_bird ''建立上传对象
name=trim(upload.form("name"))
url=trim(upload.form("url"))
if name="" then
call msg("未填写完整!","-1")
end if
Set rs = Server.CreateObject("ADODB.RecordSet")
rs.Open "select * from data_pic where id="&id&"", Conn, 1,2
rs("name")=name
rs("url")=url
rs.update
'------------------上传图片
i=0
for each formName in upload.file ''列出所有上传了的文件
Set file=upload.file(formName) ''生成一个文件对象
If file.filesize>1 Then
'说明有文件数据
If file.filesize>c_size*1024 Then
set file=nothing
set upload=nothing
call msg("Please choose picture (must be within "&c_size&"KB size)。","product_edit.asp?id="&rs("id")&"")
End If
fileExt=lcase(right(file.filename,4))
if fileEXT <>"" and fileEXT<>".gif" and fileEXT<>".jpg" then
call msg("Wrong file format (only for .Gif, or .Jpg file), please check.","product_edit.asp?id="&rs("id")&"")
end if
ReDim Preserve myfile(i)
set myfile(i)=file
i=i+1
End If
set file=nothing
Next
i=0
for each file in myfile
i=i+1
picname=year(now)&month(now)&"/pic_"&rs("id")&lcase(right(file.filename,4))
picname_s=year(now)&month(now)&"/pic_"&rs("id")&"_s"&lcase(right(file.filename,4))
response.Write("")
filename=c_pic&picname
filename_s=c_pic&picname_s
call myfind(filename)
file.SaveAs Server.mappath(filename)'保存文件
rs("img")=get_img_s(filename,filename,c_pic_width,c_pic_height)
rs("img_s")=get_img_s2(filename,filename_s,c_pic_width_s,c_pic_height_s)
set file=nothing
Next
rs.update
'--------------------------
rs.close
set rs=nothing
end sub
sub del_sub()
dim rs
if id="" then
response.Write("<script>alert('ERR!');</script>")
response.End()
end if
set rs=conn.execute("select img,img_s from data_pic where id="&id&" and img is not null ")
if not rs.eof then
if localhost(rs(0)) then
call del_file(rs(0))
end if
if localhost(rs(1)) then
call del_file(rs(1))
end if
end if
rs.close
set rs=nothing
conn.execute("delete from data_pic where id="&id&"")
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -