The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
File Manager
#1
Hi
I need that the users can access to determinated files and others don't, but this is achievable with the roles system. And the question is... how can i list the files in a page??? should i use just php or can i use a premade solution????
  Reply
#2
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...
Code:
http://www.tutorialchip.com/php-download-file-script/

I may implement this in UserSpice. I like it.
  Reply
#3
thanks for the answer and the posible solutions, its very helpful.

so there is no problem in using external third party solutions, i mean some problem with the code, the variables and so. I think that if i put aside the uploading and focusing only in the listing, i would create a page where i can list the files from a specific directory... could you recomend me a tutorial or something that not break or alter the code of userspice
  Reply
#4
It is late here but I will see if I work up an example tomorrow. If you go into the blank pages and do a save as into the root folder you can do all your practicing on a relatively blank page and not worry about breaking anything. If you are going to modify an existing userspice page you should save the page into the usersc folder. When you do that and change the path of the init file userspice will load your page instead of our default one. The big benefit for this is that if there is an update, or update will not overwrite your page.
  Reply
#5
I tried that chip download thing and I can't figure out how to pass a list of files to it. I guess it goes back to how much you want to protect the files.
  Reply
#6
Hi mudmin
i wonder if you can pass me the exercise files from tutorial chip because i try to download it from them but i cannot find the link
or maybe i'm not worthy jajajaja
  Reply
#7
The link was broken for me too. I found it on stack overflow somewhere but I could not figure out how to get it to work. I am on a boat in the Pacific now so I don't have a good way to find it for you. If you don't find it I can send ut in a few days.
  Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)