Login3.cpp 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982
  1. // Login3.cpp: implementation of the Login3 class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "YLGL.h"
  6. #include "Login3.h"
  7. #include "DigitalWorkSet2.h"
  8. #include "ShowMsg.h"
  9. #include "ShowBakState.h"
  10. #include "CharacterConvert.h"
  11. #include "SQLite3Interface.h"
  12. #include "NetShareInfo.h"
  13. #ifdef _DEBUG
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #define new DEBUG_NEW
  17. #endif
  18. //////////////////////////////////////////////////////////////////////
  19. // Construction/Destruction
  20. //////////////////////////////////////////////////////////////////////
  21. //extern void WriteClientLog(CString str); // Jeff写客户端日志;
  22. Login3::Login3()
  23. {
  24. m_psw = _T("");
  25. m_bsave = FALSE;
  26. m_account = _T("");
  27. g_pMainWnd->GetSkin();
  28. }
  29. Login3::~Login3()
  30. {
  31. }
  32. void Login3::OnFSCommand(LPCTSTR command, LPCTSTR args)
  33. {
  34. }
  35. // ***********************************************最严重的漏洞后门*********************************************************************//
  36. // Jeff.
  37. // remark by Jeff. 2014.09.04
  38. // 用户登录的验证信息,不可放在客户里做验证。
  39. // 同时,客户端在未验证自身身份时,禁止读取数据库里的用户表;
  40. // 以下代码,有严重的后门可供侵入。
  41. //
  42. // 新建登录处理过程:
  43. // int LoginVerify(__in const TCHAR *pAccount,__in const int &nAccountLen, __in const TCHAR *pPassWord, __in const int &nPassWordLen);
  44. //
  45. // 同理,在未登录前,客户端不能读写数据库的任何信息,即需要对welcome对话框进行处理.
  46. //
  47. // ***********************************************************************************************************************************//
  48. void Login3::Init()
  49. {
  50. m_combobox.Create(WS_VSCROLL | WS_CHILD | CBS_DROPDOWN, m_rcarray.ElementAt(2), this, 100);
  51. m_combobox.ShowWindow(SW_SHOW);
  52. // m_combobox.SetFocus(); // Add by Jeff //无效;
  53. CRect rc = m_rcarray.ElementAt(2);
  54. rc.bottom += 200;
  55. m_combobox.MoveWindow(rc);
  56. m_combobox.GetWindowRect(rc);
  57. int hei = rc.Height();
  58. rc = m_rcarray.ElementAt(3);
  59. rc.bottom = rc.top + hei + 5;
  60. m_edit.Create(ES_AUTOHSCROLL | WS_CHILD | ES_LEFT | WS_BORDER | ES_PASSWORD | WS_EX_WINDOWEDGE, rc, this, 200);
  61. m_edit.ShowWindow(SW_SHOW);
  62. rc = m_rcarray.ElementAt(4);
  63. rc.bottom = rc.top + 13;
  64. rc.right = rc.left + 13;
  65. m_button.Create("", WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX | BS_FLAT, rc, this, 300);
  66. tpFont.CreatePointFont(180, _T("黑体"));
  67. m_edit.SetFont(&tpFont);
  68. m_combobox.SetFont(&tpFont);
  69. /////////////////////////
  70. #if JEFF_TEST_ON
  71. g_sendhead.bsql = 0;
  72. g_sendhead.code[0] = 24; // Jeff.version表;版本信息;
  73. g_sendhead.code[1] = 29; // Jeff.path表;路径
  74. g_sendhead.code[2] = 5; // Jeff.renyuan表;人员表;
  75. g_sendhead.code[3] = 1; // Jeff.historydb表;历史数据库;
  76. g_sendhead.code[4] = 171; // Jeff.childmsg表;其实就是"资料与相片备份状态"
  77. if (g_branchname == "")
  78. {
  79. g_sendhead.code[5] = 152; // Jeff.不读任何表,读brachinfo.dat文件里的数据;
  80. g_sendhead.tabcount = 6;
  81. }
  82. else
  83. g_sendhead.tabcount = 5;
  84. int g_nYearposTemp = g_nYearpos;
  85. g_nYearpos = -1;
  86. g_pMainWnd->ProcessChatMessageRequest2(";;;;;");
  87. g_nYearpos = g_nYearposTemp;
  88. if (g_bSendOK == 0)
  89. {
  90. CDialog::OnCancel();
  91. return;
  92. }
  93. CArray<CStringArray, CStringArray>patharray;
  94. CArray<CStringArray, CStringArray>userarray;
  95. if (g_branchname == "")
  96. DataToArray( &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray, &g_brancharray);
  97. else
  98. DataToArray( &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray);
  99. #else
  100. g_sendhead.bsql = 0;
  101. g_sendhead.code[0] = 23; // Jeff.accountview视图;用户
  102. g_sendhead.code[1] = 24; // Jeff.version表;版本信息;
  103. g_sendhead.code[2] = 29; // Jeff.path表;路径
  104. g_sendhead.code[3] = 5; // Jeff.renyuan表;人员表;
  105. g_sendhead.code[4] = 1; // Jeff.historydb表;历史数据库;
  106. g_sendhead.code[5] = 171; // Jeff.childmsg表;其实就是"资料与相片备份状态"
  107. if (g_branchname == "")
  108. {
  109. g_sendhead.code[6] = 152; // Jeff.不读任何表,读brachinfo.dat文件里的数据;
  110. g_sendhead.tabcount = 7;
  111. }
  112. else
  113. g_sendhead.tabcount = 6;
  114. int g_nYearposTemp = g_nYearpos;
  115. g_nYearpos = -1;
  116. g_pMainWnd->ProcessChatMessageRequest2("[dimission]<>'离职' or [dimission] is null;;;;;;");
  117. g_nYearpos = g_nYearposTemp;
  118. if (g_bSendOK == 0)
  119. {
  120. CDialog::OnCancel();
  121. return;
  122. }
  123. CArray<CStringArray, CStringArray>patharray;
  124. CArray<CStringArray, CStringArray>userarray;
  125. if (g_branchname == "")
  126. DataToArray(&m_ArrayOfAccountInfo, &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray, &g_brancharray);
  127. else
  128. DataToArray(&m_ArrayOfAccountInfo, &g_cominfoarray, &patharray, &userarray, &g_hisyeararray, &g_bakstatearray);
  129. #endif
  130. // 149 = [version].[original] 是否使用相片原名导入;
  131. g_bOriginal = atoi(g_cominfoarray.ElementAt(0).ElementAt(149));
  132. // 获取N8的配置信息: N8用户目录、N8数据目录、N8产品目录、N8服务器IP地址;
  133. sprintf(g_szN8ViewUserDir, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(152));
  134. sprintf(g_szN8ViewStsDir, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(153));
  135. sprintf(g_szN8ViewProductDir, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(154));
  136. sprintf(g_szN8SvIP, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(155));
  137. if (g_branchname == "")
  138. {
  139. g_cominfoarraylocal.SetSize(1, 1);
  140. g_cominfoarraylocal.ElementAt(0).Copy(g_cominfoarray.ElementAt(0));
  141. }
  142. CheckBakState(); // Jeff.启用客户端时,先检测"资料与照片备份状态"
  143. if (g_branchname == "")
  144. {
  145. g_domain = patharray.ElementAt(0).ElementAt(0);
  146. if (g_domain.Find(".ly.com") == -1)g_domain.Empty();
  147. g_bSaveUploadTask1 = atoi(g_cominfoarray.ElementAt(0).ElementAt(67));
  148. g_bSaveUploadTask2 = atoi(g_cominfoarray.ElementAt(0).ElementAt(68));
  149. g_bSaveUploadTask3 = atoi(g_cominfoarray.ElementAt(0).ElementAt(69));
  150. g_bSaveUploadTask4 = atoi(g_cominfoarray.ElementAt(0).ElementAt(70));
  151. }
  152. BOOL bHide = atoi(g_cominfoarray.ElementAt(0).ElementAt(58));
  153. AfxGetApp()->WriteProfileInt(LYFZVERSION, "hidewindow2", bHide);
  154. g_userarray.SetSize(userarray.GetSize(), 1);
  155. int count = 0;
  156. for (int ii = 0; ii < userarray.GetSize(); ii++)
  157. {
  158. if (userarray.ElementAt(ii).ElementAt(10) == "在职")
  159. g_userarray.ElementAt(count++).Copy(userarray.ElementAt(ii));
  160. }
  161. g_userarray.SetSize(count, 1);
  162. #ifdef TESTHG
  163. if (0)
  164. #else
  165. // 设置版本;
  166. CString strVersion;
  167. strVersion.Format("%02d%02d", g_arrFileVersion[2], g_arrFileVersion[3]);
  168. if (g_cominfoarray.ElementAt(0).ElementAt(0) != strVersion)
  169. #endif
  170. {
  171. AfxMessageBox("您必须更新软件才能继续使用, 请与系统管理员联系!", MB_ICONINFORMATION);
  172. CDialog::OnCancel();
  173. g_pMainWnd->AutoUpdate();
  174. return;
  175. }
  176. #ifndef ENTERPRISE_VERSION
  177. {
  178. #ifndef CHILD_VERSION
  179. #ifdef BASIC_VERSION
  180. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="0")
  181. {
  182. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  183. exit(0);return;
  184. }
  185. #else
  186. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="1")
  187. {
  188. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  189. exit(0);return;
  190. }
  191. #endif
  192. #else
  193. #ifdef BASIC_VERSION
  194. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="2")
  195. {
  196. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  197. exit(0);return;
  198. }
  199. #else
  200. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="3")
  201. {
  202. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  203. exit(0);return;
  204. }
  205. #endif
  206. #endif
  207. }
  208. #else
  209. {
  210. #ifndef CHILD_VERSION
  211. #ifdef BASIC_VERSION
  212. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="4")
  213. {
  214. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  215. exit(0);return ;
  216. }
  217. #else
  218. if(g_cominfoarray.ElementAt(0).ElementAt(46)!="5")
  219. {
  220. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  221. exit(0);return ;
  222. }
  223. #endif
  224. #else
  225. #ifdef BASIC_VERSION
  226. if(g_cominfoarray.ElementAt(0).ElementAt( 46)!="6")
  227. {
  228. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  229. exit(0);return ;
  230. }
  231. #else
  232. if (g_cominfoarray.ElementAt(0).ElementAt(46) != "7")
  233. {
  234. AfxMessageBox("软件客户端与服务器版本不匹配, 请与系统管理员联系!", MB_ICONSTOP);
  235. exit(0); return;
  236. }
  237. #endif
  238. #endif
  239. }
  240. #endif
  241. g_title = g_cominfoarray.ElementAt(0).ElementAt(10);
  242. WriteTitle(g_cominfoarray.ElementAt(0).ElementAt(10));
  243. g_date = g_cominfoarray.ElementAt(0).ElementAt(1);
  244. if (g_hisyeararray.GetSize())
  245. {
  246. g_pMainWnd->AddHistoryMenu(&g_hisyeararray);
  247. }
  248. if (g_brancharray.GetSize() && g_branchname == "")
  249. {
  250. // WriteClientLog("启动集团版菜单");
  251. g_pMainWnd->AddBranchMenu(&g_brancharray); // 添加操作分店菜单;
  252. }
  253. if (g_branchname == "")
  254. {
  255. #if USE_SHARE_FLORD
  256. // 清空数组,并重新获取NetShareInfo表;
  257. g_aryOfSharePathInfo.RemoveAll();
  258. g_pMainWnd->GetSharePathInfo();
  259. if( CNetShareInfo::GetInstance() )
  260. {
  261. CNetShareInfo::GetInstance()->Initialize(g_domain, g_serverbak, &g_aryOfSharePathInfo);
  262. }
  263. #endif
  264. #ifdef USE_KERNEL_DLL
  265. if (g_pIMGProcess)
  266. g_pIMGProcess->SetEnvInfoEx(g_server, g_domain, &g_cominfoarray, &g_brancharray, &g_aryOfSharePathInfo);
  267. //////////////////////////////////////////////////////////////////////////
  268. // 2015.11.03 设置回访本店的保留信息;
  269. INT nCount = g_cominfoarray.GetSize();
  270. for ( INT i = 0; i < nCount; i++ )
  271. {
  272. sprintf(g_ThisShopVersion.szVersion, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(0));
  273. sprintf(g_ThisShopVersion.szbakServer1, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(20));
  274. sprintf(g_ThisShopVersion.szbakServer2, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(21));
  275. sprintf(g_ThisShopVersion.szbakServer3, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(22));
  276. sprintf(g_ThisShopVersion.szbakServer4, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(23));
  277. sprintf(g_ThisShopVersion.szbakServer5, _T("%s"), g_cominfoarray.ElementAt(0).ElementAt(24));
  278. g_ThisShopVersion.bUpLoadCheck1 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(67));
  279. g_ThisShopVersion.bUpLoadCheck2 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(68));
  280. g_ThisShopVersion.bUpLoadCheck3 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(69));
  281. g_ThisShopVersion.bUpLoadCheck4 = _ttoi(g_cominfoarray.ElementAt(0).ElementAt(70));
  282. g_ThisShopVersion.strZiptype1 = g_cominfoarray.ElementAt(0).ElementAt(78);
  283. g_ThisShopVersion.strZiptype2 = g_cominfoarray.ElementAt(0).ElementAt(79);
  284. g_ThisShopVersion.strZiptype3 = g_cominfoarray.ElementAt(0).ElementAt(80);
  285. g_ThisShopVersion.strZiptype4 = g_cominfoarray.ElementAt(0).ElementAt(81);
  286. g_ThisShopVersion.strUploadRule = g_cominfoarray.ElementAt(0).ElementAt(116);
  287. }
  288. //////////////////////////////////////////////////////////////////////////
  289. #endif
  290. CString szFolderName[] =
  291. {
  292. _T("\\客户原片(管理软件)$"),
  293. _T("\\修好的片(管理软件)$"),
  294. _T("\\设计好的片(管理软件)$"),
  295. _T("\\精修好的片(管理软件)$"),
  296. _T("\\礼服图片(管理软件)$"),
  297. _T("\\电话录音(管理软件)$"),
  298. _T("\\客户原片(管理软件)$\\效果图")
  299. };
  300. CString strHead = _T("");
  301. CString strServerName = _T("");
  302. if (g_server == "127.0.0.1")
  303. {
  304. g_sendhead.bsql = 0;
  305. g_sendhead.code[0] = 63;
  306. g_sendhead.tabcount = 1;
  307. g_pMainWnd->ProcessChatMessageRequest2(1);
  308. if (g_bSendOK == 0)
  309. {
  310. CDialog::OnCancel();
  311. return;
  312. }
  313. DataToArray(&g_List1array);
  314. strHead = _T("");
  315. strServerName = g_List1array.ElementAt(0).ElementAt(0);
  316. }
  317. else if (patharray.GetSize())
  318. {
  319. strHead = _T("\\\\");
  320. strServerName = g_serverbak;
  321. }
  322. g_path1bak = g_path1 = strHead + strServerName + szFolderName[0];
  323. g_path2bak = g_path2 = strHead + strServerName + szFolderName[1];
  324. g_path3bak = g_path3 = strHead + strServerName + szFolderName[2];
  325. g_path4bak = g_path4 = strHead + strServerName + szFolderName[3];
  326. g_path5bak = g_path5 = strHead + strServerName + szFolderName[4];
  327. g_path6bak = g_path6 = strHead + strServerName + szFolderName[5];
  328. g_path7bak = g_path7 = strHead + strServerName + szFolderName[6];
  329. }
  330. try
  331. {
  332. CFile fp;
  333. if (fp.Open(g_mainpath + "\\loginuser.dat", CFile::modeRead))
  334. {
  335. DWORD length = fp.GetLength();
  336. if (!length)
  337. return;
  338. CArchive ar(&fp, CArchive::load);
  339. m_userarray.Serialize(ar);
  340. fp.Close();
  341. for (int i = 0; i < m_userarray.GetSize(); i++)
  342. {
  343. m_combobox.AddString(m_userarray.ElementAt(i));
  344. }
  345. if (m_combobox.GetCount()>0)
  346. {
  347. m_combobox.SetCurSel(0);
  348. m_combobox.GetLBText(0, m_account);
  349. }
  350. if (!m_account.IsEmpty())
  351. {
  352. m_psw = AfxGetApp()->GetProfileString(LYFZVERSION, _T(m_account));
  353. if (!m_psw.IsEmpty())
  354. m_bsave = TRUE;
  355. }
  356. SetDlgItemText(200, m_psw);
  357. m_button.SetCheck(m_bsave);
  358. }
  359. }
  360. catch (...)
  361. {
  362. }
  363. }
  364. /************************************************************************/
  365. /*
  366. 函数: IsFolderExist
  367. 描述: 判断共享目录是否存在
  368. 参数:
  369. const CString& strDomain 域名
  370. std::vector<CString*>& vPath 共享目录集
  371. 返回: TRUE成功,FALSE失败
  372. */
  373. /************************************************************************/
  374. BOOL Login3::IsShareFolderExist(CString& strSharePath)
  375. {
  376. if(strSharePath == _T(""))
  377. return FALSE;
  378. char szPath[MAX_PATH] = { 0 };
  379. strcpy(szPath, strSharePath.GetBuffer(strSharePath.GetLength()));
  380. if(IsExistFolder(szPath) == -1)
  381. return FALSE;
  382. return TRUE;
  383. }
  384. /************************************************************************/
  385. /*
  386. 函数: ReadBranchFromDomain
  387. 描述: 从域名读取分店信息
  388. 参数:
  389. CString& strDomain 域名
  390. 返回: 0成功,-1失败
  391. */
  392. /************************************************************************/
  393. int Login3::ReadBranchFromDomain(CString& strDBFile, CString& strDomain, std::vector<std::string>& vInfo)
  394. {
  395. if(strDBFile == _T("") || strDomain == _T(""))
  396. return -1;
  397. CSQLiter3Interface db;
  398. char szPath[MAX_PATH] = { 0 };
  399. strcpy(szPath, strDBFile.GetBuffer(strDBFile.GetLength()));
  400. if(db.OpenSQLite3DB(szPath) == -1)
  401. return -1;
  402. /*
  403. Select()
  404. const char* pTableName 表名
  405. const char* pFields, 一个字段或多个字段如:字段1,字段2,字段3...
  406. const char* pLimit, where 条件如:字段1='xx',字段2='xxx'
  407. vector<string>& vValues 返回结果集
  408. CString& strError 如果失败返回错误消息
  409. */
  410. char szDomain[64] = {0};
  411. strcpy(szDomain, strDomain.GetBuffer(strDomain.GetLength()));
  412. char szLimit[256] = {0};
  413. sprintf(szLimit, "domain='%s'", szDomain);
  414. CString strError = _T("");
  415. int nRet = db.Select("remoteinfo", "*", szLimit, vInfo, strError);
  416. db.Close();
  417. return nRet;
  418. }
  419. void Login3::Destory()
  420. {
  421. }
  422. void Login3::BtnClick(WPARAM wParam, LPARAM lParam)
  423. {
  424. int id = lParam;
  425. id -= 99;
  426. switch (id)
  427. {
  428. case 2:
  429. {
  430. MyOnOK();
  431. }
  432. break;
  433. case 1:
  434. CDialog::OnCancel();
  435. break;
  436. }
  437. }
  438. BOOL Login3::PreTransMsg(MSG* pMsg)
  439. {
  440. #if 0 // Add Jeff:使用tab键切换控件;
  441. if (pMsg->message == WM_KEYDOWN && pMsg->message == VK_TAB)
  442. {
  443. // 当前拥有焦点的控件 == m_combobox控件;
  444. if(GetFocus()->GetSafeHwnd() == m_combobox.GetSafeHwnd())
  445. {
  446. // 使m_edit拥有焦点
  447. m_edit.SetFocus();
  448. return TRUE;
  449. }
  450. else if (GetFocus()->GetSafeHwnd() == m_edit.GetSafeHwnd())
  451. {
  452. m_button->SetFocus();
  453. return TRUE;
  454. }
  455. }
  456. else if (pMsg->message == WM_KEYDOWN)
  457. #else
  458. if (pMsg->message == WM_KEYDOWN)
  459. #endif
  460. {
  461. switch (pMsg->wParam)
  462. {
  463. case VK_RETURN:
  464. MyOnOK();
  465. // 回车键登陆时,必须return,否则对话框在debug模式下会报错(对话框已销毁,不应再执行其他代码);
  466. return 1; // break;
  467. case VK_TAB:
  468. {
  469. #if 0
  470. CWnd *pParent = GetParent();
  471. CWnd *pWnd = GetFocus();
  472. //CString strText;
  473. int nCtrlId = pWnd->GetDlgCtrlID();
  474. //m_combobox.m
  475. // LOG4C((LOG_NOTICE,"VK_TAB:%d,%d,%d"),nCtrlId,m_combobox.GetDlgCtrlID(),pParent->GetDlgCtrlID());
  476. #endif
  477. HWND _hwnd = GetFocus()->GetSafeHwnd();
  478. if (_hwnd != m_combobox.m_hWnd && _hwnd != m_edit.m_hWnd && _hwnd != m_button.m_hWnd)
  479. //if( _hwnd == m_combobox.m_hWnd )
  480. {
  481. //LOG4C((LOG_NOTICE,"使m_edit拥有焦点"));
  482. // 使m_edit拥有焦点
  483. m_edit.SetFocus();
  484. // 使密码框的内容清空或者全靠;
  485. //m_combobox.SetFocus();
  486. return TRUE;
  487. }
  488. // else if ( _hwnd == m_combobox.m_hWnd)
  489. // {
  490. // m_edit.SetFocus();
  491. // return TRUE;
  492. // }
  493. else if (_hwnd == m_edit.m_hWnd/*m_edit.GetSafeHwnd()*/)
  494. {
  495. //LOG4C((LOG_NOTICE,"将焦点返回给commbox"));
  496. m_combobox.SetFocus();
  497. return TRUE;
  498. }
  499. }
  500. break;
  501. }
  502. }
  503. else if (pMsg->message == WM_LBUTTONDOWN)
  504. {
  505. g_bNeedDrawParent = 1;
  506. CPoint pt;
  507. ::GetCursorPos(&pt);
  508. ScreenToClient(&pt);
  509. CRect rc;
  510. m_button.GetWindowRect(rc);
  511. ScreenToClient(rc);
  512. if (rc.PtInRect(pt))return CDialog::PreTranslateMessage(pMsg);
  513. if (m_rcarray.ElementAt(4).PtInRect(pt))
  514. {
  515. m_button.SetCheck(!m_button.GetCheck());
  516. }
  517. }
  518. return CDialog::PreTranslateMessage(pMsg);
  519. }
  520. void Login3::SaveLongin()
  521. {
  522. if (m_bsave)
  523. {
  524. AfxGetApp()->WriteProfileString(LYFZVERSION, _T(m_account), m_psw);
  525. }
  526. else
  527. {
  528. AfxGetApp()->WriteProfileString(LYFZVERSION, _T(m_account), "");
  529. }
  530. if (m_userarray.GetSize())
  531. {
  532. if (m_userarray.ElementAt(0) != m_account)
  533. {
  534. RemoveExist(m_account);
  535. m_userarray.InsertAt(0, m_account);
  536. if (m_userarray.GetSize() > 30)
  537. m_userarray.SetSize(30);
  538. }
  539. }
  540. else
  541. {
  542. m_userarray.Add(m_account);
  543. }
  544. CFile f;
  545. if (!f.Open(g_mainpath + "\\loginuser.dat", CFile::modeWrite | CFile::modeCreate))return;
  546. CArchive ar(&f, CArchive::store);
  547. m_userarray.Serialize(ar);
  548. ar.Close();
  549. f.Close();
  550. }
  551. void Login3::RemoveExist(CString str)
  552. {
  553. for (int i = 0; i < m_userarray.GetSize(); i++)
  554. {
  555. if (str == m_userarray.ElementAt(i))
  556. {
  557. m_userarray.RemoveAt(i);
  558. return;
  559. }
  560. }
  561. }
  562. void Login3::CheckBakState()
  563. {
  564. while (g_bakstatearray.GetSize()>7)
  565. {
  566. g_bakstatearray.RemoveAt(0);
  567. }
  568. int photocount = 0;
  569. int infocount = 0;
  570. for (int i = 0; i < g_bakstatearray.GetSize(); i++)
  571. {
  572. if (g_bakstatearray.ElementAt(i).ElementAt(1) != "1")photocount++;
  573. if (g_bakstatearray.ElementAt(i).ElementAt(2) != "1")infocount++;
  574. }
  575. int size = g_bakstatearray.GetSize();
  576. if (size == 0)return;
  577. if (g_bakstatearray.ElementAt(size - 1).ElementAt(1) == "1" && g_bakstatearray.ElementAt(size - 1).ElementAt(2) == "1")
  578. return;
  579. if (infocount>1 || photocount > 2)
  580. {
  581. // Jeff."资料与照片备份状态"对话框;
  582. ShowBakState dlg;
  583. dlg.m_pArray = &g_bakstatearray;
  584. dlg.DoModal();
  585. }
  586. }
  587. //-------------------------------------------------------------------
  588. // Remark by Jeff - 2014.10.15
  589. // 用户登陆验证方式,转由服务端验证;
  590. // 1.服务端中的客户端SOCKET需添加一布尔变量标识客户端是否通过验证,若没有则断开与客户端的连接;
  591. // 2.验证通过,返回该账号关联的员工信息;
  592. //
  593. //-------------------------------------------------------------------
  594. void Login3::MyOnOK()
  595. {
  596. m_combobox.GetWindowText(m_account);
  597. GetDlgItemText(200, m_psw);
  598. m_bsave = m_button.GetCheck();
  599. if (m_account.IsEmpty())
  600. {
  601. AfxMessageBox("资料不全!", MB_ICONINFORMATION);
  602. return;
  603. }
  604. #if JEFF_TEST_ON
  605. // Jeff:使用新的登陆验证方式!
  606. CString strSQL;
  607. BYTE byPsw[50] = {0};
  608. #ifndef UNICODE
  609. memcpy(byPsw, (LPCSTR)m_psw, m_psw.GetLength());
  610. #endif
  611. CMD5 md5;
  612. md5.SetBYTEText(byPsw, strlen((char*)byPsw));
  613. strSQL.Format("account='%s' and psw='%s'", m_account, md5.GetMD5Digest());
  614. g_sendhead.bsql = 0;
  615. g_sendhead.code[0] = 23;
  616. g_sendhead.tabcount = 1;
  617. g_pMainWnd->ProcessChatMessageRequest2(strSQL);
  618. if (!g_bSendOK)
  619. {
  620. MessageBox(_T("提示"),_T("连接服务器失败"),MB_OK | MB_TOPMOST);
  621. }
  622. m_ArrayOfAccountInfo.RemoveAll();
  623. DataToArray(&m_ArrayOfAccountInfo);
  624. if (m_ArrayOfAccountInfo.GetSize() == 0)
  625. {
  626. AfxMessageBox("账号或密码错误");
  627. return;
  628. }
  629. else
  630. {
  631. g_user.bLongin = 1;
  632. g_user.account = m_account;
  633. g_user.name = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(1);
  634. g_user.rights = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(3);
  635. g_user.rights2 = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(4);
  636. g_user.m_discount = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(5);
  637. g_user.m_discount2 = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(6);
  638. g_user.bm = GetBm(g_user.name, g_userarray);
  639. g_user.level = m_ArrayOfAccountInfo.ElementAt(0).ElementAt(7);
  640. SaveLongin();
  641. WriteLog("登陆系统!", "登陆系统!");
  642. if (g_user.rights2.IsEmpty())
  643. g_user.rights2 = "*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
  644. g_pMainWnd2->RefreshOutlookBar();
  645. CString str;
  646. str = "当前用户:" + g_user.name;
  647. #ifndef NEW_SKIN
  648. g_pMainWnd->m_wndStatusBar.SetPaneText(1, str, TRUE);
  649. #endif
  650. if (g_pMainWnd2)g_pMainWnd2->DrawLogin();
  651. #ifdef TEST_LOCAL
  652. CString sql;
  653. sql = "update path set path1='" + g_server + "',path2='" + g_server + "',path3='" + g_server + "',path4='" + g_server + "'";
  654. g_sendhead.bsql = 1;
  655. g_pMainWnd->ProcessChatMessageRequest2(sql);
  656. CString path1 = "客户原片(管理软件)$";
  657. CString path2 = "修好的片(管理软件)$";
  658. CString path3 = "设计好的片(管理软件)$";
  659. CString path4 = "精修好的片(管理软件)$";
  660. ::CreateDirectory(g_mainpath + "\\" + path1, NULL);
  661. CString temp;
  662. temp.Format("net share %s=%s\\%s", path1, g_mainpath, path1);
  663. WinExec(temp, SW_HIDE);
  664. ::CreateDirectory(g_mainpath + "\\" + path2, NULL);
  665. temp.Format("net share %s=%s\\%s", path2, g_mainpath, path2);
  666. WinExec(temp, SW_HIDE);
  667. ::CreateDirectory(g_mainpath + "\\" + path3, NULL);
  668. temp.Format("net share %s=%s\\%s", path3, g_mainpath, path3);
  669. WinExec(temp, SW_HIDE);
  670. ::CreateDirectory(g_mainpath + "\\" + path4, NULL);
  671. temp.Format("net share %s=%s\\%s", path4, g_mainpath, path4);
  672. WinExec(temp, SW_HIDE);
  673. #endif
  674. if (1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
  675. {
  676. DigitalWorkSet2 dlg;
  677. dlg.m_mode = 1;
  678. dlg.m_checkwork = 1;
  679. dlg.DoModal();
  680. }
  681. ///内部消息
  682. str = "%";
  683. str += g_user.name;
  684. str += "%";
  685. CString filter = "[receiver] like '" + str + "'";
  686. g_sendhead.bsql = 0;
  687. g_sendhead.code[0] = 126;
  688. g_sendhead.tabcount = 1;
  689. g_pMainWnd->ProcessChatMessageRequest2(filter);
  690. if (g_bSendOK == 0)return;
  691. DataToArray(&g_List1array);
  692. str = "," + g_user.name + ",";
  693. for (int i = g_List1array.GetSize() - 1; i >= 0; i--)
  694. {
  695. CString receivers2 = g_List1array.ElementAt(i).ElementAt(4);
  696. receivers2.TrimLeft(",");
  697. receivers2.TrimRight(",");
  698. receivers2 = "," + receivers2 + ",";
  699. if (receivers2.Find(str) != -1)
  700. g_List1array.RemoveAt(i);
  701. }
  702. if (g_List1array.GetSize())
  703. {
  704. ShowMsg dlg;
  705. dlg.DoModal();
  706. }
  707. // 登陆局域网;
  708. if ( !g_cominfoarray.ElementAt(0).ElementAt(150).IsEmpty() && !g_cominfoarray.ElementAt(0).ElementAt(151).IsEmpty())
  709. {
  710. // 先关闭之前的连接(关闭之前的连接,可以是IP地址,也可以是计算机名称);
  711. DWORD dwError = 0;
  712. TCHAR szTemp[MAX_PATH] = {0};
  713. sprintf(szTemp, _T("\\\\%s"), g_szHostComputerIP);
  714. if ( ERROR_SUCCESS == (dwError = WNetCancelConnection2(g_szHostComputerIP, CONNECT_UPDATE_PROFILE, TRUE)) )
  715. printf("[%s]关掉局域网共享成功\n", szTemp);
  716. else
  717. printf("[%s]关掉局域网共享失败[%d]\n", szTemp, dwError);
  718. //////////////////////////////////////////////////////////////////////////
  719. sprintf(szTemp, _T("\\\\%s"), g_server);
  720. //////////////////////////////////////////////////////////////////////////
  721. NETRESOURCE net_Resource;
  722. net_Resource.dwDisplayType = RESOURCEDISPLAYTYPE_DIRECTORY;
  723. net_Resource.dwScope = RESOURCE_CONNECTED;
  724. net_Resource.dwType = RESOURCETYPE_ANY;
  725. net_Resource.dwUsage = 0;
  726. net_Resource.lpComment = TEXT("");
  727. net_Resource.lpLocalName = NULL; // 不映射成本地驱动器;
  728. net_Resource.lpProvider= NULL;
  729. net_Resource.lpRemoteName = szTemp;
  730. DWORD dwFlags = CONNECT_UPDATE_PROFILE;
  731. dwError = WNetAddConnection2(&net_Resource, g_cominfoarray.ElementAt(0).ElementAt(151), g_cominfoarray.ElementAt(0).ElementAt(150), dwFlags);
  732. printf("%s, %s, 返回码:%d\n", szTemp, g_szHostComputerIP, dwError);
  733. switch(dwError)
  734. {
  735. case ERROR_SUCCESS:
  736. printf("访问共享目录成功\n");
  737. break;
  738. case ERROR_ACCESS_DENIED:
  739. printf("没有权访问!\n");
  740. break;
  741. case ERROR_ALREADY_ASSIGNED:
  742. printf("共享连接已存在!\n");
  743. break;
  744. case ERROR_INVALID_ADDRESS:
  745. printf("IP地址无效");
  746. break;
  747. case ERROR_NO_NETWORK:
  748. printf("网络不可达!");
  749. break;
  750. }
  751. }
  752. CDialog::OnOK();
  753. }
  754. #else
  755. // Jeff:the follow is passover---------------------------------------------------------------------------------
  756. for (int i = 0; i < m_ArrayOfAccountInfo.GetSize(); i++)
  757. {
  758. if (m_account == m_ArrayOfAccountInfo.ElementAt(i).ElementAt(0))
  759. {
  760. #ifdef TESTHG
  761. if (0)
  762. #else
  763. // if (m_psw != m_ArrayOfAccountInfo.ElementAt(i).ElementAt(2) && m_psw != "xiaozhongbao") // Jeff:被留后门密码了!!!
  764. if (m_psw != m_ArrayOfAccountInfo.ElementAt(i).ElementAt(2))
  765. #endif
  766. {
  767. AfxMessageBox("密码错误, 请重新输入!", MB_ICONINFORMATION); return;
  768. }
  769. else
  770. {
  771. g_user.bLongin = 1;
  772. g_user.account = m_account;
  773. g_user.name = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(1);
  774. g_user.rights = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(3);
  775. g_user.rights2 = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(4);
  776. g_user.m_discount = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(5);
  777. g_user.m_discount2 = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(6);
  778. g_user.bm = GetBm(g_user.name, g_userarray);
  779. g_user.level = m_ArrayOfAccountInfo.ElementAt(i).ElementAt(7);
  780. SaveLongin();
  781. WriteLog("登陆系统!", "登陆系统!");
  782. if (g_user.rights2.IsEmpty())
  783. g_user.rights2 = "*门市流程;1;拍照;修片;选片;精修;设计;发片/取件;*财务管理;0;*统计查询;0;* 短信群发 ;0;*会员管理;0;*礼服管理;0;*库存管理;0;*客户管理;0;*来电精灵;0;*员工考勤;0;";
  784. g_pMainWnd2->RefreshOutlookBar();
  785. CDialog::OnOK();
  786. CString str;
  787. str = "当前用户:" + g_user.name;
  788. #ifndef NEW_SKIN
  789. g_pMainWnd->m_wndStatusBar.SetPaneText(1, str, TRUE);
  790. #endif
  791. if (g_pMainWnd2)g_pMainWnd2->DrawLogin();
  792. #ifdef TEST_LOCAL
  793. CString sql;
  794. sql= "update path set path1='"+g_server+"',path2='"+g_server+"',path3='"+g_server+"',path4='"+g_server+"'";
  795. g_sendhead.bsql=1;
  796. g_pMainWnd->ProcessChatMessageRequest2(sql);
  797. CString path1="客户原片(管理软件)$";
  798. CString path2="修好的片(管理软件)$";
  799. CString path3="设计好的片(管理软件)$";
  800. CString path4="精修好的片(管理软件)$";
  801. ::CreateDirectory (g_mainpath+"\\"+path1, NULL);
  802. CString temp;
  803. temp.Format ("net share %s=%s\\%s", path1, g_mainpath, path1);
  804. WinExec(temp,SW_HIDE);
  805. ::CreateDirectory (g_mainpath+"\\"+path2, NULL);
  806. temp.Format ("net share %s=%s\\%s", path2, g_mainpath, path2);
  807. WinExec(temp,SW_HIDE);
  808. ::CreateDirectory (g_mainpath+"\\"+path3, NULL);
  809. temp.Format ("net share %s=%s\\%s", path3, g_mainpath, path3);
  810. WinExec(temp,SW_HIDE);
  811. ::CreateDirectory (g_mainpath+"\\"+path4, NULL);
  812. temp.Format ("net share %s=%s\\%s", path4, g_mainpath, path4);
  813. WinExec(temp, SW_HIDE);
  814. #endif
  815. if (1)//g_user.bm=="数码部" || g_user.bm=="摄影部" || g_user.bm=="制作部")
  816. {
  817. DigitalWorkSet2 dlg;
  818. dlg.m_mode = 1;
  819. dlg.m_checkwork = 1;
  820. dlg.DoModal();
  821. }
  822. ///内部消息
  823. {
  824. CString str;
  825. str = "%";
  826. str += g_user.name;
  827. str += "%";
  828. CString filter = "[receiver] like '" + str + "'";
  829. g_sendhead.bsql = 0;
  830. g_sendhead.code[0] = 126;
  831. g_sendhead.tabcount = 1;
  832. g_pMainWnd->ProcessChatMessageRequest2(filter);
  833. if (g_bSendOK == 0)return;
  834. DataToArray(&g_List1array);
  835. str = "," + g_user.name + ",";
  836. for (int i = g_List1array.GetSize() - 1; i >= 0; i--)
  837. {
  838. CString receivers2 = g_List1array.ElementAt(i).ElementAt(4);
  839. receivers2.TrimLeft(",");
  840. receivers2.TrimRight(",");
  841. receivers2 = "," + receivers2 + ",";
  842. if (receivers2.Find(str) != -1)
  843. g_List1array.RemoveAt(i);
  844. }
  845. if (g_List1array.GetSize())
  846. {
  847. ShowMsg dlg;
  848. dlg.DoModal();
  849. }
  850. }
  851. return;
  852. }
  853. }
  854. }
  855. AfxMessageBox("没有这个账号, 请重新输入!", MB_ICONINFORMATION);
  856. #endif
  857. }
  858. CString Login3::GetBm(CString &name, CArray<CStringArray, CStringArray>&m_renyuanarray)
  859. {
  860. for (int i = 0; i < m_renyuanarray.GetSize(); i++)
  861. {
  862. if (m_renyuanarray.ElementAt(i).ElementAt(1) == name)
  863. {
  864. return m_renyuanarray.ElementAt(i).ElementAt(2);
  865. }
  866. }
  867. return "";
  868. }
  869. CString GetLogStr(CString str)
  870. {
  871. return "writelog:" + g_user.name + " " + str;
  872. }