This forum is archived. Posts are preserved for historical reference. For current help, join us on Discord.

changing and adding a redirect path

In UserSpice 4.3 and Below · Started by raven on 2017-02-27 6:27 pm · 44275 views · 20 replies

i like how the security redirects but i would like to change its path as well as add a few for other user classes eg users stay where there at but, managers would direct to a account page with aditional things on it like access buttons to other parts of the system with out them being visable to non manaagers

where is that located and how would i add classes to it for redirect
The redirects are in the securePage function in us_helpers, which is a core system file so changes you make there could be overwritten with updates.

What would you like to see happen? I might be able to give you a different way to accomplish it
in practice i would like to see the error redirect to anything with a classic saying of this page is restricted etc admins have been alerted just the generic stop poking around threat. also it would be nice to user classed redirects eg regular users of permission level user redirect as normal. but users of permission level moderator redirect to the not created moderator account page that would have additional buttons and menus for the other functions that they have permission to i would like to see the main admin permission class redirect straight to the admin page... i just figured something out though with out the ability to set inheritance of permissions my per user class redirect wont work right i don't think. because as it is now say a moderator for example would have the permissions moderator and user where it should be set as moderator only because the permission moderator inherits all the perms from user and then some make sense.

i am pulling the inheritance reference from a java scrips plugin for mine craft called permessions ex or PEX for short https://dev.bukkit.org/projects/permissionsex

http://pastebin.com/m4ippcjn
this is my permissions file that i use on my server notice how each "rank" from default to owner has its inheritance

default is the lowest class player anyone who plays is auto added to this rank. then it splits from there it goes like so

donor1 inherits from default all the perms that they have plus the perms that donor1 has listed

donor2 inherits from donor1 but one command is removed and other commands are added

donor 3 inherits from donor 2 commands are removed others added

etc all the way to donor 5

the staff ranks follow the same pattern

helper inherits all default commands

mod inherits all helper commands

admin inherits from mod

headadmin inherits from admin

owner inherits from headadmin

but the catch is with the diferent rank ladders the staff are allowed to hold 2 ranks a donor rank and a staff rank but thats not what im after here just the inheritance for redirects or the ability to redirect different permission levels in side userspice

make sense
I am about to push out an update with 2 scripts in usersc/scripts

In one, you can do whatever you want for someone who was not logged in (including redirect them to somewhere else) and the other you can do whatever you want for someone who failed the permission check.
Here you go... let me know what you think...
https://userspice.com/patch/421dto421f.zip
this looks promising but how would i reference the user class eg moderator to direct to a moderator account page same as a user account page with the addition of said buttons and menu options
this is as close as i can explain what i want this is a sample of a still bugged if condition is this do this else do that

void loop() {
// put your main code here, to run repeatedly:
// ac high low
if (dcu1 == HIGH) {
if (hipressw == HIGH){
if(fan == LOW){

digitalWrite(evplow, HIGH);
delay(50);
digitalWrite(condfan, HIGH);
delay(50);
digitalWrite(accomp, HIGH);
}
else{
digitalWrite(evplow, HIGH);
delay(100);
digitalWrite(evphigh, HIGH);
delay(50);
digitalWrite(condfan, HIGH);
delay(50);
digitalWrite(accomp, HIGH);
}
}
else{
digitalWrite(accomp, LOW);
delay(50);
digitalWrite(evplow, HIGH);
delay(100);
digitalWrite(evphigh, HIGH);
delay(50);
digitalWrite(condfan, HIGH);
}
}



thats more or less what im after for the user redirects if user data permission is 1 it redirects normally
but if user data permission is 2 it redricts differently

same with any permission level that i would change else it just redirects normally
What about taking a look at the checkMenu (single) and hasPerm (array) functions in users/helpers/us-helpers... You could copy one or both of them to usersc/includes/custom_functions, rename them, and use them as the basis for your permission based redirect.
hmm tbh im not at all familar with php in the least now yaml config i can do as well as some c++ for micro controllers and i dabble with html i know enough to eventually get what i want lol
So if your permission levels in are in userspice, you can go into the admin panel and at the top click on permission levels. Each permission level has an id. 1 is regular user. 2 is admin. The others you just add on your own. So in that usersc/scripts/did_not_have_permission.php you can put...

if(hasPerm([1],$user->data->id()){
Redirect::to('here');
}

if(hasPerm([2],$user->data->id()){
Redirect::to('here');
}

You can also put them in as an array, so
if(hasPerm([3,4,5],$user->data->id()){
Redirect::to('here');
}

Finally, you can redirect them with a message
if(hasPerm([2],$user->data->id()){
Redirect::to('account.php?err=Sorry+you+do+not+have+permission!');
}
yas that is the line of code i was after php and me dont get along well lol :D
if(hasPerm([1],$user->data->id()){
Redirect::to('$us_url_root.'users/account.php');
}

if(hasPerm([2],$user->data->id()){
Redirect::to('$us_url_root.'users/admin.php');
}
?>


this is what i have now but it doesnt work it says syntax error ...
Sorry. My fault. It's
if(hasPerm([1],$user->data()->id){
dreamwever still reports a syntax on line 5

http://pastebin.com/MSWYyUt8

Dang it. haha

if(hasPerm([2],$user->data()->id)){

It's hard to do this when I'm not in my code editor.
lol beautiful

however i just noticed i have to add them in reverse order admin listed first then the others so it works as i intended lol
Yeah...if you are using a hierarchy.
well im done for the night severe storms rolling through my area tornados confirmed on the ground just a few miles away time to power off the servers for their protection meh oh well

lol they havent been off in over 1327 hrs for my ibm and 2332 hrs for my hp wow
55 days for the ibm and 97 days for my full time on server the hp
grrr this works as long as i only have one layer for redirect eg

<?php require_once 'init.php';
if (hasPerm([2], $user->data()->id)) {
Redirect::to($us_url_root.'users/adminaccount.php');
}
?>

as soon as i add in a second path on the top of the account pages it breaks

?>
<?php require_once 'init.php';
if (hasPerm([2], $user->data()->id)) {
Redirect::to($us_url_root.'users/adminaccount.php');
}
if (hasPerm([5], $user->data()->id)){
Redirect::to($us_url_root.'users/modaccount.php');
}
}?>


i eventually had intended to have more for additional perm layers

i originally went with building my own site because i though it would be more cost effective but it seems that what engin has is what i actually want

https://ravencraftnetworks.enjin.com/

its a free site

this is the user page with "permissions" they call them tags i didnt want to have to buy the ultra plan its 29 a month or more depending on if you add a ts3 server i would love to see the enjin system reverse engineered but i dont see that happening lol they have too much there donation craft etc but that could be integrated idk
Ok. What about a different approach. What about a table called redirect_groups 2 columns.

Id, int(11), auto increment
and redirect,varchar(255)

Every time you insert a row into the db you put the path of the page you want that "group" to redirect to.
Then in your users table, you can either create a new column or use the unused account_id column.

Store the place you want that person to redirect in that column.

Then just make a function like
function redir($id){
$db = DB::getInstance();
$userQ = $db->query("SELECT account_id FROM user WHERE id = ?",array($id));
$found = $userQ->first();
$redirQ = $db->query("SELECT * FROM redirect_groups WHERE id = ?",array($found->account_id));
$redir = $redirQ->first();
Redirect::to($redir->redirect);
}

if that's not it for the function, it's close.

The other idea would be to make your user account levels a hierarchy. So, let's assume level 1 (user) is only for unvalidated users. 2 is admin. Then put your highest level user groups with the lowest level numbers. Then you can do a search of all the users and their permissions to find out what the highest (in this case lowest) permission level they have. So, your query would look like this.
$highestQ = $db->query("SELECT * FROM user_permission_matches WHERE permission_id !=1 AND user_id = ?",array($user->data()->id);
$highest = $highestQ->first();
//That just gave you the highest permission level that user has.

So now you make that same table.
if($highest==2){ //admin
Redirect::to('blah');
}

Basically this deals with users having multiple permission levels.

12Next ›