josefnpat / vapor

Vapor - LÖVE Distribution Client
zlib License
77 stars 24 forks source link

Added trAInsported to games.json #71

Closed Germanunkol closed 11 years ago

Germanunkol commented 11 years ago

Added trAInsported game to src/games.json

There are two games.json files, one in the root dir and one in src, I only edited the one in src because I was unsure. Please correct if needed.

josefnpat commented 11 years ago

I checked twice, unfortunately the sha1 hash for your file is 81819c665eaeaf8056ad1600f5fd8301421cdfb0 as opposed to d3329140303dac12f40b08a7063479a553eb39f2

josefnpat commented 11 years ago

I ought to correct myself; what lua downloaded via socket.http has a hash of 81819c665eaeaf8056ad1600f5fd8301421cdfb0. I checked the content, and this is showing;

<html>
  <head>
    <meta http-equiv="refresh" content="0;url=download/trAInsported4.love">
  </head>
  <body>

    Counted download.
  </body>
</html>

If you want some help with download counts that don't interfere with downloads, I can help :)

Germanunkol commented 11 years ago

Aha, I was wondering about that, but figured it would have to work. I guess I was wrong. Sadly, I have no way of testing, because Vapor seems to update the games.json automatically (which is a good thing, of course - but that doesn't allow me to test new entries I made locally).

How do you do your download counts? I do it by redirecting to a php script which logs the download into a mysql database and then redirects to the actual download file.

For the time being, you can also link directly to the file: http://trainsportedgame.no-ip.org/download/trAInsported4.love ... or tell me how to modify my server.

josefnpat commented 11 years ago

For your file, the problem seems that you're printing out HTML which asks the browser to do a redirect.

Instead you ought to use the header() command, e.g. header("location: train.love");

http://php.net/manual/en/function.header.php

In the meantime, I'll update the json to use the link you gave me.

Feel free to submit another pull request with a new link when you get your PHP script working!

Germanunkol commented 11 years ago

Thanks, it works now with this link: http://trainsportedgame.no-ip.org/downloadCount.php?Down=download/trAInsported4.love This is the same link as in the original pull request. I tested it using the linux wget command.

However, the resulting filename, locally, using wget is: downloadCount.php?Down=download/trAInsported4.love Instead, the filename should be trAInsported4.love I assume that your client will have the same problem while downloading... so I did not make a pull request yet. You can also maybe test it (I can't, as mentioned before) by using the above link.

This is how I currently do it (shortened code):

$Down=$_GET['Down'];
if ( file_exists( $Down ) )
{
    header('Location: ' . $Down);

    // manage counters
    // ...
}
josefnpat commented 11 years ago

@Germanunkol Thank you, that works perfectly.

As for wget, try using the wget -o <target> and you can choose where the data should be stored.

qaisjp commented 11 years ago

THAT IS DANGEROUS CODE, always check user input information. You should try something like this, untested and unsyntax checked. https://gist.github.com/qaisjp/6210268 imagine a firstname of "/../../../etc/passwd"

Germanunkol commented 11 years ago

Uha, I see. Thanks for pointing that out! I DO check if the file is empty (the above is a shortened example), but I will also make sure only files from within an array can be downloaded. I'm relatively new to php - trainsported's website is the first one I built from scratch. Thanks again!

josefnpat commented 11 years ago

@qaisjp :+1: Good catch