⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dddlqserver.cpp

📁 vpn服务器的源代码
💻 CPP
字号:
// ddDlqServer.cpp : Defines the class behaviors for the application.
//

#include "stdafx.h"
#include "ddDlqServer.h"
#include "ddDlqServerDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CDdDlqServerApp

BEGIN_MESSAGE_MAP(CDdDlqServerApp, CWinApp)
	//{{AFX_MSG_MAP(CDdDlqServerApp)
		// NOTE - the ClassWizard will add and remove mapping macros here.
		//    DO NOT EDIT what you see in these blocks of generated code!
	//}}AFX_MSG
	ON_COMMAND(ID_HELP, CWinApp::OnHelp)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDdDlqServerApp construction

CDdDlqServerApp::CDdDlqServerApp()
{
	// TODO: add construction code here,
	// Place all significant initialization in InitInstance
}

/////////////////////////////////////////////////////////////////////////////
// The one and only CDdDlqServerApp object

CDdDlqServerApp theApp;

/////////////////////////////////////////////////////////////////////////////
// CDdDlqServerApp initialization

BOOL CDdDlqServerApp::InitInstance()
{
	// 初始化Winsock库
	WSADATA wsaData = {0};
	WORD sockVersion = MAKEWORD(2, 0);
	if(WSAStartup(sockVersion, &wsaData) != 0)
	{
		if(LOBYTE( wsaData.wVersion ) != LOBYTE(sockVersion) || HIBYTE( wsaData.wVersion ) != HIBYTE(sockVersion) )
			 ::MessageBox(NULL, _T("Incorrect version of Winsock.dll found"), _T("Error"), MB_OK);
		//关闭清除
		WSACleanup( );
		return FALSE;
	}

	// 创建一个自动重置的(auto-reset event),未受信的(nonsignaled)事件内核对象
	g_hAdEvent = CreateEvent(NULL, FALSE, FALSE, NULL);

	AfxEnableControlContainer();

	// Standard initialization
	// If you are not using these features and wish to reduce the size
	//  of your final executable, you should remove from the following
	//  the specific initialization routines you do not need.

#ifdef _AFXDLL
	Enable3dControls();			// Call this when using MFC in a shared DLL
#else
	Enable3dControlsStatic();	// Call this when linking to MFC statically
#endif

	CDdDlqServerDlg dlg;
	m_pMainWnd = &dlg;
	int nResponse = dlg.DoModal();
	if (nResponse == IDOK)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with OK
	}
	else if (nResponse == IDCANCEL)
	{
		// TODO: Place code here to handle when the dialog is
		//  dismissed with Cancel
	}

	// Since the dialog has been closed, return FALSE so that we exit the
	//  application, rather than start the application's message pump.
	return FALSE;
}

CString CDdDlqServerApp::glFormatDate(int iyear, int imonth, int iday)
{
	if((iyear < 2008) || (iyear > 3008))
		return "zyear";
	if((imonth < 1) || (imonth > 12))
		return "zmonth";
	if((iday < 1) || (iday > 31))
		return "zday";

	CString str;
	str.Format("%d年%02d月%02d日", iyear, imonth, iday);

	return str;
}

int CDdDlqServerApp::glUnFormatDate(CString strDate, int *iyear, int *imonth, int *iday)
{
	//"2008年8月8日"	4 7 10
	//"2008年08月8日"	4 8 11
	//"2008年8月08日"	4 7 11
	//"2008年08月08日"	4 8 12
	CString str;
	int iret = -1, mIndex, dIndex;

	str = strDate.Left(4);
	*iyear = atoi(str);
	mIndex = strDate.Find("月", 4);
	dIndex = strDate.Find("日", mIndex);
	if((mIndex == 7) && (dIndex == 10))//"2008年8月8日"
	{
		str = strDate.Mid(6, 1);
		*imonth = atoi(str);
		str = strDate.Mid(9, 1);
		*iday = atoi(str);
		iret = 1;
	}
	if((mIndex == 8) && (dIndex == 11))//"2008年08月8日"
	{
		str = strDate.Mid(6, 2);
		*imonth = atoi(str);
		str = strDate.Mid(10, 1);
		*iday = atoi(str);
		iret = 2;
	}
	if((mIndex == 7) && (dIndex == 11))//"2008年8月08日"
	{
		str = strDate.Mid(6, 1);
		*imonth = atoi(str);
		str = strDate.Mid(9, 2);
		*iday = atoi(str);
		iret = 3;
	}
	if((mIndex == 8) && (dIndex == 12))//"2008年08月08日"
	{
		str = strDate.Mid(6, 2);
		*imonth = atoi(str);
		str = strDate.Mid(10, 2);
		*iday = atoi(str);
		iret = 4;
	}

	return iret;
}
//得到vpn服务器信息表ddServer中所有vpn服务器名称列表
int CDdDlqServerApp::glGetAllServer()
{
	theApp.gServerList.RemoveAll();

	CString str;
	theApp.adoRstServer.MoveFirst();
	while(!theApp.adoRstServer.IsEOF())
	{	
		theApp.adoRstServer.GetFieldValue("servName", str);
		theApp.gServerList.AddTail(str);
		theApp.adoRstServer.MoveNext();
	}
	return 1;
}
//得到用户信息表ddUser中所有用户的用户名和IP列表
int CDdDlqServerApp::glGetAllUser()
{
	theApp.gUserNameList.RemoveAll();
	theApp.gUserIPList.RemoveAll();

	CString str;
	theApp.adoRstUser.MoveFirst();
	while(!theApp.adoRstUser.IsEOF())
	{	
		theApp.adoRstUser.GetFieldValue("ddUserName", str);
		theApp.gUserNameList.AddTail(str);
		theApp.adoRstUser.GetFieldValue("ddUserIP", str);
		theApp.gUserIPList.AddTail(str);
		theApp.adoRstUser.MoveNext();
	}
	return 1;
}
//得到用户信息表ddUser中当前某条用户信息中的可用服务器信息
int CDdDlqServerApp::glGetUsedServer()
{
	theApp.uiServerList.RemoveAll();
	
	int i, irec = 0;
	BOOL bb2, bb1;
	CString str, field;

	theApp.adoRstUser.GetFieldValue("ddCurrServer", str);
	theApp.uiServerList.AddTail(str);
	for(i=1; i<10; i++)
	{	
		field.Format("ddServer%d", i);
		bb1 = theApp.adoRstUser.IsFieldEmpty(field);
		bb2 =theApp.adoRstUser.IsFieldNull(field);
		if(!bb1 && !bb2)
		{
			theApp.adoRstUser.GetFieldValue(field, str);
			theApp.uiServerList.AddTail(str);
		}
	}
	return irec;
}

int CDdDlqServerApp::ExitInstance() 
{
	CloseHandle(g_hAdEvent);
	//卸载winsock库
	WSACleanup();
	
	return CWinApp::ExitInstance();
}

BOOL CDdDlqServerApp::glFindPositionFromUserTable(CString strUserName)
{
	CString szUserName;
	
	theApp.adoRstUser.MoveLast();
	while(!theApp.adoRstUser.IsBOF())
	{	
		theApp.adoRstUser.GetFieldValue("ddUserName", szUserName);
		if(szUserName == strUserName)
			return TRUE;
		theApp.adoRstUser.MovePrevious();
	}
	return FALSE;
}

BOOL CDdDlqServerApp::glFindPositionFromServerTable(CString strServerName)
{
	CString strServName;
	
	theApp.adoRstServer.MoveLast();
	while(!theApp.adoRstServer.IsBOF())
	{	
		theApp.adoRstServer.GetFieldValue("servName", strServName);
		if(strServName == strServerName)
			return TRUE;
		theApp.adoRstServer.MovePrevious();
	}
	return FALSE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -