Announcement

Collapse
No announcement yet.

Can I tell if a file has been downloaded?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Can I tell if a file has been downloaded?

    Does anyone know of a way to check files that are downloaded from the web server? I have an asp page that gives Guests access to certain files by right-clicking and choosing 'Save As'. I was hoping that I would see log activity for each D/L which I would then be able to parse. Since this is not the case, can anyone think of a way to get at this info? I also checked my router log and no info there either.

    Thanks,

    -Tom

    Visit my HomeSeer at http://68.55.67.82:81
    -Tom

    Visit Kernhome
    Kern Theater Gallery

    (User: guest / Pass: guest)

    #2
    Try this:

    First of all, instead of linking directly to your download file, link to an html file that will call an asp page that will download the file. This way you can run a little code to write to a text file before downloading the file. For example. Create a file named download.htm and insert this code.
    <pre class="ip-ubbcode-code-pre">
    &lt;HTML&gt;
    &lt;HEAD&gt;
    &lt;META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"&gt;
    &lt;TITLE&gt;&lt;/TITLE&gt;
    &lt;/HEAD&gt;
    &lt;a href="redirect.asp?url=datafile.exe&id=download"&gt;click here&lt;/a&gt;
    &lt;/BODY&gt;
    &lt;/HTML&gt;
    </pre>

    Then create the redirect.asp file and insert this code:
    <pre class="ip-ubbcode-code-pre">
    &lt;%
    url = Request.QueryString("url")
    logTo = Request.QueryString("id")
    fname = server.mappath(logTo + ".txt")
    strT = Time()
    strT = replace(strT,",","")
    strD = Date()
    strD = replace(strD,",","")
    strRA = Request.ServerVariables("REMOTE_ADDR")
    strRA = replace(strRA,",","")
    strUA = Request.ServerVariables("HTTP_USER_AGENT")
    strUA = replace(strUA,",","")
    Set objFSO = CreateObject("Scripting.FileSystemObject")
    Set objText = objFSO.OpenTextFile(fname, 8, true)
    objText.Write(strT + "," + strD + "," + strRA + "," + strUA) & VBcrlf
    objText.Close
    Response.Redirect(url)
    %&gt;
    </pre>

    -Rupp

    Hum ... If man evolved from monkeys and apes, why do we still have monkeys and apes?
    💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

    Comment


      #3
      Ok, thanks Rupp. I will have to see once I start messing with it how this will work, but right now the asp gives access only to Html/Downloads and includes all subfolders & files. So its very easy to just add a folder or file(s) which is then included in the download structure.

      -Tom

      Visit my HomeSeer at http://68.55.67.82:81
      -Tom

      Visit Kernhome
      Kern Theater Gallery

      (User: guest / Pass: guest)

      Comment


        #4
        Rupp,

        Its very close to working. Here the code in my download.asp so far: (have changed some things around during testing)

        For Each objItem In objFolder.Files
        Response.Write "&lt;TR class=""tablerowodd""&gt;"
        Response.Write "&lt;TD ALIGN=""left"" &gt;&lt;A HREF="""& "redirect.asp?url=" & objFolder.Name & "/" & objItem.Name & """&gt;" & objItem.Name & "&lt;/A&gt;&lt;/TD&gt;"
        sDesc = hs.GetINISetting("Descriptions", CStr(Trim(objItem.Name)), "", "GuestDL.ini")
        Response.Write "&lt;TD ALIGN=""left"" &gt;" & sDesc & "&lt;/TD&gt;"
        If CLng(objItem.Size) &gt; 0 Then
        sSize = (CLng(objItem.Size) \ 1024) + 1
        End If
        Response.Write "&lt;TD ALIGN=""right""&gt;" & FormatNumber(sSize,0) & " KB&lt;/TD&gt;"
        sSize = 0
        Response.Write "&lt;TD ALIGN=""right"" &gt;" & objItem.DateLastModified & "&lt;/TD&gt;"
        Response.Write "&lt;TD ALIGN=""right"" &gt;" & objItem.Type & "&lt;/TD&gt;"
        Response.Write "&lt;/TR&gt;"


        And the redirect code:

        &lt;%@ LANGUAGE=VBScript %&gt;
        &lt;%
        Dim url
        Dim strT
        Dim strD
        Dim strRA
        Dim strUA
        Dim objFSO
        Dim objText

        url = Request.QueryString("url")
        strT = Time()
        strT = replace(strT,",","")
        strD = Date()
        strD = replace(strD,",","")
        strRA = Request.ServerVariables("REMOTE_ADDR")
        strRA = replace(strRA,",","")
        'strUA = Request.ServerVariables("HTTP_USER_AGENT")
        strUA = replace(url,",","")
        Set objFSO = CreateObject("Scripting.FileSystemObject")
        Set objText = objFSO.OpenTextFile("E:\Program Files\HomeSeer\html\download.txt", 8, True)
        objText.Write(strT + "," + strD + "," + strRA + "," + strUA) & VBcrlf
        objText.Close
        url = "http://68.55.67.82:81/Downloads/" & url
        hs.writelog "", url
        Response.Redirect(url)
        %&gt;


        I get the following error:

        HTTP/1.0 200 OK Server: HomeSeer Expires: -1 Cache-Control: no-cache Pragma: no-cache Content-Type: text/html Accept-Ranges: none Content-Length: 126


        Also, I guess once I do get it working, it will be a training issue to left click. I think people are used to right-clicking and doing save as (like they would on here). Otherwise the winzip window opens up usually with nothing in it.

        The only way I have got it working so far is to hardcode a path and filename to an existing file...not passing it through.

        -Tom

        Visit my HomeSeer at http://68.55.67.82:81
        -Tom

        Visit Kernhome
        Kern Theater Gallery

        (User: guest / Pass: guest)

        Comment


          #5
          Can you not use the IIS logs somehow ?

          Depending on your version, I'll assume XP

          C:\Windows\System32\Logfiles\W3SVC1

          then a log file per day. Will show you all http requests, including downloads. Example entry..

          00:03:44 24.214.24.226 GET /downlaods/myfil.exe 304

          Maybe I've just misunderstood what you want

          Cheers

          Marc

          Comment


            #6
            <BLOCKQUOTE class="ip-ubbcode-quote"><font size="-1">quote:</font><HR>
            Can you not use the IIS logs somehow ?
            <HR></BLOCKQUOTE>
            HS has its own internal web server and doesn't use IIS to serve pages.

            Justin

            For PocketPC, Palm, and cell phone control:
            http://wapseer.carrotpatch.net/
            Got WAP?

            Comment


              #7
              what was the final outcome of this code to make it work..?

              Comment


                #8
                Originally posted by Bkphillips
                what was the final outcome of this code to make it work..?
                BKphillips,
                What exactly are you looking to do?
                💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                Comment


                  #9
                  count the number of downloads of a specific file, but not be liited to just a single file. I hav eone file right now on my downloads page, but eventually there will be more I'm sure, and simply having a count of the number of downloads would be nice, if it's not too much trouble.

                  Comment


                    #10
                    Do something like the doubleclick people do and use a redirection page with a counter on it.
                    Why I like my 2005 rio yellow Honda S2000 with the top down, and more!

                    Comment

                    Working...
                    X