Files
Lecteur-media/lecteur/lecteur média/Form39.vb
T
2026-06-18 14:15:48 +02:00

364 lines
16 KiB
VB.net

Imports System.IO
Imports System.Net
Imports System.Net.Mail
Imports System.Security.Cryptography
Imports System.Text
Public Class Form39
Dim stepe As Integer = 0
Dim mailtex As String = ""
Dim begeg As Integer = 0
Private Sub Form39_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Me.BackColor = Form1.BackColor
Me.ForeColor = Form1.ForeColor
TextBox1.BackColor = BackColor
TextBox1.ForeColor = ForeColor
Button1.ForeColor = ForeColor
Button1.BackColor = BackColor
ComboBox1.BackColor = BackColor
ComboBox1.ForeColor = ForeColor
stepe = 0
ComboBox1.Hide()
Label1.Text = "Entrer vôtre mail"
Button1.Text = "suivant"
PictureBox1.Hide()
End Sub
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
If stepe = 0 Then
My.Computer.Network.DownloadFile(ipsite & "/utilisateur/" & Form3.Label21.Text & "/mail.txt", cozip & "\mail.txt")
Dim lines1() As String = File.ReadAllLines(cozip & "\mail.txt")
File.Delete(cozip & "\mail.txt")
Dim texteEnBytes() As Byte = Encoding.UTF8.GetBytes(TextBox1.Text)
Dim keyBytes() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto As New DESCryptoServiceProvider()
Crypto.Key = keyBytes
Crypto.IV = keyBytes
Dim Icrypto As ICryptoTransform = Crypto.CreateEncryptor
Dim Resultatbytes() As Byte = Icrypto.TransformFinalBlock(texteEnBytes, 0, texteEnBytes.Length)
Dim passecrypt = Convert.ToBase64String(Resultatbytes)
If lines1(0) = passecrypt Then
mailtex = TextBox1.Text
TextBox1.Clear()
Label1.Text = "Entrer vôtre mots de passe"
TextBox1.UseSystemPasswordChar = True
PictureBox1.Show()
stepe = 1
Else
MsgBox("Mail incorrect", MsgBoxStyle.Critical)
End If
ElseIf stepe = 1 Then
My.Computer.Network.DownloadFile(ipsite & "/utilisateur/" & Form3.Label21.Text & "/pass.txt", cozip & "\pass.txt")
Dim lines1() As String = File.ReadAllLines(cozip & "\pass.txt")
File.Delete(cozip & "\pass.txt")
Dim texteEnBytes() As Byte = Encoding.UTF8.GetBytes(TextBox1.Text)
Dim keyBytes() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto As New DESCryptoServiceProvider()
Crypto.Key = keyBytes
Crypto.IV = keyBytes
Dim Icrypto As ICryptoTransform = Crypto.CreateEncryptor
Dim Resultatbytes() As Byte = Icrypto.TransformFinalBlock(texteEnBytes, 0, texteEnBytes.Length)
Dim passecrypt = Convert.ToBase64String(Resultatbytes)
If lines1(0) = passecrypt Then
TextBox1.Clear()
Label1.Text = "Code de vérification"
TextBox1.UseSystemPasswordChar = False
PictureBox1.Hide()
Gencode()
Else
MsgBox("Mots de passe incorrect", MsgBoxStyle.Critical)
End If
ElseIf stepe = 2 Then
If TextBox1.Text = Label2.Text Then
TextBox1.Clear()
Label1.Text = "Sélectionner un code ?"
Dim fwr As FtpWebRequest
fwr = FtpWebRequest.Create(ipserver & "/" & "Utilisateur" & "/" & Form3.Label21.Text & "/")
fwr.Credentials = New NetworkCredential("yoannsafe", passftp)
fwr.Method = WebRequestMethods.Ftp.ListDirectory
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
Dim str As String = sr.ReadLine()
While Not str Is Nothing
If str.Contains("code") Then
ComboBox1.Items.Add(str.Replace(" " & Form3.Label21.Text & ".txt", ""))
End If
str = sr.ReadLine()
End While
sr.Close()
If ComboBox1.Items.Count = 0 Then
MsgBox("Aucun code de récupération est disponible", MsgBoxStyle.Critical)
Close()
Else
ComboBox1.Show()
End If
Else
MsgBox("Le code de vérification est incorrect", MsgBoxStyle.Critical)
End If
ElseIf stepe = 3 Then
Dim lines() As String = File.ReadAllLines(cozip & ComboBox1.SelectedItem & " " & Form3.Label21.Text & ".txt")
Dim Resultatbytes() As Byte = Convert.FromBase64String(lines(0))
Dim keyBytes() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto As New DESCryptoServiceProvider()
Crypto.Key = keyBytes
Crypto.IV = keyBytes
Dim Icrypto As ICryptoTransform = Crypto.CreateDecryptor()
Dim donné() As Byte = Icrypto.TransformFinalBlock(Resultatbytes, 0, Resultatbytes.Length)
Dim maildecrypt = Encoding.UTF8.GetString(donné)
If TextBox1.Text = maildecrypt.ToString Then
File.Delete(cozip & ComboBox1.SelectedItem & " " & Form3.Label21.Text & ".txt")
TextBox1.Clear()
TextBox1.Hide()
Label1.Text = "Vérification terminer"
Button1.Text = "Régénérer les codes"
stepe = 4
Else
MsgBox("Code de récupération incorrect", MsgBoxStyle.Critical)
End If
ElseIf stepe = 4 Then
Dim msg2 = MsgBox("Voulez-vous raimer Régénérer des codes ? (Les anciens codes seront supprimés)", MsgBoxStyle.YesNo)
If msg2 = MsgBoxResult.Yes Then
regene()
Else
End If
End If
End Sub
Private Sub PictureBox1_Click(sender As Object, e As EventArgs) Handles PictureBox1.Click
If TextBox1.UseSystemPasswordChar = True Then
TextBox1.UseSystemPasswordChar = False
PictureBox1.Image = My.Resources.erggr
Else
TextBox1.UseSystemPasswordChar = True
PictureBox1.Image = My.Resources.gyugcdyug
End If
End Sub
Function Gencode() As Integer
Dim NumRandom As Integer
Dim Rand As Random = New Random
Dim NumStr As String
Try
NumRandom = (Rand.Next(1, 999999))
NumStr = Strings.Right("" & NumRandom.ToString(), 6)
Label2.Text = "LM-" & NumStr
mail()
Catch ex As Exception
End Try
End Function
Sub mail()
Dim maj As New WebClient
Dim vri As String = maj.DownloadString("http://lecteur2.lecteur-media.fr/lecteur/passmail.txt")
Dim MyMailMessage As New MailMessage()
Dim SMTPServer As New SmtpClient("mail48.lwspanel.com")
Dim mail = mailtex
Dim message = "Le code de vérification est le: " & Label2.Text
MyMailMessage.From = New MailAddress("noreply@lecteur-media.fr")
MyMailMessage.To.Add(mail)
MyMailMessage.Subject = ("Vérification de connexion")
MyMailMessage.Body = (message)
SMTPServer.Port = ("587") 'Port
SMTPServer.Credentials = New System.Net.NetworkCredential("noreply@lecteur-media.fr", vri)
SMTPServer.EnableSsl = True
SMTPServer.Send(MyMailMessage) 'Envoi
MsgBox("Le code de vérification été envoyé à l'adresse mail", MsgBoxStyle.Information)
stepe = 2
End Sub
Private Sub ComboBox1_SelectedValueChanged(sender As Object, e As EventArgs) Handles ComboBox1.SelectedValueChanged
My.Computer.Network.DownloadFile(ipsite & "/utilisateur/" & Form3.Label21.Text & "/" & ComboBox1.SelectedItem & " " & Form3.Label21.Text & ".txt", cozip & ComboBox1.SelectedItem & " " & Form3.Label21.Text & ".txt")
Label1.Text = "Entrer le code de " & ComboBox1.SelectedItem
TextBox1.Clear()
ComboBox1.Hide()
stepe = 3
End Sub
Sub regene()
Dim NumRandom As Integer
Dim Rand As Random = New Random
Dim NumStr As String
Dim code As String = ""
NumRandom = (Rand.Next(1, 999999))
NumStr = Strings.Right("" & NumRandom.ToString(), 6)
code = "LM-" & NumStr
Dim t4 = cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt"
Dim sw4 As New StreamWriter(t4)
sw4.WriteLine(Form3.Label21.Text & code & "code1")
sw4.Close()
Dim NumRandom2 As Integer
Dim Rand2 As Random = New Random
Dim NumStr2 As String
Dim code2 As String = ""
NumRandom2 = (Rand2.Next(1, 999999))
NumStr2 = Strings.Right("" & NumRandom2.ToString(), 6)
code2 = "LM-" & NumStr2
Dim t5 = cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt"
Dim sw5 As New StreamWriter(t5)
sw5.WriteLine(Form3.Label21.Text & code2 & "code2")
sw5.Close()
Dim NumRandom3 As Integer
Dim Rand3 As Random = New Random
Dim NumStr3 As String
Dim code3 As String = ""
NumRandom3 = (Rand3.Next(1, 999999))
NumStr3 = Strings.Right("" & NumRandom3.ToString(), 6)
code3 = "LM-" & NumStr3
Dim t6 = cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt"
Dim sw6 As New StreamWriter(t6)
sw6.WriteLine(Form3.Label21.Text & code3 & "code3")
sw6.Close()
Dim MyMailMessage As New MailMessage()
Dim SMTPServer As New SmtpClient("mail48.lwspanel.com")
Dim mail = mailtex
Dim message = "Bonjour, " & Form3.Label21.Text & vbNewLine & vbNewLine & "Vous trouverez en pièce jointe vos code de récupération qui vous permettras de récuperer votre compte en cas de probléme." & vbNewLine & vbNewLine & "Nous vous souhaitons une bonne journée."
MyMailMessage.From = New MailAddress("noreply@lecteur-media.fr")
MyMailMessage.To.Add(mail)
MyMailMessage.Subject = ("code de récupération")
MyMailMessage.Body = (message)
SMTPServer.Port = ("587") 'Port
SMTPServer.Credentials = New System.Net.NetworkCredential("noreply@lecteur-media.fr", "pC1*zzU9-qtZjdT")
SMTPServer.EnableSsl = True
Dim data = New Net.Mail.Attachment(cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt")
Dim data2 = New Net.Mail.Attachment(cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt")
Dim data3 = New Net.Mail.Attachment(cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt")
MyMailMessage.Attachments.Add(data)
MyMailMessage.Attachments.Add(data2)
MyMailMessage.Attachments.Add(data3)
SMTPServer.Send(MyMailMessage) 'Envoi
MyMailMessage.Attachments.Dispose()
codecrypte
End Sub
Sub codecrypte()
Dim lines1() As String = File.ReadAllLines(cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt")
Dim lines2() As String = File.ReadAllLines(cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt")
Dim lines3() As String = File.ReadAllLines(cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt")
Dim code1 As String = lines1(0)
Dim code2 As String = lines2(0)
Dim code3 As String = lines3(0)
For Each fichier As String In IO.Directory.GetFiles(cozip)
Dim info As New IO.FileInfo(fichier)
File.Delete(cozip & info.Name)
Next
Dim texteEnBytes() As Byte = Encoding.UTF8.GetBytes(code1.ToString)
Dim keyBytes() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto As New DESCryptoServiceProvider()
Crypto.Key = keyBytes
Crypto.IV = keyBytes
Dim Icrypto As ICryptoTransform = Crypto.CreateEncryptor
Dim Resultatbytes() As Byte = Icrypto.TransformFinalBlock(texteEnBytes, 0, texteEnBytes.Length)
Dim code1crypt = Convert.ToBase64String(Resultatbytes)
Dim t1 = cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt"
Dim sw1 As New StreamWriter(cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt")
sw1.WriteLine(code1crypt)
sw1.Close()
Dim texteEnBytes2() As Byte = Encoding.UTF8.GetBytes(code2.ToString)
Dim keyBytes2() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto2 As New DESCryptoServiceProvider()
Crypto2.Key = keyBytes2
Crypto2.IV = keyBytes2
Dim Icrypto2 As ICryptoTransform = Crypto2.CreateEncryptor
Dim Resultatbytes2() As Byte = Icrypto2.TransformFinalBlock(texteEnBytes2, 0, texteEnBytes2.Length)
Dim code1crypt2 = Convert.ToBase64String(Resultatbytes2)
Dim t2 = cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt"
Dim sw2 As New StreamWriter(cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt")
sw2.WriteLine(code1crypt2)
sw2.Close()
Dim texteEnBytes3() As Byte = Encoding.UTF8.GetBytes(code3.ToString)
Dim keyBytes3() As Byte = Encoding.UTF8.GetBytes("Jj@msms7")
Dim Crypto3 As New DESCryptoServiceProvider()
Crypto3.Key = keyBytes3
Crypto3.IV = keyBytes3
Dim Icrypto3 As ICryptoTransform = Crypto3.CreateEncryptor
Dim Resultatbytes3() As Byte = Icrypto3.TransformFinalBlock(texteEnBytes3, 0, texteEnBytes3.Length)
Dim code1crypt3 = Convert.ToBase64String(Resultatbytes3)
Dim t3 = cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt"
Dim sw3 As New StreamWriter(cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt")
sw3.WriteLine(code1crypt3)
sw3.Close()
Dim fwr As FtpWebRequest
fwr = FtpWebRequest.Create(ipserver & "/" & "Utilisateur" & "/" & Form3.Label21.Text & "/")
fwr.Credentials = New NetworkCredential("yoannsafe", passftp)
fwr.Method = WebRequestMethods.Ftp.ListDirectory
Dim sr As New StreamReader(fwr.GetResponse().GetResponseStream())
Dim str As String = sr.ReadLine()
While Not str Is Nothing
If str.Contains("code") Then
ListBox1.Items.Add(str.Replace(" " & Form3.Label21.Text & ".txt", ""))
End If
str = sr.ReadLine()
End While
sr.Close()
del()
End Sub
Sub del()
ListBox1.SelectedIndex = begeg
Dim ftreq As FtpWebRequest = FtpWebRequest.Create(ipserver & "/Utilisateur/" & Form3.Label21.Text & "/" & ListBox1.SelectedItem)
ftreq.Method = WebRequestMethods.Ftp.DeleteFile
ftreq.Credentials = New NetworkCredential("yoannsafe", passftp)
Dim ftpresp As FtpWebResponse = ftreq.GetResponse
If begeg = ListBox1.Items.Count - 1 Then
My.Computer.Network.UploadFile(cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt", ipserver & "/utilisateur/" & Form3.Label21.Text & "/code 1 de récupération " & Form3.Label21.Text & ".txt")
My.Computer.Network.UploadFile(cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt", ipserver & "/utilisateur/" & Form3.Label21.Text & "/code 2 de récupération " & Form3.Label21.Text & ".txt")
My.Computer.Network.UploadFile(cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt", ipserver & "/utilisateur/" & Form3.Label21.Text & "/code 3 de récupération " & Form3.Label21.Text & ".txt")
File.Delete(cozip & "code 1 de récupération " & Form3.Label21.Text & ".txt")
File.Delete(cozip & "code 2 de récupération " & Form3.Label21.Text & ".txt")
File.Delete(cozip & "code 3 de récupération " & Form3.Label21.Text & ".txt")
MsgBox("Vos nouveaux codes de récupération ont été envoyez par mail, les anciens ont été supprimer", MsgBoxStyle.Information)
Close()
Else
begeg = begeg + 1
del()
End If
End Sub
Private Sub Form39_Closed(sender As Object, e As EventArgs) Handles Me.Closed
If stepe = 3 Then
File.Delete(cozip & ComboBox1.SelectedItem & " " & Form3.Label21.Text & ".txt")
End If
TextBox1.Clear()
mailtex = ""
begeg = 0
stepe = 0
ComboBox1.Hide()
PictureBox1.Hide()
ListBox1.Items.Clear()
ComboBox1.Items.Clear()
TextBox1.Show()
End Sub
End Class