02-28-2017, 11:03 PM
yas that is the line of code i was after php and me dont get along well lol
The following warnings occurred: | ||||||||||||
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.2.25 (Linux)
|
changing and adding a redirect path
|
02-28-2017, 11:03 PM
yas that is the line of code i was after php and me dont get along well lol
02-28-2017, 11:20 PM
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 ...
02-28-2017, 11:42 PM
Sorry. My fault. It's
if(hasPerm([1],$user->data()->id){
03-01-2017, 01:39 AM
03-01-2017, 02:05 AM
Dang it. haha
if(hasPerm([2],$user->data()->id)){ It's hard to do this when I'm not in my code editor.
03-01-2017, 02:28 AM
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
03-01-2017, 02:34 AM
Yeah...if you are using a hierarchy.
03-01-2017, 03:00 AM
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
03-09-2017, 01:13 PM
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
03-09-2017, 09:50 PM
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 Code: function redir($id){ Code: $db = DB::getInstance(); Code: $userQ = $db->query("SELECT account_id FROM user WHERE id = ?",array($id)); Code: $found = $userQ->first(); Code: $redirQ = $db->query("SELECT * FROM redirect_groups WHERE id = ?",array($found->account_id)); Code: $redir = $redirQ->first(); Code: Redirect::to($redir->redirect); Code: } 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. Code: $highestQ = $db->query("SELECT * FROM user_permission_matches WHERE permission_id !=1 AND user_id = ?",array($user->data()->id); Code: $highest = $highestQ->first(); So now you make that same table. Code: if($highest==2){ //admin Code: Redirect::to('blah'); Code: } Basically this deals with users having multiple permission levels. |