Jump to content

[RESOLVED] File Protection?


Twango

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

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.

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.

Link to comment
Share on other sites

The webroot is the folder on the web server that contains everything that can be reached online. You can store files outside of that so you can't reach them directly, but PHP can still access them through the server's filesystem.

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

Ah Ok, figured it out, if you do sign up for my website i'll give you 10,000 free points, you can get songs and programs and junk.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...