0

I own a website that allows users to upload files. I have MY files on there as well, but I don't want to mix their files with mine, just in case somebody puts a bunch of malicious files and need to be mass removed. Rather than hunting them down individually, I can just delete their user folder and poof, they disappear of the website, but all the other users files and mine remain.

Now heres the catch, I wanted the users to browse a directory on the website but it would show ALL the files, mine and the users, as if they were contained in 1 directory. So I used PHP to do that and just display it to the user, and it works fine.

Problem is, I want to allow users to use FTP to browse them as if they were 1 directory as well. Of course that cannot happen since FTP just looks at the folder I tell it to. First idea would be symlinks, but I'm using VSFTPD and apparently that doesn't support symlinks. I was going to make a script that would update daily and create a sort of "pseudo directory" where everything would be combined as symlinks. This way at least the link would be in the same folder, without actually changing the real constriction of the folder layout. I'd just use python or something, but seeing as I can't use symlinks, that doesn't seem like an option either.

Just so you have some context, here's where MY files are located: /drives/ares/webroot/mywebsite/files/SOMEFOLDER/SOMEFILE.txt

Here's how the user files are constructed /drives/ares/webroot/mywebsite/users/SOMEUSERNAME/files/SOMEFOLDER/SOMEFILE.txt

For the website, I used PHP to recursively iterate through every user, and if the user folder contains 'SOMEFOLDER', it will read all the files in it and display it along with the files found in the other 'SOMEFOLDER' (my files). Its hard to explain, but I'm basically just combining a ton of directories so they appear as 1 one my website, for easier browsing. I'm now attempting to do the same thing with FTP, but since FTP is so straight forward, I'm having trouble finding a solution. Does anybody have any ideas on how I can achieve this? Thanks for any help, and sorry about the broad question, but I've been racking my brain for a while on this one.

PS: I'm on Arch Linux

4
  • Just a thought: What is the benefit of allowing FTP access? What problem does that solve for your users or you? Because it seems to cause you more problems that it solves. HTTP downloads have become more or less standard for most users and use-cases anyway. (If the use case is that an FTP client allows you to easily download all files, or to cherry-pick multiple files for download; build that "select [all or some] files for download" option into your PHP code... )
    – Bob
    Mar 12, 2021 at 15:15
  • 2 reasons. Wget will not work on my site since it requires a log in before you're given permission to even view the files. Since I cannot log in with wget, I figured I'd use FTP, since this way I could just pass the login through the wget url. Thats how it led me to the situation I'm in. The other reason I want FTP is that due to the nature of my site, it's common to need FTP in order to get their files. Because of some of the devices my users will be connecting from, they might not even have a web browser at their disposal.
    – Syllith
    Mar 12, 2021 at 15:49
  • I wouldn't really do it your way, but hardlinks should still work if all files are on the same volume.
    – Zac67
    Mar 12, 2021 at 17:13
  • Yea, its hard to explain why I need to do it like this, However, 1 thing I didn't realize is hardlinks don't work with directories, so when I was testing it, it wasn't working. I don't actually want to hard link the directories, just the files. So now I'm thinking I'll make a new directory that contains only hardlinks, combined with the files from my users. So the website will still browse the same way, but users that FTP will be pointed to the "hardlink" directory, where they can get everything like they could on the site. I'll probably just make a php script to generate the dir periodically
    – Syllith
    Mar 12, 2021 at 17:46

0

You must log in to answer this question.

Browse other questions tagged .