private void btn_change_change_Click(object sender, EventArgs e) // 변경 버튼 클릭 { // 사용자가 입력한 정보를 들고 옴 input_ip = tb_search_ip.Text.ToString(); input_email = tb_search_email.Text.ToString(); input_pre_code = tb_search_pre_code.Text.ToString(); input_post_code = tb_search_post_code.Text.ToString(); input_post_code2 = tb_search_post_code2.Text.ToString(); db_ip = ini_data.GetIniValue("Remote Control System Information", "UserIp"); // 아이피 가져오기 db_email = ini_data.GetIniValue("Remote Control System Information", "UserEmail"); // 이메일 db_pre_code = aes.AES_Decode(ini_data.GetIniValue("Remote Control System Information", "UserCode")); // 코드 가져오기 if (input_ip.Equals(db_ip) && input_email.Equals(db_email) && input_pre_code.Equals(db_pre_code)) // 아이피, 이메일, 이전 코드가 DB 정보와 일치해야 함. { if (input_post_code.Equals(input_post_code2)) // 재 입력한 비밀번호가 일치해야 함. { ini_data.SetIniValue("Remote Control System Information", "Usercode", aes.AES_Encode(input_post_code2)); MessageBox.Show("Change you Cert code", "비밀번호 변경 완료."); this.Hide(); } else // 재 입력한 비밀번호가 다를 때 { MessageBox.Show("변경 비밀번호를 확인 해 주세요.", "Check post code"); } } else // 사용자가 입력한 정보와 다를 때 { MessageBox.Show("아이피와 비밀번호를 확인 해 주세요.", "Check Information"); } }
private void btn_search_send_Click(object sender, EventArgs e) { if (tb_search_email.Text != "" || tb_search_ip.Text != "") { try { cb_user_mail = cb_mail.SelectedItem.ToString(); // 메일에 선택된 주소 } catch (Exception ex) { cb_user_mail = cb_mail.Text.ToString(); } input_ip = tb_search_ip.Text.ToString(); input_email = tb_search_email.Text.ToString() + "@" + cb_user_mail; db_ip = ini_data.GetIniValue("Remote Control System Information", "UserIp"); // 아이피 가져오기 db_email = ini_data.GetIniValue("Remote Control System Information", "UserEMail"); // 아이피 가져오기 if (input_ip.Equals(db_ip) && input_email.Equals(db_email)) // 모든 정보가 맞아야 { db_code = aes.AES_Decode(ini_data.GetIniValue("Remote Control System Information", "UserCode")); // 코드 가져오기. 가장 중요한 부분. message = new MailMessage(); message.From = new MailAddress("*****@*****.**"); // 보내는 사람 message.To.Add(input_email); // 받는 사람W message.BodyEncoding = System.Text.Encoding.UTF8; message.SubjectEncoding = System.Text.Encoding.UTF8; message.Subject = subject; message.Body = db_code; //message.Priority = MailPriority.High; // 긴급으로 전송할 때 //전자 메일 메시지 본문의 형식이 Html인지 여부를 나타내는 값을 가져오거나 설정합니다 message.IsBodyHtml = true; //응용 프로그램에서 SMTP(Simple Mail Transfer Protocol)를 사용하여 전자 메일을 보낼 수 있도록 합니다. SmtpClient client = new SmtpClient("smtp.naver.com", 587); //요청에 DefaultCredentials를 보낼지 여부를 제어하는 Boolean 값을 가져오거나 설정합니다. client.UseDefaultCredentials = false; //SmtpClient 에서 SSL(Secure Sockets Layer)을 사용하여 연결을 암호화할지 여부를 지정합니다. client.EnableSsl = true; //보낸 사람을 인증하는 데 사용되는 자격 증명을 가져오거나 설정합니다. client.Credentials = new System.Net.NetworkCredential("imgosari", "ghatwoi2!"); try { client.Send(message); MessageBox.Show("인증코드를 메일로 전송했습니다."); } catch (Exception ex) { MessageBox.Show("인증코드 전송에 실패하였습니다.\n" + ex.Message); } this.Close(); } else { MessageBox.Show("입력한 정보를 확인 해 주세요."); } } }
static void Main() { string file_path; FileInfo file_info; iniData ini_data; string temp_path = @"C:\Atop\config.ini"; // 설정 저장 경로 string db_ip, db_code, db_join, db_mail; Boolean is_join = false; AES256 aes = new AES256(); bool no_instance; Mutex mutext = new Mutex(true, "TestForBlockDuplicatedExecution", out no_instance); if (no_instance) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); #region 인증코드 최초 가입 확인 file_path = Path.Combine(Path.GetTempPath(), temp_path); ini_data = new iniData(file_path); file_info = new FileInfo(file_path); if (file_info.Exists) // 우선 ini 파일이 존재해야 한다. { db_ip = ini_data.GetIniValue("Remote Control System Information", "UserIp"); // 아이피 가져오기 db_code = aes.AES_Decode(ini_data.GetIniValue("Remote Control System Information", "UserCode")); // 코드 확보 해 놓기. db_join = ini_data.GetIniValue("Remote Control System Information", "UserIsJoin"); // 코드 확보 해 놓기. db_mail = ini_data.GetIniValue("Remote Control System Information", "UserEMail"); // 코드 확보 해 놓기. if (db_join.Equals("joined")) // 가입 되어 있으면 로그인 창 뜸. { is_join = true; } else // 가입 되어 있지 않으면 가입창 뜸 { is_join = false; } } #endregion try { if (is_join == true) // 가입 되어 있으면 메인 폼 열고 { Application.Run(new MainForm()); } else if (is_join == false) // 가입되어 있지 않으면 가입 폼을 연다. { Application.Run(new JoinForm()); } } catch (Exception e) { } } else // 프로그램이 이미 실행 중 { MessageBox.Show("이미 실행 중입니다.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }