11-27-2016, 04:56 AM
There are definitely 3rd party solutions for doing this... I'm trying to think through how I would code it if I were doing it in php.
My initial thought is that I would randomize the filenames a little bit so someone couldn't just guess the filename.
Then, you can use the checkMenu function to decide if the link to that particular file shows up for someone.
When you go into the permission levels, you'll notice that each permission has an id. That id gets passed into the checkMenu function along with the user's id. That will tell you if they have permission. So you could do something like this.
Level 2 is Admin by default.
<?php if (checkMenu(2,$user->data()->id)){ ?>
//YourDownloadLink etc
<?php } ?>
The other thing you could do is make a database table that stores each filename and a list of the access levels that can access it. Then you can create a function to check that.
Note that once you give the link to someone, this does not stop them from right clicking the actual file link and sharing it.
If you want to get a little fancier, here is a class...
I may implement this in UserSpice. I like it.
My initial thought is that I would randomize the filenames a little bit so someone couldn't just guess the filename.
Then, you can use the checkMenu function to decide if the link to that particular file shows up for someone.
When you go into the permission levels, you'll notice that each permission has an id. That id gets passed into the checkMenu function along with the user's id. That will tell you if they have permission. So you could do something like this.
Level 2 is Admin by default.
<?php if (checkMenu(2,$user->data()->id)){ ?>
//YourDownloadLink etc
<?php } ?>
The other thing you could do is make a database table that stores each filename and a list of the access levels that can access it. Then you can create a function to check that.
Note that once you give the link to someone, this does not stop them from right clicking the actual file link and sharing it.
If you want to get a little fancier, here is a class...
Code:
http://www.tutorialchip.com/php-download-file-script/
I may implement this in UserSpice. I like it.