[HELP] Admin Panel (PHP Edit)

Results 1 to 18 of 18
  1. #1

    [HELP] Admin Panel (PHP Edit)

    I'm editing Emisand's Admin Panel v3 and I'm trying to edit the function of editing the UGradeID.

    if( $type != 2 && num_rows($query02) != 1 )
    {
    setmessage("Rank Change", $_STR[Acc16]);
    redirect("index.php?do=accounts");
    die();
    }
    else
    {
    odbc_exec($connection, "UPDATE {$_CONFIG[AccountTable]} SET UGradeID = '$rank' WHERE $part = '$id'");
    writetolog( sprintf($_STR[Log2], $part, $id, $rank) );
    setmessage("Rank Change", $_STR[Acc19]);
    redirect("index.php?do=accounts");
    die();
    }
    How do I create a conditional check?

    Example: I want to block GMs from banning/changing ranks of other GMs.

    How do I check if the player ($id) is a GM?


  2. #2
    Extreme Coder - Delphi bounty-hunter is offline
    MemberRank
    Sep 2007 Join Date
    GunZone MansionLocation
    1,725Posts

    Re: [HELP] Admin Panel (PHP Edit)

    why would u wana do that, what if u need to ban a hacker O_O

  3. #3

    Re: [HELP] Admin Panel (PHP Edit)

    I don't want GM's to ban each other.

  4. #4
    Extreme Coder - Delphi bounty-hunter is offline
    MemberRank
    Sep 2007 Join Date
    GunZone MansionLocation
    1,725Posts

    Re: [HELP] Admin Panel (PHP Edit)

    make me gm :P

  5. #5
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: [HELP] Admin Panel (PHP Edit)

    Quote Originally Posted by bounty-hunter View Post
    make me gm :P
    Get ontopic.

    Quote Originally Posted by Linear88 View Post
    I'm editing Emisand's Admin Panel v3 and I'm trying to edit the function of editing the UGradeID.



    How do I create a conditional check?

    Example: I want to block GMs from banning/changing ranks of other GMs.

    How do I check if the player ($id) is a GM?
    Should go this way:

    PHP Code:
    <?php
    if( $type != && num_rows($query02) != )
    {
        
    setmessage("Rank Change"$_STR[Acc16]);
        
    redirect("index.php?do=accounts");
        die();
    }
    else
    {
        
    //Let's check it the user is staff or not.
        
    $query odbc_exec($connection"SELECT UGradeID FROM " $_CONFIG['AccountTable'] . " WHERE " $part " = " $id "");
        
    odbc_fetch_row($query);
        
    $ugradeid odbc_result($query1);
        
        
    //If the ugrade is 252 OR 254 OR 255. (OR = ||)
        
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255)
        {
            die(
    "GTFO and die. You're not worth it, ass.");
        }
        
        
    //Extra protection to prevent your staff from updating someone to staff. (Except if the staffmember has 255)
        
    if ($rank == 252 || $rank == 254 || $rank == 255 && $_SESSION['UGradeID'] != 255)
        {
            die(
    "Euhhhh no. An admin should promote staff. You should suicide.");
        }
        
        
    odbc_exec($connection"UPDATE {$_CONFIG[AccountTable]} SET UGradeID = '$rank' WHERE $part = '$id'");
        
    writetologsprintf($_STR[Log2], $part$id$rank) );
        
    setmessage("Rank Change"$_STR[Acc19]);
        
    redirect("index.php?do=accounts");
        die();
    }
    ?>
    It's possible that I made a typing mistake, it's still morning...

  6. #6
    DRGunZ 2 Creator wesman2232 is offline
    MemberRank
    Jan 2007 Join Date
    Erie, PALocation
    4,872Posts

    Re: [HELP] Admin Panel (PHP Edit)

    rofl I always love your 'die()' messages wizkid

  7. #7

    Re: [HELP] Admin Panel (PHP Edit)

    Thanks again Wiz!

    Btw the die("") messages are funny.

  8. #8

    Re: [HELP] Admin Panel (PHP Edit)

    Sorry for double posting but I really need to find out how to fix the code I have right now.

    The problem right now is: Users with UGrade 255 cannot demote users which are below its rank.

    Tried to edit it, unsure on how to...

    PHP Code:
    if( $type != && num_rows($query02) != )
    {
        
    setmessage("Rank Change"$_STR[Acc16]);
        
    redirect("index.php?do=accounts");
        die();
    }
    else
    {
        
    //Let's check if the user is staff or not.
        
    $query odbc_exec($connection"SELECT UGradeID FROM {$_CONFIG[AccountTable]}(nolock) WHERE $part =  '$id'");
        
    odbc_fetch_row($query);
        
    $ugradeid odbc_result($query1);
        
        
    //If the ugrade is 252 OR 254 OR 255. (OR = ||)
        
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255)
        {
        
    setmessage("Rank Change""You do not have permission to demote admins.");
                
    redirect("index.php?do=accounts");
        die();
        }
        
        
    //Extra protection to prevent your staff from updating someone to staff. (Except if the staff member's UGrade 255)
        
    if ($rank == 252 || $rank == 254 || $rank == 255 && $_SESSION['UGradeID'] != 255)
        {
        
    setmessage("Rank Change""You do not have permission to promote users.");
                
    redirect("index.php?do=accounts");
        die();
        }
        
        
    odbc_exec($connection"UPDATE {$_CONFIG[AccountTable]} SET UGradeID = '$rank' WHERE $part = '$id'");
        
    writetologsprintf($_STR[Log2], $part$id$rank) );
        
    setmessage("Rank Change"$_STR[Acc19]);
        
    redirect("index.php?do=accounts");
        die();
       }
    //Prevent unexpected end of die(); 

  9. #9
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: [HELP] Admin Panel (PHP Edit)

    Quote Originally Posted by Linear88 View Post
    Sorry for double posting but I really need to find out how to fix the code I have right now.

    The problem right now is: Users with UGrade 255 cannot demote users which are below its rank.

    Tried to edit it, unsure on how to...

    PHP Code:
    if( $type != && num_rows($query02) != )
    {
        
    setmessage("Rank Change"$_STR[Acc16]);
        
    redirect("index.php?do=accounts");
        die();
    }
    else
    {
        
    //Let's check if the user is staff or not.
        
    $query odbc_exec($connection"SELECT UGradeID FROM {$_CONFIG[AccountTable]}(nolock) WHERE $part =  '$id'");
        
    odbc_fetch_row($query);
        
    $ugradeid odbc_result($query1);
        
        
    //If the ugrade is 252 OR 254 OR 255. (OR = ||)
        
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255)
        {
        
    setmessage("Rank Change""You do not have permission to demote admins.");
                
    redirect("index.php?do=accounts");
        die();
        }
        
        
    //Extra protection to prevent your staff from updating someone to staff. (Except if the staff member's UGrade 255)
        
    if ($rank == 252 || $rank == 254 || $rank == 255 && $_SESSION['UGradeID'] != 255)
        {
        
    setmessage("Rank Change""You do not have permission to promote users.");
                
    redirect("index.php?do=accounts");
        die();
        }
        
        
    odbc_exec($connection"UPDATE {$_CONFIG[AccountTable]} SET UGradeID = '$rank' WHERE $part = '$id'");
        
    writetologsprintf($_STR[Log2], $part$id$rank) );
        
    setmessage("Rank Change"$_STR[Acc19]);
        
    redirect("index.php?do=accounts");
        die();
       }
    //Prevent unexpected end of die(); 
    If you mean they can't demote users which are 252, 254 or 255, replace

    PHP Code:
        //If the ugrade is 252 OR 254 OR 255. (OR = ||)
        
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255)
        {
        
    setmessage("Rank Change""You do not have permission to demote admins.");
                
    redirect("index.php?do=accounts");
        die();
        } 
    With

    PHP Code:
        //If the ugrade is 252 OR 254 OR 255. (OR = ||)
        
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255 && $_SESSION['UGradeID'] != 255)
        {
        
    setmessage("Rank Change""You do not have permission to demote admins.");
                
    redirect("index.php?do=accounts");
        die();
        } 

  10. #10
    Mako is insane. ThePhailure772 is offline
    MemberRank
    Sep 2007 Join Date
    1,115Posts

    Re: [HELP] Admin Panel (PHP Edit)

    Peter: an easier and more professional way on your if statement:

    if ( $ugradeid > 251 && $ugradeid != 253 )

    That's much more clean and can go a lot better.

  11. #11
    Extreme Coder - Delphi bounty-hunter is offline
    MemberRank
    Sep 2007 Join Date
    GunZone MansionLocation
    1,725Posts

    Re: [HELP] Admin Panel (PHP Edit)

    agreed with the failure :)

  12. #12

    Re: [HELP] Admin Panel (PHP Edit)

    Didn't work... Weird.

    I still get the message even though my UGrade is 255:

    You do not have permission to demote admins.

  13. #13
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: [HELP] Admin Panel (PHP Edit)

    Quote Originally Posted by ThePhailure772 View Post
    Peter: an easier and more professional way on your if statement:

    if ( $ugradeid > 251 && $ugradeid != 253 )

    That's much more clean and can go a lot better.
    But not much securer. If you want to do it as it should go, it'd go this way:

    PHP Code:
    if ($ugradeid >= 252 && $ugradeid != 253 && $ugradeid 255
    Well, in that case I say: do it clear with an if statement, including OR's.

    PHP Code:
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255
    Just details, but still.

    Quote Originally Posted by Linear88 View Post
    Didn't work... Weird.

    I still get the message even though my UGrade is 255:

    You do not have permission to demote admins.
    You get the setmessage("Rank Change", "You do not have permission to demote admins.");

    ?

  14. #14
    Mako is insane. ThePhailure772 is offline
    MemberRank
    Sep 2007 Join Date
    1,115Posts

    Re: [HELP] Admin Panel (PHP Edit)

    Quote Originally Posted by Wizkidje View Post
    But not much securer. If you want to do it as it should go, it'd go this way:

    PHP Code:
    if ($ugradeid >= 252 && $ugradeid != 253 && $ugradeid 255
    Well, in that case I say: do it clear with an if statement, including OR's.

    PHP Code:
    if ($ugradeid == 252 || $ugradeid == 254 || $ugradeid == 255
    Just details, but still.



    You get the setmessage("Rank Change", "You do not have permission to demote admins.");

    ?
    UGradeID is a byte and therefor can not be greater then 255, so in turn what you did was redundant.

  15. #15

    Re: [HELP] Admin Panel (PHP Edit)

    Is there a workaround for this?

  16. #16
    Praise the Sun! Solaire is offline
    MemberRank
    Dec 2007 Join Date
    Undead BurgLocation
    2,862Posts

    Re: [HELP] Admin Panel (PHP Edit)

    Quote Originally Posted by ThePhailure772 View Post
    UGradeID is a byte and therefor can not be greater then 255, so in turn what you did was redundant.
    The database field can hold 256. GunZ can't, the database can. And since the PHP has nothing to do with the game.

    @Linear, reply to my question.

  17. #17

    Re: [HELP] Admin Panel (PHP Edit)

    Yes, I still get the error...

  18. #18

    Re: [HELP] Admin Panel (PHP Edit)

    /bump.

    Needing help...



Advertisement