Hello world!
November 17, 2014
Adding a gravatar to your pages
February 2, 2016

Monitoring Additional Folders

Version 4.1, 4.2 or later…

Open the file z_us_root.php.

Line 2 has an array,

$path=[”,’users/’,’usersc/’];

https://mydomain.com and you already have https://mydomain.com/users, https://mydomain.com/usersc and you want to add a folder called ‘app’ (which would be https://mydomain.com/app

Edit the file z_us_root.php line two to say

$path=[”,’users/’,’usersc/’,’app/’];

and your php files should show right up in the admin_pages section of the dashboard and in your database.

 

Version 4.0.x…(Deprecated)

By default, UserSpice monitors the root folder of your project as well as the /users folder.  It finds all the php files and adds them to the database, controlling access to who can visit what?  But what if you want to monitor more folders?  That’s not a problem, as long as you take into consideration that all the filenames need to be unique.  In other words, you don’t really want to have two index.php files…and if you do, they probably need to have the same permissions. Let’s get started.

The first thing you need to do is to make a very simple function. I will show you the one I wrote to keep an eye on all the files in the /users folder.  Open helpers/us_helpers.php and look for a function called getUSPageFiles().  It looks something like this.

function getUSPageFiles() {
$directory = “../users/”;
$pages = glob($directory . “*.php”);
foreach ($pages as $page){
$fixed = str_replace(‘../users/’,”,$page);
$row[$fixed] = $fixed;
}
return $row;
}

All you have to do is copy/paste this function, give it a new name, and swap out the  word users for whatever folder you want to monitor.

Then, open the file /users/admin_pages.php

copy this line and paste it right below itself.

$uspages = getUSPageFiles(); //retrieves core UserSpice pages

Change the name of the variable and the function to a unique variable and the name of the function you created.

Finally, just below that you will see a line that reads…

$pages = array_merge($rootpages, $uspages);

After $uspages just add a comma and your variable that links to your new function.

Voila. Save everything.  Login and go to admin_pages and all of your files in that new folder will automatically populate the database and be controllable by UserSpice.