www.pudn.com > mailserver-muiter.zip > D_Service.cpp


// D_Service.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "InetServer.h" 
#include "D_Service.h" 
#include "tools.h" 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// D_Service dialog 
 
 
D_Service::D_Service(CWnd* pParent /*=NULL*/) 
	: CDialog(D_Service::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(D_Service) 
	m_daytimeport = _T(""); 
	m_telnetport = _T(""); 
	m_rehash = _T(""); 
	m_smtpport = _T(""); 
	m_pop3port = _T(""); 
	m_ip = _T(""); 
	m_dns = _T(""); 
	m_fwddir = _T(""); 
	m_all = _T(""); 
	m_relaycfg = -1; 
	m_maxtries = _T(""); 
	m_nexttry = _T(""); 
	m_helo = _T(""); 
	m_sname = _T(""); 
	m_error = _T(""); 
	m_webmailport = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void D_Service::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(D_Service) 
	DDX_Control(pDX, IDC_WEBMAIL, m_iswebmail); 
	DDX_Control(pDX, IDC_ERROR, mc_error); 
	DDX_Control(pDX, IDC_USERFWD3, m_iserror); 
	DDX_Control(pDX, IDC_IFMATCH, m_ifmatch); 
	DDX_Control(pDX, IDC_COPY, mc_copy); 
	DDX_Control(pDX, IDC_UNKOWN, mc_unknown); 
	DDX_Control(pDX, IDC_USERFWD2, m_allsend); 
	DDX_Control(pDX, IDC_USERFWD, m_userfwd); 
	DDX_Control(pDX, IDC_AKA, m_aka); 
	DDX_Control(pDX, IDC_ISMAIL, m_ismail); 
	DDX_Control(pDX, IDC_ISTELNET, mc_istelnet); 
	DDX_Control(pDX, IDC_RQUIT, m_rquit); 
	DDX_Control(pDX, IDC_LOGALL, m_logall); 
	DDX_Control(pDX, IDC_BUSY, m_busy); 
	DDX_Control(pDX, IDC_CHECK3, m_log2); 
	DDX_Control(pDX, IDC_CHECK1, m_log1); 
	DDX_Control(pDX, IDC_ISDAYTIME, mc_isdaytime); 
	DDX_Text(pDX, IDC_DAYTIMEPORT, m_daytimeport); 
	DDX_Text(pDX, IDC_TELNETPORT, m_telnetport); 
	DDX_Text(pDX, IDC_REHASH, m_rehash); 
	DDX_Text(pDX, IDC_SMTPPORT, m_smtpport); 
	DDX_Text(pDX, IDC_POP3PORT, m_pop3port); 
	DDX_Text(pDX, IDC_IP, m_ip); 
	DDX_Text(pDX, IDC_DNS, m_dns); 
	DDX_CBString(pDX, IDC_UNKOWN, m_fwddir); 
	DDX_CBString(pDX, IDC_COPY, m_all); 
	DDX_Radio(pDX, IDC_RADIO1, m_relaycfg); 
	DDX_Text(pDX, IDC_MAXTRIES, m_maxtries); 
	DDX_Text(pDX, IDC_MAXTRIES3, m_nexttry); 
	DDX_Text(pDX, IDC_RNAME2, m_helo); 
	DDX_Text(pDX, IDC_SNAME, m_sname); 
	DDX_CBString(pDX, IDC_ERROR, m_error); 
	DDX_Text(pDX, IDC_WEBMAILPORT, m_webmailport); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(D_Service, CDialog) 
	//{{AFX_MSG_MAP(D_Service) 
	ON_BN_CLICKED(IDOK, OnOk) 
	ON_BN_CLICKED(IDC_ADD2, OnAdd2) 
	ON_BN_CLICKED(IDC_DELETE2, OnDelete2) 
	ON_LBN_SELCHANGE(IDC_AKA, OnSelchangeAka) 
	ON_LBN_DBLCLK(IDC_AKA, OnDblclkAka) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// D_Service message handlers 
     
					  
 
 
 
 
BOOL D_Service::OnInitDialog()  
{ 
	CDialog::OnInitDialog(); 
char tempstr[255]; 
char tempstr1[255]; 
char daytimeport[255]; 
char telnetport[255]; 
char rehashtime[255]; 
 
 
 
 
 
FILE *stream; 
		if( (stream  = fopen("popuser.ctl", "rt" )) != NULL ) 
		{ 
			 
			while (!feof(stream)) 
			{ 
				fgets(tempstr,255,stream); 
				if (!feof(stream)) 
				{ 
					int pusrpos = 0; 
					char seps[] = ";\r\n"; 
					char tempstr2[255]; 
					char *token; 
 
					token = strtok( tempstr, seps ); 
					while( token != NULL ) 
					{ 
					sprintf(tempstr2,"%s",token); 
 
					for (UINT x = 1;x<=strlen(tempstr2)-1;x++) tempstr2[x-1] = tempstr2[x]; 
					tempstr2[strlen(tempstr2)-2] = '\0'; 
					 
 
					if (pusrpos == 0) 
					{ 
						strupr(tempstr2); 
						mc_unknown.AddString(tempstr2); 
						mc_error.AddString(tempstr2); 
						mc_copy.AddString(tempstr2); 
 
					} 
 
					pusrpos++; 
					token = strtok( NULL, seps ); 
					} 
					 
 
					 
				} 
			} 
			fclose(stream); 
		} 
 
 
 
 
 
 
 
sprintf(daytimeport,"%s",GetReg("Software\\InetServ","DayTimePort")); //13 
sprintf(telnetport,"%s",GetReg("Software\\InetServ","TelnetPort")); //23 
sprintf(rehashtime,"%s",GetReg("Software\\InetServ","RehashTime")); //5 
 
 
m_daytimeport = daytimeport; 
m_telnetport = telnetport; 
m_rehash = rehashtime; 
 
 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","SMTPRelayCheckHost")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_ifmatch.SetCheck(1); 
} 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","SMTPHeloName")); 
m_helo = tempstr1; 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","RelaySMTPName")); 
m_sname = tempstr1; 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","NameServer")); 
m_dns = tempstr1; 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","DaytimeEnabled")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
mc_isdaytime.SetCheck(1); 
} 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","TelnetEnabled")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
mc_istelnet.SetCheck(1); 
} 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","ShowBusy")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_busy.SetCheck(1); 
} 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","ShowQuitMsg")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_rquit.SetCheck(1); 
} 
 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","RelaySMTPMaxtries")); 
m_maxtries = tempstr1; 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","RelaySMTPTryTime")); 
m_nexttry = tempstr1; 
 
 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","Postmaster")); 
m_error = tempstr1; 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","MailError")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_iserror.SetCheck(1); 
} 
 
 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","LogScreen")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_log1.SetCheck(1); 
} 
 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","LogFile")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_log2.SetCheck(1); 
} 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","LogAll")); 
if (strcmp(tempstr1,"TRUE") == 0) 
{ 
m_logall.SetCheck(1); 
} 
 
 
 
 
 
 
 
 
 
if( (stream  = fopen("aka.ctl", "rt" )) != NULL ) 
  { 
while (!feof(stream)) 
{ 
fgets(tempstr,255,stream); 
if (tempstr[strlen(tempstr)-1] == '\n') tempstr[strlen(tempstr)-1] = '\0';  
if (tempstr[strlen(tempstr)-1] == '\r') tempstr[strlen(tempstr)-1] = '\0';  
 
if (!feof(stream)) 
{ 
m_aka.AddString(tempstr); 
} 
} 
fclose(stream); 
} 
else 
{ 
MessageBox("Could not open aka.ctl!"); 
} 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","SmtpPort")); 
m_smtpport = tempstr1; 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","WebMailPort")); 
m_webmailport = tempstr1; 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","Pop3Port")); 
m_pop3port = tempstr1; 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","ForwardUser")); 
m_fwddir = tempstr1; 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","AllMailsTo")); 
m_all = tempstr1; 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","RelayType")); 
m_relaycfg = atoi(tempstr1); 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","MailEnabled")); 
if (strcmp(tempstr1,"TRUE") == 0) m_ismail.SetCheck(1); 
if (strcmp(tempstr1,"FALSE") == 0) m_ismail.SetCheck(0); 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","WebMailEnabled")); 
if (strcmp(tempstr1,"TRUE") == 0) m_iswebmail.SetCheck(1); 
if (strcmp(tempstr1,"FALSE") == 0) m_iswebmail.SetCheck(0); 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","UserForward")); 
if (strcmp(tempstr1,"TRUE") == 0) m_userfwd.SetCheck(1); 
if (strcmp(tempstr1,"FALSE") == 0) m_userfwd.SetCheck(0); 
 
sprintf(tempstr1,"%s",GetReg("Software\\InetServ","AlltoOneForward")); 
if (strcmp(tempstr1,"TRUE") == 0) m_allsend.SetCheck(1); 
if (strcmp(tempstr1,"FALSE") == 0) m_allsend.SetCheck(0); 
 
 
 
 
UpdateData(FALSE); 
 
 
	return TRUE;  // return TRUE unless you set the focus to a control 
	              // EXCEPTION: OCX Property Pages should return FALSE 
} 
 
void D_Service::OnOk()  
{ 
 
 
	 
	 
char tempstr[255]; 
UpdateData(TRUE); 
 
 
 
 
 
if(m_aka.GetCount() == 0)  
{ 
	MessageBox("You must enter at least one hostname!"); 
	return; 
} 
 
 
UpdateData(TRUE); 
sprintf(tempstr,"%s",m_smtpport); 
SetReg("Software\\InetServ","SmtpPort" ,tempstr); 
sprintf(tempstr,"%s",m_pop3port); 
SetReg("Software\\InetServ","POP3Port" ,tempstr); 
sprintf(tempstr,"%s",m_fwddir); 
SetReg("Software\\InetServ","ForwardUser" ,tempstr); 
sprintf(tempstr,"%s",m_all); 
SetReg("Software\\InetServ","AllMailsTo" ,tempstr); 
 
sprintf(tempstr,"%s",m_helo); 
SetReg("Software\\InetServ","SMTPHeloName" ,tempstr); 
sprintf(tempstr,"%s",m_dns); 
SetReg("Software\\InetServ","NameServer" ,tempstr); 
sprintf(tempstr,"%s",m_sname); 
SetReg("Software\\InetServ","RelaySMTPName" ,tempstr); 
sprintf(tempstr,"%s",m_error); 
SetReg("Software\\InetServ","Postmaster" ,tempstr); 
 
if (m_ismail.GetCheck() == 0) SetReg("Software\\InetServ","MailEnabled" ,"FALSE"); 
if (m_ismail.GetCheck() == 1) SetReg("Software\\InetServ","MailEnabled" ,"TRUE"); 
 
if (m_iswebmail.GetCheck() == 0) SetReg("Software\\InetServ","WebMailEnabled" ,"FALSE"); 
if (m_iswebmail.GetCheck() == 1) SetReg("Software\\InetServ","WebMailEnabled" ,"TRUE"); 
 
if (m_userfwd.GetCheck() == 0) SetReg("Software\\InetServ","UserForward" ,"FALSE"); 
if (m_userfwd.GetCheck() == 1) SetReg("Software\\InetServ","UserForward" ,"TRUE"); 
if (m_allsend.GetCheck() == 0) SetReg("Software\\InetServ","AlltoOneForward" ,"FALSE"); 
if (m_allsend.GetCheck() == 1) SetReg("Software\\InetServ","AlltoOneForward" ,"TRUE"); 
 
if (m_ifmatch.GetCheck() == 0) SetReg("Software\\InetServ","SMTPRelayCheckHost" ,"FALSE"); 
if (m_ifmatch.GetCheck() == 1) SetReg("Software\\InetServ","SMTPRelayCheckHost" ,"TRUE"); 
if (m_iserror.GetCheck() == 0) SetReg("Software\\InetServ","MailError" ,"FALSE"); 
if (m_iserror.GetCheck() == 1) SetReg("Software\\InetServ","MailError" ,"TRUE"); 
 
 
sprintf(tempstr,"%s",m_daytimeport); 
SetReg("Software\\InetServ","DaytimePort" ,tempstr); 
 
sprintf(tempstr,"%s",m_telnetport); 
SetReg("Software\\InetServ","TelnetPort" ,tempstr); 
 
sprintf(tempstr,"%s",m_webmailport); 
SetReg("Software\\InetServ","WebMailPort" ,tempstr); 
 
sprintf(tempstr,"%s",m_rehash); 
SetReg("Software\\InetServ","RehashTime" ,tempstr); 
 
sprintf(tempstr,"%s",m_maxtries); 
SetReg("Software\\InetServ","RelaySMTPMaxtries" ,tempstr); 
 
sprintf(tempstr,"%s",m_nexttry); 
SetReg("Software\\InetServ","RelaySMTPTryTime" ,tempstr); 
 
sprintf(tempstr,"%i",m_relaycfg); 
SetReg("Software\\InetServ","RelayType" ,tempstr); 
 
if (mc_isdaytime.GetCheck() == 0) SetReg("Software\\InetServ","DaytimeEnabled" ,"FALSE"); 
if (mc_isdaytime.GetCheck() == 1) SetReg("Software\\InetServ","DaytimeEnabled" ,"TRUE"); 
 
if (mc_istelnet.GetCheck() == 0) SetReg("Software\\InetServ","TelnetEnabled" ,"FALSE"); 
if (mc_istelnet.GetCheck() == 1) SetReg("Software\\InetServ","TelnetEnabled" ,"TRUE"); 
 
if (m_log1.GetCheck() == 1) SetReg("Software\\InetServ","LogScreen" ,"TRUE"); 
if (m_log1.GetCheck() == 0) SetReg("Software\\InetServ","LogScreen" ,"FALSE"); 
 
if (m_log2.GetCheck() == 1) SetReg("Software\\InetServ","LogFile" ,"TRUE"); 
if (m_log2.GetCheck() == 0) SetReg("Software\\InetServ","LogFile" ,"FALSE"); 
 
if (m_busy.GetCheck() == 1) SetReg("Software\\InetServ","ShowBusy" ,"TRUE"); 
if (m_busy.GetCheck() == 0) SetReg("Software\\InetServ","ShowBusy" ,"FALSE"); 
 
if (m_rquit.GetCheck() == 1) SetReg("Software\\InetServ","ShowQuitMsg" ,"TRUE"); 
if (m_rquit.GetCheck() == 0) SetReg("Software\\InetServ","ShowQuitMsg" ,"FALSE"); 
 
if (m_logall.GetCheck() == 1) SetReg("Software\\InetServ","LogAll" ,"TRUE"); 
if (m_logall.GetCheck() == 0) SetReg("Software\\InetServ","LogAll" ,"FALSE"); 
 
 
UpdateData(FALSE); 
	 
FILE *stream; 
   if( (stream  = fopen("aka.ctl", "wt" )) != NULL ) 
   { 
		for (int i = 0;i<=m_aka.GetCount() -1;i++) 
		{ 
		 m_aka.GetText(i,tempstr); 
		fprintf(stream,"%s\n",tempstr); 
		} 
		fclose(stream); 
   } 
	else 
	{ 
	MessageBox("Could not save aka.ctl!"); 
	} 
 
 
 
	CDialog::OnOK(); 
} 
 
void D_Service::OnAdd2()  
{ 
	UpdateData(TRUE); 
	m_aka.AddString(m_ip); 
	UpdateData(FALSE); 
 
	 
} 
 
void D_Service::OnDelete2()  
{ 
	if (m_aka.GetCurSel() == LB_ERR) return; 
	m_aka.DeleteString(m_aka.GetCurSel() ); 
	 
} 
 
void D_Service::OnSelchangeAka()  
{ 
UpdateData(TRUE); 
char tempstr[255]; 
m_aka.GetText(m_aka.GetCurSel(),tempstr); 
m_ip = tempstr; 
 
UpdateData(FALSE);	 
	 
} 
 
void D_Service::OnDblclkAka()  
{ 
UpdateData(TRUE); 
char tempstr[255]; 
m_aka.GetText(m_aka.GetCurSel(),tempstr); 
m_helo = tempstr; 
 
UpdateData(FALSE);	 
	 
}