halgatewood / file-directory-list

Free Super Clean PHP File Directory Listing Script
https://halgatewood.com/free/file-directory-list/
366 stars 148 forks source link

Share across multiple sites? #8

Open cremauser opened 7 years ago

cremauser commented 7 years ago

I'm currently coding a custom dashboard that compares my the files on my server with the commits of a Github repository. However, I'd like to share this across multiple sites.

Is there a way to put this in the base directory of my server and reference it in other sites? I'm sure it's stupid simple, but I'm a bit rusty when it comes to php.

cremauser commented 7 years ago

I figured out a hacky way that solves part of what I'm trying to do, but it slows down the load time a lot. Does anyone have any better ideas than this line of code? $items = scandir(dirname(chdir('/Sites')));

halgatewood commented 7 years ago

Try this one: $items = scandir( dirname(__FILE__) . '/Sites/');

cremauser commented 7 years ago

Thanks...but that command didn't work at all for me. Just a blank screen with no errors in the Console. Previous command I posted worked, it just took several seconds to load on my local dev machine. Your default directory lister, on the other hand, is pretty quick by default. I'm no php expert, so thought I might be doing something terribly wrong : P

Adding this command (or a better one) would allow users to add a variable a the top of the file for changing the directory. Question is, can you still do that if you share the same php file between multiple sites?

Or can you automatically get the root of the file that included it, versus the location of the directory lister itself?