123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418 |
- /****************************************************************/
- /* */
- /* SecurityPage.cpp */
- /* */
- /* Implementation of the CSecurityPage class. */
- /* This class is a part of the FTP Server. */
- /* */
- /* Programmed by LYFZ van der Meer */
- /* Copyright LYFZ Software Solutions 2002 */
- /* http://www.LYFZvandermeer.nl */
- /* */
- /* Last updated: 10 july 2002 */
- /* */
- /****************************************************************/
- #include "stdafx.h"
- #include "DBServer.h"
- #include "theDBServer.h"
- #include "SecurityPage.h"
- //#include "AddIPDlg.h"
- #include "DBServerDlg.h"
- extern CtheDBServer theServer;
- #include "InputCode.h"
- #include "DlgShowNetShareInfo.h"
- #include "CreateSmallPhoto.h"
- #include "PhotoDelMgr.h"
- #include "PhotoBackupMgr.h"
- #include "DlgSetIni.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- CSecurityPage::CSecurityPage(CWnd* pParent /*=NULL*/)
- : CDialogResize(CSecurityPage::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CSecurityPage)
- m_bBlockAll = FALSE;
- //}}AFX_DATA_INIT
- }
- void CSecurityPage::DoDataExchange(CDataExchange* pDX)
- {
- CDialogResize::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CSecurityPage)
- DDX_Control(pDX, IDC_BLOCKEDLIST, m_BlockedList);
- DDX_Control(pDX, IDC_NONBLOCKEDLIST, m_NonBlockedList);
- DDX_Check(pDX, IDC_BLOCK_ALL, m_bBlockAll);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CSecurityPage, CDialogResize)
- //{{AFX_MSG_MAP(CSecurityPage)
- ON_WM_DESTROY()
- ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
- ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
- ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
- ON_BN_CLICKED(IDC_VIEW, OnView)
- ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
- ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
- //}}AFX_MSG_MAP
- ON_BN_CLICKED(IDC_VIEW2, &CSecurityPage::OnBnClickedView2)
- ON_BN_CLICKED(IDC_CREATEPHOTO_BTN, &CSecurityPage::OnBnClickedCreatePhoto)
- ON_BN_CLICKED(IDC_BUTTON8, &CSecurityPage::OnBnClickedButton8)
- ON_BN_CLICKED(BTN_SYSCONFIG, &CSecurityPage::OnBnClickedSysconfig)
- ON_BN_CLICKED(CHECK_TECHSUPPORT, &CSecurityPage::OnBnClickedTechsupport)
- ON_BN_CLICKED(CHECK_ENABLECLOUND, &CSecurityPage::OnBnClickedEnableclound)
- ON_BN_CLICKED(CHECK_EXPORTBARCODE, &CSecurityPage::OnBnClickedExportbarcode)
- ON_BN_CLICKED(CHECK_CHECKDB, &CSecurityPage::OnBnClickedCheckdb)
- ON_EN_CHANGE(ET_CHECKDBTIMEOUT, &CSecurityPage::OnEnChangeCheckdbtimeout)
- END_MESSAGE_MAP()
- BEGIN_DLGRESIZE_MAP(CSecurityPage)
- DLGRESIZE_CONTROL(IDC_BLOCKEDLIST, DLSZ_SIZE_X)
- DLGRESIZE_CONTROL(IDC_NONBLOCKEDLIST, DLSZ_SIZE_X)
- END_DLGRESIZE_MAP()
- /********************************************************************/
- /* */
- /* Function name : OnInitDialog */
- /* Description : Initialize dialog */
- /* */
- /********************************************************************/
- BOOL CSecurityPage::OnInitDialog()
- {
- CDialogResize::OnInitDialog();
- if(g_bReg)GetDlgItem(IDC_VIEW)->EnableWindow(0);
- #ifdef CHILD_VERSION
- GetDlgItem(IDC_BUTTON6)->ShowWindow(SW_HIDE);
- #endif
- InitResizing(FALSE, FALSE, WS_CLIPCHILDREN);
- m_bBlockAll = AfxGetApp()->GetProfileInt("Settings", "BlockAll", 0);
- GetDlgItem(IDC_NONBLOCKEDLIST)->EnableWindow(m_bBlockAll);
- GetDlgItem(IDC_ADD_NONBLOCK)->EnableWindow(m_bBlockAll);
- GetDlgItem(IDC_EDIT_NONBLOCK)->EnableWindow(m_bBlockAll);
- GetDlgItem(IDC_REMOVE_NONBLOCK)->EnableWindow(m_bBlockAll);
- GetDlgItem(IDC_BLOCKEDLIST)->EnableWindow(!m_bBlockAll);
- GetDlgItem(IDC_ADD_BLOCK)->EnableWindow(!m_bBlockAll);
- GetDlgItem(IDC_EDIT_BLOCK)->EnableWindow(!m_bBlockAll);
- GetDlgItem(IDC_REMOVE_BLOCK)->EnableWindow(!m_bBlockAll);
- GetDlgItem(IDC_STATIC1)->EnableWindow(!m_bBlockAll);
- GetDlgItem(IDC_Restart_Btn)->EnableWindow(FALSE);
- UpdateData(FALSE);
- CStringArray strArray;
- theServer.m_SecurityManager.GetBlockedList(strArray);
- for (int i=0; i < strArray.GetSize(); i++)
- {
- m_BlockedList.AddString(strArray[i]);
- }
- theServer.m_SecurityManager.GetNonBlockedList(strArray);
- for (int j=0; j < strArray.GetSize(); j++)
- {
- m_NonBlockedList.AddString(strArray[j]);
- }
- // get list of all ip addresses in use by this system (only show first two...)
- char szHostName[128];
- HOSTENT *lpHost=NULL;
- struct sockaddr_in sock;
- gethostname(szHostName, sizeof(szHostName));
- lpHost = gethostbyname(szHostName);
- if (lpHost != NULL)
- {
- for(int i=0; lpHost->h_addr_list[i] != NULL ;i++)
- {
- memcpy(&(sock.sin_addr), lpHost->h_addr_list[i], lpHost->h_length);
- if (i == 0)
- {
- SetDlgItemText(IDC_IPADDRESS1, inet_ntoa(sock.sin_addr));
- }
- else
- if (i == 1)
- {
- SetDlgItemText(IDC_IPADDRESS2, inet_ntoa(sock.sin_addr));
- }
- }
- }
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if ( pdb )
- {
- CString str = _T("");
- CRecordset rcSt(pdb);
- rcSt.Open(CRecordset::forwardOnly, _T("select count(*) as cot from [dbo].[user] where [account] = 'lyfzsupport'"));
- rcSt.GetFieldValue(_T("cot"), str);
- rcSt.Close();
- BOOL bCheckSupport = atoi(str);
- ((CButton*)GetDlgItem(CHECK_TECHSUPPORT))->SetCheck(bCheckSupport);
- ((CButton*)GetDlgItem(CHECK_ENABLECLOUND))->SetCheck(g_bEnableClound);
- ((CButton*)GetDlgItem(CHECK_EXPORTBARCODE))->SetCheck(g_bExportBarCode);
- }
- if ( g_bCheckdb )
- {
- ((CButton*)GetDlgItem(CHECK_CHECKDB))->SetCheck(TRUE);
- GetDlgItem(ET_CHECKDBTIMEOUT)->EnableWindow(TRUE);
- SetDlgItemInt(ET_CHECKDBTIMEOUT, g_dwCheckdbTimeOut);
- }
- else
- {
- ((CButton*)GetDlgItem(CHECK_CHECKDB))->SetCheck(FALSE);
- GetDlgItem(ET_CHECKDBTIMEOUT)->EnableWindow(FALSE);
- SetDlgItemInt(ET_CHECKDBTIMEOUT, 0);
- }
- return TRUE;
- }
- /********************************************************************/
- /* */
- /* Function name : OnDestroy */
- /* Description : Dialog is about to be destroyed. */
- /* */
- /********************************************************************/
- void CSecurityPage::OnDestroy()
- {
- UpdateData();
- AfxGetApp()->WriteProfileInt("Settings", "BlockAll", m_bBlockAll);
- CDialogResize::OnDestroy();
- }
- BOOL g_bConvertHisAll=0;
- extern CDBServerDlg *g_pMainWnd;
- void CSecurityPage::OnButton1()
- {
- // TODO: Add your control notification handler code here
- if(AfxMessageBox("温馨提示:此操作可能需要1-N小时, 应该在晚间无人操作软件时进行, 继续吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
- g_bConvertHisAll=1;
- g_pMainWnd->CheckHistoryData();
- }
- void CSecurityPage::OnButton4()
- {
- // TODO: Add your control notification handler code here
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- g_pMainWnd->MyExecuteSQL(pdb, "delete from singleincomemoney where id in(select id from singleincome where sale2type='' or sale2type is null)");
- g_pMainWnd->MyExecuteSQL(pdb, "delete from [singleincomemoney] where [paytype]='' or [paytype] is null");
- AfxMessageBox("命令已执行");
- }
- void CSecurityPage::OnButton5()
- {
- // TODO: Add your control notification handler code here
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- g_pMainWnd->MyExecuteSQL(pdb, "update dindanjd set bookingdate=date where bookingdate is null");
- g_pMainWnd->MyExecuteSQL(pdb, "update dindanjd set bookingdate=(select time2 from dindan where dindanjd.id=dindan.id) where bookingdate is null");
- g_pMainWnd->MyExecuteSQL(pdb, "update dindanjd set bookingdate=(select time2 from dindan where dindanjd.id=dindan.id) where bookingdate='' ");
- AfxMessageBox("命令已执行");
- }
- BOOL CSecurityPage::PreTranslateMessage(MSG* pMsg)
- {
- // TODO: Add your specialized code here and/or call the base class
- if(pMsg->message==WM_KEYDOWN)
- {
- }
- return CDialogResize::PreTranslateMessage(pMsg);
- }
- void CSecurityPage::OnView()
- {
- // TODO: Add your control notification handler code here
- InputCode dlg;
- dlg.DoModal ();
- }
- void CSecurityPage::OnButton6()
- {
- // TODO: Add your control notification handler code here
- g_pMainWnd->RestoreHQ();
- }
- //insert into client(id,name1,name2) select id,name1,name2 FROM dindan where id not in(select [id] from [db].[dbo].[client])
- void CSecurityPage::OnButton7()
- {
- // TODO: Add your control notification handler code here
- g_pMainWnd->ManagePhoto();
- }
- void CSecurityPage::OnBnClickedView2()
- {
- // TODO: 在此添加控件通知处理程序代码
- CDlgShowNetShareInfo dlg;
- dlg.DoModal();
- }
- //生成小图按扭
- void CSecurityPage::OnBnClickedCreatePhoto()
- {
- if(CreateSmallPhoto::GetInstance()->IsCreating())
- {
- MessageBox(_T("生成小图数量较多请稍后再试"));
- return;
- }
- ((CButton*)GetDlgItem(IDC_CREATEPHOTO_BTN))->EnableWindow(FALSE);
- CreateSmallPhoto::GetInstance()->StartThread();
- ((CButton*)GetDlgItem(IDC_CREATEPHOTO_BTN))->EnableWindow(TRUE);
- }
- //管理删除相片
- void CSecurityPage::OnBnClickedButton8()
- {
- /*
- // TODO: 在此添加控件通知处理程序代码
- CPhotoDelMgr dlg;
- TCHAR szConnect[MAX_PATH] = {0};
- if (g_dwDBServerPort)
- {
- _stprintf_s(szConnect, _T("driver={SQL Server};Server=%s,%d;database=%s;uid=%s;pwd=%s"),
- g_szDBSource, g_dwDBServerPort, g_szDBName, g_szDBAccount, g_szDBPassWord);
- }
- else
- {
- _stprintf_s(szConnect, _T("driver={SQL Server};Server=%s;database=%s;uid=%s;pwd=%s"),
- g_szDBSource, g_szDBName, g_szDBAccount, g_szDBPassWord);
- }
- if(!dlg.OpenDb(szConnect))
- MessageBox(_T("读取数据失败!"));
- dlg.DoModal();
- */
- }
- void CSecurityPage::OnBnClickedSysconfig() // 系统设置;
- {
- CDlgSetIni dlg;
- dlg.DoModal();
- }
- void CSecurityPage::OnBnClickedTechsupport() // 启用技术支持账号;
- {
- BOOL bCheckTechSupport = FALSE;
- bCheckTechSupport = ((CButton*)(GetDlgItem(CHECK_TECHSUPPORT)))->GetCheck();
- CTime ct = CTime::GetCurrentTime();
- CString strSQL = _T("");
- CDatabase *pdb = NULL;
- ODBCConnGuard ConnGuard(pdb, -1, 3000);
- if ( pdb == NULL )
- return;
- if ( bCheckTechSupport == TRUE )
- {// 启用账号;
- strSQL = _T("INSERT [user] ([account],[name],[psw],[rights],[rights2],[discount],[discount2]) VALUES "
- "( N'lyfzsupport',N'技术支持',N'918d07f6473be88fd1a59b9bb24b3c7d',N'11111111111111111111111111111111111111111111111111111111111111',N'*门市流程;1;开单;拍照;修片;选片;精修;设计;刻盘;相片冲印;发片/取件;数码安排;*财务管理;1;订单收款;其它二销;现金支出;其它收入;提成比例;计件提成;工资管理;员工奖罚;*统计查询;1;日财务表;月财务表;年财务表;年财务图表;订单图表;成本核算;工资报表;员工业绩;员工资料;员工奖惩;客户区域;* 短信管理 ;1;短信群发;短信发送;流程短信;员工短信;发送记录;短信设置;*会员管理;1;金卡会员;现金子卡;金卡图表;积分短信;蓝钻会员;转介绍返现;转介绍图表;积分设置;*礼服管理;1;礼服录入;礼服查看;礼服出租;撞期预警;礼服图片;*库存管理;1;入库单;出库单;库存查询;商品图表;固定资产管理;*客户管理;1;订单客户;老客户;意向客户;客户流失;客户来源;*来电精灵;1;客户来电;拨出电话;未接来电;*员工考勤;1;考勤记录;月统计;时间设置;排班设置;*客户服务;1;满意度;满意度汇总;*微信公众号;1;公众号设置;模板消息设置;推送记录;',N'0.0',N'0.0')");
- pdb->ExecuteSQL(strSQL);
-
- strSQL.Format(_T("INSERT [log] ([date],[datetime],[content]) VALUES ( '%s', '%s', '%s')"),
- ct.Format(_T("%Y-%m-%d")),
- ct.Format(_T("%Y-%m-%d %H:%M:%S")), _T("开启技术支持账号!") );
- pdb->ExecuteSQL(strSQL);
- }
- else
- {// 删除账号;
- strSQL = _T("delete from [user] where [account] = 'lyfzsupport' ");
- pdb->ExecuteSQL(strSQL);
- strSQL.Format(_T("INSERT [log] ([date],[datetime],[content]) VALUES ( '%s', '%s', '%s')"),
- ct.Format(_T("%Y-%m-%d")),
- ct.Format(_T("%Y-%m-%d %H:%M:%S")), _T("关闭技术支持账号!") );
- pdb->ExecuteSQL(strSQL);
- }
- }
- void CSecurityPage::OnBnClickedEnableclound()
- {
- UpdateData();
- g_bEnableClound = ((CButton*)(GetDlgItem(CHECK_ENABLECLOUND)))->GetCheck();
- TCHAR szFile[MAX_PATH] = {0};
- _stprintf_s(szFile, _T("%s\\ServiceInfo.ini"), g_ModulePath);
- WritePrivateProfileString(_T("SystemInfo"), _T("EnableClound"), g_bEnableClound ? _T("1") : _T("0"), szFile);
- }
- void CSecurityPage::OnBnClickedExportbarcode()
- {
- UpdateData();
- g_bExportBarCode = ((CButton*)(GetDlgItem(CHECK_EXPORTBARCODE)))->GetCheck();
- TCHAR szFile[MAX_PATH] = {0};
- _stprintf_s(szFile, _T("%s\\ServiceInfo.ini"), g_ModulePath);
- WritePrivateProfileString(_T("SystemInfo"), _T("ExportBarCode"), g_bExportBarCode ? _T("1") : _T("0"), szFile);
- }
- void CSecurityPage::OnBnClickedCheckdb()
- {
- // TODO: 在此添加控件通知处理程序代码
- UpdateData();
- g_bCheckdb = ((CButton*)GetDlgItem(CHECK_CHECKDB))->GetCheck();
- TCHAR szFile[MAX_PATH] = {0};
- _stprintf_s(szFile, _T("%s\\ServiceInfo.ini"), g_ModulePath);
- if ( g_bCheckdb )
- {
- GetDlgItem(ET_CHECKDBTIMEOUT)->EnableWindow(TRUE);
- SetDlgItemInt(ET_CHECKDBTIMEOUT,30);
- WritePrivateProfileString(_T("SystemInfo"), _T("CheckdbTimeOut"), _T("30"), szFile);
- HANDLE hThead = CreateThread(NULL, 0, CheckdbThread, NULL, 0, NULL);
- if ( hThead )
- CloseHandle(hThead);
- }
- else
- {
- g_bIsCatalogDamage = FALSE;
- GetDlgItem(ET_CHECKDBTIMEOUT)->EnableWindow(FALSE);
- SetDlgItemInt(ET_CHECKDBTIMEOUT,0);
- WritePrivateProfileString(_T("SystemInfo"), _T("CheckdbTimeOut"), _T("0"), szFile);
- }
- WritePrivateProfileString(_T("SystemInfo"), _T("Checkdb"), g_bCheckdb ? _T("1") : _T("0"), szFile);
- }
- void CSecurityPage::OnEnChangeCheckdbtimeout()
- {
- // TODO: 如果该控件是 RICHEDIT 控件,它将不
- // 发送此通知,除非重写 CDialogResize::OnInitDialog()
- // 函数并调用 CRichEditCtrl().SetEventMask(),
- // 同时将 ENM_CHANGE 标志“或”运算到掩码中。
- g_dwCheckdbTimeOut = GetDlgItemInt(ET_CHECKDBTIMEOUT);
- g_dwCheckdbTimeOut = g_dwCheckdbTimeOut ? g_dwCheckdbTimeOut : 1;
- TCHAR szFile[MAX_PATH] = {0};
- _stprintf_s(szFile, _T("%s\\ServiceInfo.ini"), g_ModulePath);
- TCHAR szCheckTimeout[10] = {0};
- _itoa_s(g_dwCheckdbTimeOut, szCheckTimeout, 10);
- WritePrivateProfileString(_T("SystemInfo"), _T("CheckdbTimeOut"), szCheckTimeout, szFile);
- HANDLE hThead = CreateThread(NULL, 0, CheckdbThread, NULL, 0, NULL);
- if ( hThead )
- CloseHandle(hThead);
- // TODO: 在此添加控件通知处理程序代码
- }
|