Files
Client/Server/ToolProject/AuthDBManager/AuthDBManagerDlg.cpp
LGram16 dd97ddec92 Restructure repository to include all source folders
Move git root from Client/ to src/ to track all source code:
- Client: Game client source (moved to Client/Client/)
- Server: Game server source
- GameTools: Development tools
- CryptoSource: Encryption utilities
- database: Database scripts
- Script: Game scripts
- rylCoder_16.02.2008_src: Legacy coder tools
- GMFont, Game: Additional resources

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 20:17:20 +09:00

641 lines
16 KiB
C++
Raw Blame History

// AuthDBManagerDlg.cpp : implementation file
//
#include "stdafx.h"
#include "AuthDBManager.h"
#include "AuthDBManagerDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
CListBox m_PlugList;
CString m_LastUpdate;
CString m_Creater;
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
virtual BOOL OnInitDialog();
afx_msg void OnSelchangePluginList();
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
m_LastUpdate = _T("");
m_Creater = _T("");
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
DDX_Control(pDX, ID_PLUGIN_LIST, m_PlugList);
DDX_Text(pDX, ID_LASTUPDATE, m_LastUpdate);
DDX_Text(pDX, ID_CREATER, m_Creater);
//}}AFX_DATA_MAP
}
BOOL CAboutDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CAuthDBManagerApp* pAppWnd = (CAuthDBManagerApp*)AfxGetApp();
CString PlugInfoS;
if(pAppWnd->m_PlugInInfo.PlugInfo)
{
PlugInfoS.Format("%s %s", pAppWnd->m_PlugInInfo.PlugInName, pAppWnd->m_PlugInInfo.PlugInVer);
m_PlugList.AddString(PlugInfoS);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAboutDlg::OnSelchangePluginList()
{
// TODO: Add your control notification handler code here
CAuthDBManagerApp* pAppWnd = (CAuthDBManagerApp*)AfxGetApp();
int Sel;
Sel = m_PlugList.GetCurSel();
if(Sel == 0)
{
m_Creater = pAppWnd->m_PlugInInfo.PlugInCreator.CreaterName;
m_LastUpdate = pAppWnd->m_PlugInInfo.PlugInLastUpdate;
UpdateData(FALSE);
}
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
ON_LBN_SELCHANGE(ID_PLUGIN_LIST, OnSelchangePluginList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAuthDBManagerDlg dialog
CAuthDBManagerDlg::CAuthDBManagerDlg(CWnd* pParent /*=NULL*/)
: CDialog(CAuthDBManagerDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CAuthDBManagerDlg)
m_ErrorLog = _T("");
m_SelectedCount = _T("");
m_SelectedRow = _T("");
m_SelectedUID = _T("");
m_SelectedID = _T("");
m_TotalRow = _T("");
m_Address = _T("");
m_Birth = _T("");
m_Email = _T("");
m_ID = _T("");
m_IDNumber = _T("");
m_Job = _T("");
m_Mobile = _T("");
m_Name = _T("");
m_Password = _T("");
m_Phone = _T("");
m_ZipCode = _T("");
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CAuthDBManagerDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAuthDBManagerDlg)
DDX_Control(pDX, ID_SEX, m_Sex);
DDX_Control(pDX, ID_CHAR_LIST, m_UserList);
DDX_Control(pDX, ID_QEURY_LED, m_QueryLed);
DDX_Control(pDX, ID_CONNECTION_LED, m_ConnectionLed);
DDX_Text(pDX, ID_ERROR_LOG, m_ErrorLog);
DDX_Text(pDX, ID_SELECTED_COUNT, m_SelectedCount);
DDX_Text(pDX, ID_SELECTED_ROW, m_SelectedRow);
DDX_Text(pDX, ID_SELECTED_UID, m_SelectedUID);
DDX_Text(pDX, ID_SELECTED_ID, m_SelectedID);
DDX_Text(pDX, ID_TOTAL_ROW, m_TotalRow);
DDX_Text(pDX, ID_ADDRESS, m_Address);
DDX_Text(pDX, ID_BIRTH, m_Birth);
DDX_Text(pDX, ID_EMAIL, m_Email);
DDX_Text(pDX, ID_ID, m_ID);
DDX_Text(pDX, ID_IDNUMBER, m_IDNumber);
DDX_Text(pDX, ID_JOB, m_Job);
DDX_Text(pDX, ID_MOBILE, m_Mobile);
DDX_Text(pDX, ID_NAME, m_Name);
DDX_Text(pDX, ID_PASSWORD, m_Password);
DDX_Text(pDX, ID_PHONE, m_Phone);
DDX_Text(pDX, ID_ZIPCODE, m_ZipCode);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAuthDBManagerDlg, CDialog)
//{{AFX_MSG_MAP(CAuthDBManagerDlg)
ON_WM_SYSCOMMAND()
ON_NOTIFY(LVN_ENDLABELEDIT, ID_USER_LIST, OnEndlabeleditUserList)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_COMMAND(ID_ABOUT, OnAbout)
ON_COMMAND(ID_CONNECT, OnConnect)
ON_COMMAND(ID_DISCONNECT, OnDisconnect)
ON_NOTIFY(NM_CLICK, ID_USER_LIST, OnClickUserList)
ON_COMMAND(ID_ADD_USER, OnAddUser)
ON_COMMAND(ID_DELETE_USER, OnDeleteUser)
ON_COMMAND(ID_INIT_LOGINTIME, OnInitLogintime)
ON_COMMAND(ID_REFESH, OnRefesh)
ON_COMMAND(ID_SEARCH, OnSearch)
ON_NOTIFY(LVN_KEYDOWN, ID_USER_LIST, OnKeydownUserList)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAuthDBManagerDlg message handlers
BOOL CAuthDBManagerDlg::OnInitDialog()
{
CDialog::OnInitDialog();
char SelectName[256];
int Counter;
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
CAuthDBManagerApp* pAppWnd = (CAuthDBManagerApp*)AfxGetApp();
m_UserList.SetColumn();
for(Counter = 0; Counter < 2; Counter++)
{
LoadString(pAppWnd->m_Language, IDS_S1 + Counter, SelectName, 256);
m_Sex.InsertString(Counter, SelectName);
}
m_Sex.SetCurSel(0);
m_ConnectionLed.SetLed(CLed::LED_COLOR_GREEN, CLed::LED_OFF, CLed::LED_ROUND);
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
m_Align = 0;
m_AlignType = 0;
m_SearchType = 0;
ZeroMemory(m_Search, sizeof(char) * 256);
return TRUE; // return TRUE unless you set the focus to a control
}
void CAuthDBManagerDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CAuthDBManagerDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CAuthDBManagerDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CAuthDBManagerDlg::OnAbout()
{
// TODO: Add your command handler code here
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
void CAuthDBManagerDlg::OnConnect()
{
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_ON, CLed::LED_ROUND);
if(!CDBSingleObject::GetInstance().Connect(CDBSingleObject::Class_AuthDB))
{
m_ErrorLog.Format("[<5B><><EFBFBD><EFBFBD>] <20><><EFBFBD>ӿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>߽<EFBFBD><DFBD>ϴ<EFBFBD>. %s", CDBSingleObject::GetInstance().GetErrorString());
}
else
{
m_ErrorLog.Format("[<5B><><EFBFBD><EFBFBD>] <20><><EFBFBD>ӿ<EFBFBD> <20><><EFBFBD><EFBFBD> <20>߽<EFBFBD><DFBD>ϴ<EFBFBD>.");
}
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
m_ConnectionLed.SetLed(CLed::LED_COLOR_GREEN, CLed::LED_ON, CLed::LED_ROUND);
UpdateUserTable();
}
void CAuthDBManagerDlg::OnDisconnect()
{
// TODO: Add your command handler code here
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_ON, CLed::LED_ROUND);
if(CDBSingleObject::GetInstance().DisconnectDataSource())
m_ConnectionLed.SetLed(CLed::LED_COLOR_GREEN, CLed::LED_OFF, CLed::LED_ROUND);
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
}
bool CAuthDBManagerDlg::ConnectDB(int Type, CString DataSource, CString Server, CString DataBase, CString User, CString Pass)
{
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_ON, CLed::LED_ROUND);
if(Type == 0)
{
if(!CDBSingleObject::GetInstance().ConnectSQLServer(DataSource.GetBuffer(0), NULL, NULL, NULL, CDBSingleObject::ConnType_ODBC))
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
return false;
}
}
else if(Type == 1)
{
if(!CDBSingleObject::GetInstance().ConnectSQLServer(Server.GetBuffer(0), DataBase.GetBuffer(0), User.GetBuffer(0), Pass.GetBuffer(0), CDBSingleObject::ConnType_MSSQL))
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
return false;
}
}
else if(Type == 2)
{
if(!CDBSingleObject::GetInstance().ConnectDataSourcePrompt(m_hWnd))
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
return false;
}
}
m_QueryLed.SetLed(CLed::LED_COLOR_RED, CLed::LED_OFF, CLed::LED_ROUND);
m_ConnectionLed.SetLed(CLed::LED_COLOR_GREEN, CLed::LED_ON, CLed::LED_ROUND);
return true;
}
const int MaxRow = 200;
bool CAuthDBManagerDlg::UpdateUserTable(void)
{
SELECT_AUTHUSER_TABLE LoginTable[MaxRow] = {0,};
int StartRow;
int RowCounter, Rows;
char Query[256] = "";
char Option[256] = "";
if(m_SearchType != 0)
{
if(m_SearchType == 1)
{
sprintf(Option, " where Account='%s'", m_Search);
}
else if(m_SearchType == 2)
{
sprintf(Option, " where Name='%s'", m_Search);
}
}
if(m_Align == 0)
{
strcat(Option, " order by UID");
}
else if(m_Align == 1)
{
strcat(Option, " order by Account");
}
else if(m_Align == 2)
{
strcat(Option, " order by Name");
}
if(m_AlignType == 0)
{
strcat(Option, " asc");
}
else if(m_AlignType == 1)
{
strcat(Option, " desc");
}
m_UserList.DeleteAllItems();
sprintf(Query, "select * from AuthUser %s", Option);
for(StartRow = 0;; StartRow += MaxRow)
{
if(CDBSingleObject::GetInstance().Select(Query, (void**)&LoginTable, sizeof(SELECT_AUTHUSER_TABLE), StartRow, MaxRow, &Rows))
{
for(RowCounter = 0; RowCounter < Rows; RowCounter++)
m_UserList.AddUserRow(&LoginTable[RowCounter]);
}
else
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
return false;
}
if(Rows < MaxRow)
break;
}
m_TotalRow.Format("%d", StartRow + Rows);
UpdateData(FALSE);
return true;
}
void CAuthDBManagerDlg::OnClickUserList(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
POSITION Pos;
int Index;
unsigned long UserUID;
char strUserUID[256];
char strUserID[256];
Pos= m_UserList.GetFirstSelectedItemPosition();
if(Pos != NULL)
{
while(Pos)
{
Index = m_UserList.GetNextSelectedItem(Pos);
}
m_SelectedRow.Format("%d", Index);
m_SelectedCount.Format("%d", m_UserList.GetSelectedCount());
// ij<><C4B3><EFBFBD><EFBFBD> <20><><EFBFBD>̵<EFBFBD> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʈ
if(m_UserList.GetItemText(Index, 0, strUserUID, 256))
{
UserUID = atoi(strUserUID);
m_SelectedUID.Format("%d", UserUID);
m_UserList.GetItemText(Index, 1, strUserID, 256);
m_SelectedID = strUserID;
}
UpdateData(FALSE);
}
*pResult = 0;
}
void CAuthDBManagerDlg::OnEndlabeleditUserList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
char Query[256] = "";
// TODO: Add your control notification handler code here
UPDATE_AUTHUSER_TABLE ModifyLoginTable;
LV_ITEM *plvItem = &pDispInfo->item;
ZeroMemory(&ModifyLoginTable, sizeof(UPDATE_AUTHUSER_TABLE));
if(plvItem->pszText != NULL)
{
m_UserList.SetItemText(plvItem->iItem, plvItem->iSubItem, plvItem->pszText);
m_UserList.GetUserRow(plvItem->iItem, &ModifyLoginTable);
sprintf(Query, "UpdateUser '%d', '%s', '%s', '%s', '%d', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'",
ModifyLoginTable.UID, ModifyLoginTable.AuthID, ModifyLoginTable.AuthPW, ModifyLoginTable.Name, ModifyLoginTable.Sex, ModifyLoginTable.Birth,
ModifyLoginTable.ZipCode, ModifyLoginTable.Address, ModifyLoginTable.Mobile, ModifyLoginTable.Phone, ModifyLoginTable.Email, ModifyLoginTable.Job,
ModifyLoginTable.IDNumber);
CDBSingleObject::GetInstance().ExecuteQuery(Query);;
}
*pResult = 0;
}
void CAuthDBManagerDlg::OnAddUser()
{
// TODO: Add your command handler code here
INSERT_AUTHUSER_TABLE InsertLoginTable = {0,};
char Query[256] = "";
UpdateData(TRUE);
strncpy(InsertLoginTable.AuthID, m_ID.GetBuffer(16), 16);
strncpy(InsertLoginTable.AuthPW, m_Password.GetBuffer(16), 16);
strncpy(InsertLoginTable.Name, m_Name.GetBuffer(16), 16);
InsertLoginTable.Sex = m_Sex.GetCurSel();
strncpy(InsertLoginTable.Birth, m_Birth.GetBuffer(20), 20);
strncpy(InsertLoginTable.IDNumber, m_IDNumber.GetBuffer(14), 14);
strncpy(InsertLoginTable.ZipCode, m_ZipCode.GetBuffer(12), 12);
strncpy(InsertLoginTable.Address, m_Address.GetBuffer(80), 80);
strncpy(InsertLoginTable.Mobile, m_Mobile.GetBuffer(20), 20);
strncpy(InsertLoginTable.Phone, m_Phone.GetBuffer(20), 20);
strncpy(InsertLoginTable.Email, m_Email.GetBuffer(48), 48);
strncpy(InsertLoginTable.Job, m_Job.GetBuffer(20), 20);
sprintf(Query, "InsertUser '%s', '%s', '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s'",
InsertLoginTable.AuthID, InsertLoginTable.AuthPW, InsertLoginTable.Name, InsertLoginTable.Sex, InsertLoginTable.Birth,InsertLoginTable.ZipCode,
InsertLoginTable.Address, InsertLoginTable.Mobile, InsertLoginTable.Phone, InsertLoginTable.Email, InsertLoginTable.Job, InsertLoginTable.IDNumber);
if(CDBSingleObject::GetInstance().ExecuteQuery(Query))
UpdateUserTable();
else
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
}
}
void CAuthDBManagerDlg::OnDeleteUser()
{
// TODO: Add your command handler code here
POSITION Pos;
int Index;
char Query[256] = "";
char strUserUID[256] = "";
Pos= m_UserList.GetFirstSelectedItemPosition();
if(Pos != NULL)
{
while(Pos != NULL)
{
Index = m_UserList.GetNextSelectedItem(Pos);
if(m_UserList.GetItemText(Index, 0, strUserUID, 256))
{
sprintf(Query, "DeleteUserByUID %s", strUserUID);
if(!CDBSingleObject::GetInstance().ExecuteQuery(Query))
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
break;
}
}
}
}
UpdateUserTable();
}
void CAuthDBManagerDlg::OnInitLogintime()
{
// TODO: Add your command handler code here
}
void CAuthDBManagerDlg::OnRefesh()
{
// TODO: Add your command handler code here
UpdateUserTable();
}
void CAuthDBManagerDlg::OnSearch()
{
// TODO: Add your command handler code here
CSearchDlg dlgSearch;
dlgSearch.DoModal();
UpdateUserTable();
}
void CAuthDBManagerDlg::OnKeydownUserList(NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVKEYDOWN* pKeyDown = (NMLVKEYDOWN*)pNMHDR;
// TODO: Add your control notification handler code here
POSITION Pos;
int Index;
char Query[256] = "";
char strUserUID[256] = "";
if(pKeyDown->wVKey == VK_DELETE)
{
Pos= m_UserList.GetFirstSelectedItemPosition();
if(Pos != NULL)
{
while(Pos)
{
Index = m_UserList.GetNextSelectedItem(Pos);
if(m_UserList.GetItemText(Index, 0, strUserUID, 256))
{
sprintf(Query, "DeleteUserByUID %s", strUserUID);
if(!CDBSingleObject::GetInstance().ExecuteQuery(Query))
{
m_ErrorLog = CDBSingleObject::GetInstance().GetErrorString();
UpdateData(FALSE);
break;
}
}
}
UpdateUserTable();
}
}
*pResult = 0;
}