Advertisement
Guest User

Untitled

a guest
Jan 3rd, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.55 KB | None | 0 0
  1. Imports System.IO
  2. Imports System.Net
  3. Imports MySql.Data.MySqlClient
  4.  
  5. Module Module1
  6.  
  7. Sub Main()
  8.  
  9. Dim x() As System.Net.IPAddress = System.Net.Dns.GetHostAddresses(System.Net.Dns.GetHostName())
  10. Dim timeStamp As String = DateTime.Now.ToString("dd/MM hh:mm:ss")
  11. Dim weblogs_connection As New MySqlConnection("datasource=yoursite.com;port=3306;username=root;password=root;database=db")
  12. Dim strIPAddress As String
  13. Dim strHostName As String
  14. strHostName = System.Net.Dns.GetHostName()
  15. strIPAddress = System.Net.Dns.GetHostByName(strHostName).AddressList(0).ToString()
  16. Dim command As New MySqlCommand("INSERT INTO `website_logs`(`timestamp`, `ipadress`, `visited_page`, `country`,`op_system`) VALUES (@timestamp,@ipadress,@visited_page,@country,@user_os)", weblogs_connection)
  17.  
  18. command.Parameters.Add("@timestamp", MySqlDbType.VarChar).Value = getTimestamp()
  19. command.Parameters.Add("@ipadress", MySqlDbType.VarChar).Value = GetIP()
  20. command.Parameters.Add("@visited_page", MySqlDbType.VarChar).Value = "loader"
  21. command.Parameters.Add("@country", MySqlDbType.VarChar).Value = Getcountry()
  22. command.Parameters.Add("@user_os", MySqlDbType.VarChar).Value = "Windows"
  23.  
  24. weblogs_connection.Open()
  25.  
  26. If command.ExecuteNonQuery() = 1 Then
  27.  
  28. ' do your thing here
  29.  
  30. Else
  31.  
  32. MsgBox("Error happened!")
  33. Application.Exit()
  34.  
  35. End If
  36. Try
  37.  
  38. Catch ex As MySqlException
  39. MessageBox.Show(ex.Message)
  40. Finally
  41. weblogs_connection.Close()
  42. End Try
  43. 'mysql connect
  44. Dim shit As New MySqlConnection("datasource=yoursite.com;port=3306;username=root;password=root;database=db")
  45. Dim command_user As New MySqlCommand("INSERT INTO `user_logs`(`username`, `last_known_ip`,`timestamp`) VALUES (@username,@lastknownip,@timestamp)", shit)
  46.  
  47. command_user.Parameters.Add("@username", MySqlDbType.VarChar).Value = My.Settings.loggeduser
  48. command_user.Parameters.Add("@lastknownip", MySqlDbType.VarChar).Value = GetIP()
  49. command_user.Parameters.Add("@timestamp", MySqlDbType.VarBinary).Value = getTimestamp()
  50.  
  51. shit.Open()
  52.  
  53. If command_user.ExecuteNonQuery() = 1 Then
  54. ' do your thing here
  55. Else
  56. MsgBox("problem happened")
  57. End If
  58. Try
  59. Catch ex As MySqlException
  60. MessageBox.Show(ex.Message)
  61. Finally
  62. shit.Close()
  63.  
  64. End Try
  65.  
  66.  
  67. End Sub
  68.  
  69. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement