Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Manda Mex a tutti gli Hub - Form1.vb

Form1.vb

Caricato da:
Scarica il programma completo

  1. Option Strict Off
  2.  
  3. Imports System.Net.Sockets
  4. Imports System.Text
  5. Imports System.IO
  6. Imports System
  7.  
  8. Public Class Form1
  9.     Inherits System.Windows.Forms.Form
  10.  
  11.     Dim ind, porta As String
  12.  
  13.     'General stuff
  14.     Dim ore As Integer
  15.     Dim OpList() As String
  16.     Dim isConnectedFlag As Boolean
  17.     Dim UserStats As UserStatisticStructure
  18.     Dim Timer As TimerStructure
  19.     Const BotVersion As String = "Manda mex By GoLDBeRG"
  20.  
  21.     'Socket stuff
  22.     Private Client As New TcpClient
  23.     Private ClientStream As NetworkStream
  24.     Private ReadBuffer(1024) As Byte
  25.     Private ReadMessage As String
  26.     Public Delegate Sub ProcessInvoker(ByVal Data As String)
  27.  
  28.     'Timerstuff
  29.     Private RunTime As New System.Timers.Timer(1000)
  30.  
  31.     Structure TimerStructure
  32.         Dim Connect As Integer
  33.         Dim LockConnect As Integer
  34.     End Structure
  35.  
  36.     Structure UserStatisticStructure
  37.         Dim IsOp As Boolean
  38.         Dim isOnline As Integer
  39.         Dim Username As String
  40.         Dim Password As String
  41.         Dim Email As String
  42.         Dim Description As String
  43.         Dim Sharesize As String
  44.         Dim Connection As String
  45.         Dim HubAdress As String
  46.     End Structure
  47.  
  48. #Region " Codice generato da Progettazione Windows Form "
  49.  
  50.     Public Sub New()
  51.         MyBase.New()
  52.  
  53.         'Chiamata richiesta da Progettazione Windows Form.
  54.         InitializeComponent()
  55.  
  56.         'Aggiungere le eventuali istruzioni di inizializzazione dopo la chiamata a InitializeComponent()
  57.  
  58.     End Sub
  59.  
  60.     'Form esegue l'override del metodo Dispose per pulire l'elenco dei componenti.
  61.     Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
  62.         If disposing Then
  63.             If Not (components Is Nothing) Then
  64.                 components.Dispose()
  65.             End If
  66.         End If
  67.         MyBase.Dispose(disposing)
  68.     End Sub
  69.  
  70.     'Richiesto da Progettazione Windows Form
  71.     Private components As System.ComponentModel.IContainer
  72.  
  73.     'NOTA: la procedura che segue è richiesta da Progettazione Windows Form.
  74.     'Può essere modificata in Progettazione Windows Form.  
  75.     'Non modificarla nell'editor del codice.
  76.     Friend WithEvents btnConnect As System.Windows.Forms.Button
  77.     Friend WithEvents StatusBar As System.Windows.Forms.StatusBar
  78.     Friend WithEvents StatusConnected As System.Windows.Forms.StatusBarPanel
  79.     Friend WithEvents StatusHubname As System.Windows.Forms.StatusBarPanel
  80.     Friend WithEvents StatusUsers As System.Windows.Forms.StatusBarPanel
  81.     Friend WithEvents ProgressBar As System.Windows.Forms.ProgressBar
  82.     Friend WithEvents txtshare As System.Windows.Forms.TextBox
  83.     Friend WithEvents txtuser As System.Windows.Forms.TextBox
  84.     Friend WithEvents txtpass As System.Windows.Forms.TextBox
  85.     Friend WithEvents txtdesc As System.Windows.Forms.TextBox
  86.     Friend WithEvents txtemail As System.Windows.Forms.TextBox
  87.     Friend WithEvents cmbSpeed As System.Windows.Forms.ComboBox
  88.     Friend WithEvents nmrAutoreconnect As System.Windows.Forms.NumericUpDown
  89.     Friend WithEvents Label1 As System.Windows.Forms.Label
  90.     Friend WithEvents btnDisconnect As System.Windows.Forms.Button
  91.     Friend WithEvents lblShareSize As System.Windows.Forms.Label
  92.     Friend WithEvents chkConfirmExit As System.Windows.Forms.CheckBox
  93.     Friend WithEvents Button2 As System.Windows.Forms.Button
  94.     Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
  95.     Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
  96.     Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
  97.     Friend WithEvents Button3 As System.Windows.Forms.Button
  98.     Friend WithEvents Button4 As System.Windows.Forms.Button
  99.     Friend WithEvents ok As System.Windows.Forms.Label
  100.     Friend WithEvents cmd2 As System.Windows.Forms.TextBox
  101.     Friend WithEvents cmd4 As System.Windows.Forms.TextBox
  102.     Friend WithEvents cmd1 As System.Windows.Forms.TextBox
  103.     Friend WithEvents cmd3 As System.Windows.Forms.TextBox
  104.     Friend WithEvents txtport As System.Windows.Forms.TextBox
  105.     Friend WithEvents txtip As System.Windows.Forms.ListBox
  106.     Friend WithEvents ContextMenu1 As System.Windows.Forms.ContextMenu
  107.     Friend WithEvents MenuItem1 As System.Windows.Forms.MenuItem
  108.     Friend WithEvents Timer2 As System.Windows.Forms.Timer
  109.     Friend WithEvents Button1 As System.Windows.Forms.Button
  110.     <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
  111.         Me.components = New System.ComponentModel.Container
  112.         Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
  113.         Me.btnConnect = New System.Windows.Forms.Button
  114.         Me.StatusBar = New System.Windows.Forms.StatusBar
  115.         Me.StatusConnected = New System.Windows.Forms.StatusBarPanel
  116.         Me.StatusHubname = New System.Windows.Forms.StatusBarPanel
  117.         Me.StatusUsers = New System.Windows.Forms.StatusBarPanel
  118.         Me.ProgressBar = New System.Windows.Forms.ProgressBar
  119.         Me.txtshare = New System.Windows.Forms.TextBox
  120.         Me.txtuser = New System.Windows.Forms.TextBox
  121.         Me.txtpass = New System.Windows.Forms.TextBox
  122.         Me.txtdesc = New System.Windows.Forms.TextBox
  123.         Me.txtemail = New System.Windows.Forms.TextBox
  124.         Me.cmbSpeed = New System.Windows.Forms.ComboBox
  125.         Me.nmrAutoreconnect = New System.Windows.Forms.NumericUpDown
  126.         Me.Label1 = New System.Windows.Forms.Label
  127.         Me.btnDisconnect = New System.Windows.Forms.Button
  128.         Me.lblShareSize = New System.Windows.Forms.Label
  129.         Me.chkConfirmExit = New System.Windows.Forms.CheckBox
  130.         Me.Button2 = New System.Windows.Forms.Button
  131.         Me.GroupBox1 = New System.Windows.Forms.GroupBox
  132.         Me.TextBox1 = New System.Windows.Forms.TextBox
  133.         Me.TextBox2 = New System.Windows.Forms.TextBox
  134.         Me.Button3 = New System.Windows.Forms.Button
  135.         Me.Button4 = New System.Windows.Forms.Button
  136.         Me.ok = New System.Windows.Forms.Label
  137.         Me.cmd2 = New System.Windows.Forms.TextBox
  138.         Me.cmd4 = New System.Windows.Forms.TextBox
  139.         Me.cmd1 = New System.Windows.Forms.TextBox
  140.         Me.cmd3 = New System.Windows.Forms.TextBox
  141.         Me.txtport = New System.Windows.Forms.TextBox
  142.         Me.txtip = New System.Windows.Forms.ListBox
  143.         Me.ContextMenu1 = New System.Windows.Forms.ContextMenu
  144.         Me.MenuItem1 = New System.Windows.Forms.MenuItem
  145.         Me.Timer2 = New System.Windows.Forms.Timer(Me.components)
  146.         Me.Button1 = New System.Windows.Forms.Button
  147.         CType(Me.StatusConnected, System.ComponentModel.ISupportInitialize).BeginInit()
  148.         CType(Me.StatusHubname, System.ComponentModel.ISupportInitialize).BeginInit()
  149.         CType(Me.StatusUsers, System.ComponentModel.ISupportInitialize).BeginInit()
  150.         CType(Me.nmrAutoreconnect, System.ComponentModel.ISupportInitialize).BeginInit()
  151.         Me.GroupBox1.SuspendLayout()
  152.         Me.SuspendLayout()
  153.         '
  154.         'btnConnect
  155.         '
  156.         Me.btnConnect.FlatStyle = System.Windows.Forms.FlatStyle.System
  157.         Me.btnConnect.Location = New System.Drawing.Point(32, 256)
  158.         Me.btnConnect.Name = "btnConnect"
  159.         Me.btnConnect.TabIndex = 0
  160.         Me.btnConnect.TabStop = False
  161.         Me.btnConnect.Text = "Connetti"
  162.         '
  163.         'StatusBar
  164.         '
  165.         Me.StatusBar.Location = New System.Drawing.Point(0, 422)
  166.         Me.StatusBar.Name = "StatusBar"
  167.         Me.StatusBar.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.StatusConnected, Me.StatusHubname, Me.StatusUsers})
  168.         Me.StatusBar.ShowPanels = True
  169.         Me.StatusBar.Size = New System.Drawing.Size(374, 22)
  170.         Me.StatusBar.SizingGrip = False
  171.         Me.StatusBar.TabIndex = 1
  172.         '
  173.         'StatusConnected
  174.         '
  175.         Me.StatusConnected.Alignment = System.Windows.Forms.HorizontalAlignment.Center
  176.         Me.StatusConnected.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
  177.         Me.StatusConnected.Text = "Not Connected"
  178.         Me.StatusConnected.Width = 124
  179.         '
  180.         'StatusHubname
  181.         '
  182.         Me.StatusHubname.Alignment = System.Windows.Forms.HorizontalAlignment.Center
  183.         Me.StatusHubname.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
  184.         Me.StatusHubname.Text = "No Hub"
  185.         Me.StatusHubname.Width = 124
  186.         '
  187.         'StatusUsers
  188.         '
  189.         Me.StatusUsers.Alignment = System.Windows.Forms.HorizontalAlignment.Center
  190.         Me.StatusUsers.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring
  191.         Me.StatusUsers.Text = "0"
  192.         Me.StatusUsers.Width = 124
  193.         '
  194.         'ProgressBar
  195.         '
  196.         Me.ProgressBar.Location = New System.Drawing.Point(8, 360)
  197.         Me.ProgressBar.Maximum = 3
  198.         Me.ProgressBar.Name = "ProgressBar"
  199.         Me.ProgressBar.Size = New System.Drawing.Size(360, 16)
  200.         Me.ProgressBar.Step = 1
  201.         Me.ProgressBar.TabIndex = 3
  202.         '
  203.         'txtshare
  204.         '
  205.         Me.txtshare.Location = New System.Drawing.Point(8, 80)
  206.         Me.txtshare.MaxLength = 15
  207.         Me.txtshare.Name = "txtshare"
  208.         Me.txtshare.Size = New System.Drawing.Size(96, 20)
  209.         Me.txtshare.TabIndex = 1
  210.         Me.txtshare.Text = "5435743573"
  211.         Me.txtshare.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  212.         '
  213.         'txtuser
  214.         '
  215.         Me.txtuser.Location = New System.Drawing.Point(8, 104)
  216.         Me.txtuser.Name = "txtuser"
  217.         Me.txtuser.Size = New System.Drawing.Size(96, 20)
  218.         Me.txtuser.TabIndex = 2
  219.         Me.txtuser.Text = "AstaLaVista"
  220.         Me.txtuser.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  221.         '
  222.         'txtpass
  223.         '
  224.         Me.txtpass.AutoSize = False
  225.         Me.txtpass.Font = New System.Drawing.Font("Comic Sans MS", 9.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
  226.         Me.txtpass.Location = New System.Drawing.Point(8, 128)
  227.         Me.txtpass.Name = "txtpass"
  228.         Me.txtpass.PasswordChar = Microsoft.VisualBasic.ChrW(8226)
  229.         Me.txtpass.Size = New System.Drawing.Size(96, 20)
  230.         Me.txtpass.TabIndex = 3
  231.         Me.txtpass.Text = "123456123"
  232.         Me.txtpass.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  233.         '
  234.         'txtdesc
  235.         '
  236.         Me.txtdesc.BackColor = System.Drawing.Color.White
  237.         Me.txtdesc.Location = New System.Drawing.Point(8, 152)
  238.         Me.txtdesc.Name = "txtdesc"
  239.         Me.txtdesc.Size = New System.Drawing.Size(360, 20)
  240.         Me.txtdesc.TabIndex = 4
  241.         Me.txtdesc.TabStop = False
  242.         Me.txtdesc.Text = "Manda Mex By GoLDBeRG"
  243.         Me.txtdesc.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  244.         '
  245.         'txtemail
  246.         '
  247.         Me.txtemail.BackColor = System.Drawing.Color.White
  248.         Me.txtemail.Location = New System.Drawing.Point(8, 176)
  249.         Me.txtemail.Name = "txtemail"
  250.         Me.txtemail.Size = New System.Drawing.Size(360, 20)
  251.         Me.txtemail.TabIndex = 5
  252.         Me.txtemail.TabStop = False
  253.         Me.txtemail.Text = "www.oenrik.it"
  254.         Me.txtemail.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  255.         '
  256.         'cmbSpeed
  257.         '
  258.         Me.cmbSpeed.BackColor = System.Drawing.Color.White
  259.         Me.cmbSpeed.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
  260.         Me.cmbSpeed.Items.AddRange(New Object() {"BOT", "ISDN", "DSL", "Satellite", "Wireless", "LAN(T1)", "LAN(T3)"})
  261.         Me.cmbSpeed.Location = New System.Drawing.Point(112, 120)
  262.         Me.cmbSpeed.Name = "cmbSpeed"
  263.         Me.cmbSpeed.Size = New System.Drawing.Size(256, 21)
  264.         Me.cmbSpeed.TabIndex = 2
  265.         Me.cmbSpeed.TabStop = False
  266.         '
  267.         'nmrAutoreconnect
  268.         '
  269.         Me.nmrAutoreconnect.BackColor = System.Drawing.Color.White
  270.         Me.nmrAutoreconnect.Location = New System.Drawing.Point(8, 200)
  271.         Me.nmrAutoreconnect.Maximum = New Decimal(New Integer() {60, 0, 0, 0})
  272.         Me.nmrAutoreconnect.Name = "nmrAutoreconnect"
  273.         Me.nmrAutoreconnect.ReadOnly = True
  274.         Me.nmrAutoreconnect.Size = New System.Drawing.Size(48, 20)
  275.         Me.nmrAutoreconnect.TabIndex = 6
  276.         Me.nmrAutoreconnect.TabStop = False
  277.         Me.nmrAutoreconnect.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  278.         '
  279.         'Label1
  280.         '
  281.         Me.Label1.ImageAlign = System.Drawing.ContentAlignment.TopCenter
  282.         Me.Label1.Location = New System.Drawing.Point(56, 200)
  283.         Me.Label1.Name = "Label1"
  284.         Me.Label1.Size = New System.Drawing.Size(80, 16)
  285.         Me.Label1.TabIndex = 7
  286.         Me.Label1.Text = "Autoriconnetti"
  287.         Me.Label1.TextAlign = System.Drawing.ContentAlignment.BottomLeft
  288.         '
  289.         'btnDisconnect
  290.         '
  291.         Me.btnDisconnect.FlatStyle = System.Windows.Forms.FlatStyle.System
  292.         Me.btnDisconnect.Location = New System.Drawing.Point(112, 256)
  293.         Me.btnDisconnect.Name = "btnDisconnect"
  294.         Me.btnDisconnect.TabIndex = 0
  295.         Me.btnDisconnect.TabStop = False
  296.         Me.btnDisconnect.Text = "Disconnetti"
  297.         '
  298.         'lblShareSize
  299.         '
  300.         Me.lblShareSize.ImageAlign = System.Drawing.ContentAlignment.TopCenter
  301.         Me.lblShareSize.Location = New System.Drawing.Point(104, 80)
  302.         Me.lblShareSize.Name = "lblShareSize"
  303.         Me.lblShareSize.Size = New System.Drawing.Size(100, 16)
  304.         Me.lblShareSize.TabIndex = 7
  305.         Me.lblShareSize.TextAlign = System.Drawing.ContentAlignment.BottomLeft
  306.         '
  307.         'chkConfirmExit
  308.         '
  309.         Me.chkConfirmExit.FlatStyle = System.Windows.Forms.FlatStyle.System
  310.         Me.chkConfirmExit.Location = New System.Drawing.Point(8, 232)
  311.         Me.chkConfirmExit.Name = "chkConfirmExit"
  312.         Me.chkConfirmExit.Size = New System.Drawing.Size(104, 16)
  313.         Me.chkConfirmExit.TabIndex = 8
  314.         Me.chkConfirmExit.TabStop = False
  315.         Me.chkConfirmExit.Text = "Conferma uscita"
  316.         '
  317.         'Button2
  318.         '
  319.         Me.Button2.FlatStyle = System.Windows.Forms.FlatStyle.System
  320.         Me.Button2.Location = New System.Drawing.Point(192, 256)
  321.         Me.Button2.Name = "Button2"
  322.         Me.Button2.TabIndex = 0
  323.         Me.Button2.TabStop = False
  324.         Me.Button2.Text = "Chiudi"
  325.         '
  326.         'GroupBox1
  327.         '
  328.         Me.GroupBox1.Controls.Add(Me.Button1)
  329.         Me.GroupBox1.Controls.Add(Me.TextBox1)
  330.         Me.GroupBox1.Controls.Add(Me.TextBox2)
  331.         Me.GroupBox1.Controls.Add(Me.Button3)
  332.         Me.GroupBox1.FlatStyle = System.Windows.Forms.FlatStyle.System
  333.         Me.GroupBox1.Location = New System.Drawing.Point(8, 280)
  334.         Me.GroupBox1.Name = "GroupBox1"
  335.         Me.GroupBox1.Size = New System.Drawing.Size(360, 72)
  336.         Me.GroupBox1.TabIndex = 9
  337.         Me.GroupBox1.TabStop = False
  338.         Me.GroupBox1.Text = "Aggiunta Hub"
  339.         '
  340.         'TextBox1
  341.         '
  342.         Me.TextBox1.Location = New System.Drawing.Point(8, 16)
  343.         Me.TextBox1.Name = "TextBox1"
  344.         Me.TextBox1.Size = New System.Drawing.Size(272, 20)
  345.         Me.TextBox1.TabIndex = 10
  346.         Me.TextBox1.Text = "pippo.no-ip.info"
  347.         Me.TextBox1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  348.         '
  349.         'TextBox2
  350.         '
  351.         Me.TextBox2.Location = New System.Drawing.Point(280, 16)
  352.         Me.TextBox2.Name = "TextBox2"
  353.         Me.TextBox2.Size = New System.Drawing.Size(64, 20)
  354.         Me.TextBox2.TabIndex = 11
  355.         Me.TextBox2.Text = "411"
  356.         Me.TextBox2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  357.         '
  358.         'Button3
  359.         '
  360.         Me.Button3.FlatStyle = System.Windows.Forms.FlatStyle.System
  361.         Me.Button3.Location = New System.Drawing.Point(280, 40)
  362.         Me.Button3.Name = "Button3"
  363.         Me.Button3.Size = New System.Drawing.Size(64, 23)
  364.         Me.Button3.TabIndex = 0
  365.         Me.Button3.TabStop = False
  366.         Me.Button3.Text = "Aggiungi"
  367.         '
  368.         'Button4
  369.         '
  370.         Me.Button4.FlatStyle = System.Windows.Forms.FlatStyle.System
  371.         Me.Button4.Location = New System.Drawing.Point(272, 256)
  372.         Me.Button4.Name = "Button4"
  373.         Me.Button4.TabIndex = 0
  374.         Me.Button4.TabStop = False
  375.         Me.Button4.Text = "Salva"
  376.         '
  377.         'ok
  378.         '
  379.         Me.ok.Location = New System.Drawing.Point(8, 384)
  380.         Me.ok.Name = "ok"
  381.         Me.ok.Size = New System.Drawing.Size(360, 32)
  382.         Me.ok.TabIndex = 10
  383.         Me.ok.TextAlign = System.Drawing.ContentAlignment.TopCenter
  384.         '
  385.         'cmd2
  386.         '
  387.         Me.cmd2.Location = New System.Drawing.Point(256, 208)
  388.         Me.cmd2.MaxLength = 32512
  389.         Me.cmd2.Name = "cmd2"
  390.         Me.cmd2.Size = New System.Drawing.Size(112, 20)
  391.         Me.cmd2.TabIndex = 7
  392.         Me.cmd2.Text = "2° comando"
  393.         Me.cmd2.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  394.         '
  395.         'cmd4
  396.         '
  397.         Me.cmd4.Location = New System.Drawing.Point(256, 232)
  398.         Me.cmd4.MaxLength = 32512
  399.         Me.cmd4.Name = "cmd4"
  400.         Me.cmd4.Size = New System.Drawing.Size(112, 20)
  401.         Me.cmd4.TabIndex = 9
  402.         Me.cmd4.Text = "4° comando"
  403.         Me.cmd4.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  404.         '
  405.         'cmd1
  406.         '
  407.         Me.cmd1.Location = New System.Drawing.Point(144, 208)
  408.         Me.cmd1.MaxLength = 32512
  409.         Me.cmd1.Name = "cmd1"
  410.         Me.cmd1.Size = New System.Drawing.Size(112, 20)
  411.         Me.cmd1.TabIndex = 6
  412.         Me.cmd1.Text = "1° comando"
  413.         Me.cmd1.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  414.         '
  415.         'cmd3
  416.         '
  417.         Me.cmd3.Location = New System.Drawing.Point(144, 232)
  418.         Me.cmd3.MaxLength = 32512
  419.         Me.cmd3.Name = "cmd3"
  420.         Me.cmd3.Size = New System.Drawing.Size(112, 20)
  421.         Me.cmd3.TabIndex = 8
  422.         Me.cmd3.Text = "3° comando"
  423.         Me.cmd3.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  424.         '
  425.         'txtport
  426.         '
  427.         Me.txtport.BackColor = System.Drawing.Color.White
  428.         Me.txtport.Location = New System.Drawing.Point(112, 96)
  429.         Me.txtport.MaxLength = 15
  430.         Me.txtport.Name = "txtport"
  431.         Me.txtport.ReadOnly = True
  432.         Me.txtport.Size = New System.Drawing.Size(256, 20)
  433.         Me.txtport.TabIndex = 1
  434.         Me.txtport.Text = "411"
  435.         Me.txtport.TextAlign = System.Windows.Forms.HorizontalAlignment.Center
  436.         '
  437.         'txtip
  438.         '
  439.         Me.txtip.BackColor = System.Drawing.Color.White
  440.         Me.txtip.ContextMenu = Me.ContextMenu1
  441.         Me.txtip.Location = New System.Drawing.Point(8, 8)
  442.         Me.txtip.Name = "txtip"
  443.         Me.txtip.ScrollAlwaysVisible = True
  444.         Me.txtip.Size = New System.Drawing.Size(360, 69)
  445.         Me.txtip.Sorted = True
  446.         Me.txtip.TabIndex = 11
  447.         Me.txtip.TabStop = False
  448.         Me.txtip.UseTabStops = False
  449.         '
  450.         'ContextMenu1
  451.         '
  452.         Me.ContextMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.MenuItem1})
  453.         '
  454.         'MenuItem1
  455.         '
  456.         Me.MenuItem1.Index = 0
  457.         Me.MenuItem1.Text = "Elimina"
  458.         '
  459.         'Timer2
  460.         '
  461.         Me.Timer2.Interval = 10000
  462.         '
  463.         'Button1
  464.         '
  465.         Me.Button1.FlatStyle = System.Windows.Forms.FlatStyle.System
  466.         Me.Button1.Location = New System.Drawing.Point(8, 40)
  467.         Me.Button1.Name = "Button1"
  468.         Me.Button1.Size = New System.Drawing.Size(272, 23)
  469.         Me.Button1.TabIndex = 12
  470.         Me.Button1.TabStop = False
  471.         Me.Button1.Text = "Non riesco ad utilizzare il programma!"
  472.         '
  473.         'Form1
  474.         '
  475.         Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
  476.         Me.BackColor = System.Drawing.SystemColors.Control
  477.         Me.ClientSize = New System.Drawing.Size(374, 444)
  478.         Me.Controls.Add(Me.txtip)
  479.         Me.Controls.Add(Me.ok)
  480.         Me.Controls.Add(Me.GroupBox1)
  481.         Me.Controls.Add(Me.Label1)
  482.         Me.Controls.Add(Me.nmrAutoreconnect)
  483.         Me.Controls.Add(Me.txtpass)
  484.         Me.Controls.Add(Me.txtshare)
  485.         Me.Controls.Add(Me.ProgressBar)
  486.         Me.Controls.Add(Me.StatusBar)
  487.         Me.Controls.Add(Me.btnConnect)
  488.         Me.Controls.Add(Me.txtuser)
  489.         Me.Controls.Add(Me.txtdesc)
  490.         Me.Controls.Add(Me.txtemail)
  491.         Me.Controls.Add(Me.cmbSpeed)
  492.         Me.Controls.Add(Me.btnDisconnect)
  493.         Me.Controls.Add(Me.lblShareSize)
  494.         Me.Controls.Add(Me.chkConfirmExit)
  495.         Me.Controls.Add(Me.Button2)
  496.         Me.Controls.Add(Me.Button4)
  497.         Me.Controls.Add(Me.cmd2)
  498.         Me.Controls.Add(Me.cmd4)
  499.         Me.Controls.Add(Me.cmd1)
  500.         Me.Controls.Add(Me.cmd3)
  501.         Me.Controls.Add(Me.txtport)
  502.         Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D
  503.         Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
  504.         Me.MaximizeBox = False
  505.         Me.Name = "Form1"
  506.         Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
  507.         Me.Text = "Manda Mex By GoLDBeRG"
  508.         CType(Me.StatusConnected, System.ComponentModel.ISupportInitialize).EndInit()
  509.         CType(Me.StatusHubname, System.ComponentModel.ISupportInitialize).EndInit()
  510.         CType(Me.StatusUsers, System.ComponentModel.ISupportInitialize).EndInit()
  511.         CType(Me.nmrAutoreconnect, System.ComponentModel.ISupportInitialize).EndInit()
  512.         Me.GroupBox1.ResumeLayout(False)
  513.         Me.ResumeLayout(False)
  514.  
  515.     End Sub
  516.  
  517. #End Region
  518.  
  519.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  520.         AddHandler RunTime.Elapsed, AddressOf TimerFired
  521.  
  522.         If File.Exists(Application.StartupPath & "\indirizzi.gold") = True Then
  523.  
  524.             Dim share As StreamReader = New StreamReader(Application.StartupPath & "\share.gold")
  525.             If share.ReadLine = "" Then
  526.                 share.Close()
  527.                 GoTo casa
  528.             Else
  529.                 share.Close()
  530.             End If
  531.  
  532.  
  533.             Dim connessione As StreamReader = New StreamReader(Application.StartupPath & "\connessione.gold")
  534.             cmbSpeed.Text = connessione.ReadLine
  535.             connessione.Close()
  536.  
  537.             Dim percorso2 As String = Application.StartupPath & "\indirizzi.gold"
  538.             Dim linea As Object
  539.             FileOpen(1, percorso2, OpenMode.Input)
  540.             Do While Not EOF(1)
  541.                 linea = LineInput(1)
  542.                 If linea <> "" Then txtip.Items.Add((linea))
  543.             Loop
  544.             FileClose(1)
  545.  
  546.             Dim share2 As StreamReader = New StreamReader(Application.StartupPath & "\share.gold")
  547.             txtshare.Text = share2.ReadLine
  548.             share2.Close()
  549.  
  550.             Dim descr2 As StreamReader = New StreamReader(Application.StartupPath & "\descrizione.gold")
  551.             txtdesc.Text = descr2.ReadLine
  552.             descr2.Close()
  553.  
  554.             On Error Resume Next
  555.             txtip.SelectedIndex = 0
  556.  
  557.             Dim nick As StreamReader = New StreamReader(Application.StartupPath & "\nick.gold")
  558.             txtuser.Text = nick.ReadLine
  559.             nick.Close()
  560.  
  561.             Dim passwd As StreamReader = New StreamReader(Application.StartupPath & "\passwd.gold")
  562.             txtpass.Text = passwd.ReadLine
  563.             passwd.Close()
  564.  
  565.             Dim email As StreamReader = New StreamReader(Application.StartupPath & "\email.gold")
  566.             txtemail.Text = email.ReadLine
  567.             email.Close()
  568.  
  569.             Dim nmrautoriconnetti As StreamReader = New StreamReader(Application.StartupPath & "\autoriconnetti.gold")
  570.             nmrAutoreconnect.Text = nmrautoriconnetti.ReadLine
  571.             nmrautoriconnetti.Close()
  572.  
  573.             Dim conferma As StreamReader = New StreamReader(Application.StartupPath & "\confermachiusura.gold")
  574.             Dim conf As String
  575.             conf = conferma.ReadLine
  576.             If conf = "si" Then
  577.                 chkConfirmExit.Checked = True
  578.                 conferma.Close()
  579.             Else
  580.                 chkConfirmExit.Checked = False
  581.                 conferma.Close()
  582.             End If
  583.  
  584.             Dim comando1 As StreamReader = New StreamReader(Application.StartupPath & "\comando1.gold")
  585.             cmd1.Text = comando1.ReadLine
  586.             comando1.Close()
  587.  
  588.             Dim comando2 As StreamReader = New StreamReader(Application.StartupPath & "\comando2.gold")
  589.             cmd2.Text = comando2.ReadLine
  590.             comando2.Close()
  591.  
  592.             Dim comando3 As StreamReader = New StreamReader(Application.StartupPath & "\comando3.gold")
  593.             cmd3.Text = comando3.ReadLine
  594.             comando3.Close()
  595.  
  596.             Dim comando4 As StreamReader = New StreamReader(Application.StartupPath & "\comando4.gold")
  597.             cmd4.Text = comando4.ReadLine
  598.             comando4.Close()
  599.  
  600.         Else
  601.             File.Create(Application.StartupPath & "\indirizzi.gold")
  602.             File.Create(Application.StartupPath & "\connessione.gold")
  603.             File.Create(Application.StartupPath & "\share.gold")
  604.             File.Create(Application.StartupPath & "\nick.gold")
  605.             File.Create(Application.StartupPath & "\passwd.gold")
  606.             File.Create(Application.StartupPath & "\email.gold")
  607.             File.Create(Application.StartupPath & "\autoriconnetti.gold")
  608.             File.Create(Application.StartupPath & "\confermachiusura.gold")
  609.             File.Create(Application.StartupPath & "\comando1.gold")
  610.             File.Create(Application.StartupPath & "\comando2.gold")
  611.             File.Create(Application.StartupPath & "\comando3.gold")
  612.             File.Create(Application.StartupPath & "\comando4.gold")
  613.             File.Create(Application.StartupPath & "\descrizione.gold")
  614.             MessageBox.Show("Ok i file di salvataggio sono stati correttamente creati, si prega di riavviare l'appilicazione", "Attention", MessageBoxButtons.OK, MessageBoxIcon.Information)
  615.             End
  616.         End If
  617. casa:
  618.     End Sub
  619.  
  620.     Public Sub TimerFired(ByVal sender As Object, ByVal e As System.Timers.ElapsedEventArgs)
  621.         If RunTime.Enabled Then
  622.  
  623.             If Timer.LockConnect > 0 Then
  624.                 btnConnect.Text = CStr(Timer.LockConnect)
  625.                 Timer.LockConnect -= 1
  626.             ElseIf Timer.LockConnect = 0 Then
  627.                 Timer.LockConnect = -1
  628.                 btnConnect.Text = "Connect"
  629.                 btnConnect.Enabled = True
  630.             ElseIf btnConnect.Enabled = False Then
  631.                 btnConnect.Text = "Connect"
  632.                 btnConnect.Enabled = True
  633.             End If
  634.  
  635.             If UserStats.isOnline > -1 Then UserStats.isOnline -= 1
  636.  
  637.             If Timer.Connect > 0 Then
  638.                 Me.StatusConnected.Text = "Connecting in " & CStr(Timer.Connect)
  639.                 Timer.Connect -= 1
  640.             ElseIf Timer.Connect = 0 Then
  641.                 Timer.Connect = -1
  642.                 Connect(txtip.Text, txtport.Text)
  643.             End If
  644.  
  645.             'End timer
  646.             If Timer.Connect = -1 And UserStats.isOnline = -1 And Timer.LockConnect = -1 Then RunTime.Stop()
  647.  
  648.         End If
  649.     End Sub
  650.  
  651.     Private Sub Disconnect()
  652.         On Error Resume Next
  653.         Timer.Connect = -1
  654.         ClientStream.Close()
  655.         Client.Close()
  656.         Timer.LockConnect = -1
  657.         ProgressBar.Value = 0
  658.         UserStats.isOnline = -1
  659.         Me.StatusUsers.Text = "0"
  660.         Me.StatusConnected.Text = "Not Connected"
  661.         Me.StatusHubname.Text = "No Hub"
  662.         isConnectedFlag = False
  663.         ReadMessage = ""
  664.         Timer2.Enabled = True
  665.     End Sub
  666.  
  667.     Private Sub StoreUserdata()
  668.         ok.Text = ("*** Connecting to " & txtip.Text & "..")
  669.         UserStats.Username = txtuser.Text
  670.         UserStats.Password = txtpass.Text
  671.         UserStats.Description = txtdesc.Text
  672.         UserStats.Email = txtemail.Text
  673.         If txtshare.Text <> "" Then UserStats.Sharesize = txtshare.Text Else UserStats.Sharesize = "0"
  674.         UserStats.Connection = cmbSpeed.Text
  675.         UserStats.HubAdress = txtip.Text
  676.     End Sub
  677.  
  678.     Private Sub Connect(ByVal HubAdress As String, ByVal HubPort As String)
  679.         'Lock the Connect button
  680.         Timer.Connect = -1
  681.         Disconnect()
  682.  
  683.         'Check if a hubadress was entered
  684.         If txtip.Text = "" Then
  685.             MsgBox("Please enter an adress or IP to connect to.", MsgBoxStyle.Exclamation, Me.Text)
  686.             Exit Sub
  687.         End If
  688.  
  689.         'Check if a sharesize was entered
  690.         If txtshare.Text = "" Then
  691.             UserStats.Sharesize = "0"
  692.         ElseIf Not IsNumeric(txtshare.Text) Then
  693.             MsgBox("Sharesize requires a numeric value in bytes to work.", MsgBoxStyle.Exclamation, Me.Text)
  694.             Exit Sub
  695.         End If
  696.  
  697.         'Check if a username is entered
  698.         If txtuser.Text = "" Then
  699.             MsgBox("Please enter a username in the settings.", MsgBoxStyle.Exclamation, Me.Text)
  700.             Exit Sub
  701.         End If
  702.  
  703.         'Check if a port is entered
  704.         If HubPort.Length = 0 Then
  705.             HubPort = "411"
  706.         ElseIf Not IsNumeric(HubPort) Then
  707.             MsgBox("Server Port is not a valid port. Try again (leave blank for default 411)", MsgBoxStyle.Exclamation, Me.Text)
  708.             Exit Sub
  709.         End If
  710.  
  711.         ProgressBar.Value = 1
  712.         btnConnect.Enabled = False
  713.         StoreUserdata()
  714.  
  715.         Try
  716.  
  717.             'Make new connection
  718.             Client = New TcpClient(HubAdress, HubPort)
  719.             ClientStream = Client.GetStream
  720.             isConnectedFlag = True
  721.             ClientStream.BeginRead(ReadBuffer, 0, 1024, AddressOf DoRead, Nothing)
  722.  
  723.         Catch Ex As Exception
  724.             'Nobody answered
  725.             ok.Text = ("*** Server is not active or the adress/port is invalid.")
  726.             ProgressBar.Value = 0
  727.             btnConnect.Enabled = True
  728.             If nmrAutoreconnect.Value > 0 Then
  729.                 Timer.Connect = CInt(nmrAutoreconnect.Value)
  730.                 RunTime.Start()
  731.             End If
  732.         End Try
  733.  
  734.     End Sub
  735.  
  736.     Private Sub ProcessData(ByVal strMessage As String)
  737.         Dim dataArray(), strLock, Lock2Key, strCase As String
  738.         Dim i, x As Integer
  739.  
  740.         ' Message parts are divided by "|"  Break the string into an array accordingly.
  741.         dataArray = strMessage.Split("|".ToCharArray)
  742.  
  743.         'I recommend http://wza.digitalbrains.com/DC/doc/Introduction.html for info on DC protocol.
  744.         Try
  745.  
  746.             For i = dataArray.GetLowerBound(0) To dataArray.GetUpperBound(0)
  747.  
  748.                 If dataArray(i).StartsWith("$") And dataArray(i).IndexOf(" ") > 0 Then
  749.                     strCase = dataArray(i).Substring(0, (dataArray(i).IndexOf(" ")))
  750.                 Else
  751.                     strCase = dataArray(i)
  752.                 End If
  753.  
  754.                 Select Case strCase
  755.                     Case "$Search"
  756.                         ' $Search <ip:port> <1>?<2>?<3>?<4>?<string>|
  757.                         ' $Search Hub:<name> <1>?<2>?<3>?<4>?<string>|
  758.                     Case "$MyINFO"
  759.                         ' $MyINFO $ALL <name> <description>$ $<connection><char>$<email>$<share>$|
  760.                     Case "$Hello"
  761.                         '$Hello <name>|
  762.                         If dataArray(i) = "$Hello " & UserStats.Username Then
  763.  
  764.                             'If we're not an OP, we don't share
  765.                             Dim ShareSize As String = "0"
  766.                             'If UserStats.IsOp Then
  767.                             ShareSize = UserStats.Sharesize
  768.                             'End If
  769.  
  770.                             '$Version <version>|$GetNickList|$MyINFO $ALL <name> <description>$ $<connection><char>$<email>$<share>$|
  771.                             SendData("$Version 1,0091|$GetNickList|$MyINFO $ALL " & UserStats.Username & " " & UserStats.Description & " <" & BotVersion & ">$ $" & UserStats.Connection & " $" & UserStats.Email & "$" & ShareSize & "$|")
  772.                             ProgressBar.Value = 3
  773.                             If cmd1.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd1.Text & "|")
  774.                             If cmd2.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd2.Text & "|")
  775.                             If cmd3.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd3.Text & "|")
  776.                             If cmd4.Text <> "" Then SendData("<" + txtuser.Text + ">" & " " & cmd4.Text & "|")
  777.                             If txtip.SelectedIndex = txtip.Items.Count - 1 Then
  778.                                 End
  779.                             End If
  780.                             btnDisconnect.PerformClick()
  781.                         Else
  782.                             HubUsers(1)
  783.                         End If
  784.                     Case "$Quit"
  785.                         '$Quit <name>|
  786.                         Me.StatusUsers.Text = CStr(CInt(Me.StatusUsers.Text) - 1)
  787.                     Case "$To:"
  788.                         '$To <name> From: <name> $<<name>> <message>|
  789.                         CheckMessage(dataArray(i), 2)
  790.                     Case "$Supports"
  791.                         '$Supports <feature> <feature_etc>|
  792.                     Case "$HubINFO"
  793.                         '$HubINFO <hubname> <etc>|
  794.                     Case "$UserIP"
  795.                         '$UserIP <name> <ip>|
  796.                     Case "$UserCommand"
  797.                         '$UserCommand <type> <context> <details>|
  798.                     Case "$ForceMove"
  799.                         ok.Text = ("*** You are being redirected to " & (dataArray(i).Substring(11)))
  800.                         If txtip.SelectedIndex = txtip.Items.Count - 1 Then
  801.                             End
  802.                         End If
  803.                         btnDisconnect.PerformClick()
  804.                         '$ForceMove <address>|
  805.                     Case "$LogedIn"
  806.                         '$LogedIn|
  807.                         'Yes, it really is "LogedIn", not "LoggedIn"
  808.                         UserStats.IsOp = True
  809.                     Case "$ValidateDenide"
  810.                         ok.Text = ("*** Nickname was already taken, try something else.")
  811.                         If txtip.SelectedIndex = txtip.Items.Count - 1 Then
  812.                             End
  813.                         End If
  814.                         btnDisconnect.PerformClick()
  815.                         '$ValidateDenide <name>|
  816.                     Case "$HubIsFull"
  817.                         ok.Text = ("*** The hub is currently full, try again later.")
  818.                         If txtip.SelectedIndex = txtip.Items.Count - 1 Then
  819.                             End
  820.                         End If
  821.                         btnDisconnect.PerformClick()
  822.                         '$HubIsFull|
  823.                     Case "$BadPass"
  824.                         ok.Text = ("*** The password was incorrect.")
  825.                         If txtip.SelectedIndex = txtip.Items.Count - 1 Then
  826.                             End
  827.                         End If
  828.                         btnDisconnect.PerformClick()
  829.                         '$BadPass|
  830.                     Case "$NickList"
  831.                         '$NickList <name>$$<etc>$$|
  832.                         Dim NickList() As String
  833.                         Dim nicks As String
  834.                         nicks = (dataArray(i).Substring(10)).Replace("$$", "$")
  835.                         NickList = nicks.Split("$".ToCharArray)
  836.                         'For x = NickList.GetLowerBound(0) To NickList.GetUpperBound(0) - 1
  837.                         ' Use this to make a list of online users
  838.                         'Next
  839.                         HubUsers(NickList.GetUpperBound(0) - 1)
  840.                     Case "$OpList"
  841.                         '$OpList <name>$$<etc>$$|
  842.                         Dim nicks As String
  843.                         nicks = (dataArray(i).Substring(8)).Replace("$$", "$")
  844.                         OpList = Nothing
  845.                         OpList = nicks.Split("$".ToCharArray)
  846.                     Case "$GetPass"
  847.                         '$GetPass|
  848.                         ok.Text = ("*** Nickname is registered, sending password.")
  849.                         SendData("$MyPass " & UserStats.Password & "|")
  850.                     Case "$HubName"
  851.                         '$HubName <name>|
  852.                         Me.StatusConnected.Text = "Connected"
  853.  
  854.                         If UserStats.isOnline = -1 Then
  855.                             UserStats.isOnline = 10
  856.                             RunTime.Start()
  857.                         End If
  858.                         btnConnect.Enabled = True
  859.                     Case "$Lock"
  860.                         '$Lock <string>|
  861.  
  862.                         Lock2Key = LockToKey(dataArray(i).Substring(6), 5)
  863.  
  864.                         If dataArray(i).Substring(0, 22) = "$Lock EXTENDEDPROTOCOL" Then
  865.                             'If there is an EXTENDEDPROTOCOL, we can send the $Supports command to find out what it can do
  866.                             SendData("$Supports UserIP BotINFO|$Key " & Lock2Key & "|$ValidateNick " & UserStats.Username & "|")
  867.                         Else
  868.                             SendData("$Key " & Lock2Key & "|$ValidateNick " & UserStats.Username & "|")
  869.                         End If
  870.                         ProgressBar.Value = 2
  871.                     Case Else
  872.                         'Handle mainchat messages
  873.                         If dataArray(i).StartsWith("<") And dataArray(i).IndexOf(">") < dataArray(i).IndexOf(" ") Then
  874.                         ElseIf Not dataArray(i).StartsWith("$") And dataArray(i).Length > 0 Then
  875.                         End If
  876.                 End Select
  877.             Next
  878.  
  879.         Catch e As Exception
  880.             'Something went bad, but we can probably stay online and hope for the best.
  881.         End Try
  882.     End Sub
  883.  
  884.     Private Sub CheckMessage(ByVal text As String, ByVal type As Integer)
  885.         If UserStats.isOnline = -1 Then
  886.  
  887.             Dim nick, data As String
  888.  
  889.             If type = 1 Then
  890.                 nick = text.Substring(text.IndexOf("<") + 1, text.IndexOf(">") - text.IndexOf("<") - 1)
  891.             ElseIf type = 2 Then
  892.                 '$To: <name> From: <name> $<<name>> <message>|
  893.                 nick = text.Substring(text.IndexOf("From: ") + 6, text.IndexOf("$", 1) - (text.IndexOf("From: ") + 7))
  894.                 ChatTextPM("[PM] <-- [" & nick & "] " & text.Substring(text.IndexOf("<")))
  895.             End If
  896.             If text.Length > (text.IndexOf(">") + 2) Then data = text.Substring(text.IndexOf(">") + 2)
  897.  
  898.         End If
  899.     End Sub
  900.  
  901.  
  902.     'Do stuff with incoming private messages
  903.     Private Sub ChatTextPM(ByVal text As String)
  904.  
  905.     End Sub
  906.  
  907.     'Do stuff with incoming chatmessages
  908.     Private Sub ChatText(ByVal text As String)
  909.  
  910.     End Sub
  911.  
  912.     Private Sub HubUsers(ByVal amount As Integer)
  913.         Me.StatusUsers.Text = CStr(CInt(Me.StatusUsers.Text) + amount)
  914.     End Sub
  915.  
  916.     Public Function LockToKey(ByRef strLock As String, ByVal n As Long) As String
  917.         Dim h As Long
  918.         Dim ub As Long
  919.         Dim test As Long
  920.  
  921.         'n = 5 for hub and client locks
  922.  
  923.         h = strLock.IndexOf(" Pk=")
  924.         If h Then strLock = strLock.Substring(0, h)
  925.         'The lock only continues to the first space (Pk= comes after)
  926.  
  927.         'Make sure it is more than 3 characters
  928.         If strLock.Length > 3 Then
  929.             ub = strLock.Length - 1
  930.  
  931.             'The first character is handled differently from the others
  932.             'h = Asc(strLock) Xor Asc(strLock.Chars(ub)) Xor Asc(strLock.Chars(ub - 1)) Xor n
  933.             h = Asc(strLock.Chars(0)) Xor Asc(strLock.Chars(ub)) Xor Asc(strLock.Chars(ub - 1)) Xor n
  934.             h = ((h * 16) And 240) Or ((h \ 16) And 15)
  935.             'Equivalent of bit shifting four to the left (* 2^4) and four to the right (\ 2^4)
  936.  
  937.             'Check for illegal characters
  938.             Select Case h
  939.                 Case 0, 5, 36, 96, 124, 126
  940.                     LockToKey = "/%DCN" & StrReverse(StrReverse("00" & h).Substring(0, 3)) & "%/"
  941.                     'LockToKey = "/%DCN" & Right$("00" & h, 3) & "%/"
  942.                 Case Else
  943.                     LockToKey = Chr(h)
  944.             End Select
  945.  
  946.             'Now the rest of the characaters in the lock are handled the same
  947.             For n = 1 To ub
  948.                 h = Asc(strLock.Chars(n)) Xor Asc(strLock.Chars(n - 1))
  949.  
  950.                 h = ((h * 16) And 240) Or ((h \ 16) And 15)
  951.  
  952.                 Select Case h
  953.                     Case 0, 5, 36, 96, 124, 126
  954.                         LockToKey = LockToKey & "/%DCN" & StrReverse(StrReverse("00" & h).Substring(0, 3)) & "%/"
  955.                     Case Else
  956.                         LockToKey = LockToKey & Chr(h)
  957.                 End Select
  958.             Next
  959.         Else
  960.             LockToKey = "Lock string length must be greater than 3 characters."
  961.         End If
  962.  
  963.         Exit Function
  964.     End Function
  965.  
  966.     Private Sub SendData(ByVal Data As String)
  967.         On Error Resume Next
  968.         Data.Replace("||", "|") 'Cleanup, just in case
  969.         If Not Data.EndsWith("|") Then Data = Data & "|"
  970.         Dim networkStream As NetworkStream = ClientStream
  971.         Dim sendBytes As [Byte]() = Encoding.Default.GetBytes(Data)
  972.         networkStream.Write(sendBytes, 0, sendBytes.Length)
  973.         networkStream.Flush()
  974.     End Sub
  975.  
  976.     Private Sub DoRead(ByVal ar As IAsyncResult)
  977.         Dim intCount As Integer
  978.         Try
  979.             intCount = ClientStream.EndRead(ar)
  980.             If intCount < 1 Then
  981.                 Disconnect()
  982.                 Exit Sub
  983.             End If
  984.  
  985.             ReadMessage = ReadMessage & Encoding.Default.GetString(ReadBuffer, 0, intCount)
  986.  
  987.             If ReadMessage.EndsWith("|".ToCharArray) Then
  988.                 Dim params() As Object = {ReadMessage}
  989.                 Me.Invoke(New ProcessInvoker(AddressOf Me.ProcessData), params)
  990.                 ReadMessage = ""
  991.             End If
  992.  
  993.  
  994.             ClientStream.BeginRead(ReadBuffer, 0, 1024, AddressOf DoRead, Nothing)
  995.  
  996.         Catch e As System.ObjectDisposedException
  997.             'Don't know why these happen, but they're socket related.
  998.             'If you can fix 'em, please do. But no harms seems to come from hiding them
  999.             isConnectedFlag = False
  1000.             Disconnect()
  1001.         Catch e As System.IO.IOException
  1002.             isConnectedFlag = False
  1003.             Disconnect()
  1004.         Catch e As Exception
  1005.             isConnectedFlag = False
  1006.             Disconnect()
  1007.         End Try
  1008.     End Sub
  1009.  
  1010.     Private Sub btnDisconnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnDisconnect.Click
  1011.         txtip.SelectedIndex = txtip.SelectedIndex + 1
  1012.         btnConnect.Enabled = False
  1013.         Me.Timer.LockConnect = 2
  1014.         RunTime.Start()
  1015.         Disconnect()
  1016.     End Sub
  1017.  
  1018.     Private Sub btnConnect_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConnect.Click
  1019.         Dim arr() As String
  1020.         arr = Split(txtip.SelectedItem, ":")
  1021.         ind = arr(0)
  1022.         porta = arr(1)
  1023.         txtport.Text = porta
  1024.         ore = 0
  1025.         Connect(ind, porta)
  1026.     End Sub
  1027.  
  1028.     Private Sub txtshare_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtshare.TextChanged
  1029.         If IsNumeric(txtshare.Text) Then
  1030.             Dim size As Int64 = Convert.ToInt64(txtshare.Text)
  1031.             size = Convert.ToInt64(Math.Floor(size / 1024 / 1024 / 1024))
  1032.             lblShareSize.Text = size.ToString & " GB"
  1033.         Else
  1034.             txtshare.Text = "0"
  1035.             lblShareSize.Text = "0 GB"
  1036.             MessageBox.Show("Immettere uno share valido", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
  1037.         End If
  1038.     End Sub
  1039.  
  1040.     Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
  1041.         If chkConfirmExit.Checked Then
  1042.             If MessageBox.Show("Are you sure you want to exit?", Me.Text, MessageBoxButtons.YesNo) = DialogResult.Yes Then
  1043.                 If isConnectedFlag Then Disconnect()
  1044.             Else
  1045.                 e.Cancel = True
  1046.             End If
  1047.         Else
  1048.             If isConnectedFlag Then Disconnect()
  1049.         End If
  1050.     End Sub
  1051.  
  1052.     Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
  1053.         Me.Close()
  1054.     End Sub
  1055.  
  1056.     Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
  1057.         Dim comando1 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando1.gold")
  1058.         comando1.WriteLine(cmd1.Text)
  1059.         comando1.Close()
  1060.  
  1061.         Dim descr As StreamWriter = New StreamWriter(Application.StartupPath & "\descrizione.gold")
  1062.         descr.WriteLine(txtdesc.Text)
  1063.         descr.Close()
  1064.  
  1065.         Dim comando2 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando2.gold")
  1066.         comando2.WriteLine(cmd2.Text)
  1067.         comando2.Close()
  1068.  
  1069.         Dim comando3 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando3.gold")
  1070.         comando3.WriteLine(cmd3.Text)
  1071.         comando3.Close()
  1072.  
  1073.         Dim comando4 As StreamWriter = New StreamWriter(Application.StartupPath & "\comando4.gold")
  1074.         comando4.WriteLine(cmd4.Text)
  1075.         comando4.Close()
  1076.  
  1077.         Dim share3 As StreamWriter = New StreamWriter(Application.StartupPath & "\share.gold")
  1078.         share3.WriteLine(txtshare.Text)
  1079.         share3.Close()
  1080.  
  1081.         Dim nick As StreamWriter = New StreamWriter(Application.StartupPath & "\nick.gold")
  1082.         nick.WriteLine(txtuser.Text)
  1083.         nick.Close()
  1084.  
  1085.         Dim pass As StreamWriter = New StreamWriter(Application.StartupPath & "\passwd.gold")
  1086.         pass.WriteLine(txtpass.Text)
  1087.         pass.Close()
  1088.  
  1089.         Dim email As StreamWriter = New StreamWriter(Application.StartupPath & "\email.gold")
  1090.         email.WriteLine(txtemail.Text)
  1091.         email.Close()
  1092.  
  1093.         Dim uscita As StreamWriter = New StreamWriter(Application.StartupPath & "\confermachiusura.gold")
  1094.         If chkConfirmExit.Checked = True Then
  1095.             uscita.WriteLine("si")
  1096.             uscita.Close()
  1097.         Else
  1098.             uscita.WriteLine("no")
  1099.             uscita.Close()
  1100.         End If
  1101.  
  1102.         Dim riconnetti As StreamWriter = New StreamWriter(Application.StartupPath & "\autoriconnetti.gold")
  1103.         riconnetti.WriteLine(nmrAutoreconnect.Text)
  1104.         riconnetti.Close()
  1105.  
  1106.         Dim speed As StreamWriter = New StreamWriter(Application.StartupPath & "\connessione.gold")
  1107.         speed.WriteLine(cmbSpeed.Text)
  1108.         speed.Close()
  1109.  
  1110.         Dim percorso As String
  1111.         percorso = Application.StartupPath & "\indirizzi.gold"
  1112.         Dim i As Integer
  1113.         FileOpen(1, percorso, OpenMode.Output)
  1114.         For i = 0 To txtip.Items.Count - 1
  1115.             PrintLine(1, txtip.Items(i) & Chr(13))
  1116.         Next i
  1117.         FileClose(1)
  1118.     End Sub
  1119.  
  1120.     Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
  1121.         If e.KeyChar = Chr(13) Then Button3.PerformClick()
  1122.     End Sub
  1123.  
  1124.     Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
  1125.         If e.KeyChar = Chr(13) Then Button3.PerformClick()
  1126.     End Sub
  1127.  
  1128.     Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  1129.         txtip.Items.Add(TextBox1.Text & ":" & TextBox2.Text)
  1130.         TextBox1.Clear()
  1131.         TextBox2.Clear()
  1132.     End Sub
  1133.  
  1134.     Private Sub MenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem1.Click
  1135.         If txtip.Items.Count <= 2 Then
  1136.             MessageBox.Show("Almeno 2 Hub in lista", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
  1137.         Else
  1138.             txtip.Items.Remove(txtip.SelectedItem)
  1139.         End If
  1140.     End Sub
  1141.  
  1142.     Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
  1143.         Timer2.Enabled = False
  1144.         btnConnect.PerformClick()
  1145.     End Sub
  1146.  
  1147.     Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
  1148.         MessageBox.Show("1) Aggiungere alla lista hub almeno 2 hub altrimenti nn funziona      2)una volta inseriti tutti i dati (nick,share,i comandi da mandare in main etc.... Selezione il primo hub in alto della lista e premere su connetti, dopodichè lasciar fare tutto al programma   Saluti da Gold ;)            PS:Se il programma dovesse continuamente blokkarsi su un hub in particolare è molto probabile che si è stato o bannati o kikkati da quell'hub.", Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Information)
  1149.     End Sub
  1150. End Class
  1151.  
  1152. Public Class Main
  1153.     Shared Sub Main()
  1154.         Application.EnableVisualStyles()
  1155.         Application.Run(New Form1)
  1156.     End Sub
  1157. End Class