This plugin improves the built in cloaking for UserSpice by adding a helper function to cloak with a number of options, and a logout hook to use this as a secondary method of returning to the original user.
- Callable function for easy cloaking with security checks
- Automatic redirection after cloaking
- Storage and redirection to original destination after cloaking session ended
- Logout button will double as an uncloak button
- Function option overrides including master account check skips, and modifications to the plugins core features
UserSpice can be downloaded from their website or on GitHub.
- Visit Spice Shaker in your Admin Dashboard
- Search for "IPCheck CloudFlare"
- Press "Download"
- Press "Checkout/Install"
- Enjoy :)
- Download the Release ZIP
- Upload the Plugin Folder to
usersc/plugins
- Visit the Plugin Manager
- Press "Install Plugin"
- Enjoy :)
The CloakPlus_Cloak
function will return a state
which can be accessed through the array
, and in the event the state
is false
, it likely will return an error
as well. If cloaking is successful, the plugin will redirect the user automatically to the homepage. If you disable this, it will return a state
of true
. The state
will always be a boolean
.
Behavior | Override | Error |
---|---|---|
Check if there is a user logged in | None | not_logged_in |
Check if the provided cloakTo variable is an int (or can be converted) and is a valid User ID |
None | cloakee_invalid |
Checks if the provided cloakTo variable is the same as the cloaker's ID |
None | cloakee_is_self |
Check if the cloaker is in the Master Account Array | skip_master_check |
cloaker_not_in_master_array |
Check if the cloakee (person being cloaked to) is not in the Master Account Array | allow_master_cloaking |
cloakee_in_master_array |
Store URI that the user cloaked from, to redirect them back to after | do_not_store_original_dest |
None |
Logging out triggers uncloaking | disable_logout_uncloak |
None |
Auto redirect on cloaking | no_redirect_on_success |
None |
# Placeholder Variables
$userId = 100;
$errors = [];
$cloak = CloakPlus_Cloak($userId);
if (!$cloak['state']) {
$errors[] = $cloak['error'] ?? 'There was an error processing your request';
}
# Placeholder Variables
$userId = 100;
$errors = [];
$cloak = CloakPlus_Cloak($userId, ['disable_logout_uncloak']);
if (!$cloak['state']) {
$errors[] = $cloak['error'] ?? 'There was an error processing your request';
}
# Placeholder Variables
$userId = 100;
$errors = [];
$cloak = CloakPlus_Cloak($userId, ['skip_master_check']);
if (!$cloak['state']) {
$errors[] = $cloak['error'] ?? 'There was an error processing your request';
}
In some instances, the URL you may have cloaked from could cause a redirect loop if you use URL parameters to trigger the cloaking. For example, if you cloak from https://example.com/user/bobsmith/cloak/, it will cause a redirect loop. If you still want to redirect them back to a URL other than the homepage however, you can do this by setting the REQUEST_URI
to something else. In the above URL, we'll want to drop the cloak/
, so we'll do that using the below code:
# Placeholder Variables
$userId = 100;
$errors = [];
$request_uri_override = $_SERVER['REQUEST_URI'];
$request_uri_override = explode('cloak/', $request_uri_override);
$_SERVER['REQUEST_URI'] = $request_uri_override[0];
$cloak = CloakPlus_Cloak($userId, ['skip_master_check']);
if (!$cloak['state']) {
$errors[] = $cloak['error'] ?? 'There was an error processing your request';
}
If you simply want to strip out regular URL parameters, eg. ?cloak=1
, we'll do this:
# Placeholder Variables
$userId = 100;
$errors = [];
$request_uri_override = $_SERVER['REQUEST_URI'];
$request_uri_override = explode('?', $request_uri_override);
$_SERVER['REQUEST_URI'] = $request_uri_override[0];
$cloak = CloakPlus_Cloak($userId, ['skip_master_check']);
if (!$cloak['state']) {
$errors[] = $cloak['error'] ?? 'There was an error processing your request';
}
Note, anything else that depends on REQUEST_URI
before the user is redirected into the cloaked session will be using this new URI that you set. This is the only way to handle a modified redirection at the time of writing, however.
If you have any issues please open an issue here on GitHub. This includes feature requests. If you wish to resolve an issue, you may complete a pull request. Please do not make a pull request for features without opening an issue first.
Pull Requests are expected to be validated with PHP CS Fixer using the following standards. A config file for this is included in the repo.
@PSR2, @Symfony, -phpdoc_annotation_without_dot, -phpdoc_no_alias_tag, -phpdoc_separation, -yoda_style
Any help with UserSpice can be asked in their Discord.