Login3.cpp 28 KB

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