<!--#include file="../Include/Conn.jsp" -->
<!--#include file="../Include/const.jsp" -->
<!--#include file="../Include/char.jsp" -->
<!--#include file="../Include/upload_club.inc"-->
<!--#include file="IsLogin.jsp" -->
<%
 m_ID = Request.Cookies("aspxnet")("CurUserID")
 m_username= Request.Cookies("aspxnet")("CurUsername")
 m_grade=request.cookies("aspxnet")("curgrade")

club_id=session("f_club_id")
session("f_club_id")=""
'response.write request("m_id")
'response.end
 if club_id="" then
 Call Msgbox("对不起，ID号错误！",1)
 Response.end
 end if
set rs_a=server.createobject("adodb.recordset")
sql_a="select * from t_club where F_id="&club_id
rs_a.open sql_a,conn,1,3

if rs_a.eof then
 Call Msgbox("对不起，该小圈子已经不存在！",1)
 Response.end
end if

 'filepath="ClubImages/"&f_id  '子小圈子的照片存放位置
 filepath="ClubImages/"  '小圈子的图片位置
 
if Request.ServerVariables("REQUEST_METHOD")="POST" then
 
dim upload,file,formName,formPath,iCount,filename,fileExt,i
set upload=new upload_5xSoft '建立上传对象

formPath=upload.form("filepath")
m_content=upload.form("content")
if m_content="" then
m_content="暂无说明"
end if

'在目录后加(/)
if right(formPath,1)<>"/" then formPath=formPath&"/" 
iCount=0

for each formName in upload.file '列出所有上传了的文件
    set file=upload.file(formName)  '生成一个文件对象
  next  
    if file.filesize<0 then
        Call Msgbox("对不起，参数不足错误！",1)
        response.end
    end if

'判别身份，是否有权限上传照片
set rs_user=server.createobject("adodb.recordset")
sql_user="select f_ischeck,f_identity from t_club_member where F_club_id="&club_id&" and f_username='"&m_username&"'"
rs_user.open sql_user,conn
if rs_user.eof and rs_user.bof then
 Call Msgbox("对不起,您还未加入本小圈子！",1)
 Response.end
 else
 if rs_user("f_ischeck")=false then
 Call Msgbox("对不起,您还未通过审核加入本小圈子，请耐心等待！",1)
 Response.end
 end if
end if
if rs_user("f_identity")="初级会员" then    '初级会员无权上传照片
 Call Msgbox("对不起,您是本小圈子[初级会员]暂无上传照片权限！",1)
 Response.end
end if
rs_user.close
set rs_user=nothing
   
   
   
    if file.filesize>100000 then
        response.write ("<script language=JavaScript>alert('错误：您上传子小圈子的照片大小已超过100k！');history.go(-1);</script>")
        response.end
    end if

    fileExt=lcase(right(file.filename,4))
    if fileEXT<>".gif" and fileEXT<>".jpg" and fileEXT<>".png" then
    response.write ("<script language=JavaScript>alert('错误：请检查您上传小圈子的照片的格式/JPG/GIG/PNG/！');history.go(-1);</script>")
    response.end
    end if 

    filenamett=file.FileName
	m_rnd=cint(((hour(now)*second(now))*rnd(5))+574)
  '  filenamett=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&file.FileName
	filenamett=year(now)&month(now)&day(now)&hour(now)&minute(now)&second(now)&clng(m_ID*m_rnd)&fileExt
	
    filename=formPath&filenamett

    filesize=file.filesize
    if file.FileSize>0 then         '如果 FileSize > 0 说明有文件数据
        file.SaveAs Server.mappath(filename)   '
          iCount=iCount+1
    end if

    set file=nothing

    FilePath=Server.MapPath(".")	
    FilePath=FilePath & "\pic\" 
	



    '开始变更所有文件扩展名为jpg
  ' filenamelen=len(filenamet)
 '  filenamelen=filenamelen-4
   filenamet1=filenamett
  ' filenamet=left(filenamet,filenamelen)
  ' filenamet=filenamet&".jpg"
    '结束文件名变更

    xx=right("00"&hour(time),2)
    ff=right("00"&minute(time),2)
    mm=right("00"&second(time),2)
    itime=xx & ":" & ff & ":" & mm

    itime=idate&itime
  
    photourlb=formPath & filenamet1
   ' photourls=formPath & "small_" & filenamet
	m_datenow=now()
	'写入照片表
	sql1="select * from t_club_photo"
	set rs1=server.createobject("ADODB.Recordset")
     rs1.open sql1,conn,1,3
	 rs1.addnew
	 rs1("f_club_id")=club_id
	 rs1("f_username")=m_username
     rs1("f_photo")=photourlb
	 rs1("f_regtime")=m_datenow
	 rs1("f_content")=m_content
	 '照片审核机制
	' if rs_a("f_manage_username")=m_username then
	 rs1("f_ischeck")=true
	 rs_a("f_clubphoto")=rs_a("f_clubphoto")+1
	 rs_a.update
	' else
	' rs1("f_ischeck")=false	
	' end if
	 rs1.update
	' m_club_id=itime
	' rs1.movenext	 
	 rs1.close
	 set rs1=nothing
	  '写入小圈子表 增加照片数量
    
		'FilePath1=Server.MapPath("..") & "\ClubImages\" &m_club_id
	FilePath1=Server.MapPath("..") & "\Club\ClubImages\" &m_club_id
    Set Fso=server.createobject("scripting.filesystemobject")
    if Fso.FileExists(FilePath1) then
    response.redirect "发生错误"
    response.end
    else
   
   end if	

    'conn.execute "insert into photourl (photourl,photourls,ifshare,uid,photointro,imgheight,imgwidth,filesize,puttime) values ('"&photourlb&"','"&photourls&"',"&cint(ifshare)&",'"&uid&"','"&photointro&"','"&imgheight&"','"&imgwidth&"','"&filesize&"','"&itime&"')"
  '  conn.execute "update userinfo set usesize=usesize+'"&filesize&"',photono=photono+1 where uid='"&uid&"'"

 '  conn.execute "update photocoll set collsize=collsize+'"&filesize&"',collsum=collsum+1,moditime='"&itime&"' where id=" & collid
  '  conn.execute "update sysinfo set usesize=usesize+'"&filesize&"',sumphoto=sumphoto+1,uptime='"&itime&"'"

    '结束数据库写入
   
    'response.write "<br>文件上传完毕<br>" & itime
    set upload=nothing  '删除对象
    url="club_photomanage.jsp?id="&rs_a("f_id")
    response.redirect url 
 end if
 '////////////////////////////////
%>




<%
rs_a.close
set rs_c=nothing
%>
