<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="../Include/connect.asp" -->
<%
Username=Checkstr(request.querystring("Username"))
if Username="" then
response.end()
end if

if session("username") <> Username then
response.write("你没有权限！")
response.redirect("../default.asp")
response.end()
end if

topic=request.form("topic")
groupid=request.form("photogroup")
sysgroupid=request.form("photosysgroup")
content=request.form("content")
filename=request.form("filename")
'信息入库
set rs = server.CreateObject("adodb.recordset")
sql="select * from Show5_ALLPhoto where PhotoID is null"
rs.open sql,cn,1,3
rs.addnew
rs("Topic")=topic
rs("Username")=username
rs("GroupID")=groupid
rs("SysGroupID")=sysgroupid
rs("Content")=content
rs("Filename")=filename
rs.update
rs.close
set rs=nothing

set rs = server.CreateObject("adodb.recordset")
sql="select * from Show5_PhotoSysGroup where GroupID="&request.form("photosysgroup")&""
rs.open sql,cn,1,3
rs("PhotoNum")=rs("PhotoNum")+1
rs.update
rs.close
set rs=nothing

Dim Path
Set Jpeg = Server.CreateObject("Persits.Jpeg")
Path = Server.MapPath("../UploadPhoto_temp/"&filename&"")
Jpeg.Open Path
If Jpeg.OriginalWidth / Jpeg.OriginalHeight > 1 then 
Jpeg.Width = 130 
Jpeg.Height = int((130/Jpeg.OriginalWidth)*Jpeg.OriginalHeight) 
elseif Jpeg.OriginalWidth / Jpeg.OriginalHeight < 1 then 
Jpeg.Height = 130 
Jpeg.Width= int(Jpeg.OriginalWidth*(130/Jpeg.OriginalHeight)) 
end if
Jpeg.Save Server.MapPath("../UploadPhoto_s/"&filename&"")
Set Jpeg = Nothing

Set fs = Server.CreateObject("Scripting.FileSystemObject")
On Error Resume Next
fs.CreateFolder("E:\Wwwroot\show5netnew\UploadPhoto\"&username&"")
SFile = Server.MapPath("../UploadPhoto_temp/"&filename&"")
NFile = "E:\Wwwroot\show5netnew\UploadPhoto\"&username&"\"&filename&""
on Error Resume Next
fs.MoveFile SFile, NFile
fs.close
set fs=nothing

Response.write("<script>alert('照片已成功上传！');window.location.replace('photolist.asp?username="&Username&"');</script>")
Response.End()
%>