Jump to content

Recommended Posts

ok im having trouble with the session thing

 

this is my include file for my side menu every lvl got other links to show but it only displays the

if( $session->logged_in part it ignores the rest. So my question is what im i missing or doing wrong here?

 

<?
/**
* Users can see logged_in
* Members --> lvl5
* Mods --> lvl7
* Admin/lvl9 isAdmin
*/
if( $session->logged_in){
echo "<h3>Menu</h3>";

echo "<li><a href=\"userinfo.php?user=$session->username\">My Account</a></li>"
."<li><a href=\"useredit.php\">Edit Account</a></li>";
echo "<p>  </p>";

if( $session->isUserlevel(5)){
echo "<li><a href=\"filmen_leden.php\">Filmen</a></li>";

if( $session->isUserlevel(7)){
echo "<li><a href=\"links.php\">links</a></li>"
."<li><a href=\"upload_kalender/upload.form.php\">upload kalender</a></li>";

if($session->isAdmin()){ 

echo "<li><a href=\"../livre d'or/admin/index.php\">livre d'or</a></li>"
."<li><a href=\"../gastenboek/admin/index.php\">Gastenboek</a></li>"
."<li><a href=\"admin/index.php?id=1\">Admin Center</a></li>";
}
echo "<p>  </p>"
."<li><a href=\"process.php\">Logout</a></li>";


}}}

?>

 

thx

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/
Share on other sites

I assume the problem is because you are checking if the user's level is exactly 5, 7, or admin.  You need to set up your user levels to be inclusive of the lower privileges as well - if that fits your scheme.  The way you have it now, if you are ?SuperModerator? and your level is 7, you will return false for being Userlevel 5 ?Moderator?

 

There are several different approaches to privilege levels.  You could

[*] check for permission levels based on actions (can edit, can post, can delete, etc) where as user levels raise, so do the perms. 

[*] check if user level is >= 5/7/9, which would return true for admin to see mod privs

[*] create a perms table with boolean rows for things like: is_banned, is_member, is_mod, is_supermod, is_admin, is_superadmin and change your functions accordingly.

 

Bottom line, no matter how you do it, you need to give your high priv'd users access to lower level perms. 

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356610
Share on other sites

thats exactly what i want that the admin/lvl9 can see everyting and a user as good as nothing.

i dont rlly understand this option

check if user level is >= 5/7/9, which would return true for admin to see mod privs

 

how do i approach this?

or is it possible to redirect each lvl to another page?

 

thanks

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356615
Share on other sites

Well not rlly i only need to lvl the members of the club non members stay at low lvl.

So i only need to make 1 a mod so he can help me with uploads of pics ect... and then the rest members ,so that the members cant mess around.

I need to activate acounts so i might aswell asign a lvl while im busy its not that we got 100 members (yet).

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356638
Share on other sites

"How" is part of the programmatic puzzle that is your job as the developer to figure out.  The answers to that lie in your application, how it's going to be used, what can be accomplished, and how you're going to accomplish it.

 

Foremost, you need to rectify your establishment of user privileges - ensuring that the top can see all the way down and your levels between A and Z have the proper privileges.  You've gotten half-way there already, but you need to make some modifications that I eluded to previously.  Once you have proper privs established, then you can assign permissions.

 

Let's say, for instance, you have a news blog up.  This news blog permits registered users to post comments on the blog.  And you've already established an admin section for writing and editing the articles.

 

Since every blog post will follow the same template, you only need one view file, right?  This has things like the title, a summary, the body, and an area for comments.  So, based on the URI your visitors browse to, the proper article gets loaded with database info.  Now, since you have varying amounts of privileges, there are different things that people can do while on this page.  Admin may get a special link that directs them to the admin section where they can edit the post // moderators may get a special icon that allows them to delete a comment // and banned users may not get to even comment.

 

There's no need for new pages, you'll just draw in special elements depending on privilege level.  It's your job to figure out who, what, where, when, and how.  If you get lost trying to accomplish something, this forum has many dedicated and helpful members.  If you want somebody to do this for you, you'll need to visit the freelancer section and be prepared to pony up some cash.

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356862
Share on other sites

I explained it to you in my first reply, but let's look at it again.

 

<?php
if( $session->isUserlevel(5)){
     // do something

     if( $session->isUserlevel(7)){
          // do something

          if($session->isAdmin()){ 
               // do something
          }
     }
}

As you can see, you are checking levels backwards.  You are checking that the user level is 5.  This obviously will not work because if the value is NOT 5 the function returns as false and doesn't even bother to look down the road. So the check for level 7 is never performed, and nor is the check for admin status.

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356867
Share on other sites

ok but if i do it otherwise and the user isnt admin the script wont bother to look for 7, 5 ect

and if i would use elseif would that do the trick?

 

like

<?php
if( $session->Logged_in){
     // do something

     if( $session->isAdmin()){
          // do something

          elseif($session->isUserlevel(7)){ 
               // do something
          }
     }
}

 

thx

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356873
Share on other sites

I assume the problem is because you are checking if the user's level is exactly 5, 7, or admin.  You need to set up your user levels to be inclusive of the lower privileges as well - if that fits your scheme.  The way you have it now, if you are ?SuperModerator? and your level is 7, you will return false for being Userlevel 5 ?Moderator?

 

There are several different approaches to privilege levels.  You could

[*] check for permission levels based on actions (can edit, can post, can delete, etc) where as user levels raise, so do the perms. 

[*] check if user level is >= 5/7/9, which would return true for admin to see mod privs

[*] create a perms table with boolean rows for things like: is_banned, is_member, is_mod, is_supermod, is_admin, is_superadmin and change your functions accordingly.

 

Bottom line, no matter how you do it, you need to give your high priv'd users access to lower level perms.

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356875
Share on other sites

check if user level is >= 5/7/9, which would return true for admin to see mod privs

 

how do i approach this?

 

<?php
if( $session->=(3)(5)(7)){
     // but then it doesnt matter what lvl they are thell all see the same here?

     if( $session->isAdmin()){
          // do something

     }
}

 

thx

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356880
Share on other sites

<?
if($session->logged_in){
echo "<h3>Menu</h3>";

echo "<li><a href=\"userinfo.php?user=$session->username\">Mijn Account</a></li>"     
."<li><a href=\"useredit.php\">Instellingen</a></li>";
echo "<p>  </p>";

if($session->isAdmin()){
echo "<li><a href=\"filmen_leden.php\">Filmen</a></li>"
."<li><a href=\"links.php\">links</a></li>"
."<li><a href=\"upload_kalender/upload.form.php\">upload kalender</a></li>"
."<li><a href=\"../livre d'or/admin/index.php\">livre d'or</a></li>"
."<li><a href=\"../gastenboek/admin/index.php\">Gastenboek</a></li>"
."<li><a href=\"admin/index.php?id=1\">Admin Center</a></li>";

}
echo "<p>  </p>"
."<li><a href=\"process.php\">Logout</a></li>";

}

?>

you mean this?

atm its still set for users and admin only.

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356884
Share on other sites

This is going to seem rather blunt, but you're trying to get other people to blindly throw possible solutions at some code that you didn't write, don't understand, the author no longer supports, and has terrible documentation. It may be time to find a different application that actually works.

Link to comment
https://forums.phpfreaks.com/topic/264686-if-session-problem/#findComment-1356900
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.