SecurityPage.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. /****************************************************************/
  2. /* */
  3. /* SecurityPage.cpp */
  4. /* */
  5. /* Implementation of the CSecurityPage class. */
  6. /* This class is a part of the FTP Server. */
  7. /* */
  8. /* Programmed by LYFZ van der Meer */
  9. /* Copyright LYFZ Software Solutions 2002 */
  10. /* http://www.LYFZvandermeer.nl */
  11. /* */
  12. /* Last updated: 10 july 2002 */
  13. /* */
  14. /****************************************************************/
  15. #include "stdafx.h"
  16. #include "DBServer.h"
  17. #include "theDBServer.h"
  18. #include "SecurityPage.h"
  19. //#include "AddIPDlg.h"
  20. #include "DBServerDlg.h"
  21. extern CtheDBServer theServer;
  22. #include "InputCode.h"
  23. #include "DlgShowNetShareInfo.h"
  24. #include "CreateSmallPhoto.h"
  25. #include "PhotoDelMgr.h"
  26. #include "PhotoBackupMgr.h"
  27. #include "DlgSetIni.h"
  28. #ifdef _DEBUG
  29. #define new DEBUG_NEW
  30. #undef THIS_FILE
  31. static char THIS_FILE[] = __FILE__;
  32. #endif
  33. CSecurityPage::CSecurityPage(CWnd* pParent /*=NULL*/)
  34. : CDialogResize(CSecurityPage::IDD, pParent)
  35. {
  36. //{{AFX_DATA_INIT(CSecurityPage)
  37. m_bBlockAll = FALSE;
  38. //}}AFX_DATA_INIT
  39. }
  40. void CSecurityPage::DoDataExchange(CDataExchange* pDX)
  41. {
  42. CDialogResize::DoDataExchange(pDX);
  43. //{{AFX_DATA_MAP(CSecurityPage)
  44. DDX_Control(pDX, IDC_BLOCKEDLIST, m_BlockedList);
  45. DDX_Control(pDX, IDC_NONBLOCKEDLIST, m_NonBlockedList);
  46. DDX_Check(pDX, IDC_BLOCK_ALL, m_bBlockAll);
  47. //}}AFX_DATA_MAP
  48. }
  49. BEGIN_MESSAGE_MAP(CSecurityPage, CDialogResize)
  50. //{{AFX_MSG_MAP(CSecurityPage)
  51. ON_WM_DESTROY()
  52. ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
  53. ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
  54. ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
  55. ON_BN_CLICKED(IDC_VIEW, OnView)
  56. ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
  57. ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
  58. //}}AFX_MSG_MAP
  59. ON_BN_CLICKED(IDC_VIEW2, &CSecurityPage::OnBnClickedView2)
  60. ON_BN_CLICKED(IDC_CREATEPHOTO_BTN, &CSecurityPage::OnBnClickedCreatePhoto)
  61. ON_BN_CLICKED(IDC_BUTTON8, &CSecurityPage::OnBnClickedButton8)
  62. ON_BN_CLICKED(BTN_SYSCONFIG, &CSecurityPage::OnBnClickedSysconfig)
  63. ON_BN_CLICKED(CHECK_TECHSUPPORT, &CSecurityPage::OnBnClickedTechsupport)
  64. ON_BN_CLICKED(CHECK_ENABLECLOUND, &CSecurityPage::OnBnClickedEnableclound)
  65. ON_BN_CLICKED(CHECK_EXPORTBARCODE, &CSecurityPage::OnBnClickedExportbarcode)
  66. END_MESSAGE_MAP()
  67. BEGIN_DLGRESIZE_MAP(CSecurityPage)
  68. DLGRESIZE_CONTROL(IDC_BLOCKEDLIST, DLSZ_SIZE_X)
  69. DLGRESIZE_CONTROL(IDC_NONBLOCKEDLIST, DLSZ_SIZE_X)
  70. END_DLGRESIZE_MAP()
  71. /********************************************************************/
  72. /* */
  73. /* Function name : OnInitDialog */
  74. /* Description : Initialize dialog */
  75. /* */
  76. /********************************************************************/
  77. BOOL CSecurityPage::OnInitDialog()
  78. {
  79. CDialogResize::OnInitDialog();
  80. if(g_bReg)GetDlgItem(IDC_VIEW)->EnableWindow(0);
  81. #ifdef CHILD_VERSION
  82. GetDlgItem(IDC_BUTTON6)->ShowWindow(SW_HIDE);
  83. #endif
  84. InitResizing(FALSE, FALSE, WS_CLIPCHILDREN);
  85. m_bBlockAll = AfxGetApp()->GetProfileInt("Settings", "BlockAll", 0);
  86. GetDlgItem(IDC_NONBLOCKEDLIST)->EnableWindow(m_bBlockAll);
  87. GetDlgItem(IDC_ADD_NONBLOCK)->EnableWindow(m_bBlockAll);
  88. GetDlgItem(IDC_EDIT_NONBLOCK)->EnableWindow(m_bBlockAll);
  89. GetDlgItem(IDC_REMOVE_NONBLOCK)->EnableWindow(m_bBlockAll);
  90. GetDlgItem(IDC_BLOCKEDLIST)->EnableWindow(!m_bBlockAll);
  91. GetDlgItem(IDC_ADD_BLOCK)->EnableWindow(!m_bBlockAll);
  92. GetDlgItem(IDC_EDIT_BLOCK)->EnableWindow(!m_bBlockAll);
  93. GetDlgItem(IDC_REMOVE_BLOCK)->EnableWindow(!m_bBlockAll);
  94. GetDlgItem(IDC_STATIC1)->EnableWindow(!m_bBlockAll);
  95. GetDlgItem(IDC_Restart_Btn)->EnableWindow(FALSE);
  96. UpdateData(FALSE);
  97. CStringArray strArray;
  98. theServer.m_SecurityManager.GetBlockedList(strArray);
  99. for (int i=0; i < strArray.GetSize(); i++)
  100. {
  101. m_BlockedList.AddString(strArray[i]);
  102. }
  103. theServer.m_SecurityManager.GetNonBlockedList(strArray);
  104. for (int j=0; j < strArray.GetSize(); j++)
  105. {
  106. m_NonBlockedList.AddString(strArray[j]);
  107. }
  108. // get list of all ip addresses in use by this system (only show first two...)
  109. char szHostName[128];
  110. HOSTENT *lpHost=NULL;
  111. struct sockaddr_in sock;
  112. gethostname(szHostName, sizeof(szHostName));
  113. lpHost = gethostbyname(szHostName);
  114. if (lpHost != NULL)
  115. {
  116. for(int i=0; lpHost->h_addr_list[i] != NULL ;i++)
  117. {
  118. memcpy(&(sock.sin_addr), lpHost->h_addr_list[i], lpHost->h_length);
  119. if (i == 0)
  120. {
  121. SetDlgItemText(IDC_IPADDRESS1, inet_ntoa(sock.sin_addr));
  122. }
  123. else
  124. if (i == 1)
  125. {
  126. SetDlgItemText(IDC_IPADDRESS2, inet_ntoa(sock.sin_addr));
  127. }
  128. }
  129. }
  130. CDatabase *pdb = NULL;
  131. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  132. if ( pdb )
  133. {
  134. CString str = _T("");
  135. CRecordset rcSt(pdb);
  136. rcSt.Open(CRecordset::forwardOnly, _T("select count(*) as cot from [dbo].[user] where [account] = 'lyfzsupport'"));
  137. rcSt.GetFieldValue(_T("cot"), str);
  138. rcSt.Close();
  139. BOOL bCheckSupport = atoi(str);
  140. ((CButton*)GetDlgItem(CHECK_TECHSUPPORT))->SetCheck(bCheckSupport);
  141. ((CButton*)GetDlgItem(CHECK_ENABLECLOUND))->SetCheck(g_bEnableClound);
  142. ((CButton*)GetDlgItem(CHECK_EXPORTBARCODE))->SetCheck(g_bExportBarCode);
  143. }
  144. return TRUE;
  145. }
  146. /********************************************************************/
  147. /* */
  148. /* Function name : OnDestroy */
  149. /* Description : Dialog is about to be destroyed. */
  150. /* */
  151. /********************************************************************/
  152. void CSecurityPage::OnDestroy()
  153. {
  154. UpdateData();
  155. AfxGetApp()->WriteProfileInt("Settings", "BlockAll", m_bBlockAll);
  156. CDialogResize::OnDestroy();
  157. }
  158. BOOL g_bConvertHisAll=0;
  159. extern CDBServerDlg *g_pMainWnd;
  160. void CSecurityPage::OnButton1()
  161. {
  162. // TODO: Add your control notification handler code here
  163. if(AfxMessageBox("温馨提示:此操作可能需要1-N小时, 应该在晚间无人操作软件时进行, 继续吗?", MB_YESNO|MB_ICONSTOP)!=IDYES)return;
  164. g_bConvertHisAll=1;
  165. g_pMainWnd->CheckHistoryData();
  166. }
  167. void CSecurityPage::OnButton4()
  168. {
  169. // TODO: Add your control notification handler code here
  170. CDatabase *pdb = NULL;
  171. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  172. g_pMainWnd->MyExecuteSQL(pdb, "delete from singleincomemoney where id in(select id from singleincome where sale2type='' or sale2type is null)");
  173. g_pMainWnd->MyExecuteSQL(pdb, "delete from [singleincomemoney] where [paytype]='' or [paytype] is null");
  174. AfxMessageBox("命令已执行");
  175. }
  176. void CSecurityPage::OnButton5()
  177. {
  178. // TODO: Add your control notification handler code here
  179. CDatabase *pdb = NULL;
  180. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  181. g_pMainWnd->MyExecuteSQL(pdb, "update dindanjd set bookingdate=date where bookingdate is null");
  182. g_pMainWnd->MyExecuteSQL(pdb, "update dindanjd set bookingdate=(select time2 from dindan where dindanjd.id=dindan.id) where bookingdate is null");
  183. g_pMainWnd->MyExecuteSQL(pdb, "update dindanjd set bookingdate=(select time2 from dindan where dindanjd.id=dindan.id) where bookingdate='' ");
  184. AfxMessageBox("命令已执行");
  185. }
  186. BOOL CSecurityPage::PreTranslateMessage(MSG* pMsg)
  187. {
  188. // TODO: Add your specialized code here and/or call the base class
  189. if(pMsg->message==WM_KEYDOWN)
  190. {
  191. }
  192. return CDialogResize::PreTranslateMessage(pMsg);
  193. }
  194. void CSecurityPage::OnView()
  195. {
  196. // TODO: Add your control notification handler code here
  197. InputCode dlg;
  198. dlg.DoModal ();
  199. }
  200. void CSecurityPage::OnButton6()
  201. {
  202. // TODO: Add your control notification handler code here
  203. g_pMainWnd->RestoreHQ();
  204. }
  205. //insert into client(id,name1,name2) select id,name1,name2 FROM dindan where id not in(select [id] from [db].[dbo].[client])
  206. void CSecurityPage::OnButton7()
  207. {
  208. // TODO: Add your control notification handler code here
  209. g_pMainWnd->ManagePhoto();
  210. }
  211. void CSecurityPage::OnBnClickedView2()
  212. {
  213. // TODO: 在此添加控件通知处理程序代码
  214. CDlgShowNetShareInfo dlg;
  215. dlg.DoModal();
  216. }
  217. //生成小图按扭
  218. void CSecurityPage::OnBnClickedCreatePhoto()
  219. {
  220. if(CreateSmallPhoto::GetInstance()->IsCreating())
  221. {
  222. MessageBox(_T("生成小图数量较多请稍后再试"));
  223. return;
  224. }
  225. ((CButton*)GetDlgItem(IDC_CREATEPHOTO_BTN))->EnableWindow(FALSE);
  226. CreateSmallPhoto::GetInstance()->StartThread();
  227. ((CButton*)GetDlgItem(IDC_CREATEPHOTO_BTN))->EnableWindow(TRUE);
  228. }
  229. //管理删除相片
  230. void CSecurityPage::OnBnClickedButton8()
  231. {
  232. /*
  233. // TODO: 在此添加控件通知处理程序代码
  234. CPhotoDelMgr dlg;
  235. TCHAR szConnect[MAX_PATH] = {0};
  236. if (g_dwDBServerPort)
  237. {
  238. _stprintf_s(szConnect, _T("driver={SQL Server};Server=%s,%d;database=%s;uid=%s;pwd=%s"),
  239. g_szDBSource, g_dwDBServerPort, g_szDBName, g_szDBAccount, g_szDBPassWord);
  240. }
  241. else
  242. {
  243. _stprintf_s(szConnect, _T("driver={SQL Server};Server=%s;database=%s;uid=%s;pwd=%s"),
  244. g_szDBSource, g_szDBName, g_szDBAccount, g_szDBPassWord);
  245. }
  246. if(!dlg.OpenDb(szConnect))
  247. MessageBox(_T("读取数据失败!"));
  248. dlg.DoModal();
  249. */
  250. }
  251. void CSecurityPage::OnBnClickedSysconfig() // 系统设置;
  252. {
  253. CDlgSetIni dlg;
  254. dlg.DoModal();
  255. }
  256. void CSecurityPage::OnBnClickedTechsupport() // 启用技术支持账号;
  257. {
  258. BOOL bCheckTechSupport = FALSE;
  259. bCheckTechSupport = ((CButton*)(GetDlgItem(CHECK_TECHSUPPORT)))->GetCheck();
  260. CTime ct = CTime::GetCurrentTime();
  261. CString strSQL = _T("");
  262. CDatabase *pdb = NULL;
  263. ODBCConnGuard ConnGuard(pdb, -1, 3000);
  264. if ( pdb == NULL )
  265. return;
  266. if ( bCheckTechSupport == TRUE )
  267. {// 启用账号;
  268. strSQL = _T("INSERT [user] ([account],[name],[psw],[rights],[rights2],[discount],[discount2]) VALUES "
  269. "( 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')");
  270. pdb->ExecuteSQL(strSQL);
  271. strSQL.Format(_T("INSERT [log] ([date],[datetime],[content]) VALUES ( '%s', '%s', '%s')"),
  272. ct.Format(_T("%Y-%m-%d")),
  273. ct.Format(_T("%Y-%m-%d %H:%M:%S")), _T("开启技术支持账号!") );
  274. pdb->ExecuteSQL(strSQL);
  275. }
  276. else
  277. {// 删除账号;
  278. strSQL = _T("delete from [user] where [account] = 'lyfzsupport' ");
  279. pdb->ExecuteSQL(strSQL);
  280. strSQL.Format(_T("INSERT [log] ([date],[datetime],[content]) VALUES ( '%s', '%s', '%s')"),
  281. ct.Format(_T("%Y-%m-%d")),
  282. ct.Format(_T("%Y-%m-%d %H:%M:%S")), _T("关闭技术支持账号!") );
  283. pdb->ExecuteSQL(strSQL);
  284. }
  285. }
  286. void CSecurityPage::OnBnClickedEnableclound()
  287. {
  288. UpdateData();
  289. g_bEnableClound = ((CButton*)(GetDlgItem(CHECK_ENABLECLOUND)))->GetCheck();
  290. TCHAR szFile[MAX_PATH] = {0};
  291. _stprintf_s(szFile, _T("%s\\ServiceInfo.ini"), g_ModulePath);
  292. WritePrivateProfileString(_T("SystemInfo"), _T("EnableClound"), g_bEnableClound ? _T("1") : _T("0"), szFile);
  293. }
  294. void CSecurityPage::OnBnClickedExportbarcode()
  295. {
  296. UpdateData();
  297. g_bExportBarCode = ((CButton*)(GetDlgItem(CHECK_EXPORTBARCODE)))->GetCheck();
  298. TCHAR szFile[MAX_PATH] = {0};
  299. _stprintf_s(szFile, _T("%s\\ServiceInfo.ini"), g_ModulePath);
  300. WritePrivateProfileString(_T("SystemInfo"), _T("ExportBarCode"), g_bExportBarCode ? _T("1") : _T("0"), szFile);
  301. }