How can we check user privileges from another PHP page?
From a completely separate (non-CWIS) PHP page, we want to check if the user is logged in to CWIS, and check the privileges.
Tried this (after first getting a good $path variable to CWIS root):
# set up operating environment
require_once($path . "/include/StartUp.php");
# set UI for logged-in user (or default UI if not logged in)
$AF->ActiveUserInterface(GetActiveUI());
if ($G_User->HasPriv(PRIV_SYSADMIN)) {
echo 'You do have sufficient permissions to browse the server.';
} else {
echo 'You do not have sufficient permissions to browse the server.';
die();
}
But this is failing; getting this:
PHP Fatal error: Class 'SystemConfiguration' not found in /public_html/include/EnvSetup.php on line 113
Even tried monkeying to get the base dir right in StartUp.php:
if (strpos($page, 'ourcustomphppage') === false)
{
chdir(dirname(__FILE__)."/..");
} else {
chdir(dirname(__FILE__)."/../../../..");
}
But even getting that right we still get the error.
Can you advise, how we can get a reference to the user in a non-CWIS page and check the user privs?
I think what you posted should work. We run code all the time in-house that initializes the environment with nothing more than:
require_once("include/StartUp.php");
StartUp.php
), and then proceeds to do almost anything you can do in normal CWIS code.require_once($path."/include/StartUp.php)
, and post the output?echo var_dump(spl_autoload_functions());
The output is:
array(1) { [0]=> string(10) "__autoload" }
Okay, so that means that ApplicationFramework's class autoloading is not being connected at all.
What version of CWIS are you running, and what version of PHP?
}
CKFinder definitely has its own array of added complexities, but I don't see any reason offhand why the above shouldn't work.
I'd suggest copying the two files in the attached zipfile into
lib/ScoutLib
in the CWIS directory tree, and see if that helps. It's the very latest version ofApplicationFramework
, with a newer class autoloading mechanism.Thank you. I copied those files into lib/ScoutLib.
Got it working now!