469 lines
15 KiB
Plaintext
469 lines
15 KiB
Plaintext
<%
|
|
|
|
'###########################################################################################
|
|
'URL Redirect
|
|
'###########################################################################################
|
|
Function call_Url(url,msg)
|
|
Response.Write "<html xmlns='http://www.w3.org/1999/xhtml'>" & vbCRLF
|
|
Response.Write "<head>" & vbCrLF
|
|
Response.Write "<title>" & SurveyTitle & "</title>" & vbCrlf
|
|
Response.Write "<meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" & vbCrlf
|
|
Response.Write "</head>" & vbCrLF
|
|
Response.Write "<script language='javascript'>" & vbCrlf
|
|
Response.Write "<!--" & vbCrlf
|
|
|
|
if Trim(msg)<>"" Then
|
|
Response.Write " alert('" & trim(msg) & "');" & vbCrlf
|
|
end if
|
|
|
|
Response.Write " location.replace('" & trim(url) & "');" & vbCrlf
|
|
|
|
Response.Write "//-->" & vbCrlf
|
|
Response.Write "</script>" & vbCrlf
|
|
Response.Write "</html>"
|
|
End Function
|
|
|
|
|
|
Function LoadSkin(fnName)
|
|
|
|
Dim objStream
|
|
Set objStream = CreateObject("ADODB.Stream")
|
|
With objStream
|
|
.Charset = "utf-8"
|
|
.Type=2
|
|
.mode=3
|
|
.Open
|
|
.loadfromfile Server.Mappath(fnName)
|
|
LoadSkin=.readtext
|
|
.Close
|
|
End With
|
|
|
|
Set objStream = Nothing
|
|
|
|
End Function
|
|
|
|
'###########################################################################################
|
|
'메일 발송
|
|
'###########################################################################################
|
|
Function MailSend(FromStr,ToStr,Subject,BodyStr)
|
|
Dim objMail,iConf
|
|
|
|
Set objMail=server.CreateObject("CDO.Message")
|
|
Set iConf = objMail.Configuration
|
|
With iConf.Fields
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") =2
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") =MAIL_SV
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") =1
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") =MAIL_ID
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") =MAIL_PW
|
|
.Update
|
|
End with
|
|
|
|
objMail.To = ToStr
|
|
objMail.From = FromStr
|
|
objmail.Subject = Subject
|
|
|
|
objmail.htmlBody = BodyStr
|
|
objMail.BodyPart.Charset="utf-8"
|
|
objMail.Send
|
|
|
|
Set objMail = Nothing
|
|
End Function
|
|
|
|
'###########################################################################################
|
|
'CDO 메일 발송
|
|
'###########################################################################################
|
|
Function CMailSend(FromStr,ToStr,Subject,BodyStr)
|
|
Dim objMail,iConf
|
|
|
|
Set objMail=server.CreateObject("CDO.Message")
|
|
Set iConf = objMail.Configuration
|
|
With iConf.Fields
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 1
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="localhost"
|
|
.item("http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory") = "C:\inetpub\mailroot\pickup"
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
|
|
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 30
|
|
.Update
|
|
End with
|
|
|
|
objMail.To = ToStr
|
|
objMail.From = FromStr
|
|
objmail.Subject = Subject
|
|
|
|
objmail.htmlBody = BodyStr
|
|
objMail.BodyPart.Charset="utf-8"
|
|
objMail.Send
|
|
|
|
Set objMail = Nothing
|
|
End Function
|
|
|
|
'###########################################################################################
|
|
'랜덤 난수 발생
|
|
'###########################################################################################
|
|
Function RandomNum(start,limit)
|
|
Dim Val,MyValue
|
|
|
|
if Not IsNumeric(start) Or Not IsNumeric(limit) then
|
|
RandomNum = 0
|
|
Exit Function
|
|
end if
|
|
|
|
Randomize
|
|
MyValue = Int(limit * Rnd) + start
|
|
|
|
RandomNum=MyValue
|
|
|
|
End Function
|
|
|
|
|
|
'###########################################################################################
|
|
'에러 메일 발송
|
|
'###########################################################################################
|
|
Private Sub ErrorMail(er)
|
|
Dim ErrBody
|
|
ErrBody = LoadSkin("./SKIN/Error.htm")
|
|
ErrBody = Replace(ErrBody,"##PROJECTTITLE##",SURVEYTITLE)
|
|
ErrBody = Replace(ErrBody,"##PROJECTCODE##",PROJECTCODE)
|
|
ErrBody = Replace(ErrBody,"##PAGE##",Request.Form("PageName"))
|
|
ErrBody = Replace(ErrBody,"##ERKEY##",Request.Form("IDKey"))
|
|
ErrBody = Replace(ErrBody,"##CODE##",er.Description)
|
|
ErrBody = Replace(ErrBody,"##NUMBER##",er.Number)
|
|
|
|
MailSend "system@survey.kr","wmkim@trendmr.com;ehlee@trendmr.com;" & ERROREMAIL ,"Error Message",ErrBody
|
|
|
|
End Sub
|
|
|
|
|
|
'###########################################################################################
|
|
'makeItem
|
|
'###########################################################################################
|
|
'사용방법
|
|
'Call QuestionMultiCNT(VARS,CODES,QUESTION,3,2,HTMLSCRIPT,JSCRIPT)
|
|
'HTMLSCRIPT = Replace(HTMLSCRIPT,"[$_STITEM_$]",makeItem("Front_1_A.jpg,Front_1_B.jpg,Front_1_C.jpg,Front_1_D.jpg",getXValue("MQ1"),"LIKE"))
|
|
|
|
Function makeItem(IMAGES,SELNUM,TEXT)
|
|
|
|
Dim TableBody,ImageArray,tCount,Twidth
|
|
TableBody = ""
|
|
ImageArray = Split(IMAGES,",")
|
|
TWidth = FormatNumber(CDbl(100/(UBound(ImageArray)+1)),2)
|
|
|
|
TableBody = TableBody & "<table id='V_table' class='attab01' cellpadding='0' cellspacing='0' border='0'>" & vbCrLF
|
|
TableBody = TableBody & "<colgroup>" & vbCrLF
|
|
For tCount=0 To UBound(ImageArray)
|
|
TableBody = TableBody & " <col width="""&TWidth&"%""/>" & vbCrLF
|
|
Next
|
|
TableBody = TableBody & "</colgroup>" & vbCrLF
|
|
TableBody = TableBody & "<tr>" & vbCrLF
|
|
For tCount=0 To UBound(ImageArray)
|
|
TableBody = TableBody & "<th style='text-align:center;background:#fff;'>"&vbCrLF
|
|
TableBody = TableBody & " <img src=""./media/"&ImageArray(tCount)&""" alt=''/>"&vbCrLF
|
|
TableBody = TableBody & "</th>"&vbCrLF
|
|
Next
|
|
TableBody = TableBody & "</tr>" & vbCrLF
|
|
TableBody = TableBody & "<tr>" & vbCrLF
|
|
For tCount=0 To UBound(ImageArray)
|
|
TableBody = TableBody & "<td style='text-align:center;background:#fff;'>"&vbCrLF
|
|
If (tCount+1)=CInt(SELNUM) Then
|
|
TableBody = TableBody & " <b><font color='red'>" & TEXT & "</font></b>"&vbCrLF
|
|
Else
|
|
TableBody = TableBody & " " & vbCrLF
|
|
End IF
|
|
TableBody = TableBody & "</td>"&vbCrLF
|
|
Next
|
|
TableBody = TableBody & "</tr>" & vbCrLF
|
|
TableBody = TableBody & "</table>"&vbCrLF
|
|
makeItem = TableBody
|
|
|
|
End Function
|
|
|
|
|
|
Function makeItem2(IMAGES,SELNUM,TEXT,COL)
|
|
|
|
Dim TableBody,ImageArray,tCount,Twidth
|
|
Dim EStr,DStr,XStr,mxCOL,colCnt
|
|
|
|
mxCOL = CLng(COL)
|
|
colCnt=1
|
|
|
|
TableBody = ""
|
|
ImageArray = Split(IMAGES,",")
|
|
TWidth = FormatNumber(CDbl(100/CLng(COL)),2)
|
|
|
|
TableBody = TableBody & "<table id='V_table' class='attab01' cellpadding='0' cellspacing='0' border='0'>" & vbCrLF
|
|
TableBody = TableBody & "<colgroup>" & vbCrLF
|
|
For tCount=1 To CLng(COL)
|
|
TableBody = TableBody & " <col width="""&TWidth&"%""/>" & vbCrLF
|
|
Next
|
|
TableBody = TableBody & "</colgroup>" & vbCrLF
|
|
' TableBody = TableBody & "<tr>" & vbCrLF
|
|
|
|
DStr = ""
|
|
EStr = ""
|
|
|
|
For tCount=0 To UBound(ImageArray)
|
|
|
|
EStr = EStr & "<th style='text-align:center;background:#fff;'>"&vbCrLF
|
|
EStr = EStr & " <img src=""./media/"&ImageArray(tCount)&""" alt=''/>"&vbCrLF
|
|
EStr = EStr & "</th>"&vbCrLF
|
|
|
|
DStr = DStr & "<td style='text-align:center;background:#fff;'>"&vbCrLF
|
|
If (tCount+1)=CInt(SELNUM) Then
|
|
DStr = DStr & " <b><font color='red'>" & TEXT & "</font></b>"&vbCrLF
|
|
Else
|
|
DStr = DStr & " " & vbCrLF
|
|
End IF
|
|
DStr = DStr & "</td>"&vbCrLF
|
|
|
|
If colCnt=mxCOL Then
|
|
XSTR = XSTR & " <tr>" & vbCRLF
|
|
XSTR = XSTR & EStr
|
|
XSTR = XSTR & " </tr>" & vbCRLF
|
|
XSTR = XSTR & " <tr>" & vbCRLF
|
|
XSTR = XSTR & DStr
|
|
XSTR = XSTR & " </tr>" & vbCRLF
|
|
ESTR = ""
|
|
DSTR = ""
|
|
colCnt=1
|
|
Else
|
|
colCnt=colCnt+1
|
|
End If
|
|
|
|
Next
|
|
|
|
If ESTR<>"" AND DSTR<>"" Then
|
|
XSTR = XSTR & " <tr>" & vbCRLF
|
|
XSTR = XSTR & EStr & DSTR
|
|
XSTR = XSTR & " </tr>" & vbCRLF
|
|
End If
|
|
|
|
TableBody = TableBody & XStr
|
|
TableBody = TableBody & "<tr>" & vbCrLF
|
|
|
|
For tCount=0 To UBound(ImageArray)
|
|
Next
|
|
|
|
' TableBody = TableBody & "</tr>" & vbCrLF
|
|
TableBody = TableBody & "</table>"&vbCrLF
|
|
makeItem2 = TableBody
|
|
|
|
End Function
|
|
|
|
'##############################################################################
|
|
'#http:체크
|
|
'##############################################################################
|
|
Function checkHTTP(linkStr)
|
|
If Left(linkStr,7)="http://" Then
|
|
checkHTTP = linkStr
|
|
Else
|
|
checkHTTP = "http://" & linkStr
|
|
End If
|
|
|
|
End Function
|
|
|
|
'###########################################################################################
|
|
'DB 날짜 형식대로 ASP로 출력하기
|
|
'###########################################################################################
|
|
Function ConvertDBDate(dates)
|
|
Dim yy,mm,dd,hh,mi,se
|
|
yy = year(dates)
|
|
mm = right("0" & month(dates),2)
|
|
dd = right("0" & day(dates),2)
|
|
hh = right("0" & hour(dates),2)
|
|
mi = right("0" & minute(dates),2)
|
|
se = right("0" & second(dates),2)
|
|
|
|
ConvertDBDate = yy & "-" & mm & "-" & dd & " " & hh & ":" & mi & ":" & se
|
|
|
|
End Function
|
|
|
|
'###########################################################################################
|
|
'ADODB Recordset to CSV
|
|
'###########################################################################################
|
|
Sub Write_CSV_From_Recordset(RS)
|
|
|
|
'
|
|
' Export Recordset to CSV
|
|
' http://salman-w.blogspot.com/2009/07/export-recordset-data-to-csv-using.html
|
|
'
|
|
' This sub-routine Response.Writes the content of an ADODB.RECORDSET in CSV format
|
|
' The function closely follows the recommendations described in RFC 4180:
|
|
' Common Format and MIME Type for Comma-Separated Values (CSV) Files
|
|
' http://tools.ietf.org/html/rfc4180
|
|
'
|
|
' @RS: A reference to an open ADODB.RECORDSET object
|
|
'
|
|
|
|
if RS.EOF then
|
|
|
|
'
|
|
' There is no data to be written
|
|
'
|
|
exit sub
|
|
|
|
end if
|
|
|
|
dim RX
|
|
set RX = new RegExp
|
|
RX.Pattern = "\r|\n|,|"""
|
|
|
|
dim i
|
|
dim Field
|
|
dim Separator
|
|
|
|
'
|
|
' Writing the header row (header row contains field names)
|
|
'
|
|
|
|
Separator = ""
|
|
for i = 0 to RS.Fields.Count - 1
|
|
Field = RS.Fields(i).Name
|
|
if RX.Test(Field) then
|
|
'
|
|
' According to recommendations:
|
|
' - Fields that contain CR/LF, Comma or Double-quote should be enclosed in double-quotes
|
|
' - Double-quote itself must be escaped by preceeding with another double-quote
|
|
'
|
|
Field = """" & Replace(Field, """", """""") & """"
|
|
end if
|
|
Response.Write Separator & Field
|
|
Separator = ","
|
|
next
|
|
Response.Write vbNewLine
|
|
|
|
'
|
|
' Writing the data rows
|
|
'
|
|
|
|
do until RS.EOF
|
|
Separator = ""
|
|
for i = 0 to RS.Fields.Count - 1
|
|
'
|
|
' Note the concatenation with empty string below
|
|
' This assures that NULL values are converted to empty string
|
|
'
|
|
Field = RS.Fields(i).Value & ""
|
|
if RX.Test(Field) then
|
|
Field = """" & Replace(Field, """", """""") & """"
|
|
Field = Replace(Field,vbCrLF," ")
|
|
end If
|
|
If isNumeric(Field) Then
|
|
'Response.Write Separator & Chr(34) & "'" & Field & Chr(34)
|
|
Response.Write Separator & Chr(34) & Field & Chr(34)
|
|
Else
|
|
Response.Write Separator & Chr(34) & Field & Chr(34)
|
|
End IF
|
|
Separator = ","
|
|
next
|
|
Response.Write vbNewLine
|
|
RS.MoveNext
|
|
loop
|
|
|
|
End Sub
|
|
|
|
|
|
Function URLDecode(Expression)
|
|
Dim strSource, strTemp, strResult, strchr
|
|
Dim lngPos, AddNum, IFKor
|
|
|
|
strSource = Replace(Expression, "+", " ")
|
|
For lngPos = 1 To Len(strSource)
|
|
AddNum = 2
|
|
strTemp = Mid(strSource, lngPos, 1)
|
|
|
|
If strTemp = "%" Then
|
|
If lngPos + AddNum < Len(strSource) + 1 Then
|
|
strchr = CInt("&H" & Mid(strSource, lngPos + 1, AddNum))
|
|
|
|
If strchr > 130 Then
|
|
AddNum = 5
|
|
IFKor = Mid(strSource, lngPos + 1, AddNum)
|
|
IFKor = Replace(IFKor, "%", "")
|
|
strchr = CInt("&H" & IFKor )
|
|
End If
|
|
|
|
strResult = strResult & Chr(strchr)
|
|
lngPos = lngPos + AddNum
|
|
End If
|
|
Else
|
|
strResult = strResult & strTemp
|
|
End If
|
|
Next
|
|
URLDecode = strResult
|
|
End Function
|
|
|
|
'======================================================
|
|
' 사용할때,, getRefererPage 함수를 호출하면 이전 페이지 이름만 리턴합니다.
|
|
' Response.Write("refererValue : " & getRefererPage & "<br>")
|
|
'======================================================
|
|
Function getRefererPage
|
|
|
|
Dim refererValue, chkPos
|
|
|
|
' 호출한 페이지값을 받습니다.
|
|
refererValue = Request.ServerVariables("HTTP_REFERER")
|
|
' 호출한 페이지 값이 없을 경우
|
|
IF Len(refererValue) = 0 Then
|
|
getRefererPage = ""
|
|
Exit Function
|
|
End IF
|
|
|
|
' 문자열에서 마지막 '/'값의 위치를 찾습니다. Text비교
|
|
chkPos = InstrRev(refererValue, "/", -1, 1)
|
|
' 마지막 '/'값을 찾은 위치에서 마지막까지의 문자열만 추출합니다.
|
|
refererValue = Right( refererValue, Len(refererValue) - chkPos )
|
|
|
|
' 추출한 페이지이름을 리턴합니다.
|
|
getRefererPage = refererValue
|
|
|
|
End Function
|
|
|
|
'###########################################################################################
|
|
'로그아웃
|
|
'return : void
|
|
'###########################################################################################
|
|
Sub Logout()
|
|
Session("name")=""
|
|
Session("phone")=""
|
|
Session.Contents.RemoveAll()
|
|
Session.Abandon
|
|
End Sub
|
|
|
|
'###########################################################################################
|
|
'로그인 여부 체크 함수
|
|
'return : void
|
|
'###########################################################################################
|
|
Function Login()
|
|
If Session("name")="" Or Session("phone")="" Then
|
|
Response.Write "<script type='text/javascript'>alert('로그인 후 확인 가능합니다.'); window.location.href='../index.asp';</script>"
|
|
'Response.Redirect "../Index.asp"
|
|
End If
|
|
End Function
|
|
|
|
Function GoMain(msg,url)
|
|
Response.Write "<SCRIPT type='text/javascript'>"&VbCrlf
|
|
'Response.Write "alert('"&msg&"');"&VbCrlf
|
|
'Response.Write "window.location.href='"&url&"';"&VbCrlf
|
|
'Response.Write "</SCRIPT>"&VbCrlf
|
|
Response.Write "// 사파리나 체크"&VbCrlf
|
|
Response.Write "var agent = navigator.userAgent.toLowerCase();"&VbCrlf
|
|
Response.Write "if (agent.indexOf('safari') != -1) {"&VbCrlf
|
|
Response.Write " window.onpageshow = function(event){"&VbCrlf
|
|
Response.Write " if(event.persisted){"&VbCrlf
|
|
Response.Write " window.location.repload();"&VbCrlf
|
|
Response.Write " }else{"&VbCrlf
|
|
Response.Write " alert('"&msg&"');"&VbCrlf
|
|
Response.Write " window.location.href='"&url&"';"&VbCrlf
|
|
Response.Write " }"&VbCrlf
|
|
Response.Write " }"&VbCrlf
|
|
Response.Write "}else{"&VbCrlf
|
|
Response.Write " alert('"&msg&"');"&VbCrlf
|
|
Response.Write " window.location.href='"&url&"';"&VbCrlf
|
|
Response.Write "}"&VbCrlf
|
|
|
|
|
|
Response.Write "</SCRIPT>"&VbCrlf
|
|
End Function
|
|
%> |