public fMain() { InitializeComponent(); frmNewFtp = new NewFTP(); frmNewFtp.Tag = this; newDir = new fNewDir(); newDir.Tag = this; }
private void bDone_Click(object sender, EventArgs e) { bool ftporsftp; bool ftps = false; bool ftpes = true; if (cMode.SelectedIndex == 0) { ftporsftp = true; if (cEncryption.SelectedIndex != 0) { ftps = true; if (cEncryption.SelectedIndex == 1) { Log.Write(l.Info, "FTPS Explicit"); ftpes = true; } else { Log.Write(l.Info, "FTPS Implicit"); ftpes = false; } } else { Log.Write(l.Info, "Plain FTP"); } } else { ftporsftp = false; Log.Write(l.Info, "SFTP"); } try { if (ftporsftp) { ftpc = new FtpClient(tHost.Text, Convert.ToInt32(nPort.Value)); if (ftps) { if (ftpes) { ftpc.SecurityProtocol = FtpSecurityProtocol.Tls1OrSsl3Explicit; } else { ftpc.SecurityProtocol = FtpSecurityProtocol.Tls1OrSsl3Implicit; } ftpc.ValidateServerCertificate += new EventHandler <ValidateServerCertificateEventArgs>(ftp_ValidateServerCertificate); } ftpc.Open(tUsername.Text, tPass.Text); Log.Write(l.Info, "Connected: " + ftpc.IsConnected.ToString()); ftpc.Close(); } else { string pass = AESEncryption.Encrypt(tPass.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); ((frmMain)this.Tag).SetPass(pass); //FTPbox.Properties.Settings.Default.ftpPass = tPass.Text; sftp_login(); //MessageBox.Show("SFTP Connected"); sftpc.quit(); } string hostEncr = AESEncryption.Encrypt(tHost.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); string unEncr = AESEncryption.Encrypt(tUsername.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); string passEncr = AESEncryption.Encrypt(tPass.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); ((frmMain)this.Tag).UpdateAccountInfo(hostEncr, unEncr, passEncr, Convert.ToInt32(nPort.Value), "", ftporsftp, ftps, ftpes); //FTPbox.Properties.Settings.Default.ftpHost = tHost.Text; //FTPbox.Properties.Settings.Default.ftpPort = Convert.ToInt32(nPort.Value); //FTPbox.Properties.Settings.Default.ftpUsername = tUsername.Text; //FTPbox.Properties.Settings.Default.ftpPass = tPass.Text; //FTPbox.Properties.Settings.Default.FTPorSFTP = ftporsftp; //FTPbox.Properties.Settings.Default.timedif = ""; //FTPbox.Properties.Settings.Default.Save(); Log.Write(l.Debug, "got new ftp acccount details"); ((frmMain)this.Tag).ClearLog(); ((frmMain)this.Tag).UpdateDetails(); //((frmMain)this.Tag).GetServerTime(); ((frmMain)this.Tag).loggedIn = true; fNewDir fnewdir = new fNewDir(); fnewdir.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("Could not connect to FTP server. Check your account details and try again." + Environment.NewLine + " Error message: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (ftporsftp) { Log.Write(l.Info, "Connected: " + ftpc.IsConnected.ToString()); } } }
private void frmMain_Load(object sender, EventArgs e) { //FTPbox.Properties.Settings.Default.ftpUsername = ""; KillPrevInstances(); //ClearLog(); foreach (string s in nLog().Split('|', '|')) { Log.Write("In Log: {0}", s); } fNewFtp = new NewFTP(); fNewFtp.Tag = this; newDir = new fNewDir(); newDir.Tag = this; int i = 0; while (i < 5) { recentfiles.Add("Not available"); i++; } StartUpWork(); CheckForUpdate(); Get_Language(); //WatchRemote.Start(); }
private void bDone_Click(object sender, EventArgs e) { bool ftporsftp; if (cMode.SelectedIndex == 0) { ftporsftp = true; Log.Write("FTP"); } else { ftporsftp = false; Log.Write("SFTP"); } try { if (ftporsftp) { ftp = new FtpConnection(tHost.Text, Convert.ToInt32(nPort.Value), tUsername.Text, tPass.Text); ftp.Open(); ftp.Login(); ftp.Close(); } else { string pass = AESEncryption.Encrypt(tPass.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); ((frmMain)this.Tag).SetPass(pass); //FTPbox.Properties.Settings.Default.ftpPass = tPass.Text; sftp_login(); //MessageBox.Show("SFTP Connected"); sftpc.quit(); } string hostEncr = AESEncryption.Encrypt(tHost.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); string unEncr = AESEncryption.Encrypt(tUsername.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); string passEncr = AESEncryption.Encrypt(tPass.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); ((frmMain)this.Tag).UpdateAccountInfo(hostEncr, unEncr, passEncr, Convert.ToInt32(nPort.Value), "", ftporsftp); //FTPbox.Properties.Settings.Default.ftpHost = tHost.Text; //FTPbox.Properties.Settings.Default.ftpPort = Convert.ToInt32(nPort.Value); //FTPbox.Properties.Settings.Default.ftpUsername = tUsername.Text; //FTPbox.Properties.Settings.Default.ftpPass = tPass.Text; //FTPbox.Properties.Settings.Default.FTPorSFTP = ftporsftp; //FTPbox.Properties.Settings.Default.timedif = ""; //FTPbox.Properties.Settings.Default.Save(); Log.Write("got new ftp acccount details"); ((frmMain)this.Tag).ClearLog(); ((frmMain)this.Tag).UpdateDetails(); //((frmMain)this.Tag).GetServerTime(); ((frmMain)this.Tag).loggedIn = true; fNewDir fnewdir = new fNewDir(); fnewdir.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("Could not connect to FTP server. Check your account details and try again." + Environment.NewLine + " Error message: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void bDone_Click(object sender, EventArgs e) { bool ftporsftp; bool ftps = false; bool ftpes = true; if (cMode.SelectedIndex == 0) { ftporsftp = true; if (cEncryption.SelectedIndex != 0) { ftps = true; if (cEncryption.SelectedIndex == 1) { Log.Write(l.Info, "FTPS Explicit"); ftpes = true; } else { Log.Write(l.Info, "FTPS Implicit"); ftpes = false; } } else Log.Write(l.Info, "Plain FTP"); } else { ftporsftp = false; Log.Write(l.Info, "SFTP"); } try { if (ftporsftp) { ftpc = new FtpClient(tHost.Text, Convert.ToInt32(nPort.Value)); if (ftps) { if (ftpes) ftpc.SecurityProtocol = FtpSecurityProtocol.Tls1OrSsl3Explicit; else ftpc.SecurityProtocol = FtpSecurityProtocol.Tls1OrSsl3Implicit; ftpc.ValidateServerCertificate += new EventHandler<ValidateServerCertificateEventArgs>(ftp_ValidateServerCertificate); } ftpc.Open(tUsername.Text, tPass.Text); Log.Write(l.Info, "Connected: " + ftpc.IsConnected.ToString()); ftpc.Close(); } else { string pass = AESEncryption.Encrypt(tPass.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); ((frmMain)this.Tag).SetPass(pass); //FTPbox.Properties.Settings.Default.ftpPass = tPass.Text; sftp_login(); //MessageBox.Show("SFTP Connected"); sftpc.quit(); } string hostEncr = AESEncryption.Encrypt(tHost.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); string unEncr = AESEncryption.Encrypt(tUsername.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); string passEncr = AESEncryption.Encrypt(tPass.Text, decpass, salt, "SHA1", 2, "OFRna73m*aze01xY", 256); ((frmMain)this.Tag).UpdateAccountInfo(hostEncr, unEncr, passEncr, Convert.ToInt32(nPort.Value), "", ftporsftp, ftps, ftpes); //FTPbox.Properties.Settings.Default.ftpHost = tHost.Text; //FTPbox.Properties.Settings.Default.ftpPort = Convert.ToInt32(nPort.Value); //FTPbox.Properties.Settings.Default.ftpUsername = tUsername.Text; //FTPbox.Properties.Settings.Default.ftpPass = tPass.Text; //FTPbox.Properties.Settings.Default.FTPorSFTP = ftporsftp; //FTPbox.Properties.Settings.Default.timedif = ""; //FTPbox.Properties.Settings.Default.Save(); Log.Write(l.Debug, "got new ftp acccount details"); ((frmMain)this.Tag).ClearLog(); ((frmMain)this.Tag).UpdateDetails(); //((frmMain)this.Tag).GetServerTime(); ((frmMain)this.Tag).loggedIn = true; fNewDir fnewdir = new fNewDir(); fnewdir.ShowDialog(); this.Close(); } catch (Exception ex) { MessageBox.Show("Could not connect to FTP server. Check your account details and try again." + Environment.NewLine + " Error message: " + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); if (ftporsftp) Log.Write(l.Info, "Connected: " + ftpc.IsConnected.ToString()); } }