Skip to content
This repository has been archived by the owner on Apr 8, 2021. It is now read-only.

Commit

Permalink
Fixes #31
Browse files Browse the repository at this point in the history
Added URL validation when checking for duplicate mod.
  • Loading branch information
alec-hs committed Feb 15, 2018
1 parent 871318c commit db01fc3
Showing 1 changed file with 49 additions and 43 deletions.
92 changes: 49 additions & 43 deletions Flax's-Arma-Server-Tool/ImportMod.vb
Original file line number Diff line number Diff line change
Expand Up @@ -24,63 +24,69 @@ Public Class ImportMod
MainWindow.CheckModFile()
Dim lines As List(Of String) = System.IO.File.ReadAllLines(modsfile).ToList

modID = modUrl.Substring(modUrl.IndexOf("?id="))
modID = Integer.Parse(Regex.Replace(modID, "[^\d]", ""))

For Each line In lines
Dim values() As String = line.Split(",")
If modID = values(0) Then
duplicate = True
End If
Next
If modUrl Like "http*://steamcommunity.com/*/filedetails/?id=*" Then
modID = modUrl.Substring(modUrl.IndexOf("?id="))
modID = Integer.Parse(Regex.Replace(modID, "[^\d]", ""))

For Each line In lines
Dim values() As String = line.Split(",")
If modID = values(0) Then
duplicate = True
End If
Next

If Not duplicate Then
Try
sourceString = New System.Net.WebClient().DownloadString(modUrl)
If Not duplicate Then
Try
sourceString = New System.Net.WebClient().DownloadString(modUrl)

appName = sourceString.Substring(sourceString.IndexOf("content=" & ControlChars.Quote & "Steam Workshop:") + 25, 6)
appName = sourceString.Substring(sourceString.IndexOf("content=" & ControlChars.Quote & "Steam Workshop:") + 25, 6)


If appName Like "Arma 3" Then
modName = sourceString.Substring(sourceString.IndexOf("<title>Steam Workshop :: ") + 25)
modName = StrReverse(modName)
modName = modName.Substring(modName.IndexOf(">eltit/<") + 8)
modName = StrReverse(modName)
If appName Like "Arma 3" Then
modName = sourceString.Substring(sourceString.IndexOf("<title>Steam Workshop :: ") + 25)
modName = StrReverse(modName)
modName = modName.Substring(modName.IndexOf(">eltit/<") + 8)
modName = StrReverse(modName)


If modUrl Like "http*://steamcommunity.com/*/filedetails/?id=*" Then
Try
Dim steamUpdate As New DateTime(1970, 1, 1, 0, 0, 0)
Dim modLine As String = modID & "," & modName & ",Not Installed," & steamUpdate & ",public" & Environment.NewLine
If modUrl Like "http*://steamcommunity.com/*/filedetails/?id=*" Then
Try
Dim steamUpdate As New DateTime(1970, 1, 1, 0, 0, 0)
Dim modLine As String = modID & "," & modName & ",Not Installed," & steamUpdate & ",public" & Environment.NewLine

MainWindow.CheckModFile()
Dim fs As StreamWriter = File.AppendText(modsfile)
MainWindow.CheckModFile()
Dim fs As StreamWriter = File.AppendText(modsfile)

fs.Write(modLine)
fs.Close()
fs.Write(modLine)
fs.Close()

Me.Close()
MainWindow.UpdateModGrid()
Me.Close()
MainWindow.UpdateModGrid()

Catch ex As Exception
modID = Nothing
MessageBox.Show("Please remove any charcters after the mod ID in the url.")
MsgBox("An exception occurred:" & vbCrLf & ex.Message)
End Try
Catch ex As Exception
modID = Nothing
MessageBox.Show("Please remove any charcters after the mod ID in the url.")
MsgBox("An exception occurred:" & vbCrLf & ex.Message)
End Try
Else
MessageBox.Show("Please use format: https://steamcommunity.com/sharedfiles/filedetails/?id=*********")
End If
Else
MessageBox.Show("Please use format: https://steamcommunity.com/sharedfiles/filedetails/?id=*********")
MessageBox.Show("This is a workshop Item for a different game.")
Me.Close()
End If
Else
MessageBox.Show("This is a workshop Item for a different game.")
Me.Close()
End If
Catch ex As Exception
MsgBox("An exception occurred:" & vbCrLf & ex.Message)
End Try
Catch ex As Exception
MsgBox("An exception occurred:" & vbCrLf & ex.Message)
End Try
Else
Me.Close()
MsgBox("Mod already imported.")
End If

Else
Me.Close()
MsgBox("Mod already imported.")
MessageBox.Show("Please use format: https://steamcommunity.com/sharedfiles/filedetails/?id=*********")
End If

Cursor.Current = Cursors.Default
End Sub

Expand Down

0 comments on commit db01fc3

Please sign in to comment.