Jump to content

[RESOLVED] File Protection?


Twango
 Share

Recommended Posts

Hi, I have a point system on my website where users can buy points then redeem them for things...As of now, these things are only database features...Is there any way I can it so the ONLY way possible to download that feature is if the user has enough points in the database?I already have the if statements for the database features. So I already have that.What I need is say, if the user has 10,000 points, it automatically downloads a song.Is this possible?Thanks

Edited by Twango
Link to comment
Share on other sites

yes. just keep track of points a user has, and set defined values for how many points are required to get a feature. if the user's points meets or exceeds that criteria, then show the something that would otherwise be "hidden" (literally or figuratively). It would probably be easier if you had some code with what you've attempted that we can work with.

Edited by thescientist
Link to comment
Share on other sites

I really have tried include("file.wav") and require("file.wav") and also echo "<iframe src=file.wav>" but my problem is autodownloading and protecting

Link to comment
Share on other sites

you can put your file outside the webroot. if criteria to downloading matches. get the file using file_get_contents()and echo it out with appropaite content-type header.

Link to comment
Share on other sites

..and if you want a download prompt you can use

header("content-disposition:attachment; filename=myfilename.ext");

remember to change ext in myfilename.ext with appropiate extension. without the filename part or with inapropiate extension in filename part it will not show it apropiately. myfilename will be replaced with desired file name which will be save as with that name.

Edited by birbal
Link to comment
Share on other sites

Wooh, I figured it out! Used

header("content-disposition:attachment; filename=myfilename.ext");

and then CHModded it to 0.0.0 and it works great ~ for your guys help if you want to sign up for my social network, I'll give you 5,000 AAN Points. :)

Link to comment
Share on other sites

Well I thought I had it... then I didn't...It WILL download it... here's a quick overview of my code... I set a variable (for this example, let's use $p) to the number of points.Then if ($p >= 10000) { Then I subtract the 10000 points, then I do this:echo "<h1>Congratulations! You bought <u>ASCII by DJ 3P1C</u>!</h1><br/><h2>Download should automatically start, if it does not, contact error@appattacknetwork.com with error code AS-erReqfrom:" . $_SERVER['REMOTE_ADDR'] . "<br/><br/>Thank you for purchasing!";header("content-disposition:attachment; filename=http://www.appattackftp.us/music/ASCII.wav");And it does download and subtract the points... but it doesn't go to the PHP page, on the HTML page I use a dropdown menu each with a unique name, then in the php page (buy.php) I use if ($_POST['uniqeidentifier'] == "whatever) { then I start the download.So the HTML page seems to be posting the data (as it downloads, which is on the php page) but for some reason, it's just not echoing, so basically, here's how it works: 1. User selects thing to buy >> clicks buy >> posts to php page >> handles/checks >> echos confirmation to page >> downloads.But it doesn't go to buy.php, and doesn't echo the confirmation (since it isnt on the buy.php page) I really have no clue why this isnt working. Please help

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...