최초 커밋

This commit is contained in:
2025-10-01 09:29:34 +09:00
commit a8b84ff39a
1677 changed files with 954149 additions and 0 deletions

61
AdminPoll/Lib/DBConn.asp Normal file
View File

@@ -0,0 +1,61 @@
<%
'Database Connection
'DBConn : DataBase
Dim DBFlag,RBFlag
'###########################################################################################
'CAPI 시스템 DB 연결
'###########################################################################################
Sub DBConnect()
Set DBConn=Server.CreateObject("ADODB.Connection")
DBConn.CommandTimeout = 0 ' select 쿼리 시간 무제한
DBConn.Open GetDBStr()
DBFlag = True
End Sub
'###########################################################################################
'CAPI Project DB 연결
'###########################################################################################
Sub DBConnect1()
Set DBConn=Server.CreateObject("ADODB.Connection")
DBConn.Open GetDBStr1()
DBFlag = True
End Sub
Sub DBConnect2()
Set DBConn=Server.CreateObject("ADODB.Connection")
DBConn.Open GetDBStr2()
DBFlag = True
End Sub
Function GetDBStr()
GetDBStr = "Driver=SQL Server; Server=" & SV_NAME & "; Database=" & DB_NAME & "; UID=" & UID & "; PWD=" & PWD
End Function
Function GetDBStr1()
GetDBStr1 = "Driver=SQL Server; Server=" & SV_NAME1 & "; Database=" & DB_NAME1 & "; UID=" & UID1 & "; PWD=" & PWD1
End Function
Function GetDBStr2()
GetDBStr2 = "Provider=SQLOLEDB; Server=" & SV_NAME2 & ";Initial Catalog=" & DB_NAME2 & "; UID=" & UID2 & "; PWD=" & PWD2
End Function
'DB 끊기
Sub DBClose()
If Not DBConn Is Nothing Then
DBConn.Close
Set DBConn = Nothing
End If
DBFlag = False
End Sub
%>

451
AdminPoll/Lib/DBHelper.asp Normal file
View File

@@ -0,0 +1,451 @@
<!--METADATA TYPE= "typelib" NAME= "ADODB Type Library"
FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" -->
<%
Class clsDBHelper
Private DefaultConnString
Private DefaultConnection
Private m_ServerIP
Private m_DBName
Private m_UserID
Private m_UserPW
Dim cmd
Dim rs
Dim inum
Private sub Class_Initialize()
'----------------------------------------------------
'SQL OLE DB ConnString
'----------------------------------------------------
'DefaultConnString = "Provider=SQLOLEDB;Data Source=" & m_ServerIP & ";Initial Catalog=" & m_DBName & ";User Id=" & m_UserID & ";Password=" & m_UserPW & ";"
'----------------------------------------------------
'MS SQL DB ConnString
'----------------------------------------------------
DefaultConnString = "Driver=SQL Server; Server=" & m_ServerIP & "; Database=" & m_DBName & "; UID=" & m_UserID & "; PWD=" & m_UserPW
Set DefaultConnection = Nothing
End Sub
'소멸자
Private Sub Class_Terminate()
Set DefaultConnection = Nothing
End Sub
'---------------------------------------------------
' 서버 설정
'---------------------------------------------------
Public Property Set Server(mServer)
m_ServerIP = mServer
End Property
Public Property Set DBName(mDBName)
m_DBName = mDBName
End Property
Public Property Set UserID(mUserID)
m_UserID = mUserID
End Property
Public Property Set UserPW(mUserPW)
m_UserPW = mUserPW
End Property
'---------------------------------------------------
' SP를 실행하고, RecordSet을 반환한다.
'---------------------------------------------------
Public Function ExecSPReturnRS(spName, params, connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
If DefaultConnection is Nothing Then
Set DefaultConnection = CreateObject("ADODB.Connection")
DefaultConnection.Open DefaultConnString
End If
Set connectionString = DefaultConnection
End If
End If
Set rs = CreateObject("ADODB.RecordSet")
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = connectionString
cmd.CommandText = spName
cmd.CommandType = adCmdStoredProc
Set cmd = collectParams(cmd, params)
'cmd.Parameters.Refresh
rs.CursorLocation = adUseClient
rs.Open cmd, ,adOpenStatic, adLockReadOnly
For i = 0 To cmd.Parameters.Count - 1
If cmd.Parameters(i).Direction = adParamOutput OR cmd.Parameters(i).Direction = adParamInputOutput OR cmd.Parameters(i).Direction = adParamReturnValue Then
If IsObject(params) Then
If params is Nothing Then
Exit For
End If
Else
params(i)(4) = cmd.Parameters(i).Value
End If
End If
Next
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
If rs.State = adStateClosed Then
Set rs.Source = Nothing
End If
Set rs.ActiveConnection = Nothing
Set ExecSPReturnRS = rs
End Function
'---------------------------------------------------
' SQL Query를 실행하고, RecordSet을 반환한다.
'---------------------------------------------------
Public Function ExecSQLReturnRS(strSQL, params, connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
If DefaultConnection is Nothing Then
Set DefaultConnection = CreateObject("ADODB.Connection")
DefaultConnection.Open DefaultConnString
End If
Set connectionString = DefaultConnection
End If
End If
Set rs = CreateObject("ADODB.RecordSet")
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = connectionString
cmd.Prepared = true
cmd.CommandText = strSQL
cmd.CommandType = adCmdText
Set cmd = collectParams(cmd, params)
' On Error Resume Next
' Response.Write strSQL & "<BR>"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockReadOnly
If Err.Number<>0 Then
ErrorLog DefaultConnection.Number, DefaultConnection.Description
End IF
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
If rs.State = adStateClosed Then
Set rs.Source = Nothing
End If
Set rs.ActiveConnection = Nothing
Set ExecSQLReturnRS = rs
End Function
'---------------------------------------------------
' SQL Query를 실행하고, RecordSet Array을 반환한다.
'---------------------------------------------------
Public Function ExecSQLReturnAR(strSQL, params, connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
If DefaultConnection is Nothing Then
Set DefaultConnection = CreateObject("ADODB.Connection")
DefaultConnection.Open DefaultConnString
End If
Set connectionString = DefaultConnection
End If
End If
Set rs = CreateObject("ADODB.RecordSet")
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = connectionString
cmd.Prepared = true
cmd.CommandText = strSQL
cmd.CommandType = adCmdText
Set cmd = collectParams(cmd, params)
' On Error Resume Next
'Response.Write strSQL & "<BR>"& "<BR>"& "<BR>"& "<BR>"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockReadOnly
If Err.Number<>0 Then
ErrorLog DefaultConnection.Number, DefaultConnection.Description
End IF
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
If rs.State = adStateClosed Then
Set rs.Source = Nothing
End If
Set rs.ActiveConnection = Nothing
Set ExecSQLReturnAR = rs.getRows
End Function
'---------------------------------------------------
' SQL Query를 실행하고, RecordSet String을 반환한다.
'---------------------------------------------------
Public Function ExecSQLReturnST(strSQL, params, connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
If DefaultConnection is Nothing Then
Set DefaultConnection = CreateObject("ADODB.Connection")
DefaultConnection.Open DefaultConnString
End If
Set connectionString = DefaultConnection
End If
End If
Set rs = CreateObject("ADODB.RecordSet")
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = connectionString
cmd.Prepared = true
cmd.CommandText = strSQL
cmd.CommandType = adCmdText
Set cmd = collectParams(cmd, params)
' On Error Resume Next
'Response.Write strSQL & "<BR>"& "<BR>"& "<BR>"& "<BR>"
rs.CursorLocation = adUseClient
rs.Open cmd, , adOpenStatic, adLockReadOnly
If Err.Number<>0 Then
ErrorLog DefaultConnection.Number, DefaultConnection.Description
End IF
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
If rs.State = adStateClosed Then
Set rs.Source = Nothing
End If
Set rs.ActiveConnection = Nothing
Set ExecSQLReturnAR = rs.getString(2)
End Function
'---------------------------------------------------
' SP를 실행한다.(RecordSet 반환없음)
'---------------------------------------------------
Public Sub ExecSP(strSP,params,connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
If DefaultConnection is Nothing Then
Set DefaultConnection = CreateObject("ADODB.Connection")
DefaultConnection.Open DefaultConnString
End If
Set connectionString = DefaultConnection
End If
End If
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = connectionString
cmd.CommandText = strSP
cmd.CommandType = adCmdStoredProc
Set cmd = collectParams(cmd, params)
cmd.Execute , , adExecuteNoRecords
For inum = 0 To cmd.Parameters.Count - 1
If cmd.Parameters(inum).Direction = adParamOutput OR cmd.Parameters(inum).Direction = adParamInputOutput OR cmd.Parameters(inum).Direction = adParamReturnValue Then
If IsObject(params) Then
If params is Nothing Then
Exit For
End If
Else
params(inum)(4) = cmd.Parameters(inum).Value
End If
End If
Next
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
End Sub
'---------------------------------------------------
' SQL Query를 실행한다.(RecordSet 반환없음)
'---------------------------------------------------
Public Sub ExecSQL(strSQL,params,connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
If DefaultConnection is Nothing Then
Set DefaultConnection = CreateObject("ADODB.Connection")
DefaultConnection.Open DefaultConnString
End If
Set connectionString = DefaultConnection
End If
End If
On Error Resume Next
Set cmd = CreateObject("ADODB.Command")
cmd.ActiveConnection = connectionString
cmd.CommandText = strSQL
cmd.CommandType = adCmdText
Set cmd = collectParams(cmd, params)
cmd.Execute , , adExecuteNoRecords
' If DefaultConnection.Errors.Count <> 0 Then
' For each objErr in DefaultConnection.Errors
' response.write("<p>")
' response.write("Description: ")
' response.write(objErr.Description & "<br>")
' response.write("Help context: ")
' response.write(objErr.HelpContext & "<br>")
' response.write("Help file: ")
' response.write(objErr.HelpFile & "<br>")
' response.write("Native error: ")
' response.write(objErr.NativeError & "<br>")
' response.write("Error number: ")
' response.write(objErr.Number & "<br>")
' response.write("Error source: ")
' response.write(objErr.Source & "<br>")
' response.write("SQL state: ")
' response.write(objErr.SQLState & "<br>")
' response.write("</p>")
' Next
' Response.End
' End IF
if err.number <> 0 then
response.Write("<b>SQL :</B>"&strSQL&"<br>")
response.Write("<b>err.description :</B>"&err.Description&"<br>")
response.Write("<b>err.number : </b>"&err.Number&"<br>")
response.Write("<b>err.Source : </b>"&err.Source&"<br>")
Response.End
End IF
Set cmd.ActiveConnection = Nothing
Set cmd = Nothing
End Sub
'---------------------------------------------------
' 트랜잭션을 시작하고, Connetion 개체를 반환한다.
'---------------------------------------------------
Public Function BeginTrans(connectionString)
If IsObject(connectionString) Then
If connectionString is Nothing Then
connectionString = DefaultConnString
End If
End If
Set conn = CreateObject("ADODB.Connection")
conn.Open connectionString
conn.BeginTrans
Set BeginTrans = conn
End Function
'---------------------------------------------------
' 활성화된 트랜잭션을 커밋한다.
'---------------------------------------------------
Public Sub CommitTrans(connectionObj)
If Not connectionObj Is Nothing Then
connectionObj.CommitTrans
connectionObj.Close
Set ConnectionObj = Nothing
End If
End Sub
'---------------------------------------------------
' 활성화된 트랜잭션을 롤백한다.
'---------------------------------------------------
Public Sub RollbackTrans(connectionObj)
If Not connectionObj Is Nothing Then
connectionObj.RollbackTrans
connectionObj.Close
Set ConnectionObj = Nothing
End If
End Sub
'---------------------------------------------------
' 배열로 매개변수를 만든다.
'---------------------------------------------------
Public Function MakeParam(PName,PType,PDirection,PSize,PValue)
MakeParam = Array(PName, PType, PDirection, PSize, PValue)
End Function
'---------------------------------------------------
' 매개변수 배열 내에서 지정된 이름의 매개변수 값을 반환한다.
'---------------------------------------------------
Public Function GetValue(params, paramName)
For Each param in params
If param(0) = paramName Then
GetValue = param(4)
Exit Function
End If
Next
End Function
Public Sub Dispose
if (Not DefaultConnection is Nothing) Then
if (DefaultConnection.State = adStateOpen) Then DefaultConnection.Close
Set DefaultConnection = Nothing
End if
End Sub
'---------------------------------------------------------------------------
'Array로 넘겨오는 파라메터를 Parsing 하여 Parameter 객체를
'생성하여 Command 객체에 추가한다.
'---------------------------------------------------------------------------
Private Function collectParams(cmd,argparams)
Dim params
Dim i,l,u,v
If VarType(argparams) = 8192 or VarType(argparams) = 8204 or VarType(argparams) = 8209 then
params = argparams
For i = LBound(params) To UBound(params)
l = LBound(params(i))
u = UBound(params(i))
' Check for nulls.
If u - l = 4 Then
If VarType(params(i)(4)) = vbString Then
If params(i)(4) = "" Then
v = Null
Else
v = Trim(params(i)(4))
End If
Else
v = params(i)(4)
End If
' On Error Resume Next
' If err.number <> 0 then
' Response.Write params(i)(0) & ":" & params(i)(1) & ":" & params(i)(2) & ":" & params(i)(3)& ":" &v&"<BR>"
' End If
If VarType(params(i)(4)) = vbString And params(i)(4) = "" Then
Set cnParam = cmd.CreateParameter(params(i)(0))
cnParam.attributes=adParamNullable
cnParam.type = params(i)(1)
cnParam.Direction = params(i)(2)
cnParam.Size=1
cnParam.value=Null
cmd.Parameters.Append cnParam 'cmd.CreateParameter(params(i)(0), params(i)(1), params(i)(2), params(i)(3), Null)
Else
cmd.Parameters.Append cmd.CreateParameter(params(i)(0), params(i)(1), params(i)(2), params(i)(3), v)
End If
End If
Next
Set collectParams = cmd
Exit Function
Else
Set collectParams = cmd
End If
End Function
End Class
%>

857
AdminPoll/Lib/DBLib.asp Normal file
View File

@@ -0,0 +1,857 @@
<%
'###########################################################################################
'정규식을 이용하여 문자열을 치환하는 함수
'###########################################################################################
Public Function eregi_replace(ByVal pattern, ByVal replacestr, ByVal text)
Dim eregObj
'** Create regular expression
Set eregObj = New RegExp
eregObj.Pattern = pattern '** Set Pattern(패턴 설정)
eregObj.IgnoreCase = True '** Set Case Insensitivity(대소문자 구분 여부)
eregObj.Global = True '** Set All Replace(전체 문서에서 검색)
eregi_replace = eregObj.Replace(text, replacestr) '** Replace String
End Function
'###########################################################################################
'데이터입력시 쿼리에 영향주는 문자 제거
'###########################################################################################
Function checkValue(inWord)
inWord = eregi_replace("'", "´", inWord)
inWord = eregi_replace("'", "&#039;", inWord)
inWord = eregi_replace("--", "", inWord)
inWord = eregi_replace("\@variable ", "", inWord)
inWord = eregi_replace("\@@variable ", "", inWord)
inWord = eregi_replace("\+", "", inWord)
inWord = eregi_replace("print ", "", inWord)
inWord = eregi_replace("set ", "", inWord)
inWord = eregi_replace("union ", "", inWord)
inWord = eregi_replace("insert ", "", inWord)
inWord = eregi_replace("select ", "", inWord)
inWord = eregi_replace("update ", "", inWord)
inWord = eregi_replace("create ", "", inWord)
inWord = eregi_replace("drop ", "", inWord)
inWord = eregi_replace("openrowset ", "", inWord)
inWord = eregi_replace("exec ", "", inWord)
inWord = eregi_replace("§", "", inWord)
inWord = eregi_replace("∑", "", inWord)
inWord = eregi_replace("∮", "", inWord)
checkValue = inWord
End Function
'###########################################################################################
'값 찾아서 가져오기
'###########################################################################################
Function getValue(fieldNm)
Dim TB,SQL
Dim rsField
If checkField(fieldNm,TB_NAME) Then
TB=TB_NAME
ElseIf checkField(fieldNm,TB_NAME1) Then
TB=TB_NAME1
ElseIf checkField(fieldNm,TB_NAME2) Then
TB=TB_NAME2
End If
DBConnect()
Set rsField = Server.CreateObject("ADODB.Recordset")
SQL = "select " & fieldNm & " from " & TB & " WHERE [KEY]='" & Request.Form("IDKEY") & "'"
RsField.Open SQL,DBConn,3,1,1
If RsField.Eof or RsField.Bof Then
getValue=""
else
getValue = rsField(0)
End if
RsField.Close
DBClose()
End Function
'###########################################################################################
'Project DB SQL 쿼리 실행
'###########################################################################################
Function ExecuteSQL(SQL)
If SQL="" then
ExecuteSQL = true
Exit Function
end If
ExecuteSQL=TExecuteSQL(SQL)
End Function
'###########################################################################################
'설문 DB SQL 쿼리 실행
'###########################################################################################
Function ExecuteSQL1(SQL)
If SQL="" then
ExecuteSQL1 = true
Exit Function
end If
ExecuteSQL1=TExecuteSQL1(SQL)
End Function
'###########################################################################################
'설문 DB SQL 쿼리 실행 트랜잭션 제거
'###########################################################################################
Function ExecuteSQL2(SQL)
If SQL="" then
ExecuteSQL2 = true
Exit Function
end If
DBConnect1()
DBConn.Execute SQL
DBClose()
ExecuteSQL2 = True
End Function
'###########################################################################################
'Project DB SQL 쿼리 실행
'###########################################################################################
Function TExecuteSQL(SQL)
If SQL="" then
TExecuteSQL = true
Exit Function
end If
On Error Resume Next
DBConnect()
DBConn.BeginTrans
DBConn.Execute SQL
If DBConn.Errors.Count > 0 Then
Response.Write SQL & "<BR>"
for each objErr in DBConn.Errors
response.write("<p>")
response.write("Description: ")
response.write(objErr.Description & "<br>")
response.write("Help context: ")
response.write(objErr.HelpContext & "<br>")
response.write("Help file: ")
response.write(objErr.HelpFile & "<br>")
response.write("Native error: ")
response.write(objErr.NativeError & "<br>")
response.write("Error number: ")
response.write(objErr.Number & "<br>")
response.write("Error source: ")
response.write(objErr.Source & "<br>")
response.write("SQL state: ")
response.write(objErr.SQLState & "<br>")
response.write("</p>")
Next
TExecuteSQL = False
DBConn.RollbackTrans
DBClose()
Else
TExecuteSQL = True
DBConn.CommitTrans
DBClose()
End IF
End Function
'###########################################################################################
'설문 DB SQL 쿼리 실행
'###########################################################################################
Function TExecuteSQL1(SQL)
If SQL="" then
TExecuteSQL1 = true
Exit Function
end If
DBConnect1()
DBConn.BeginTrans
On Error Resume Next
DBConn.Execute SQL
If DBConn.Errors.Count > 0 Then
Response.Write SQL & "<BR>"
for each objErr in DBConn.Errors
response.write("<p>")
response.write("Description: ")
response.write(objErr.Description & "<br>")
response.write("Help context: ")
response.write(objErr.HelpContext & "<br>")
response.write("Help file: ")
response.write(objErr.HelpFile & "<br>")
response.write("Native error: ")
response.write(objErr.NativeError & "<br>")
response.write("Error number: ")
response.write(objErr.Number & "<br>")
response.write("Error source: ")
response.write(objErr.Source & "<br>")
response.write("SQL state: ")
response.write(objErr.SQLState & "<br>")
response.write("</p>")
next
TExecuteSQL1 = False
DBConn.RollbackTrans
DBClose()
Else
TExecuteSQL1 = True
DBConn.CommitTrans
DBClose()
End IF
End Function
'###########################################################################################
'Table내의 필드이름 확인
'###########################################################################################
Function checkField(fieldNm,tableNm)
Dim Tvars,SQL
Dim rsField
Tvars = replace(tableNm,"[","")
Tvars = replace(Tvars,"]","")
DBConnect()
Set rsField = Server.CreateObject("ADODB.Recordset")
SQL = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = '" & Trim(Tvars) &"' and column_name='" & trim(fieldNm) & "'"
RsField.Open SQL,DBConn,3,1,1
If RsField.Eof or RsField.Bof Then
checkField=false
else
checkField=true
End if
RsField.Close
DBClose()
End Function
'###########################################################################################
'Table내의 필드이름 확인
'복수응답, 속성 필드 이름 가져오기
'###########################################################################################
Function getFieldNames(fieldNm,tableNm)
Dim Tvars,SQL
Dim rsField
Tvars = replace(tableNm,"[","")
Tvars = replace(Tvars,"]","")
DBConnect()
Set rsField = Server.CreateObject("ADODB.Recordset")
SQL = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = '" & Trim(Tvars) &"' and column_name LIKE '" & trim(fieldNm) & "_%'"
RsField.Open SQL,DBConn,3,1,1
If RsField.Eof or RsField.Bof Then
getFieldNames=""
else
getFieldNames = RsField.GetString(2)
End if
RsField.Close
DBClose()
End Function
'###########################################################################################
'Table내의 필드이름 확인
'복수응답, 속성 필드 이름 가져오기
'###########################################################################################
Function getFieldNames1(fieldNm,tableNm)
Dim Tvars,SQL
Dim rsField
Tvars = replace(tableNm,"[","")
Tvars = replace(Tvars,"]","")
DBConnect1()
Set rsField = Server.CreateObject("ADODB.Recordset")
SQL = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = '" & Trim(Tvars) &"' and column_name LIKE '" & trim(fieldNm) & "#_%' ESCAPE '#' "
RsField.Open SQL,DBConn,3,1,1
If RsField.Eof or RsField.Bof Then
getFieldNames1=""
else
getFieldNames1 = RsField.GetString(2)
End if
RsField.Close
DBClose()
End Function
'###########################################################################################
'Table내의 필드이름 확인
'복수응답, 속성 필드 이름 가져오기
'###########################################################################################
Function getFieldNameLike(fieldNm,tableNm)
Dim Tvars,SQL
Dim rsField
Tvars = replace(tableNm,"[","")
Tvars = replace(Tvars,"]","")
DBConnect()
Set rsField = Server.CreateObject("ADODB.Recordset")
SQL = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = '" & Trim(Tvars) &"' and column_name LIKE '" & trim(fieldNm) & "_%'"
RsField.Open SQL,DBConn,3,1,1
If RsField.Eof or RsField.Bof Then
getFieldNameLike=""
else
getFieldNameLike = RsField(0)
End if
RsField.Close
DBClose()
End Function
'###########################################################################################
'Table내의 필드이름 확인
'복수응답, 속성 필드 이름 가져오기
'###########################################################################################
Function getFieldNameLike1(fieldNm,tableNm)
Dim Tvars,SQL
Dim rsField
Tvars = replace(tableNm,"[","")
Tvars = replace(Tvars,"]","")
DBConnect1()
Set rsField = Server.CreateObject("ADODB.Recordset")
SQL = "select column_name from INFORMATION_SCHEMA.COLUMNS where table_name = '" & Trim(Tvars) &"' and column_name LIKE '" & trim(fieldNm) & "_%'"
RsField.Open SQL,DBConn,3,1,1
If RsField.Eof or RsField.Bof Then
getFieldNameLike1=""
else
getFieldNameLike1 = RsField(0)
End if
RsField.Close
DBClose()
End Function
'###########################################################################################
'쿼리 결과를 리턴
'###########################################################################################
Public Function getRecordset(ByVal SQL,ByRef RecordSet)
If DBFlag=False Then
DBConnect()
End If
Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.Open SQL,DBConn,3,1,1
getRecordset = Recordset
End Function
'###########################################################################################
'쿼리 결과를 리턴 2 스트링 형태로 리턴
'Row는 vbCR 로 Split 하여 사용하고 Col은 vbTab으로 Split 하여 사용
'단순 리스트 조회의 경우 사용 권장
'###########################################################################################
Public Function getRecordString(ByVal SQL)
Dim Recordset
If DBFlag=False Then
DBConnect()
End If
Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.Open SQL,DBConn,3,1,1
If Recordset.Eof Or Recordset.Bof Then
getRecordString = ""
Else
getRecordString = Recordset.GetString(2)
End if
Recordset.Close
Set Recordset = Nothing
DBClose()
End Function
'###########################################################################################
'쿼리 결과를 리턴 2 배열 형태로 리턴
'단순 리스트 조회의 경우 사용 권장
'###########################################################################################
Public Function getRecordArray(ByVal SQL)
Dim Recordset
If DBFlag=False Then
DBConnect()
End If
Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.Open SQL,DBConn,3,1,1
If Recordset.Eof Or Recordset.Bof Then
getRecordArray = null
Else
getRecordArray = Recordset.getRows
End If
Recordset.Close
Set Recordset = Nothing
DBClose()
End Function
'###########################################################################################
'쿼리 결과를 리턴, 맨 앞의 데이터 첫번째 행 데이터만 가져옴
'단순 리스트 조회의 경우 사용 권장
'###########################################################################################
Public Function getRecordDataCOL(ByVal SQL)
Dim Recordset
If DBFlag=False Then
DBConnect()
End If
Set Recordset = Server.CreateObject("ADODB.Recordset")
Recordset.Open SQL,DBConn,3,1,1
If Recordset.Eof Or Recordset.Bof Then
getRecordDataCOL = null
Else
getRecordDataCOL = Recordset(0)
End If
Recordset.Close
Set Recordset = Nothing
DBClose()
End Function
'###########################################################################################
'XML에 저장하는 함수
'DataSTR은 SQ1=1&SQ1_1=2 이런식으로 "&" 로 데이터를 저장한다.
'###########################################################################################
Function SaveXML(DataSTR)
Dim objXML
Set objXML = New XMLClass
If SURVEYSTATUS<>"3" Then
On Error Resume Next
End IF
Dim VSTR,TSTR
Dim iCnt
If FileChecker(XMLFolder) Then
objXML.Load XMLFolder
End If
If DataSTR="" Then
SaveXML = False
Else
VSTR = Split(DataSTR & DB2STR,DB2STR)
For iCnt=0 To UBound(VSTR)
If VarType(VSTR(iCnt))<>0 And VarType(VSTR(iCnt))<>1 And VSTR(iCnt)<>"" Then
TSTR = Split(VSTR(iCnt),DB1STR)
objXML.SetValue TSTR(0),checkValue(TSTR(1))
End IF
Next
objXML.Save XMLFolder
SaveXML = True
End IF
Set objXML = Nothing
If Err.Number>0 Then
SaveXML = False
End IF
End Function
'###########################################################################################
'로그파일 읽어오기
'###########################################################################################
Function LoadStream(FilePath)
Dim oFSO,wFile
'Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
Set oFSO = Server.CreateObject("ADODB.Stream")
oFSO.CharSet = "utf-8"
oFSO.Mode = 3
oFSO.Type = 2
oFSO.Open
oFSO.LoadFromFile FilePath
LoadStream = oFSO.ReadText
oFSO.Close
Set oFSO = Nothing
End Function
'###########################################################################################
'Table List 갯수 카운트
'TABLENAME : 테이블명
'FIELDNAME : 키워드 필드
'SearchSQL : 검색 SQL 형태
'###########################################################################################
Function TableCount(TABLENAME,FIELDNAME,SearchSQL)
Dim MLSQL,LCount,IDFIELD
MLSQL = ""
IDFIELD= ""
If FIELDNAME="" Then
IDFIELD = "IDX"
Else
IDFIELD = FIELDNAME
End IF
If SearchSQL="" Then
MLSQL = "SELECT COUNT(["&IDFIELD&"]) FROM ["&TABLENAME&"]"
Else
MLSQL = "SELECT COUNT(["&IDFIELD&"]) FROM ["&TABLENAME&"] WHERE " & SearchSQL
End If
LCount=getRecordDataCOL(MLSQL)
If isNull(LCount) Then
TableCount=0
Else
TableCount=CLng(LCount)
End If
End Function
'###########################################################################################
'List
'TABLENAME : 테이블명
'FIELDNAME : 키워드 필드
'PAGE_SIZE : 화면에 보여질 글자 수
'CU_PAGE : 현재 PAGE 넘버
'LIST_KEY : 정렬용 필드명
'ORDER_TYPE : 정렬 형태
'SearchSQL : 검색 SQL 형태
'###########################################################################################
Function TableList(TABLENAME,FIELDARRAY,PAGE_SIZE,CU_PAGE,LIST_KEY,ORDER_TYPE,SearchSQL)
Dim MLSQL,pagesize,cupage,listkey,ordertype
Dim PSQL,PCnt
MLSQL = ""
If PAGE_SIZE="" Then
pagesize=10
Else
pagesize = CLng(PAGE_SIZE)
End If
If CU_PAGE="" Then
cupage=1
Else
cupage = CLng(CU_PAGE)
End If
If LIST_KEY="" Then
listkey = "IDX"
Else
listkey = LIST_KEY
End If
If ORDER_TYPE="" Then
ordertype = "DESC"
Else
ordertype = ORDER_TYPE
End If
If VarType(FIELDARRAY) = 8192 or VarType(FIELDARRAY) = 8204 or VarType(FIELDARRAY) = 8209 then
PSQL = "SELECT TOP " & pagesize
For PCnt = LBound(FIELDARRAY) To UBound(FIELDARRAY)
PSQL = PSQL & "["& FIELDARRAY(PCnt) & "],"
Next
PSQL = Left(PSQL,Len(PSQL)-1)
Else
PSQL = "SELECT TOP " & pagesize & "[" & LISTKEY & "]"
End If
If CLng(cupage)=1 Then
If SearchType="" And SearchSQL="" Then
MLSQL = PSQL & " FROM ["& TABLENAME &"] ORDER BY [" & listkey & "] " & ordertype
Else
MLSQL = PSQL & " FROM ["& TABLENAME &"]"
MLSQL = MLSQL & " WHERE " & SearchSQL
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
End If
Else
If SearchType="" And SearchSQL="" Then
MLSQL = PSQL & " FROM ["& TABLENAME &"]"
MLSQL = MLSQL & " WHERE [MIDX] NOT IN ("
MLSQL = MLSQL & " SELECT TOP " & (cupage-1) * pagesize & " ["& FIELDARRAY(0) &"] FROM ["& TABLENAME &"] ORDER BY [" & LISTKEY & "] " & ORDERTYPE & ")"
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
Else
MLSQL = PSQL & " FROM ["& TABLENAME &"]"
MLSQL = MLSQL & " WHERE " & SearchSQL
MLSQL = MLSQL & " AND ["& FIELDARRAY(0) &"] NOT IN ("
MLSQL = MLSQL & " SELECT TOP " & (cupage-1) * pagesize & " [" & FIELDARRAY(0) & "] FROM ["& TABLENAME &"] WHERE " & SearchSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE & ")"
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
End If
End If
TableList = getRecordArray(MLSQL)
End Function
'###########################################################################################
'List
'TABLENAME : 테이블명
'FIELDNAME : 키워드 필드
'PAGE_SIZE : 화면에 보여질 글자 수
'CU_PAGE : 현재 PAGE 넘버
'LIST_KEY : 정렬용 필드명
'ORDER_TYPE : 정렬 형태
'SearchSQL : 검색 SQL 형태
'###########################################################################################
Function TableListJS(TABLENAME,FIELDARRAY,PAGE_SIZE,CU_PAGE,LIST_KEY,ORDER_TYPE,SearchSQL)
Dim MLSQL,pagesize,cupage,listkey,ordertype
Dim PSQL,PCnt
MLSQL = ""
If PAGE_SIZE="" Then
pagesize=10
Else
pagesize = CLng(PAGE_SIZE)
End If
If CU_PAGE="" Then
cupage=1
Else
cupage = CLng(CU_PAGE)
End If
If LIST_KEY="" Then
listkey = "IDX"
Else
listkey = LIST_KEY
End If
If ORDER_TYPE="" Then
ordertype = "DESC"
Else
ordertype = ORDER_TYPE
End If
If VarType(FIELDARRAY) = 8192 or VarType(FIELDARRAY) = 8204 or VarType(FIELDARRAY) = 8209 then
PSQL = "SELECT TOP " & pagesize
For PCnt = LBound(FIELDARRAY) To UBound(FIELDARRAY)
PSQL = PSQL & "["& FIELDARRAY(PCnt) & "],"
Next
PSQL = Left(PSQL,Len(PSQL)-1)
Else
PSQL = "SELECT TOP " & pagesize & "[" & LISTKEY & "]"
End If
If CLng(cupage)=1 Then
If SearchType="" And SearchSQL="" Then
MLSQL = PSQL & " FROM ["& TABLENAME &"] ORDER BY [" & listkey & "] " & ordertype
Else
MLSQL = PSQL & " FROM ["& TABLENAME &"]"
MLSQL = MLSQL & " WHERE " & SearchSQL
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
End If
Else
If SearchType="" And SearchSQL="" Then
MLSQL = PSQL & " FROM ["& TABLENAME &"]"
MLSQL = MLSQL & " WHERE [MIDX] NOT IN ("
MLSQL = MLSQL & " SELECT TOP " & (cupage-1) * pagesize & " ["& FIELDARRAY(0) &"] FROM ["& TABLENAME &"] ORDER BY [" & LISTKEY & "] " & ORDERTYPE & ")"
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
Else
MLSQL = PSQL & " FROM ["& TABLENAME &"]"
MLSQL = MLSQL & " WHERE " & SearchSQL
MLSQL = MLSQL & " AND ["& FIELDARRAY(0) &"] NOT IN ("
MLSQL = MLSQL & " SELECT TOP " & (cupage-1) * pagesize & " [" & FIELDARRAY(0) & "] FROM ["& TABLENAME &"] WHERE " & SearchSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE & ")"
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
End If
End If
Dim Rs
Call getRecordSet(MLSQL,Rs)
TableListJS = RecordsetToJSON(Rs).jsString
Rs.Close
End Function
'###########################################################################################
'List
'TABLENAME : 테이블명
'FIELDNAME : 키워드 필드
'PAGE_SIZE : 화면에 보여질 글자 수
'CU_PAGE : 현재 PAGE 넘버
'LIST_KEY : 정렬용 필드명
'ORDER_TYPE : 정렬 형태
'SearchSQL : 검색 SQL 형태
'###########################################################################################
Function TableListJO(TABLENAME,FIELDARRAY,PAGE_SIZE,CU_PAGE,LIST_KEY,ORDER_TYPE,SearchSQL,responsibleProject)
Dim MLSQL,pagesize,cupage,listkey,ordertype
Dim PSQL,PCnt
MLSQL = ""
If PAGE_SIZE="" Then
pagesize=10
Else
pagesize = CLng(PAGE_SIZE)
End If
If CU_PAGE="" Then
cupage=1
Else
cupage = CLng(CU_PAGE)
End If
If LIST_KEY="" Then
listkey = "IDX"
Else
listkey = LIST_KEY
End If
If ORDER_TYPE="" Then
ordertype = "DESC"
Else
ordertype = ORDER_TYPE
End If
Dim QCTEAM
'##### QC 팀
IF Session("department") <> "S201" THEN
QCTEAM = " and department <> 'S201' "
ELSE
QCTEAM = ""
END IF
If VarType(FIELDARRAY) = 8192 or VarType(FIELDARRAY) = 8204 or VarType(FIELDARRAY) = 8209 then
PSQL = "SELECT TOP " & pagesize
For PCnt = LBound(FIELDARRAY) To UBound(FIELDARRAY)
PSQL = PSQL & "["& FIELDARRAY(PCnt) & "],"
Next
PSQL = PSQL &"isnull((select username from capi.dbo.Member where userid = a.userid),'') as [username]," '##### 등록자 이름
PSQL = PSQL &"isnull((select T_name from project2.dbo.v_Department where code = a.department), a.department) as [depart]," '##### 그룹명
PSQL = Left(PSQL,Len(PSQL)-1)
Else
PSQL = "SELECT TOP " & pagesize & "[" & LISTKEY & "]"
End If
If CLng(cupage)=1 Then
If SearchType="" And SearchSQL="" AND responsibleProject = "NONE" Then
MLSQL = PSQL & " FROM ["& TABLENAME &"] as a "
IF responsibleProject <> "NONE" and responsibleProject <> "" THEN MLSQL = MLSQL & " WHERE SUBSTRING(code,0,charindex('_',code)) IN ("&responsibleProject&")" & QCTEAM
MLSQL = MLSQL & "ORDER BY [" & listkey & "] " & ordertype
Else
MLSQL = PSQL & " FROM ["& TABLENAME &"] as a "
IF SearchSQL <> "" then MLSQL = MLSQL & " WHERE " & SearchSQL
IF responsibleProject <> "NONE" and responsibleProject <> "" THEN
IF SearchSQL <> "" THEN MLSQL = MLSQL & " and "
MLSQL = MLSQL & " SUBSTRING(code,0,charindex('_',code)) IN ("&responsibleProject&")" & QCTEAM
END IF
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
End If
Else
If SearchType="" And SearchSQL="" AND responsibleProject = "NONE" Then
MLSQL = PSQL & " FROM ["& TABLENAME &"] as a "
MLSQL = MLSQL & " WHERE [ID] NOT IN ("
MLSQL = MLSQL & " SELECT TOP " & (cupage-1) * pagesize & " ["& FIELDARRAY(0) &"] FROM ["& TABLENAME &"] as a ORDER BY [" & LISTKEY & "] " & ORDERTYPE & ")" & QCTEAM
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
Else
MLSQL = PSQL & " FROM ["& TABLENAME &"] as a "
MLSQL = MLSQL & " WHERE " & SearchSQL
IF responsibleProject <> "NONE" and responsibleProject <> "" THEN
IF SearchSQL <> "" THEN MLSQL = MLSQL & " and "
MLSQL = MLSQL & " SUBSTRING(code,0,charindex('_',code)) IN ("&responsibleProject&")" & QCTEAM
END IF
MLSQL = MLSQL & " AND ["& FIELDARRAY(0) &"] NOT IN ("
MLSQL = MLSQL & " SELECT TOP " & (cupage-1) * pagesize & " [" & FIELDARRAY(0) & "] FROM ["& TABLENAME &"] as a WHERE " & SearchSQL
IF responsibleProject <> "NONE" and responsibleProject <> "" THEN
IF SearchSQL <> "" THEN MLSQL = MLSQL & " and "
MLSQL = MLSQL & " SUBSTRING(code,0,charindex('_',code)) IN ("&responsibleProject&")" & QCTEAM
END IF
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE & ")"
MLSQL = MLSQL & " ORDER BY [" & LISTKEY & "] " & ORDERTYPE
End If
End If
Dim Rs
Call getRecordSet(MLSQL,Rs)
Set TableListJO = RecordsetToJSON(Rs)
Rs.Close
End Function
Function responsible_Project(name)
Dim ProjectLists : ProjectLists = ""
Dim PSQL
PSQL = "select p_no from project2.dbo.person where p_name='"&name&"' and p_resign='0' and krc_out_date = ''"
Dim Rs,Rs2
Call getRecordSet(PSQL ,Rs)
IF Rs.eof or Rs.bof THEN
responsible_Project = ""
ELSE
PSQL = "select p_sn from project2.dbo.T_PROJECT_METHOD where p_rsch_1_a = '"&Rs("p_no")&"' OR p_rsch_2_a = '"&Rs("p_no")&"' OR p_rsch_3_a = '"&Rs("p_no")&"' OR p_rsch_4_a = '"&Rs("p_no")&"' OR p_rsch_1_b = '"&Rs("p_no")&"' OR p_rsch_2_b = '"&Rs("p_no")&"' OR p_rsch_3_b = '"&Rs("p_no")&"' OR p_rsch_4_b = '"&Rs("p_no")&"' OR p_rsch_1_c = '"&Rs("p_no")&"' OR p_rsch_2_c = '"&Rs("p_no")&"' OR p_rsch_3_c = '"&Rs("p_no")&"' OR p_rsch_4_c = '"&Rs("p_no")&"' OR p_sv_1 = '"&Rs("p_no")&" ' OR p_sv_2 = '"&Rs("p_no")&"' OR p_sv_3 = '"&Rs("p_no")&"' OR p_sv_4 = '"&Rs("p_no")&"' OR p_code_1 = '"&Rs("p_no")&"' OR p_code_2 = '"&Rs("p_no")&"' OR p_code_3 = '"&Rs("p_no")&"' OR p_code_4 = '"&Rs("p_no")&"' OR p_verify_1 = '"&Rs("p_no")&"' OR p_verify_2 = '"&Rs("p_no")&"' OR p_verify_3 = '"&Rs("p_no")&"' OR p_verify_4 = '"&Rs("p_no")&"' OR p_dp_1 = '"&Rs("p_no")&"' OR p_dp_2 = '"&Rs("p_no")&"' OR p_dp_3 = '"&Rs("p_no")&"' OR p_dp_4 = '"&Rs("p_no")&"' OR p_it_1 = '"&Rs("p_no")&"' OR p_it_2 = '"&Rs("p_no")&"' OR p_it_3 = '"&Rs("p_no")&"' OR p_it_4 = '"&Rs("p_no")&"' OR p_supp_1 = '"&Rs("p_no")&"' OR p_supp_2 = '"&Rs("p_no")&"' OR p_supp_3 = '"&Rs("p_no")&"' OR p_supp_4 = '"&Rs("p_no")&"'"
Call getRecordSet(PSQL ,Rs2)
IF Rs2.eof or Rs2.bof then
responsible_Project = ""
ELSE
while not Rs2.eof
IF ProjectLists <> "" THEN ProjectLists = ProjectLists & ","
ProjectLists = ProjectLists & "'"&Rs2("p_sn")&"'"
Rs2.movenext : wend
responsible_Project = ProjectLists
END IF
END IF
End Function
%>

View File

@@ -0,0 +1,210 @@
<%
'
' VBS JSON 2.0.3
' Copyright (c) 2009 Tu?ul Topuz
' Under the MIT (MIT-LICENSE.txt) license.
'
Const JSON_OBJECT = 0
Const JSON_ARRAY = 1
Class jsCore
Public Collection
Public Count
Public QuotedVars
Public Kind ' 0 = object, 1 = array
Private Sub Class_Initialize
Set Collection = CreateObject("Scripting.Dictionary")
QuotedVars = True
Count = 0
End Sub
Private Sub Class_Terminate
Set Collection = Nothing
End Sub
' counter
Private Property Get Counter
Counter = Count
Count = Count + 1
End Property
' - data maluplation
' -- pair
Public Property Let Pair(p, v)
If IsNull(p) Then p = Counter
Collection(p) = v
End Property
Public Property Set Pair(p, v)
If IsNull(p) Then p = Counter
If TypeName(v) <> "jsCore" Then
Err.Raise &hD, "class: class", "Incompatible types: '" & TypeName(v) & "'"
End If
Set Collection(p) = v
End Property
Public Default Property Get Pair(p)
If IsNull(p) Then p = Count - 1
If IsObject(Collection(p)) Then
Set Pair = Collection(p)
Else
Pair = Collection(p)
End If
End Property
' -- pair
Public Sub Clean
Collection.RemoveAll
End Sub
Public Sub Remove(vProp)
Collection.Remove vProp
End Sub
' data maluplation
' encoding
Function jsEncode(str)
Dim charmap(127), haystack()
charmap(8) = "\b"
charmap(9) = "\t"
charmap(10) = "\n"
charmap(12) = "\f"
charmap(13) = "\r"
charmap(34) = "\"""
charmap(47) = "\/"
charmap(92) = "\\"
Dim strlen : strlen = Len(str) - 1
ReDim haystack(strlen)
Dim i, charcode
For i = 0 To strlen
haystack(i) = Mid(str, i + 1, 1)
charcode = AscW(haystack(i)) And 65535
If charcode < 127 Then
If Not IsEmpty(charmap(charcode)) Then
haystack(i) = charmap(charcode)
ElseIf charcode < 32 Then
haystack(i) = "\u" & Right("000" & Hex(charcode), 4)
End If
Else
haystack(i) = "\u" & Right("000" & Hex(charcode), 4)
End If
Next
jsEncode = Join(haystack, "")
End Function
' converting
Public Function toJSON(vPair)
Select Case VarType(vPair)
Case 0 ' Empty
toJSON = "null"
Case 1 ' Null
toJSON = "null"
Case 7 ' Date
' toJSON = "new Date(" & (vPair - CDate(25569)) * 86400000 & ")" ' let in only utc time
toJSON = """" & CStr(vPair) & """"
Case 8 ' String
toJSON = """" & CStr(vPair) & """"
Case 9 ' Object
Dim bFI,i
bFI = True
If vPair.Kind Then toJSON = toJSON & "[" Else toJSON = toJSON &VbCrlf& " {"&VbCrlf
For Each i In vPair.Collection
If bFI Then bFI = False Else toJSON = toJSON & ","&VbCrlf
If vPair.Kind Then
toJSON = toJSON & toJSON(vPair(i))
Else
If QuotedVars Then
toJSON = toJSON & " """ & i & """:" & toJSON(vPair(i))
Else
toJSON = toJSON & i & ":" & toJSON(vPair(i))
End If
End If
Next
If vPair.Kind Then toJSON = toJSON &VbCrlf& "]" Else toJSON = toJSON &VbCrlf& " }"
Case 11
If vPair Then toJSON = "true" Else toJSON = "false"
Case 12, 8192, 8204
toJSON = RenderArray(vPair, 1, "")
Case Else
toJSON = Replace(vPair, ",", ".")
End select
End Function
Function RenderArray(arr, depth, parent)
Dim first : first = LBound(arr, depth)
Dim last : last = UBound(arr, depth)
Dim index, rendered
Dim limiter : limiter = ","
RenderArray = "["
For index = first To last
If index = last Then
limiter = ""
End If
On Error Resume Next
rendered = RenderArray(arr, depth + 1, parent & index & "," )
If Err = 9 Then
On Error GoTo 0
RenderArray = RenderArray & toJSON(Eval("arr(" & parent & index & ")")) & limiter
Else
RenderArray = RenderArray & rendered & "" & limiter
End If
Next
RenderArray = RenderArray & "]"
End Function
Public Property Get jsString
jsString = toJSON(Me)
End Property
Sub Flush
If TypeName(Response) <> "Empty" Then
Response.Write(jsString)
ElseIf WScript <> Empty Then
WScript.Echo(jsString)
End If
End Sub
Public Function Clone
Set Clone = ColClone(Me)
End Function
Private Function ColClone(core)
Dim jsc, i
Set jsc = new jsCore
jsc.Kind = core.Kind
For Each i In core.Collection
If IsObject(core(i)) Then
Set jsc(i) = ColClone(core(i))
Else
jsc(i) = core(i)
End If
Next
Set ColClone = jsc
End Function
End Class
Function jsObject
Set jsObject = new jsCore
jsObject.Kind = JSON_OBJECT
End Function
Function jsArray
Set jsArray = new jsCore
jsArray.Kind = JSON_ARRAY
End Function
Function toJSON(val)
toJSON = (new jsCore).toJSON(val)
End Function
%>

View File

@@ -0,0 +1,29 @@
<%
Function QueryToJSON(dbc, sql)
Dim rs, jsa, col
Set rs = dbc.Execute(sql)
Set jsa = jsArray()
While Not (rs.EOF Or rs.BOF)
Set jsa(Null) = jsObject()
For Each col In rs.Fields
jsa(Null)(col.Name) = col.Value
Next
rs.MoveNext
Wend
Set QueryToJSON = jsa
End Function
Function RecordsetToJSON(ByVal rs)
Dim jsa,col
Set jsa = jsArray()
While Not (rs.EOF Or rs.BOF)
Set jsa(Null) = jsObject()
For Each col In rs.Fields
jsa(Null)(col.Name) = col.Value
Next
rs.MoveNext
Wend
Set RecordsetToJSON = jsa
End Function
%>

32
AdminPoll/Lib/config.asp Normal file
View File

@@ -0,0 +1,32 @@
<% @Language="VBScript" CODEPAGE="65001"%>
<!--METADATA TYPE= "typelib" NAME= "ADODB Type Library" FILE="C:\Program Files\Common Files\SYSTEM\ADO\msado15.dll" -->
<%
Option Explicit
Dim SV_NAME, DB_NAME, SV_NAME1, DB_NAME1
Dim UID, PWD, UID1, PWD1
Dim DBConn
'#######################################################################################
'DB 설정값 Read
'#######################################################################################
SV_NAME = "10.10.11.7,20022"
DB_NAME= "exitpoll"
UID = "sa"
PWD = "it#51304"
SV_NAME1 = "10.10.11.6"
DB_NAME1= "project2"
UID1 = "sa"
PWD1 = "krco#51304"
Login_chk()
%>
<!-- #include Virtual = "/Lib/DBConn.asp" -->
<!-- #include Virtual = "/Lib/DBLib.asp" -->
<!-- #include Virtual = "/Lib/DBHelper.asp" -->
<!-- #include Virtual = "/Lib/Func.asp" -->
<!-- #include Virtual = "/Lib/JSON_2.0.4.asp" -->
<!-- #include Virtual = "/Lib/JSON_UTIL_0.1.1.asp" -->

474
AdminPoll/Lib/func.asp Normal file
View File

@@ -0,0 +1,474 @@
<%
'###########################################################################################
'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 & "&nbsp;" & 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 & "&nbsp;" & 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("p_no") = ""
Session("name") = ""
Session("ip") = ""
Session("admin") = ""
Session.Contents.RemoveAll()
Session.Abandon
Response.Redirect "/Index.asp"
End Sub
'###########################################################################################
'로그인 여부 체크 함수
'return : void
'###########################################################################################
Function Login_chk()
Dim Page : Page = Request.ServerVariables("SCRIPT_NAME")
Page = split(Page,"/")
If Session("p_no")="" Then
If Page(2) <> "login.asp" Then
'Response.Write "<script type='text/javascript'>alert('로그인 후 확인 가능합니다."&Session("p_no")&"'); window.location.href='../index.asp';</script>"
'Response.Redirect "/Index.asp"
End If
End If
End Function
Function GoMain(msg,url)
Response.Write "<SCRIPT type='text/javascript'>"&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
%>