<%
' ************************
' 1.회원관련
' ************************
'function memgr_idpwdchk(m_id,m_pwd) '아이디패스워드검사
'function memgr_logincookie(m_id, m_pwd) '로긴시 쿠키생성
'function memgr_logout() '로그아웃
'function memgr_ad_cmscookie() '관리자페이지 쿠키생성
'function security_ad_cms() '관리자페이지 체크
'function member_login_chk(url) '회원로그인 체크
'get_level(g_num) '등급이름찾기


'**************  Information  ****************************************
'	Program Title	:	security_ad_cms
'	Company		    :	
'	Creator		    :	
'*********************************************************************/
sub security_ad_cms()

	If session("ss_security_ad_cms") <> "ok" then
%>
		<script type='text/javascript'>
		//alert('잘못된 접속입니다.');
		//history.back();
		top.location.href='/manager/login.asp';
		</script>
<%
		response.end
	End If
End sub


'**************  Information  ****************************************
'	Program Title	:   '등급이름찾기
'	Company		    :	
'	reator		    :	윤 종 우 2007-02-07
'*********************************************************************
function get_level(g_num)
	Dim rs, g_menuname
	If g_num <> "" Then
		sql = "select g_num, g_menuname from member_group where g_num = " & g_num
		Set rs = dbcon.execute( sql )
		If rs.bof Or rs.eof Then
			If g_num = "-1" Then
				If session("sp_g_num") = "-2" Then
					get_level = "슈퍼관리자"
				Else
					get_level = "총관리자"
				End if
			Else
				get_level = ""
			End if
		Else
			g_menuname = rs(1)
			get_level = g_menuname

		End If
		Set rs = Nothing

	End If
End Function


'**************  Information  ****************************************
'	Program Title	:   아이디패스워드검사
'	Company		    :	
'	Creator		    :	윤 종 우  2004. 05
'*********************************************************************

function memgr_idpwdchk(m_id, m_pwd)
	Dim sql, rs

'	sql = " select m_num from member_view where m_id = '" & m_id & "' and m_pwd = '" & m_pwd & "' and g_manager = 'Y'"
	sql = " select m_num from member_view where m_id = '" & m_id & "' and m_pwd = '" & m_pwd & "' "
	Set rs = dbcon.execute( sql )

	If rs.bof Or rs.eof Then
		memgr_idpwdchk = false
	Else
		memgr_idpwdchk = true
	End if

	Set rs = nothing

End function


'**************  Information  ****************************************
'	Program Title	:   아이디패스워드검사
'	Company		    :	
'	Creator		    :	윤 종 우  2004. 05
'*********************************************************************
function memgr_idpwdchk3(m_id, m_pwd)

	Dim sql, rs
	sql = " select m_num from member_view where m_id = '" & m_id & "' and m_pwd = '" & m_pwd & "' and m_level <> '2'"
	'Response.write sql
	'Response.end
	Set rs = dbcon.execute( sql )

	If rs.bof Or rs.eof Then
		memgr_idpwdchk3 = false
	Else
		memgr_idpwdchk3 = true
	End if

	Set rs = nothing

End function

'**************  Information  ****************************************
'	Program Title	:   '로긴시 쿠키생성
'	Company		    :	
'	Creator		    :	윤 종 우  2004. 05
'*********************************************************************

function memgr_logincookie(m_id, m_pwd)
	Dim sql, Rs_m, lastdate

	'sql = " select m_num, m_id, m_name, m_level, m_pwd, m_jumin, (m_mobile1+'-'+m_mobile2+'-'+m_mobile3)as m_mobile, bdm_idx from member where m_id = '" & m_id & "' and m_pwd = '" & m_pwd & "'"
	sql = " select m_num, m_id, m_name, m_level, m_pwd, m_jumin, m_mobile1, m_mobile2, m_mobile3, bdm_idx from member where m_id = '" & m_id & "' and m_pwd = '" & m_pwd & "'"
	Set Rs_m = dbcon.execute( sql )

	'1544-9642 처럼 m_mobile3 없는 발신번호때문에 다시 조합.. (은영20240112)
	m_mobile = Rs_m("m_mobile1") & "-" & Rs_m("m_mobile2")
	If Rs_m("m_mobile3") <> "" Then 
		m_mobile = m_mobile & "-" & Rs_m("m_mobile3")
	End If 

	SESSION("ss_m_num") = Rs_m("m_num")
	SESSION("ss_m_id") = Rs_m("m_id")
	SESSION("ss_m_name") = Rs_m("m_name")
	SESSION("ss_g_num") = Rs_m("m_level")
	SESSION("ss_m_pwd") = Rs_m("m_pwd")
	SESSION("ss_m_jumin") = Rs_m("m_jumin")
	SESSION("ss_m_mobile") = m_mobile
	SESSION("ss_bdm_idx") = Rs_m("bdm_idx")

	'최근접속일 등록
	lastdate = date()
	sql = "update member set m_lastdate='" & lastdate & "' where m_id = '" & Trim( Rs_m("m_id") ) & "'"
	dbcon.execute sql

	
	'접속로그 남기기
'	sql = "insert into login_log (log_id,log_name,log_ip,log_wdate) values('" & trim( Rs_m("m_id") ) & "' ,'" & trim( Rs_m("m_name") ) & "', '" & request.ServerVariables("REMOTE_ADDR") & "' ,'" & date() & "')"
'	dbcon.execute sql

	Set Rs_m = nothing
End Function

'**************  Information  ****************************************
'	Program Title	:   아이디패스워드검사
'	Company		    :	
'	Creator		    :	윤 종 우  2004. 05
'*********************************************************************
'function memgr_idpwdchk2(m_id,m_pwd) {
'
'	$DbCon2 = mysql_connect("localhost","root","tkdlxm##");
'	mysql_select_db("super_user",$DbCon2);
'
'	$sql = " select m_num from super_member where m_id = '".$m_id."' and m_pwd = '".$m_pwd."'";
'	$query = mysql_query($sql,$DbCon2);
'
'	if (mysql_num_rows($query) > 0) {
'		return true;
'	}else{
'		return false;
'	}
'	exit;
'	
'}

'//**************  Information  ****************************************
'//	Program Title	:   '로긴시 쿠키생성
'//	Company		    :	
'//	Creator		    :	윤 종 우  2004. 05
'//*********************************************************************
'function memgr_logincookie2($m_id, $m_pwd) {
'
'	global $Application_domain;
'
'	$DbCon2 = mysql_connect("localhost","root","tkdlxm##");
'	mysql_select_db("super_user",$DbCon2);
'
'	$sql = " select m_num, m_id, m_name,m_level from super_member where m_id = '".$m_id."' and m_pwd = '".$m_pwd."'";
'	$query = mysql_query($sql,$DbCon2);
'
'	$col = mysql_fetch_array($query);
'
'		setcookie("ck_m_num", $col[m_num], 0, "/", $Application_domain);		//--회원pk	 
'		setcookie("ck_m_id", $col[m_id], 0, "/", $Application_domain);		//--회원id
'		setcookie("ck_m_name", $col[m_name], 0, "/", $Application_domain);	//--회원이름
'		setcookie("ck_g_num", $col[m_level], 0, "/", $Application_domain);	//--등급pk -1
'
'		setcookie("sp_g_num", "-2", 0, "/", $Application_domain);	//--관리자페이지 권한부여 
'
'	mysql_close($DbCon2);
'}

'//**************  Information  ****************************************
'//	Program Title	:   관리자페이지 쿠키생성
'//	Company		    :	
'//	Creator		    :	윤 종 우  2004. 05
'//*********************************************************************
sub memgr_ad_cmscookie()

	SESSION("ss_security_ad_cms") = "ok"

End sub

'//**************  Information  ****************************************
'//	Program Title	:   로그아웃
'//	Company		    :	
'//	Creator		    :	윤 종 우  2004. 05
'//*********************************************************************
sub memgr_logout()

	session.abandon

End Sub


sub member_login_chk(url)

	If session("ss_m_id") = "" Then
		'goUrl(url)
		Call Back_back2("세션이 만료되어 로그아웃됩니다.", url)
	End if

End sub

%>