<!--#include file="../Include/Conn.asp" -->
<!--#include file="../Include/const.asp" -->
<!--#include file="../Include/char.asp" -->
<!--#include file="../Include/upload_club.inc"-->
<!--#include file="IsLogin.asp" -->
<%

dim upload,file,formName,formPath,iCount,filename,fileExt,i,f_id
set upload=new upload_5xSoft '建立上传对象

club_id=clng(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
 m_ID = Session("CurUserID")
 m_username= Session("CurUserName")

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
'判别身份，是否有权限上传照片
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

 'filepath="ClubImages/"&f_id  '子俱乐部的照片存放位置
 


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


   
    if file.filesize>1000000 then
        response.write ("<script language=JavaScript>alert('错误：您上传子俱乐部的照片大小已超过1M！');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
	  '写入俱乐部表 增加照片数量
    
	

    '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.asp?id="&rs_a("f_id")
    response.redirect url 
 
 '////////////////////////////////
%>




<%
rs_a.close
set rs_c=nothing
%>
