#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0

    Serving personal downloads


    Hello, I have a question/problem. I need to give a different exe/jar file to different users on my page.
    What is the best way of accomplishing it?

    If that was not clear maybe this will be:
    database:
    id name
    1 user1
    2 user2

    if user1 is logged in and he presses download he will be served a compiled application that has a int id = 1
    if user2 is logged in and he presses download he will be served a compiled application that has a int id = 2

    and so on.

    ps. The only way I am familiar with would be to use shell(); and recompile the program when user registers(that leads to server being spammed) so maybe when user downloads(being slow)

    Thanks, Radexito
  2. #2
  3. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    Are these applications pre-compiled? Or do you have to compile them in real-time when they click?

    If you already have the files, you can serve them just like you serve any other file. Print the correct file name into the "download" link.

    You could also use a download.php which streams the correct file dynamically so you don't expose the download ID in the URL.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2012
    Posts
    2
    Rep Power
    0
    Originally Posted by ManiacDan
    Are these applications pre-compiled? Or do you have to compile them in real-time when they click?

    If you already have the files, you can serve them just like you serve any other file. Print the correct file name into the "download" link.

    You could also use a download.php which streams the correct file dynamically so you don't expose the download ID in the URL.
    I don't think you quite understood me ;(
    What i meant is when a person (that is logged in) clicks download it will serve him a precompiled file but (compiled, byte code edited, whatever) with one of the variables(int id being his user id that it would get from MySQL database

    Basically fully automate doing:
    open file
    edit the user id to the persons user id
    save the file
    compile
  6. #4
  7. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6351
    So then you do have to compile it before you serve it. How long does compilation take?
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  8. #5
  9. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    If all you have to do is inject one integer you could probably pre compile the binary, then examine the compiled code to find your integer, then program PHP to modify that part of the binary before serving it.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around

IMN logo majestic logo threadwatch logo seochat tools logo