File Manager

Discussions about the usage of KeyHelp.
Post Reply
User avatar
keyhelpuser
Posts: 30
Joined: Sat 13. Mar 2021, 21:56
Location: ...earth
Contact:

File Manager

Post by keyhelpuser »

Hi, how can I hide the folders and files listed below:
.cache ,
.config ,
.local ,
.ssh ,
files ,
logs ,
tmp ,
.bashrc ,
.bash_history ,
.bash_logout ,
.profile ,

I would like to only for user access to the www folder by File Manager. Is there such an option to configure?
Regards
User avatar
Alexander
Keyweb AG
Posts: 4641
Joined: Wed 20. Jan 2016, 02:23

Re: File Manager

Post by Alexander »

Hello,

you can use the white-label feature for that purpose. Just use some JavaScript code to hide the table rows you don't want to see.

Please note, that your users might like to still have access to at least the directories files/, logs/, tmp/.
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
User avatar
keyhelpuser
Posts: 30
Joined: Sat 13. Mar 2021, 21:56
Location: ...earth
Contact:

Re: File Manager

Post by keyhelpuser »

Alexander wrote: Fri 14. Nov 2025, 09:41 Hello,

you can use the white-label feature for that purpose. Just use some JavaScript code to hide the table rows you don't want to see.

Please note, that your users might like to still have access to at least the directories files/, logs/, tmp/.
can you help me with this?
User avatar
Alexander
Keyweb AG
Posts: 4641
Joined: Wed 20. Jan 2016, 02:23

Re: File Manager

Post by Alexander »

keyhelpuser wrote: Sat 15. Nov 2025, 15:40 can you help me with this?

Okay, the following code should work.
It hides all the items in the hidePaths array and updates the total number in the table foot accordingly.

Code: Select all

let url = new URL(window.location.href);
let page = url.searchParams.get("page");
let path = url.searchParams.get("path");

if (page === "client_file_manager" && path === "/") {
  	// Hide paths
	let hidePaths = [
    		".cache",
        	".config",
        	".local",
        	".ssh",
		".bash_history",
		".bash_logout",
		".bashrc",
      		".profile",
      		"bin",
      		"dev",
      		"etc",
      		"lib",
      		"lib64",
      		"usr",
        	// ... add paths as you like
    	];

	let rows = document.querySelectorAll('#form-file-manager table tbody tr');

	rows.forEach(row => {
		let path = row.querySelector('input[name="config_id"]');
        	if (!path) return;
        	if (hidePaths.includes(path.value)) {
            		row.style.display = "none";
        	}
   	 });
  
  	// Update total number 
	let totalCell = document.querySelector(
		'#form-file-manager table tfoot td'
	);

	if (totalCell) {
      		let visibleRows = Array.from(rows).filter(r => r.style.display !== "none").length;
      		totalCell.textContent = totalCell.textContent.replace(/^\s*\d+/, visibleRows);
	}
}
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
User avatar
keyhelpuser
Posts: 30
Joined: Sat 13. Mar 2021, 21:56
Location: ...earth
Contact:

Re: File Manager

Post by keyhelpuser »

Alexander wrote: Mon 17. Nov 2025, 15:44
keyhelpuser wrote: Sat 15. Nov 2025, 15:40 can you help me with this?

Okay, the following code should work.
It hides all the items in the hidePaths array and updates the total number in the table foot accordingly.

Code: Select all

let url = new URL(window.location.href);
let page = url.searchParams.get("page");
let path = url.searchParams.get("path");

if (page === "client_file_manager" && path === "/") {
  	// Hide paths
	let hidePaths = [
    		".cache",
        	".config",
        	".local",
        	".ssh",
		".bash_history",
		".bash_logout",
		".bashrc",
      		".profile",
      		"bin",
      		"dev",
      		"etc",
      		"lib",
      		"lib64",
      		"usr",
        	// ... add paths as you like
    	];

	let rows = document.querySelectorAll('#form-file-manager table tbody tr');

	rows.forEach(row => {
		let path = row.querySelector('input[name="config_id"]');
        	if (!path) return;
        	if (hidePaths.includes(path.value)) {
            		row.style.display = "none";
        	}
   	 });
  
  	// Update total number 
	let totalCell = document.querySelector(
		'#form-file-manager table tfoot td'
	);

	if (totalCell) {
      		let visibleRows = Array.from(rows).filter(r => r.style.display !== "none").length;
      		totalCell.textContent = totalCell.textContent.replace(/^\s*\d+/, visibleRows);
	}
}
unfortunately it doesn't work :(
User avatar
Alexander
Keyweb AG
Posts: 4641
Joined: Wed 20. Jan 2016, 02:23

Re: File Manager

Post by Alexander »

unfortunately it doesn't work :(
It works fine on multiple servers on my end.
Without showing a potential error message from your browsers console there is now way someone could tell what went wrong on your side.


I see in your signature, you may use a custom theme, this might be the reason for this.
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
User avatar
keyhelpuser
Posts: 30
Joined: Sat 13. Mar 2021, 21:56
Location: ...earth
Contact:

Re: File Manager

Post by keyhelpuser »

original theme and firefox
User avatar
Alexander
Keyweb AG
Posts: 4641
Joined: Wed 20. Jan 2016, 02:23

Re: File Manager

Post by Alexander »

It also works fine in firefox for me.

Have you copied the code into the right input field?
What does the browser console say when accessing the page?
Mit freundlichen Grüßen / Best regards
Alexander Mahr

**************************************************************
Keyweb AG - Die Hosting Marke
Neuwerkstr. 45/46, 99084 Erfurt / Germany
http://www.keyweb.de - http://www.keyhelp.de
**************************************************************
User avatar
keyhelpuser
Posts: 30
Joined: Sat 13. Mar 2021, 21:56
Location: ...earth
Contact:

Re: File Manager

Post by keyhelpuser »

I have no errors on both macOS and Ubuntu?!
console-keyhelp-firefox.png
Post Reply