As promised... Asp.net 2.0 default.aspx that I use to manage the downloads...
It has references to mysql and quiksoft.freesmtp Feel free to remove them if you are not interested in getting emails and pulling information from a database. Following the default.aspx code is the web.config code. I think that is it. If anyone has any questions please feel free to ask. -Scott '''''''''''''''''''''''''''''''''''''''''''''' '''''''''' begin default.aspx '''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''' <%@ Page Language="VB" %> <%@ Import Namespace="System" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="MySql.Data.MySqlClient" %> <%@ Import Namespace="Quiksoft.FreeSMTP" %> <script runat="server"> Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Try Dim strHost As String = Request.ServerVariables("HTTP_HOST") Dim strRequestedFile As String strRequestedFile = Request.QueryString("f") Dim strSQL As String strSQL = "SELECT * from database where serverip = '" & strHost & "'" Dim strEmailText As String = "" strEmailText &= "************File Requested************" & vbCrLf strEmailText &= "File Requested: " & strRequestedFile & vbCrLf strEmailText &= "From Server: " & strHost & vbCrLf 'strEmailText &= "From Server: " & strRefererIP & ":" & strRefererPort & vbCrLf strEmailText &= "Query String: " & strSQL & vbCrLf strEmailText &= "**********End File Requested**********" & vbCrLf & vbCrLf strEmailText &= "***********Server Variables***********" & vbCrLf Dim sName As String For Each sName In Request.ServerVariables strEmailText &= sName & " === " & Request.ServerVariables(sName) & vbCrLf Next strEmailText &= "*********End Server Variables*********" & vbCrLf 'SendEmail("Your Name", "[EMAIL PROTECTED]", "Helper Name", "[EMAIL PROTECTED]", "sv_downloadurl debugging", strEmailText, , ) 'Check for appropriate user agent If Request.ServerVariables("HTTP_USER_AGENT") <> "Half-Life 2" And Request.ServerVariables("HTTP_USER_AGENT") <> "Half-Life" Then 'SendEmail("Your Name", "[EMAIL PROTECTED]", "Helper Name", "[EMAIL PROTECTED]", "sv_downloadurl unauthorized useragent", strEmailText, , ) Response.Clear() 'Response.Status = "Not Found" Response.StatusCode = 404 Response.Flush() Exit Sub End If Dim ds As DataSet ds = GetDS(strSQL) ' ds holds information about what directory the server is located ' and the mod type so that I know where to serve the files from ' you would just use the returned dataset below where I use "Y:\cs1.6\cstrike" ' an example might be ds.tables(0).rows(0)("serverdir") & "\" & ds.tables(0).rows(0)("modtype") If ds.Tables(0).Rows.Count <> 1 Then Response.Clear() 'Response.Status = "Not Found" Response.StatusCode = 404 Response.Flush() SendEmail("Your Name", "[EMAIL PROTECTED]", "Helper Name", "[EMAIL PROTECTED]", "sv_downloadurl server not found", strEmailText, , ) Exit Sub Else If Not System.IO.File.Exists("Y:\cs1.6\cstrike" & strRequestedFile.Replace("/", "\")) Then Response.Clear() 'Response.Status = "Not Found" Response.StatusCode = 404 Response.Flush() Exit Sub Else 'if file approved download If ApprovedDownload(strRequestedFile) Then Dim fileInfo As System.IO.FileInfo = New System.IO.FileInfo("Y:\cs1.6\cstrike" & strRequestedFile.Replace("/", "\")) Response.Clear() Response.AddHeader("Content-Disposition", "attachment; filename=" & fileInfo.Name) Response.AddHeader("Content-Length", fileInfo.Length.ToString()) Response.ContentType = "application/octet-stream" Response.WriteFile(fileInfo.FullName) Else If DisapprovedDownload(strRequestedFile) Then SendEmail("Your Name", "[EMAIL PROTECTED]", "Helper Name", "[EMAIL PROTECTED]", "sv_downloadurl unapproved file", strEmailText, , ) Response.Clear() 'Response.Status = "Not Found" Response.StatusCode = 404 Response.Flush() Exit Sub Else SendEmail("Your Name", "[EMAIL PROTECTED]", "Helper Name", "[EMAIL PROTECTED]", "sv_downloadurl 404", strEmailText, , ) Response.Clear() 'Response.Status = "Not Found" Response.StatusCode = 404 Response.Flush() Exit Sub End If End If End If End If Catch ex As Exception SendEmail("Your Name", "[EMAIL PROTECTED]", "Helper Name", "[EMAIL PROTECTED]", "sv_downloadurl error", ex.ToString, , ) End Try End Sub Function ApprovedDownload(ByVal strFileName As String) As Boolean If System.Configuration.ConfigurationManager.AppSettings("approvedtypes").Index Of(Right(strFileName, 4)) <> 0 Then Return True Else Return False End If End Function Function DisapprovedDownload(ByVal strFileName As String) As Boolean If System.Configuration.ConfigurationManager.AppSettings("disapprovedtypes").In dexOf(Right(strFileName, 4)) <> 0 Then Return False Else Return True End If End Function Function ExecuteSQL(ByVal Query As String) As Integer Dim myConnection As MySqlConnection Dim myCommand As MySqlCommand Dim intReturn As Integer myConnection = New MySqlConnection myConnection.ConnectionString = "myconnstring" Try myConnection.Open() myCommand = New MySqlCommand(Query, myConnection) intReturn = myCommand.ExecuteNonQuery myConnection.Close() Catch exc As System.Exception Throw exc Finally If myConnection.State = ConnectionState.Open Then myConnection.Close() End Try End Function Function GetDS(ByVal Query As String) As DataSet 'Dim cnn As MySqlConnection 'Dim rs As MySqlDataAdapter 'Dim ds As DataSet 'cnn = New MySqlConnection 'cnn.ConnectionString = strConnString 'cnn.Open() 'cnn.Close() Dim myConnection As MySqlConnection Dim myDataAdapter As MySqlDataAdapter Dim ds As New DataSet myConnection = New MySqlConnection myConnection.ConnectionString = "myconnstring" Try myConnection.Open() myDataAdapter = New MySqlDataAdapter(Query, myConnection) myDataAdapter.Fill(ds) myConnection.Close() Catch exc As System.Exception Throw exc Finally If myConnection.State = ConnectionState.Open Then myConnection.Close() End Try Return ds End Function Public Sub SendEmail(ByVal ToName As String, ByVal ToEmail As String, ByVal FromName As String, ByVal FromEmail As String, ByVal Subject As String, ByVal TextBody As String, Optional ByVal HtmlBody As String = "", Optional ByVal Xref As String = "") 'Create the EmailMessage object Dim msgObj As New EmailMessage 'Specify from address and display name msgObj.From.Email = FromEmail msgObj.From.Name = FromName 'Add a normal recipient msgObj.Recipients.Add(ToEmail, ToName, RecipientType.To) 'Specify the subject msgObj.Subject = Subject 'Add an HTML body part If HtmlBody <> "" Then msgObj.BodyParts.Add("<html><body>" & HtmlBody & "</body></html>", BodyPartFormat.HTML) 'Add a text body part to server as alternative text for non HTML mail readers msgObj.BodyParts.Add(TextBody, BodyPartFormat.Plain) 'Add an attachment 'msgObj.Attachments.Add("c:\attachment.txt") 'Create the SMTP object using the constructor to specify the mail server Dim smtpObj As New SMTP("localhost") 'Send the message smtpObj.Send(msgObj) End Sub </script> '''''''''''''''''''''''''''''''''''''''''''''' '''''''''''' end default.aspx '''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''' '''''''''''' begin web.config '''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''' <?xml version="1.0"?> <!-- Note: As an alternative to hand editing this file you can use the web admin tool to configure settings for your application. Use the Website->Asp.Net Configuration option in Visual Studio. A full list of settings and comments can be found in machine.config.comments usually located in \Windows\Microsoft.Net\Framework\v2.x\Config --> <configuration> <appSettings> <add key="approvedtypes" value="txt,bsp,wav,tga,mdl,wad,bz2,dem" /> <add key="disapprovedtypes" value="cfg" /> </appSettings> <connectionStrings/> <system.web> <!-- Set compilation debug="true" to insert debugging symbols into the compiled page. Because this affects performance, set this value to true only during development. Visual Basic options: Set strict="true" to disallow all data type conversions where data loss can occur. Set explicit="true" to force declaration of all variables. --> <compilation debug="false" strict="false" explicit="true"/> <pages> <namespaces> <clear/> <add namespace="System"/> <add namespace="System.Collections"/> <add namespace="System.Collections.Specialized"/> <add namespace="System.Configuration"/> <add namespace="System.Text"/> <add namespace="System.Text.RegularExpressions"/> <add namespace="System.Web"/> <add namespace="System.Web.Caching"/> <add namespace="System.Web.SessionState"/> <add namespace="System.Web.Security"/> <add namespace="System.Web.Profile"/> <add namespace="System.Web.UI"/> <add namespace="System.Web.UI.WebControls"/> <add namespace="System.Web.UI.WebControls.WebParts"/> <add namespace="System.Web.UI.HtmlControls"/> </namespaces> </pages> <!-- The <authentication> section enables configuration of the security authentication mode used by ASP.NET to identify an incoming user. --> <authentication mode="Windows"/> <!-- The <customErrors> section enables configuration of what to do if/when an unhandled error occurs during the execution of a request. Specifically, it enables developers to configure html error pages to be displayed in place of a error stack trace. --> <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" redirect="NoAccess.htm" /> <error statusCode="404" redirect="FileNotFound.htm" /> </customErrors> </system.web> </configuration> '''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''' end web.config '''''''''''''''' '''''''''''''''''''''''''''''''''''''''''''''' > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Scott Tuttle > Sent: Friday, August 18, 2006 11:59 AM > To: hlds@list.valvesoftware.com > Subject: RE: [hlds] Maps not downloading > > Well I use it on multiple servers and it gets server > directory information > from a mysql database, based on the requested > http://game.server.i.p . I > will have to sanatize it a bit so that someone could use it > by hardcoding > the game server path into it. > > I will see what I can do this weekend. > > > -----Original Message----- > > From: [EMAIL PROTECTED] > > [mailto:[EMAIL PROTECTED] On Behalf Of cbass > > Sent: Friday, August 18, 2006 11:28 AM > > To: hlds@list.valvesoftware.com > > Subject: RE: [hlds] Maps not downloading > > > > Since your showing cool ASPX coding, you want to share? > > -----Original message----- > > From: "Scott Tuttle" [EMAIL PROTECTED] > > Date: Fri, 18 Aug 2006 10:07:38 -0400 > > To: hlds@list.valvesoftware.com > > Subject: RE: [hlds] Maps not downloading > > > > > What I have is an aspx page in my download url > > > > > > sv_downloadurl "http://game.server.i.p/?f=" > > > > > > When the server gets a request > > default.aspx?f=/maps/de_westwood.bsp for > > > example, I stream out the /maps/de_westwood.bsp from the > game server > > > directory. I limit the files that can be streamed by > > coding the "approved > > > file types" in my aspx file. For example, I allow > > > txt,bsp,wav,tga,mdl,wad,bz2,dem. Any other requested file > > like /server.cfg > > > would return a 404 error in the code. > > > > > > I do not have to move any files. Your server will not lag > > if you have > > > enough bandwidth. > > > > > > > -----Original Message----- > > > > From: [EMAIL PROTECTED] > > > > [mailto:[EMAIL PROTECTED] On Behalf Of > > Dave Williams > > > > Sent: Friday, August 18, 2006 2:53 AM > > > > To: hlds@list.valvesoftware.com > > > > Subject: Re: [hlds] Maps not downloading > > > > > > > > i personally think that it was moving the map foldet to > > the virtual > > > > directory. the true path to my sv_downloadurl folder is > > > > http://www.noquestionsasked.co.uk/httpdocs/sv_downloadurl > > but it shows > > > > up on the internet as > > http://www.noquestionsasked.co.uk/sv_downloadurl > > > > (btw don't try and access it as i have turned off directory > > > > listing. so > > > > it will just error out on you). > > > > > > > > i'm not too hot with iis. i get my webserver host to worry > > > > about that. i > > > > just thought i mention your setup now sounds similar to mine. > > > > > > > > Valdimar Kristjansson wrote: > > > > > Hi Frazer, > > > > > > > > > > As usual I'm amazed at the level of help. > > > > > Followed the instructions and voila, I'm up and running :) > > > > > > > > > > There are a few things that could have been the cause of my > > > > problems: > > > > > > > > > > 1. My MIME types weren't described as application > > (don't know if it > > > > > matters) > > > > > > > > > > 2. I hadn't allowed scripts on the virtual directory > > (it's off by > > > > > default) > > > > > > > > > > 3. I changed my sv_downloadurl to > > > > http://myIP/MyVirtualDirectory/hl2mp > > > > > It might be that the hl2mp directory within the > > virtual directory > > > > > did the trick. > > > > > I just put the maps folder in my virtual directory. > > > > > > > > > > > > > > > This can thus be thought of as possible problems for > > > > allowing downloads > > > > > with IIS :) > > > > > > > > > > > > > > > See Frazers guide below for the solution. > > > > > > > > > > Valdimar Kristjansson, CTO > > > > > 00 (+354) 693 2062_ > > > > > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>; > > > > _www.eleanetwork.com_ > > > > > <http://www.eleanetwork.com/> > > > > > > > > > > This communication is solely intended for the > > addressee, it may be > > > > > confidential and it is not for third party distribution. > > > > > > > > > > > > > > > Frazer wrote: > > > > >> Select the web site you want share the directory on. > > Usually, the > > > > >> Default > > > > >> Web Site is fine. > > > > >> > > > > >> Press the "Add" button to create an IIS virtual > > directory and alias > > > > >> name. > > > > >> > > > > >> Enter "svdl" for the Alias name. Ensure Read access is > > > > selected and > > > > >> that > > > > >> Scripts is selected for Application Permissions. > > Press "OK" twice. > > > > >> > > > > >> Open up the IIS Management console. > > > > >> > > > > >> Select the new svdl virtual directory in the tree view > > > > under Default Web > > > > >> Site (or wherever you put it). View the properties > > for the virtual > > > > >> directory. > > > > >> > > > > >> Go to the Directory Security tab. Press the Edit... > > button in the > > > > >> Authentication and access control section - and select > > > > Enable anonymous > > > > >> access. Leave Integrated Windows Authentication > > checked - no other > > > > >> options > > > > >> should be checked. Press "OK" > > > > >> > > > > >> Go to the HTTP Headers tab. Press the MIME Types... > > > > button. Add the > > > > >> following MIME types: > > > > >> > > > > >> Extension: .ain MIME Type: application > > > > >> Extension: .bsp MIME Type: application > > > > >> Extension: .bz2 MIME Type: application (this last one > > > > for compressed > > > > >> maps) > > > > >> > > > > >> Not sure if it is necessary - but an IISRESET at this > > > > stage eases the > > > > >> nerves > > > > >> of us paranoids. > > > > >> > > > > >> Create the following sub-directory structure within your > > > > svdl directory. > > > > >> (assuming D:\svdl): > > > > >> > > > > >> D:\svdl\dod\maps > > > > >> D:\svdl\hl2mp\maps > > > > >> etc... > > > > >> > > > > >> This is largely a matter of preference - but whatever > > structure and > > > > >> convention you use, you need to be consistent with your > > > > sv_download cvar > > > > >> setting. > > > > >> > > > > >> Assuming you use the above structure, place your game > > maps in the > > > > >> appropriate game map directory. From this point > > forward, I will > > > > >> assume you > > > > >> are working with hl2dm. Your maps should all have the > > > > extension .bsp > > > > >> (or > > > > >> bsp.bz2, if they are compressed with bzip2. - recommended > > > > - and yes, > > > > >> you > > > > >> must specify the entire "bsp.bz2"). > > > > >> > > > > >> Make sure you have files, with matching names, for all the > > > > maps in your > > > > >> rotation. > > > > >> > > > > >> In the server.cfg file for your game, specify the > > > > following two CVars: > > > > >> > > > > >> sv_allowdownload "1" > > > > >> sv_downloadurl "http://yourwebserver.woot/svdl/dod/" > > > > >> > > > > >> <shamelessPlug> > > > > >> > > > > >> If you are using ogsWatcher, specify the following > > > > CVar tags, > > > > >> in the > > > > >> <CVars> section of your game config: > > > > >> > > > > >> <CVar Name="sv_allowdownload" Value="1" /> > > > > >> <CVar Name="sv_downloadurl" > > > > >> Value="http://yourwebserver.woot/svdl/dod/" /> > > > > >> > > > > >> </shamelessPlug> > > > > >> > > > > >> Start your game server in your preferred fashion. Map > > downloading > > > > >> should be > > > > >> working. > > > > >> > > > > >> To test: changelevel your server to some custom map > > that your game > > > > >> client PC > > > > >> does not have. Connect and see if it downloads. > > > > >> > > > > >> Hope this helps. > > > > >> > > > > >> > > > > >> Frazer > > > > >> > > > > >> -----Original Message----- > > > > >> From: [EMAIL PROTECTED] > > > > >> [mailto:[EMAIL PROTECTED] On Behalf > > Of Valdimar > > > > >> Kristjansson > > > > >> Sent: Thursday, August 17, 2006 4:23 PM > > > > >> To: hlds@list.valvesoftware.com > > > > >> Subject: Re: [hlds] Maps not downloading > > > > >> > > > > >> I even tried adding .* to the MIME but no luck > > > > >> > > > > >> Valdimar Kristjansson, CTO > > > > >> 00 (+354) 693 2062_ > > > > >> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>; > > > > _www.eleanetwork.com_ > > > > >> <http://www.eleanetwork.com/> > > > > >> > > > > >> This communication is solely intended for the > > addressee, it may be > > > > >> confidential and it is not for third party distribution. > > > > >> > > > > >> > > > > >> Valdimar Kristjansson wrote: > > > > >> > > > > >>> Thanks for the link Ian, but nothing in there is new to > > > > me and it's > > > > >>> still not working. > > > > >>> > > > > >>> I added .bsp , .ain and .bz2 to the MIME types in IIS > > and now the > > > > >>> address works in IE/FF e.g. > > > > >>> http://www.eleanetwork.com/HLMaps/dm_agora.bsp but > > the game still > > > > >>> refuses to connect. > > > > >>> > > > > >>> This is the error I get: > > > > >>> Missing map Maps/dm_agora.bsp disconnected (why is it > > > > referring to the > > > > >>> maps folder instead of HLmaps?) > > > > >>> > > > > >>> It's strange though that when I try to connect the > > > > progressbar moves > > > > >>> beyond the bsp file and stops on the .ain file. > > > > >>> Also all the ain files are 1 kb and all of them seem to > > > > contain only > > > > >>> #, is that ok? > > > > >>> > > > > >>> >From what I've been reading from the forums it seems > > that this > > > > >>> sv_downloadurl isn't neccessary except for if you want to > > > > download the > > > > >>> maps from somewhere else than your server. I have all of > > > > the maps on > > > > >>> my server and this new address is on the same server > > as the game > > > > >>> server. It doesn't even work to download them without the > > > > >>> sv_downloadurl so I'm wondering if this is still a port > > > > problem. Could > > > > >>> it be that maps and such are sent through another > > port than 27015? > > > > >>> > > > > >>> I just tried disabling sv_allowdownload, sv_allowUpload and > > > > >>> sv_downloadurl and the progressbar still seems to start > > > > the download > > > > >>> as before, although with the same consequences (the > > > > progressbar label > > > > >>> also says it's downloading a bz2 file but I don't have > > > > any of those). > > > > >>> > > > > >>> Thanks, > > > > >>> Valdimar Kristjansson, CTO > > > > >>> 00 (+354) 693 2062_ > > > > >>> [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>; > > > > >>> _www.eleanetwork.com_ <http://www.eleanetwork.com/> > > > > >>> > > > > >>> This communication is solely intended for the > > addressee, it may be > > > > >>> confidential and it is not for third party distribution. > > > > >>> > > > > >> > > > > >> _______________________________________________ > > > > >> To unsubscribe, edit your list preferences, or view the > > > > list archives, > > > > >> please visit: > > > > >> http://list.valvesoftware.com/mailman/listinfo/hlds > > > > >> > > > > >> > > > > >> _______________________________________________ > > > > >> To unsubscribe, edit your list preferences, or view the list > > > > >> archives, please visit: > > > > >> http://list.valvesoftware.com/mailman/listinfo/hlds > > > > >> > > > > >> > > > > >> > > > > > > > > > > _______________________________________________ > > > > > To unsubscribe, edit your list preferences, or view the > > > > list archives, > > > > > please visit: > > > > > http://list.valvesoftware.com/mailman/listinfo/hlds > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > To unsubscribe, edit your list preferences, or view the list > > > > archives, please visit: > > > > http://list.valvesoftware.com/mailman/listinfo/hlds > > > > > > > > > _______________________________________________ > > > To unsubscribe, edit your list preferences, or view the > > list archives, please visit: > > > http://list.valvesoftware.com/mailman/listinfo/hlds > > > > > > _______________________________________________ > > To unsubscribe, edit your list preferences, or view the list > > archives, please visit: > > http://list.valvesoftware.com/mailman/listinfo/hlds > > > _______________________________________________ > To unsubscribe, edit your list preferences, or view the list > archives, please visit: > http://list.valvesoftware.com/mailman/listinfo/hlds _______________________________________________ To unsubscribe, edit your list preferences, or view the list archives, please visit: http://list.valvesoftware.com/mailman/listinfo/hlds