<%
Class Cls_UpLoad

    Private iChannelId, iUpType, iUpFileSize, iUpLoadPath
    Private sUpFileExt, sUpFileName, sUpLoadPath, sUpThumbnailFile


    Private Sub Class_Initialize()

    End Sub

    Private Sub Class_Terminate()

    End Sub

    Public Property Let SetChannelId(ByVal v)
        iChannelId = v
    End Property

    Public Property Let SetUpType(ByVal v)
        iUpType = v
    End Property

    Public Property Get GetUpFileSize()
        GetUpFileSize = iUpFileSize
    End Property

    Public Property Get GetUpFileExt()
        GetUpFileExt = sUpFileExt
    End Property

    Public Property Get GetUpLoadPath()
        GetUpLoadPath = sUpLoadPath
    End Property

    Public Property Let SetUpFileName(ByVal v)
        sUpFileName = v
    End Property

    Public Property Get UpThumbnailFile()
        UpThumbnailFile = sUpThumbnailFile
    End Property

    Public Sub GetUpFileValue()
        Select Case CmsFun.ChkNumEric(iUpType)
            Case 1
                iUpType = CmsUpImagesType
                iUpFileSize = Easp.IIf(Easp.IsN(CmsUpImagesSize), "50MB", CmsUpImagesSize)
                sUpLoadPath = CmsUpLoadFile & iChannelId & "/Image/"& Easp.DateTime(Now(), "yyyy-mm/")
            Case 2
                iUpType = CmsUpFlashType
                iUpFileSize = Easp.IIf(Easp.IsN(CmsUpFlashSize), "50MB", CmsUpFlashSize)
                sUpLoadPath = CmsUpLoadFile & iChannelId & "/Flash/"& Easp.DateTime(Now(), "yyyy-mm/")
            Case 3
                iUpType = CmsUpMediaType
                iUpFileSize = Easp.IIf(Easp.IsN(CmsUpMediaSize), "50MB", CmsUpMediaSize)
                sUpLoadPath = CmsUpLoadFile & iChannelId & "/Media/"& Easp.DateTime(Now(), "yyyy-mm/")
            Case 4
                iUpType = CmsUpFileType
                iUpFileSize = Easp.IIf(Easp.IsN(CmsUpFileSize), "50MB", CmsUpFileSize)
                sUpLoadPath = CmsUpLoadFile & iChannelId & "/File/"& Easp.DateTime(Now(), "yyyy-mm/")
            Case 5
                iUpType = CmsUpAdType
                iUpFileSize = Easp.IIf(Easp.IsN(CmsUpAdSize), "50MB", CmsUpAdSize)
                sUpLoadPath = CmsUpLoadFile & iChannelId & "/Images/"& Easp.DateTime(Now(), "yyyy-mm/")
        End Select
    End Sub

    Public Sub CreateUpFile()
        CreateThumbnail()
        CreatePic()
    End Sub

    Public Sub CreateThumbnail()
        If Easp.IsInstall("Persits.Jpeg") And IsArray(IsChannel()) Then
            Dim ArrayData
            ArrayData = IsChannel()
            If ArrayData(0, 0) > 0 Then
                sUpThumbnailFile = CmsFun.MakeThumb(sUpFileName, Replace(sUpFileName, ".", "s."), ArrayData(1, 0), ArrayData(2, 0), ArrayData(3, 0))
            End If
        End If
    End Sub

    Public Sub CreatePic()
        If Easp.IsInstall("Persits.Jpeg") And IsArray(IsChannel()) Then
            Dim ArrayData
            ArrayData = IsChannel()
            If ArrayData(4, 0) > 0 Then
                If ArrayData(4, 0) = 1 Then
                    CmsFun.CreateWaterMark sUpFileName, ArrayData(5, 0), ArrayData(6, 0)
                Else
                    CmsFun.CreateWaterMarkText sUpFileName, ArrayData(8, 0), ArrayData(7, 0)
                End If
            End If
        End If
    End Sub

    Public Function IsChannel()
        Dim oRs, FieldList
        FieldList = "IsThumbnail,ThumbW,ThumbH,ThumbMode,IsWaterMark,"
        FieldList = FieldList & "WaterMarkLogo,WaterLogoPos,WaterMarkTextPos,WaterMarkText"
        Set oRs = Easp.db.GR(TablePrefix & "Channel:"& FieldList &":1", " Id = "& iChannelId &" ", "")
        If Easp.IsN(oRs) Then
            IsChannel = Null
        Else
            IsChannel = oRs.GetRows()
        End If
        Easp.C oRs
    End Function

End Class
%>