The following warnings occurred:
Warning [2] Undefined variable $unreadreports - Line: 26 - File: global.php(961) : eval()'d code PHP 8.1.2-1ubuntu2.18 (Linux)
File Line Function
/global.php(961) : eval()'d code 26 errorHandler->error
/global.php 961 eval
/showthread.php 28 require_once





× This forum is read only. As of July 23, 2019, the UserSpice forums have been closed. To receive support, please join our Discord by clicking here. Thank you!

  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing and adding a redirect path
#11
yas that is the line of code i was after php and me dont get along well lol Big Grin
  Reply
#12
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 ...
  Reply
#13
Sorry. My fault. It's
if(hasPerm([1],$user->data()->id){
  Reply
#14
dreamwever still reports a syntax on line 5

http://pastebin.com/MSWYyUt8

  Reply
#15
Dang it. haha

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

It's hard to do this when I'm not in my code editor.
  Reply
#16
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
  Reply
#17
Yeah...if you are using a hierarchy.
  Reply
#18
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
  Reply
#19
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
  Reply
#20
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();
//That just gave you the highest permission level that user has.

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.

  Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)