<!--#Include File="../conn.asp"-->
<%
MyDbPath = "../"
Call OpenConn
dim Nslove,SqlNowString,Conn
On Error Resume Next
Set Nslove =Server.CreateObject("NS_Comment4.Ns_Manage")
Nslove.iConnStr=ConnStr
Nslove.IsSqlData=IsSqlDataBase
Nslove.Chk_Sys()
if IsSqlDataBase=0 then
	SqlNowString="Now()"
else
	SqlNowString="GetDate()"
end if
If Not IsObject(Conn) Then
	On Error Resume Next
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open ConnStr
    If Err Then
        Err.Clear
        Set Conn = Nothing
        Response.Write "数据库连接出错，请检查链接字串。"
        Response.End
    End If
end if
Sub CloseConn()
    On Error Resume Next
    If IsObject(conn) Then
        conn.Close
        Set conn = Nothing
    End If
End Sub
'读取上传目录
Function CheckFolder(ID)
	CheckFolder=Get_Folder(ID,"NotPage",Nslove.iSession(22))
	'在目录后加(/)
	If Right(CheckFolder,1)<>"/" Then CheckFolder=CheckFolder&"/"
End Function

'按月份自动明名上传文件夹,需要ＦＳＯ组件支持。
Private Function CreatePath(PathValue)
	Dim objFSO,Fsofolder,uploadpath
	'以年月创建上传文件夹，格式：2003－8
	uploadpath =year(now) & "-" & month(now)
	If Right(PathValue,1)<>"/" Then PathValue = PathValue&"/"
	On Error Resume Next
	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
		If objFSO.FolderExists(Server.MapPath(PathValue & uploadpath))=False Then
			objFSO.CreateFolder Server.MapPath(PathValue & uploadpath)
		End If
		If Err.Number = 0 Then
			CreatePath = PathValue & uploadpath & "/"
		Else
			CreatePath = PathValue
		End If
	Set objFSO = Nothing
End Function

 ''按时间创建目录,如：2006/1/7/
    Function Create_Path(PathValue)
        Dim objFSO, i, TempStr, TempStr1
        On Error Resume Next
        Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
        PathValue = Replace(PathValue, "//", "/")
        TempStr = Split(PathValue, "/")
        TempStr1 = "/"
        For i = 1 To UBound(TempStr)
            If objFSO.FolderExists(Server.MapPath(TempStr1 & TempStr(i))) = False Then
                objFSO.CreateFolder Server.MapPath(TempStr1 & TempStr(i))
            End If
            TempStr1 = TempStr1 & TempStr(i) & "/"
        Next
            TempStr1 = Replace(TempStr1, "//", "/")
            Create_Path = TempStr1
        Set objFSO = Nothing
    End Function

''函数名Rep_Split替换数组中某个元素
  	Function Rep_Split(str, i, SplitChr, NewStr)
        'Str旧字段字串
        'i字段要修改的位置
        'SplitChr 分割的字符
        'NewStr新替换的内容
        Dim TempStr
        TempStr = Split(str, SplitChr)
        If i <= UBound(TempStr) Then TempStr(i) = NewStr
        Rep_Split = Join(TempStr, SplitChr)
    End Function
'//以下为功能函数
    ''检查特殊字符
	Function Checkstr(str)
        If IsNull(str) Then
            Checkstr = ""
            Exit Function
        End If
        str = Replace(str, Chr(0), "")
        Checkstr = Replace(str, "'", "''")
    End Function
	Function ChkPost() ''判断提交地址
        Dim server_v1, server_v2
        ChkPost = False
        server_v1 = CStr(Request.ServerVariables("HTTP_REFERER"))
        server_v2 = CStr(Request.ServerVariables("SERVER_NAME"))
        If Mid(server_v1, 8, Len(server_v2)) = server_v2 Then ChkPost = True
    End Function
	Function Get_Folder(ArrID, PageName, UPath)
        Dim TempStr, Ns_Folder
            TempStr = UPath
            Ns_Folder = Split(Nslove.iNs_setting(32), "|") ''系统栏目录
            If ArrID <> 0 Then
                TempStr = TempStr & Trim(Ns_Folder(ArrID)) ''ArrID=0时没有目录index.html
            Else
                TempStr = TempStr ''个人主页
            End If
            If Right(TempStr, 1) <> "/" Then TempStr = TempStr & "/"
            
            If PageName <> "NotPage" Then ''网页名称为空！
                TempStr = TempStr & PageName & Nslove.iNs_setting(31) ''文件格式
            End If
        Get_Folder = Nslove.iNs_setting(29) & TempStr
    End Function
Function SendResults(errorNumber, fileUrl, fileName, customMsg )
	Response.Charset = "UTF-8"
	Response.Write "<script type=""text/javascript"">"
	Response.Write "window.parent.OnUploadCompleted(" & errorNumber & ",""" & Replace( fileUrl, """", "\""" ) & """,""" & Replace( fileName, """", "\""" ) & """,""" & Replace( customMsg , """", "\""" ) & """) ;"
	Response.Write "</script>"
	Response.End
End Function
%>

