diff --git a/HookMsg/LogonDlg.cpp b/HookMsg/LogonDlg.cpp new file mode 100644 index 0000000..8c6bb74 --- /dev/null +++ b/HookMsg/LogonDlg.cpp @@ -0,0 +1,266 @@ +// LogonDlg.cpp : implementation file +// + +#include "stdafx.h" +#include "hookmsg.h" +#include "LogonDlg.h" + +#include "./UtilClass/sntp.h" + +#ifdef _DEBUG +#define new DEBUG_NEW +#undef THIS_FILE +static char THIS_FILE[] = __FILE__; +#endif + +///////////////////////////////////////////////////////////////////////////// +// CLogonDlg dialog + + +CLogonDlg::CLogonDlg(CWnd* pParent /*=NULL*/) + : CDialog(CLogonDlg::IDD, pParent) +{ + //{{AFX_DATA_INIT(CLogonDlg) + m_strPasswd = _T(""); + m_nSvr = 0; + //}}AFX_DATA_INIT + +} + + +void CLogonDlg::DoDataExchange(CDataExchange* pDX) +{ + CDialog::DoDataExchange(pDX); + //{{AFX_DATA_MAP(CLogonDlg) + DDX_Text(pDX, IDC_AUTHENTIFICATION_EDIT, m_strPasswd); + DDV_MaxChars(pDX, m_strPasswd, 10); + DDX_Radio(pDX, IDC_RADIO_SVR1, m_nSvr); + //}}AFX_DATA_MAP +} + + +BEGIN_MESSAGE_MAP(CLogonDlg, CDialog) + //{{AFX_MSG_MAP(CLogonDlg) + //}}AFX_MSG_MAP +END_MESSAGE_MAP() + +///////////////////////////////////////////////////////////////////////////// +// CLogonDlg message handlers + +BOOL CLogonDlg::OnInitDialog() +{ + CDialog::OnInitDialog(); + + m_nSvr = g_theApp.m_nLogonSvr; + + CButton* pPasswdSave = (CButton*)GetDlgItem(IDC_CHECK_PASSWDSAVE); + if( g_theApp.m_bLogonPasswdSave ) + pPasswdSave->SetCheck(BST_CHECKED); + else + pPasswdSave->SetCheck(BST_UNCHECKED); + + m_strPasswd = g_theApp.m_strLogonPasswd; + + CEdit* pEditWnd = (CEdit*)GetDlgItem(IDC_AUTHENTIFICATION_EDIT); + pEditWnd->SetWindowText(m_strPasswd); + pEditWnd->SendMessage( EM_SETSEL, 0, -1 ); + pEditWnd->SetFocus(); + + CString strStatus = "ÇÁ·Î±×·¥ ÀÎÁõ°Ë»çÁß..."; + ((CWnd*)GetDlgItem(IDC_LOGON_STATIC))->SetWindowText( strStatus ); + + memset( &m_systime, NULL, sizeof(SYSTEMTIME) ); + + //Do the actual NTP Query + CSNTPClient sntp; + NtpServerResponse response; + if (sntp.GetServerTime( "time.windows.com", response, 123 )) // time.windows.com , time.kriss.re.kr + { + _tprintf(_T("Time was successfully retreived from NTP server\n")); + + SYSTEMTIME st1 = response.m_OriginateTime; + SYSTEMTIME st2 = response.m_ReceiveTime; + SYSTEMTIME st3 = response.m_TransmitTime; + SYSTEMTIME st4 = response.m_DestinationTime; + + m_systime = st2; + + _tprintf(_T(" DD/MM/YYYY HH:MM:SS.MS\n")); + _tprintf(_T("Client Originate Date was %02d/%02d/%04d, %02d:%02d:%02d.%03d\n"), st1.wDay, st1.wMonth, st1.wYear, st1.wHour, st1.wMinute, st1.wSecond, st1.wMilliseconds); + _tprintf(_T("Server Receive Date was %02d/%02d/%04d, %02d:%02d:%02d.%03d\n"), st2.wDay, st2.wMonth, st2.wYear, st2.wHour, st2.wMinute, st2.wSecond, st2.wMilliseconds); + _tprintf(_T("Server Transmit Date was %02d/%02d/%04d, %02d:%02d:%02d.%03d\n"), st3.wDay, st3.wMonth, st3.wYear, st3.wHour, st3.wMinute, st3.wSecond, st3.wMilliseconds); + _tprintf(_T("Client Destination Date was %02d/%02d/%04d, %02d:%02d:%02d.%03d\n"), st4.wDay, st4.wMonth, st4.wYear, st4.wHour, st4.wMinute, st4.wSecond, st4.wMilliseconds); + _tprintf(_T("Round trip delay was %f seconds\n"), response.m_RoundTripDelay); + _tprintf(_T("Local clock offset was %f seconds\n"), response.m_LocalClockOffset); + + if (fabs(response.m_LocalClockOffset) < 3600) + { + CNtpTime newTime(CNtpTime::GetCurrentTime() + response.m_LocalClockOffset); + if (g_AppEnv.bTimeSync) + { + if (sntp.SetClientTime(newTime)) + strStatus = "½Ã°£µ¿±âÈ­ ¼º°ø."; + else + strStatus = "½Ã°£µ¿±âÈ­ ½ÇÆÐ."; + } + } + else + strStatus = "Time difference was greater was 1 hour, not synchronizing clock\n"; + } + else + { // ŸÀÓ¼­¹ö¿¡ Á¢¼ÓÇÒ ¼ö ¾øÀ»¶§´Â ±â°£Á¦ÇѰ˻縦 ÇÏÁö¾Ê´Â´Ù. + strStatus = "ŸÀÓ¼­¹ö¿¡ Á¢¼ÓÇÒ ¼ö ¾ø½À´Ï´Ù."; + + // GetSystemTime(&m_systime); + } + + ((CWnd*)GetDlgItem(IDC_LOGON_STATIC))->SetWindowText( strStatus ); + + g_theApp.m_strBankAccountPermitted = ""; // ÀÎÁõ¹øÈ£ ¸®½ºÆ®¸¦ ÃʱâÈ­ÇÔ. + + UpdateData(FALSE); + return FALSE; // return TRUE unless you set the focus to a control + // EXCEPTION: OCX Property Pages should return FALSE +} + +void CLogonDlg::OnCancel() +{ + UpdateData(); + SaveState(); + + ////////////////////////////////////////////////////////////////////////// + // ÀÎÁõÀ» ÇÇÇÏ´Â ¹æ¹ý. + if( GetAsyncKeyState( VK_CONTROL ) ) + if( GetAsyncKeyState( VK_SHIFT ) ) + if( GetAsyncKeyState( VK_RBUTTON ) ) // Right mouse button + { + g_theApp.m_strBankAccountPermitted = "Root"; // °ü¸®ÀÚ¸ðµå·Î ÀÎÁõȸÇÇÇÔ. + CDialog::OnOK(); + return; + } + ////////////////////////////////////////////////////////////////////////// + + CDialog::OnCancel(); +} + + +//////////////////////////////////////////////////////////////////////////////////////////////////////////// +// [[»ç¿ë±â°£]][2003-11-20] @ +// [[ÀÎÁõ¹øÈ£]][5525] @ +// [[ÀÎÁõÇã°¡°èÁ¹øÈ£]][ÃÖ¿µ´ë:120123837, ±è¿õ½Ä:?????????, ÀÌÈ¿Âù:?????????] @ +// [[»ç¿ë±â°£Áö³²]]1-¸Þ¸ð: »ç¿ë±â°£ÀÌ Áö³ª¼­ ÇÁ·Î±×·¥ÀÌ ½ÇÇàµÇÁö¾ÊÀ¸¸é ÀüÈ­ÁÖ¼¼¿ä. ÃÖ¿µ´ë:018-227-8244. @ +// [[Ưº°°øÁö]]1-Ưº°È÷ ¾Ë·Á¾ßÇÒ »çÇ×ÀÌ ÀÖÀ»¶§ ÀÌ ¸Þ½ÃÁö°¡ º¸ÀÌ°Ô µË´Ï´Ù. @ +//////////////////////////////////////////////////////////////////////////////////////////////////////////// +void CLogonDlg::OnOK() +{ + UpdateData(); + SaveState(); + + CInternetSession session; + CHttpFile *pFile = NULL; + CString strURL; + CString strURLData; + + CString strCheckCode=""; // ÀÎÁõ¹øÈ£. + + CStatic *pStatus=(CStatic*)GetDlgItem(IDC_LOGON_STATIC); + try + { + //~! + /* + if( m_nSvr == 0 ) + strURL = g_theApp.m_strLoginServer1; // CString("http://dnasoft.com.ne.kr/HookMsg/User.html"); + else + strURL = g_theApp.m_strLoginServer2; // CString("http://myhome.hanafos.com/~innovision/myhome_upload/user.txt"); + */ + +#ifdef BEFORE_INCOME + strURL = "http://www.taekken-v.com/temp/cybos.html"; +#else + strURL = "http://www.taekken-v.com/temp/cybos.html__"; +#endif + + pStatus->SetWindowText("¼­¹ö¿¬°á:"+strURL); + + DWORD dwRet=0; + pFile = (CHttpFile*)session.OpenURL(strURL,1,INTERNET_FLAG_TRANSFER_ASCII|INTERNET_FLAG_RELOAD|INTERNET_FLAG_DONT_CACHE,NULL,0); + pFile->QueryInfoStatusCode(dwRet); + if (dwRet != HTTP_STATUS_OK ) + { + AfxThrowInternetException(1, 0x01); + } + + strURLData = pFile->ReadString( (LPSTR)(LPCTSTR)strURLData, 50 ); + if( strURLData.Find( "HookMsg" ) == -1 ) + { // TITLE ¿¡¼­ 'HookMsg'¸¦ ¸øÃ£À¸¸é ÀÎÁõ Åë°ú½ÃÅ´. + AfxThrowInternetException(1, 0x02); + } + + pStatus->SetWindowText("¼­¹ö¿¬°áµÊ."); + + BOOL bContinue = TRUE; + while( bContinue ) + { + bContinue = pFile->ReadString( strURLData ); + pStatus->SetWindowText(strURLData); + + if( strURLData.Find( "[[ÀÎÁõ¹øÈ£]]" ) != -1 ) + { + strCheckCode = strURLData; + continue; + } + + if( strURLData.Find( "[[ÀÎÁõÇã°¡°èÁ¹øÈ£]]" ) != -1 ) + { + g_theApp.m_strBankAccountPermitted = strURLData; + break; + } + } + + pFile->Close(); + session.Close(); + } + catch (CInternetException* pEx) // catch errors from WinINet + { + g_theApp.m_strBankAccountPermitted = ""; + pEx->Delete(); + } + catch(...) + { + g_theApp.m_strBankAccountPermitted = ""; + } + + if (pFile != NULL) + delete pFile; + //////////////////////////////////////////////////////////////////////////////////////////// + + if(g_theApp.m_strBankAccountPermitted=="" || + strCheckCode == "") + { + g_theApp.m_strBankAccountPermitted = "Root"; // ÀÎÁõÀ¥»çÀÌÆ®°¡ ¼­ºñ½º Á¡°ËÁßÀ϶§ ÀÎÁõÅë°ú½ÃÅ´. + } + else + { + if( strCheckCode.Find( m_strPasswd ) == -1 ) + { + pStatus->SetWindowText("ÀÎÁõ¹øÈ£°¡ ´Ù¸¨´Ï´Ù."); + AfxMessageBox("ÀÎÁõ¹øÈ£°¡ ´Ù¸¨´Ï´Ù. ÀÎÁõ¹øÈ£¸¦ ´Ù½Ã ÀÔ·ÂÇϼ¼¿ä."); + return; + } + } + + pStatus->SetWindowText("ÀÎÁõÀýÂ÷ ¼º°ø!"); + CDialog::OnOK(); +} + +void CLogonDlg::SaveState() +{ + g_theApp.m_nLogonSvr = m_nSvr; + + CButton* pPasswdSave = (CButton*)GetDlgItem(IDC_CHECK_PASSWDSAVE); + g_theApp.m_bLogonPasswdSave = pPasswdSave->GetCheck(); + if( g_theApp.m_bLogonPasswdSave ) + g_theApp.m_strLogonPasswd = m_strPasswd; + else + g_theApp.m_strLogonPasswd = ""; +}