Files
KIN/lib/Function.asp
2025-09-29 17:55:08 +09:00

888 lines
27 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<%
'======================================================================
'업 무 명 :
'모듈기능 :
'작성일자 :
'작 성 자 :
'-----------------------------------------------------------------------
'변경일자 변경자 변동내역
'=======================================================================
'
'=======================================================================
'Response.Expires = -1
%>
<%
' Response.Buffer=true
Const Ref = "D7EFGBCHL640MN598OIJKPQRSATWXVYZ123U"
public Function TransFormat(arg1)
'// 10이하의 숫자 앞에 0을 붙인다
Dumy=""
if arg1 < 10 then
Dumy= "0" & arg1
else
Dumy=arg1
end if
TransFormat=Dumy
End Function
public Function ZeroFormat(arg1, arg2)
'//값의 형식에 맞게 값앞에 0을 붙인다
'arg1:입력값, arg2:출력하고자하는 값의 길이
'vb의 format(x,"0000")의 경우임.단 #과 ,는 정의 안됨
dim dumy, i, j,arg1_len
Dumy=""
arg1 = trim(arg1)
arg1_len = len(arg1)
for i=1 to eval(arg2) - arg1_len
dumy = dumy & "0"
next
dumy = dumy & arg1
ZeroFormat = dumy
End function
public Function Admin_Check(arg)
if arg <> "OK" then
Response.Write "<script>"
Response.Write "window.alert ('사용 권한이 없습니다.');"
Response.Write "history.back();"
Response.Write "</script>"
end if
end Function
public Function Buser_Check(arg1, arg2, arg3, arg4) ''부서 확인용
'arg1 : 해당부서코드
'arg2 : 로그인자 해당부서코드
'arg3 : Session("admin_Code") 부서장인가 확인용
'arg4 : Session("Admin")
if arg4 = "OK" then '관리자인가
else
if arg1 = arg2 and (arg3 = "1" or arg3 = "True") then '특정1개 부서이면서 팀장만
elseif (arg1 = "연구부서") and arg2 >= 1 and arg2 <= 10 then '연구부서 전체만(연구부서의 부서코드는 10이하이어야 함)
else
Response.Write "<script>"
Response.Write "window.alert ('사용 권한이 없습니다.');"
Response.Write "history.back();"
Response.Write "</script>"
end if
end if
end Function
public Function Buser_Check2(arg1, arg2, arg3, arg4, arg5) ''부서 확인용
'arg1 : 해당부서코드
'arg2 : 로그인자 해당부서코드
'arg3 : Session("admin_Code") 부서장인가 확인용
'arg4 : Session("Admin")
'arg5 : 해당부서코드
' call Buser_Check2("12", Session("p_depart"), 1, Session("Admin"), "13")
if arg4 = "OK" then '관리자인가
else
if (arg1 = arg2 or arg5 = arg2) and (arg3 = "1" or arg3 = "True") then '특정1개 부서이면서 팀장만
elseif (arg1 = "연구부서") and arg2 >= 1 and arg2 <= 10 then '연구부서 전체만(연구부서의 부서코드는 10이하이어야 함)
else
Response.Write "<script>"
Response.Write "window.alert ('사용 권한이 없습니다.');"
Response.Write "history.back();"
Response.Write "</script>"
end if
end if
end Function
public Function Admin_Code_Check(depart, security)
if not((depart = "11" and security = "1") or (depart = "13" and security = "1")) then
Response.Write "<script>"
Response.Write "window.alert ('사용 권한이 없습니다.');"
Response.Write "history.back();"
Response.Write "</script>"
end if
end Function
public Function Time_Check(arg)
dim tmp_cnt
if arg <> "OK" then
if request.Cookies("p_ip") = "" then
%>
<script language="javascript">
alert('시간이 만료되어 자동 로그아웃 되었습니다.\n다시 로그인하시기 바랍니다.');
location.href = "/";
</script>
<%
end if
query="select * from person where p_ip ='" & request.Cookies("p_ip") & "'"
query = query & "and p_resign = 0"
adors.open query, adoconn, 1
tmp_cnt = adors.recordCount
if tmp_cnt = 1 then
Session("errmsg") = ""
Session("Login_Check") = "OK"
Session("loginuser") = adors("p_name") '사용자이름
Session("Depart_Code") = adors("p_depart") '부서코드
Session("User_Number") = adors("p_no") '사원번호
Session("User_Mail") = adors("p_User_Mail") '사용자메일
Session("admin_Code") = adors("p_admin") '팀장코드(true,1:팀장,false,2:팀원)
Session("Position_Code")= adors("p_pos") '직위코드
Session("keupho_Code") = adors("keupho") '급호코드
session("job_code") = adors("p_job_part") '업무파트(p_job_part => 0:임원, 1:연구, 2:제작, 3:s/v, 4:검증, 5:코딩, 6:펀치, 7:dp, 8:it, 9:회계, 99:기타
Session("USERIP") = replace(replace(Request.ServerVariables("REMOTE_ADDR"), "10.10.20.", "10.10.13."), "10.10.17.", "10.10.13.") '사용자IP
response.Cookies("p_no")= adors("p_no") '사원번호
response.Cookies("p_ip")= adors("p_ip") 'IP번호
Session("teamcode") = adors("p_team") '사용자 팀번호
Session("teamplace") = adors("p_team_place") '사용자 팀직위(0:무, 1:팀원, 2:팀장, 3:부서장, 4:본부장, 5:임원, 6:사장or대표, 7:부회장, 8:회장)
Session("job_view") = adors("p_job_view_depart") '사용자 뷰부서(임원용)
Session("pw_new") = adors("p_pass_new") 'FCS 로그인용
Session("N_depart") = adors("p_depart_now") '신규 부서 코드
Session("N_team") = adors("p_team_now") '신규 팀 코드
adors.close
elseif tmp_cnt > 1 then
adors.close
query="select * from person where p_no ='" & request.Cookies("p_no") & "'"
query = query & "and p_resign = 0"
adors.open query, adoconn, 1
if adors.recordCount > 0 then
Session("errmsg") = ""
Session("Login_Check") = "OK"
Session("loginuser") = adors("p_name") '사용자이름
Session("Depart_Code") = adors("p_depart") '부서코드
Session("User_Number") = adors("p_no") '사원번호
Session("User_Mail") = adors("p_User_Mail") '사용자메일
Session("admin_Code") = adors("p_admin") '팀장코드(true,1:팀장,false,2:팀원)
Session("Position_Code")= adors("p_pos") '직위코드
Session("keupho_Code") = adors("keupho") '급호코드
session("job_code") = adors("p_job_part") '업무파트(p_job_part => 0:임원, 1:연구, 2:제작, 3:s/v, 4:검증, 5:코딩, 6:펀치, 7:dp, 8:it, 9:회계, 99:기타
Session("USERIP") = replace(replace(Request.ServerVariables("REMOTE_ADDR"), "10.10.20.", "10.10.13."), "10.10.17.", "10.10.13.") '사용자IP
response.Cookies("p_no")= adors("p_no") '사원번호
response.Cookies("p_ip")= adors("p_ip") 'IP번호
Session("teamcode") = adors("p_team") '사용자 팀번호
Session("teamplace") = adors("p_team_place") '사용자 팀직위(0:무, 1:팀원, 2:팀장, 3:부서장, 4:본부장, 5:임원, 6:사장or대표, 7:부회장, 8:회장)
Session("job_view") = adors("p_job_view_depart") '사용자 뷰부서(임원용)
Session("pw_new") = adors("p_pass_new") 'FCS 로그인용
Session("N_depart") = adors("p_depart_now") '신규 부서 코드
Session("N_team") = adors("p_team_now") '신규 팀 코드
end if
adors.close
else
adors.close
end if
if Session("loginuser") = "김홍완" or Session("loginuser") = "김동석" or Session("loginuser") = "김종휘" or Session("loginuser") = "박준빈" or Session("loginuser") = "정형기" then
session("admin_ip") = replace(replace(Request.ServerVariables("REMOTE_ADDR"), "10.10.20.", "10.10.13."), "10.10.17.", "10.10.13.")
end if
query = "select p_team_name as d_name from V_Person where p_no = '" & Session("User_Number") & "' "
adoRs.open query, adoconn, 1,1
Session("Depart_name") = adors("d_name") '부서명
adors.close
if Session("Login_Check") <> "OK" then
Session("errmsg") = "시간이 만료되어 자동 로그아웃 되었습니다.\n다시 로그인하시기 바랍니다."
%>
<script language="javascript">
alert('시간이 만료되어 자동 로그아웃 되었습니다.\n다시 로그인하시기 바랍니다.');
location.href = "/";
</script>
<%
'response.End
end if
end if
end Function
public Function Time_Check2(arg)
if arg <> "OK" then
Session("errmsg")="시간 초과"
Response.Write "<script LANGUAGE='JavaScript'>"
Response.Write " var objPopup = window.open('/login.asp','','left=200,top=50,width=780,height=600,scrollbars=yes,resizable=yes,location=no,toolbar=no, menubar=no,status=yes');"
Response.Write " if (objPopup != null) { "
Response.Write " window.close();"
Response.Write " }else{"
Response.Write " }"
Response.Write "</script>"
end if
end Function
Function date_time()
v_year = year(date)
v_month = month(date)
if v_month < 10 then v_month = "0" & v_month
v_day = day(date)
if v_day < 10 then v_day = "0" & v_day
v_hour = hour(time)
if v_hour < 10 then v_hour = "0" & v_hour
v_minute = minute(time)
if v_minute < 10 then v_minute = "0" & v_minute
v_second = second(time)
if v_second < 10 then v_second = "0" & v_second
v_datetime = v_year&v_month&v_day&v_hour&v_minute&v_second
date_time = v_datetime
End Function
Function FormatDate()
dim yyyy, mm, dd,dumy
yyyy=year(date)
mm=month(date)
dd=day(date)
dumy=time
if mm < 10 then
mm="0" & mm
end if
if dd < 10 then
dd="0" & dd
end if
formatdate=yyyy & "-" & mm & "-" & dd & " " & dumy
End Function
Function Change(txt)
j=1
txt = replace(txt, "&dsin;", " ")
txt = replace(txt, "&sin;", " ")
txt = replace(txt, chr(34), " ")
txt = replace(txt, "'", " ")
for k=1 to 100
j= instr(txt, chr(13))
if j > 0 and k >= 7 then
response.write "" & "<br>"
response.write "" & "<br>"
response.write "....." & "<br>"
response.write "" & "<br>"
response.write "<b>계속 되는 문장입니다. 클릭해서 보세요....<b>" & "<br>"
exit for
end if
if j =0 then
response.write txt & "<br>"
k=100
else
response.write Mid(txt,1, j-1) & "<br>"
txt = Mid(txt,j+2)
end if
next
End Function
Function Change2(txt)
dim jjj
dim kkk
jjj=1
txt = replace(txt, "&dsin;", " ")
txt = replace(txt, "&sin;", " ")
txt = replace(txt, chr(34), " ")
txt = replace(txt, "'", " ")
for kkk=1 to 100
jjj= instr(txt, chr(13))
if jjj =0 then
response.write txt & "<br>"
kkk=100
else
response.write Mid(txt,1, jjj-1) & "<br>"
txt = Mid(txt,jjj+2)
end if
next
End Function
Function msg0(txt)
txt = replace(txt, "'", " ")
Response.Write "<script>"
Response.Write "window.alert ('" + txt + "');"
Response.Write "</script>"
End Function
Function msg(txt,tit)
txt = replace(txt, "'", " ")
tit = replace(tit, "'", " ")
Response.Write "<script>"
Response.Write "window.alert ('" + txt + ", " + tit + "');"
Response.Write "</script>"
End Function
'경고 메세지 보여주기
Function Alert(msg)
msg = replace(msg, "'", " ")
Response.Write "<Script>alert('" & msg & "');</Script>"
' Response.End
End Function
'경고 메세지 보여주기
Function Alert4(msg)
msg = replace(msg, "'", " ")
Response.Write "<Script>alert('"&msg&"');self.opener=self;window.close();</Script>"
' Response.End
End Function
'경고 메세지 보여주기
Function Alert2(msg)
msg = replace(msg, "'", " ")
Response.Write "<script>"
Response.Write "window.alert ('" &msg & "');"
Response.Write "history.back();"
Response.Write "</script>"
' Response.End
End Function
'경고 메세지 보여주기
Function Alert_Back(msg)
msg = replace(msg, "'", " ")
Response.Write "<script>"
Response.Write "window.alert ('" &msg & "');"
Response.Write "history.back(-2);"
Response.Write "</script>"
' Response.End
End Function
Function Pagelist(Url,page, Sort_key, txt_title, pagecount, strPath)
'Url:파일명, Page:현재 페이지, Sort_key:소트키워드, txt_title:제목, pagecount:페이지 갯수, strPath : 기타패스
Response.Write "<table class='table table-bordered my-2 mx-auto w-auto border-top-0'>"
Response.Write "<tr>"
'나머지가 있들때는 1을 더해줘서 페이지 숫자를 하나더 나오게 한다
dim Back_page, tmp_page, i
Back_page = 0
gotopage_str = "?gotopage="
if right(url, 1) = "&" then
gotopage_str = "gotopage="
end if
if pagecount >= 2 AND 1 <> int(page) AND 10 < int(page) then
Response.Write "<td class='p-1 px-2'><A href='" & url & gotopage_str & "1" & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'><i class='fas fa-angle-double-left'></i></A></td>"
end if
if cint(page) > 10 then '이전10개
back_page = page - 10
Response.Write "<td class='p-1 px-2'><A href='" & url & gotopage_str & back_page & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'><i class='fas fa-angle-left'></i></A></td>"
end if
if cint(page) > 1 then
back_page= page - 1
'Response.Write "<td class=''><A href='" & url & gotopage_str & Back_page & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'><</A></td>"
end if
tmp_page=(Cint(page) \ 10)
if Cint(page) mod 10 = 0 then
tmp_page=tmp_page-1
end if
tmp_page=tmp_page * 10
for i=tmp_page +1 to tmp_page +10
if i > pagecount then
exit for
end if
if Cint(page)=i then
Response.Write "<td class='p-1 px-2' style='font-weight:bold;'>" & i & "</td>"
Else
Response.Write "<td class='p-1 px-2'><A href='" & Url & gotopage_str & i & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'>" & i & "</A></td>"
End if
next
if cint(page) < pagecount then
next_page= page + 1
'Response.Write "<td class=''><A href='" & url & gotopage_str & next_page & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'>></A></td>"
end if
if Back_page=0 then
Back_page = 11
else
Back_page = page +10
end if
if Back_page <= pagecount then '다음10개
Response.Write "<td class='p-1 px-2'><A href='" & url & gotopage_str & Back_page & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'><i class='fas fa-angle-right'></i></A></td>"
Elseif (Back_page-1) Mod 10 > (pagecount-1) Mod 10 And pagecount > 0 Then
Response.Write "<td class='p-1 px-2'><A href='" & url & gotopage_str & pagecount & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'><i class='fas fa-angle-right'></i></A></td>"
end if
if pagecount >= 11 AND pagecount <> int(page) then
Response.Write "<td class='p-1 px-2'><A href='" & url & gotopage_str & pagecount & strPath & "&SortKeyWd=" & Sort_key & "&txt_title=" & txt_title & "' class='blue'><i class='fas fa-angle-double-right'></i></A></td>"
end if
Response.Write "</tr>"
Response.Write "</table>"
End Function
'디비에 저장시 문자 치환하기
Function CheckWord(CheckValue)
if CheckValue <> "" then
CheckValue = replace(CheckValue, "&" , "&amp;")
CheckValue = replace(CheckValue, "<", "&lt;")
CheckValue = replace(CheckValue, ">", "&gt;")
CheckValue = replace(CheckValue, "'", "'")
' CheckValue = replace(CheckValue, "'", "&quot;")
CheckValue = replace(CheckValue, ",", "&apos;")
CheckValue = replace(CheckValue, "%", "&per;")
' CheckValue = replace(CheckValue, " ", "&nbsp;")
' CheckValue = replace(CheckValue, "?", "&nbsp;")
' CheckValue = replace(CheckValue, chr(34), "&dsin;") '더블 쿼테이션
CheckValue = replace(CheckValue, chr(34), "˝") '더블 쿼테이션
CheckValue = replace(CheckValue, "'", "&sin;")
end if
CheckWord=CheckValue
End Function
'보여줄때 문자 치환하기
Function ViewWord(CheckValue)
if CheckValue <> "" then
CheckValue = replace(CheckValue, "&amp;" , "&")
CheckValue = replace(CheckValue, "&lt;", "<")
CheckValue = replace(CheckValue, "&gt;", ">")
CheckValue = replace(CheckValue, "&quot;", "'")
CheckValue = replace(CheckValue, "&apos;", ",")
CheckValue = replace(CheckValue, "&nbsp;" , " ")
CheckValue = replace(CheckValue, "&per;", "%")
CheckValue = replace(CheckValue, "&dsin;", chr(34))
CheckValue = replace(CheckValue, "&sin;", "'")
end if
ViewWord=CheckValue
End Function
Function TransHTML(CheckValue)
if Not isNull(CheckValue) then
CheckValue = replace(CheckValue, "&sin;", "'")
' CheckValue = replace(CheckValue, " ", "&nbsp;")
CheckValue = replace(CheckValue, "&dsin;", chr(34)) '더블 쿼테이션
CheckValue = replace(CheckValue, chr(13), "<br>")
end if
TransHTML = CheckValue
End Function
Function HTMLEncode(CheckValue)
' CheckValue=server.HTMLEncode(CheckValue)
''// 밑에 pre태그를 쓰면서 안씀
''//pre 태그를 쓰지 않으면 (처음)스페이스가 없어짐
if Not isNull(CheckValue) then
CheckValue = replace(CheckValue, chr(13), "<br>")
' CheckValue = replace(CheckValue, "<br>", chr(13))
end if
HTMLEncode = CheckValue
End Function
Function TransSTR(CheckValue)
if Not isNull(CheckValue) then
CheckValue = replace(CheckValue, "'", "&sin;")
CheckValue = replace(CheckValue, chr(34), "&dsin;")
CheckValue = replace(CheckValue, "<br>", "")
' CheckValue = replace(CheckValue, chr(13), "<br>")
end if
TransSTR = CheckValue
End Function
Function clen(STRIN)
Dim i, j
Dim LL
LL = 0
i = Len(STRIN)
For j = 1 To i
If Asc(Mid(STRIN, j, 1)) < 0 Then
LL = LL + 2
Else
LL = LL + 1
End If
Next
CLEN = LL
End Function
Function cmid(CSTRIN, CSTPOS, SLEN)
Dim i, j, l
Dim STT
Dim OUTSTR
Dim STPOS, ENPOS
Dim cnt
OUTSTR = ""
STT = RTrim(CSTRIN)
i = CLEN(STT)
l = 0
If i < CSTPOS Then
OUTSTR = Space(SLEN)
ElseIf CSTPOS < 2 Then
OUTSTR = Csformat(STT, SLEN)
Else
STPOS = 0
ENPOS = 0
cnt = 0
For j = 1 To Len(STT)
If Asc(Mid(STT, j, 1)) < 0 Then
cnt = cnt + 2
Else
cnt = cnt + 1
End If
If STPOS = 0 Then
If cnt >= (CSTPOS - 1) Then
STPOS = j + 1
If cnt > (CSTPOS - 1) Then
OUTSTR = " "
End If
End If
Else
If cnt <= (CSTPOS + SLEN - 1) Then
OUTSTR = OUTSTR + Mid(STT, j, 1)
If cnt = (CSTPOS + SLEN - 1) Then
j = Len(STT) + 10
End If
Else
j = Len(STT) + 10
End If
End If
Next
End If
i = CLEN(OUTSTR)
If i < SLEN Then
for j = 1 to (SLEN - i)
OUTSTR = OUTSTR + "&nbsp;"
next
End If
If i > SLEN Then
msg0 "ERROR- 'cmid' function return size error"
End If
Cmid = OUTSTR
End Function
Function csformat(STRIN, SLEN)
Dim i, j, l, k
Dim STT
STT = RTrim(STRIN)
i = CLEN(STT)
l = 0
If i > SLEN Then
For j = Len(STT) To 1 Step -1
If Asc(Mid(STT, j, 1)) < 0 Then
l = l + 2
Else
l = l + 1
End If
If i - l <= SLEN Then
STT = Mid(STT, 1, j - 1)
i = CLEN(STT)
for k = 1 to (SLEN - i)
stt = stt & "&nbsp;"
next
Csformat = STT
Exit For
End If
Next
Else
for k = 1 to (SLEN - i)
stt = stt & "&nbsp;"
next
Csformat = STT
End If
End Function
Function encode(str, chipVal)
' 암호화
''chipval의 값은 3으로 고정
Dim Temp, TempChar, Conv, Cipher, i: Temp = ""
chipVal = 3
chipVal = CInt(chipVal)
str = StringToHex(str)
For i = 0 To Len(str) - 1
TempChar = Mid(str, i + 1, 1)
Conv = InStr(Ref, TempChar) - 1
Cipher = Conv Xor chipVal
Cipher = Mid(Ref, Cipher + 1, 1)
Temp = Temp + Cipher
Next
encode = Temp
End Function
Function decode(str, chipVal)
' 복호화
''chipval의 값은 3으로 고정
Dim Temp, TempChar, Conv, Cipher, i: Temp = ""
chipVal = 3
chipVal = CInt(chipVal)
For i = 0 To Len(str) - 1
TempChar = Mid(str, i + 1, 1)
Conv = InStr(Ref, TempChar) - 1
Cipher = Conv Xor chipVal
Cipher = Mid(Ref, Cipher + 1, 1)
Temp = Temp + Cipher
Next
Temp = HexToString(Temp)
decode = Temp
End Function
Function StringToHex(pStr)
' 문자열 -> 16진수
Dim i, one_hex, retVal
For i = 1 To Len(pStr)
one_hex = Hex(Asc(Mid(pStr, i, 1)))
retVal = retVal & one_hex
Next
StringToHex = retVal
End Function
Function HexToString(pHex)
' 16진수 -> 문자열
Dim one_hex, tmp_hex, i, retVal
For i = 1 To Len(pHex)
one_hex = Mid(pHex, i, 1)
If IsNumeric(one_hex) Then
tmp_hex = Mid(pHex, i, 2)
i = i + 1
Else
tmp_hex = Mid(pHex, i, 4)
i = i + 3
End If
retVal = retVal & Chr("&H" & tmp_hex)
Next
HexToString = retVal
End Function
'-- 권한체크(20170303)
function fnc_user_level(mo_mode,mo_category,mo_val)
dim tval : tval="0"
dim mo_sql
dim mo_val1 : mo_val1 = replace(replace(mo_val, "10.10.20.", "10.10.13."), "10.10.17.", "10.10.13.")
select case mo_mode
case "0" '-- 개인
mo_sql=" select top 1 id from dbo.T_special "&vbCrLf
mo_sql=mo_sql&" where div_use='1' "&vbCrLf
mo_sql=mo_sql&" and tcategory1='"&mo_category&"' "&vbCrLf
mo_sql=mo_sql&" and tval1='"&mo_val1&"' "&vbCrLf
Rs.Open mo_sql, adoConn, 1
if not Rs.eof then
tval="1"
end if
Rs.Close
case "1" '-- 팀
mo_sql=" select top 1 id from dbo.T_special "&vbCrLf
mo_sql=mo_sql&" where div_use='1' "&vbCrLf
mo_sql=mo_sql&" and tcategory1='"&mo_category&"' "&vbCrLf
mo_sql=mo_sql&" and tval1 in ( "&vbCrLf
mo_sql=mo_sql&" select p_depart from dbo.person "&vbCrLf
mo_sql=mo_sql&" where p_no='"&mo_val1&"' "&vbCrLf
mo_sql=mo_sql&" ) "&vbCrLf
Rs.Open mo_sql, adoConn, 1
if not Rs.eof then
tval="1"
end if
Rs.Close
end select
fnc_user_level=tval
end function
function iif(condition, a, b)
if condition then
iif = a
else
iif = b
end if
end function
function formatNumberDbl(num)
dim str, nc
nc = 0
if IsNumeric(num) then
tmparr = split(cstr(cdbl(num)), ".")
if (uBound(tmparr) - LBound(tmparr) + 1) > 1 then
nc = len(tmparr(1))
end if
str = formatNumber(num, nc)
formatNumberDbl = str
else
formatNumberDbl = "None"
end if
end function
Function dayofweek(str)
If Not Isnumeric(str) Then str = weekDay(str)
Select Case cInt(str)
Case 1 : str = "일요일"
Case 2 : str = "월요일"
Case 3 : str = "화요일"
Case 4 : str = "수요일"
Case 5 : str = "목요일"
Case 6 : str = "금요일"
Case 7 : str = "토요일"
End Select
dayofweek = str
End Function
Function weekNum(condate)
'condate는 '2020-01-05' 형식
weekNum = int((Day(cdate(condate)) - weekday(cdate(condate)) + 13) / 7)
End Function
Function weekRange(ym, weekNum)
dim tmp_first_day, tmp_last_day, tmp_min_date, tmp_max_day, tmp_range
tmp_first_day = cDate(ym + "-01")
tmp_min_date = DateAdd("d", 7 * (weekNum - 1) - (weekday(tmp_first_day) - 1), tmp_first_day)
tmp_last_day = DateAdd("d", -1, DateAdd("m", 1, tmp_first_day))
tmp_max_day = DateAdd("d", 6, tmp_min_date)
If tmp_min_date < tmp_first_day Then
tmp_min_date = tmp_first_day
End If
If tmp_max_day > tmp_last_day Then
tmp_max_day = tmp_last_day
End If
if tmp_min_date > tmp_max_day Then
tmp_range = "undefined"
Else
tmp_range = Cstr(tmp_min_date) & "~" & Cstr(tmp_max_day)
End if
weekRange = tmp_range
End Function
''//--------------------------------------------------------------------
''//-- 월요일 부터 한 주 시작 start
''//-- dayofweek_mon, weekday_mon, weekNum_mon, weekRange
Function dayofweek_mon(str)
If Not Isnumeric(str) Then str = weekday_mon(str)
Select Case cInt(str)
Case 1 : str = "월요일"
Case 2 : str = "화요일"
Case 3 : str = "수요일"
Case 4 : str = "목요일"
Case 5 : str = "금요일"
Case 6 : str = "토요일"
Case 7 : str = "일요일"
End Select
dayofweek_mon = str
End Function
Function weekday_mon(str)
If Not Isnumeric(str) Then str = weekDay(str)
Select Case cInt(str)
Case 1 : str = 7
Case 2 : str = 1
Case 3 : str = 2
Case 4 : str = 3
Case 5 : str = 4
Case 6 : str = 5
Case 7 : str = 6
End Select
weekday_mon = str
End Function
'-- 현재일의 주차
Function weekNum_mon(condate)
'response.write "----------------------"&condate
''condate는 '2020-01-05' 형식
''weekNum_mon = int((Day(cdate(condate)) - weekday_mon(cdate(condate)) + 13) / 7)
query=" SELECT weeknum FROM project2.dbo.login_weeknum with(nolock) WHERE '"& condate &"' BETWEEN sdate and edate; "&vbCrLf
'response.write query
Rs.open query, adoConn, 1
if not Rs.eof then
weekNum_mon = Rs("weeknum")
else
weekNum_mon = 0
end if
Rs.Close
End Function
Function weekRange_mon(ym, weekNum)
dim tmp_first_day, tmp_last_day, tmp_min_date, tmp_max_day, tmp_range
'tmp_first_day = cDate(ym + "-01")
'tmp_min_date = DateAdd("d", 7 * (weekNum - 1) - (weekday(tmp_first_day) - 1), tmp_first_day)
'
'tmp_last_day = DateAdd("d", -1, DateAdd("m", 1, tmp_first_day))
'tmp_max_day = DateAdd("d", 6, tmp_min_date)
'
'If tmp_min_date < tmp_first_day Then
' tmp_min_date = tmp_first_day
'End If
'
'If tmp_max_day > tmp_last_day Then
' tmp_max_day = tmp_last_day
'End If
'if tmp_min_date > tmp_max_day Then
' tmp_range = "undefined"
'Else
' tmp_range = Cstr(tmp_min_date) & "~" & Cstr(tmp_max_day)
'End if
query=" SELECT sdate+'~'+edate AS rangedate FROM project2.dbo.login_weeknum with(nolock) WHERE yearnum = '"& left(ym,4) &"' AND weeknum = '"& weekNum &"' ; "&vbCrLf
'response.write query
Rs.open query, adoConn, 1
if not Rs.eof then
tmp_range = Rs("rangedate")
else
tmp_range = 0
end if
Rs.Close
weekRange_mon = tmp_range
End Function
''//-- 월요일 부터 한 주 시작 end
''//--------------------------------------------------------------------
Function queryToJson(query)
Dim resJson, i
resJson = "["
Rs.open query, adoConn, 1
Do While Not Rs.Eof
resJson = resJson & "{"
For i = 0 To Rs.fields.Count - 1
resJson = resJson & """" & Rs.Fields.Item(i).Name & """:""" & Replace(Rs(i), """", "\""") & """"
if i < Rs.fields.Count - 1 Then
resJson = resJson & ","
End if
Next
resJson = resJson & "}"
Rs.MoveNext
if Rs.Eof = false Then
resJson = resJson & ","
End if
Loop
Rs.Close
resJson = resJson & "]"
queryToJson = resJson
End Function
'//-- 2020-10-21 12:14:40
Function adminView(query)
if replace(replace(Request.ServerVariables("REMOTE_ADDR"), "10.10.20.", "10.10.13."), "10.10.17.", "10.10.13.") = session("admin_ip") then
response.write query
end if
end function
'//-- hwkim 20220117
Function adminView_hwkim(query)
if Request.ServerVariables("REMOTE_ADDR") = "10.10.17.82" then
response.write query
end if
end function
%>