<!--#include file="../../Conn.asp"-->
<!--#include file="../../fy_inc/fy.Main.asp"-->
<!--#include file="../../fy_inc/UpLoadClass.asp"-->
<!--#include file="../../fy_inc/CreateView.asp"-->
 <% 	
	Dim fycms
	Set fycms = New ACT_Main
	Public Function UserLoginChecked()
	on error resume next
	Dim AdminName,PassWord
		UserLoginChecked = false 
   		AdminName = RSQL(fycms.toasc(fycms.s("U")))
		PassWord= RSQL(fycms.toasc(fycms.s("P")))
		IF AdminName="" Or PassWord = "" Then
		   UserLoginChecked=false
		   Exit Function
		Else
			Dim UserRs
			Set Userrs=fycms.Actexe("Select Admin_Name,PassWord From Admin_fy Where Admin_Name='" & AdminName & "' And PassWord='" & PassWord & "'")
			IF UserRS.Eof And UserRS.Bof Then
				UserLoginChecked=false
			Else
				UserLoginChecked = true
			End if
			UserRS.Close:Set UserRS=Nothing
	   End IF
	End Function 
	IF Cbool(UserLoginChecked)=false Then
	  echo "error"
	  Response.end
	End If
 Dim ModeID,Yname,instrs,myid,fp,ih,rs,aid,id
 Yname=request("Yname")
 myid=Request("myid")
 ih=Request("ih")
 If ih="" Then ih="fycms"
aid = ChkNumeric(Request("aid"))
ModeID = ChkNumeric(Request("ModeID"))
If  ModeID=0 or ModeID="" Then ModeID=1
 IF myid="Upload" Then
	If ModeID="999" Then fp=fycms.ActSys&"UpFiles/UserFile/Other/" Else fp=fycms.ActSys&fycms.ACT_C(ModeID,8)&year(now) & "/" & month(now)& "/" & Day(now)&"/"
 	Call fycms.CreateFolder(fp)
	Dim UpFile,FileTitles
	set UpFile = New UpLoadClass
  	UpFile.AutoSave = 2
	UpFile.MaxSize =  fycms.fycms_Sys(10)* 1024
	UpFile.FileType = fycms.fycms_Sys(11)
	UpFile.Charset="gb2312"
	UpFile.SavePath = fp
	UpFile.Open() '# 打开对象
 	If UpFile.Save("Filedata",0) Then
 		Dim W:Set W = New CreateView
		 Call  W.SY(fycms.ActSys&fp&UpFile.Form("Filedata"),UpFile.Form("Filedata_Ext"))
	'	Call OutUploadScript(UpFile.Form("Filedata_Ext"),fycms.PathDoMain&fp&UpFile.Form("Filedata"),Yname)
        'If Not  IsNull(UpFileObj.Form("fileNames")) Then FileTitles=unescape(UpFileObj.Form("fileNames")) '防止中文乱码

			FileTitles=UpFile.Form("Filedata_Name")
 			 	If Instr(FileTitles,"?")<>0 Then 
					FileTitles=(left(FileTitles,len(FileTitles)-6))
				Else 
					FileTitles=(left(FileTitles,len(FileTitles)-4))
				End If 
    fycms.actexe("insert Into Upload_fy(aid,UpfileDir,Extension,ModeID,addtime) values("&aid&",'" & fycms.PathDoMain&fp&UpFile.Form("Filedata") & "','"&UpFile.Form("Filedata_Ext")&"',0,'"&Now()&"')")

	
	If  Trim(FileTitles)<>"" Then FileTitles=unescape(FileTitles) '防止中文乱码
		
		 fycms.actexe("insert Into syspic(aid,picurl,title,ModeID,addtime,Fieldname,ext,orderid) values("&aid&",'" &fycms.PathDoMain&fp&UpFile.Form("Filedata") & "','"&FileTitles&"',"&ModeID&",'"&Now()&"','"&ih&"','"&UpFile.Form("Filedata_Ext")&"',10)")
 		 	Set rs=fycms.actexe("Select top 1 id from syspic where Fieldname='"&ih&"' and aid="&aid&" order by id desc")
			If Not rs.eof Then ID = rs("ID")

	echo ih&"|"&replace(fycms.PathDoMain&fp&UpFile.Form("Filedata"),"|","") &  "|" & fycms.PathDoMain&fp&UpFile.Form("Filedata") & "|" &FileTitles& "|"&id

 	End If
 	Set UpFile = Nothing
End If 

Sub OutUploadScript(sType,strPath,instrct)
	sType = LCase(sType)
	Dim Temps
	If Yname<>"content"  Then 
 		Temps=LTemplate("../../fy_inc/T/"&ModeID&"/"&sType&".Html")
		If temps="" Then Temps=LTemplate("../../fy_inc/T/1/"&sType&".Html")
 	Else
		Temps=LTemplate("../../fy_inc/T/"&ModeID&"/C"&sType&".Html")
		If temps="" Then Temps=LTemplate("../../fy_inc/T/1/C"&sType&".Html")
	End If 
	If Trim(Temps)="" Then Temps=LTemplate("../../fy_inc/T/1/fycms.Html")


	If InStr(Temps, "#FileName") > 0  Then
 		   Temps = Replace(Temps, "#FileName",strPath)
 	End if
	
	If InStr(Temps, "{$InstallDir}") > 0  Then
 		   Temps = Replace(Temps, "{$InstallDir}",fycms.fycms_Sys(3))
 	End if
 	echo instrct&"|"&Temps & vbCrLf
End Sub



 %>