Listusers problem after deleting a 2nd page of users

Discussion in 'General Support' started by david62311, Jul 24, 2020.

  1. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,144
    Likes Received:
    246
    I see a bug in the Admin Panel under Users. I just went to go delete some of the bots that got in somehow and I deleted the 3 I found on the 2nd page. Now I can't get the page 1 to show.

    User Page Bug.png

    • I tried to flip to another tab and then come back.
    • I logged out and then logged back in and it still shows page 2 with no users.
    • I switched themes and still got the same problem.

    I think this would be a PHP and database issue.
     
  2. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,144
    Likes Received:
    246
    Here's the code around line 127 on the listusers.php page:

    PHP:
    // get page limits
    if (isset($_GET['PAGE']) && is_numeric($_GET['PAGE'])) {
        
    $PAGE intval($_GET['PAGE']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } elseif (isset(
    $_SESSION['RETURN_LIST_OFFSET']) && $_SESSION['RETURN_LIST'] == 'listusers.php') {
        
    $PAGE intval($_SESSION['RETURN_LIST_OFFSET']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } else {
        
    $OFFSET 0;
        
    $PAGE 1;
    }

    $_SESSION['RETURN_LIST'] = 'listusers.php';
    $_SESSION['RETURN_LIST_OFFSET'] = $PAGE;
    $PAGES = ($TOTALUSERS == 0) ? ceil($TOTALUSERS $system->SETTINGS['perpage']);

    $params = array();
    if (isset(
    $Q)) {
        
    $query "SELECT * FROM " $DBPrefix "users WHERE suspended = " $Q;
    } elseif (isset(
    $_POST['keyword'])) {
        
    $query "SELECT * FROM " $DBPrefix "users
                  WHERE name LIKE :name OR nick LIKE :nick OR email LIKE :email"
    ;
        
    $params[] = array(':name''%' $keyword '%''str');
        
    $params[] = array(':nick''%' $keyword '%''str');
        
    $params[] = array(':email''%' $keyword '%''str');
    } else {
        
    $query "SELECT * FROM " $DBPrefix "users";
    }
    $query .= " ORDER BY id"// ordered by
    $query .= " LIMIT :offset, :perpage";
    $params[] = array(':offset'$OFFSET'int');
    $params[] = array(':perpage'$system->SETTINGS['perpage'], 'int');
    $db->query($query$params);
    The settings perpage in my database is set to 30 as seen here:

    webid per page.png
     
  3. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,144
    Likes Received:
    246
    I replaced the two && with two || and it fixed it. I need to do more testing on this to see if it the coding I just did is right.

    Original listuser.phps:

    PHP:
    // get page limits
    if (isset($_GET['PAGE']) && is_numeric($_GET['PAGE'])) {
        
    $PAGE intval($_GET['PAGE']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } elseif (isset(
    $_SESSION['RETURN_LIST_OFFSET']) && $_SESSION['RETURN_LIST'] == 'listusers.php') {
        
    $PAGE intval($_SESSION['RETURN_LIST_OFFSET']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } else {
        
    $OFFSET 0;
        
    $PAGE 1;
    }
    Use this code:
    PHP:
    // get page limits
    if (isset($_GET['PAGE']) || is_numeric($_GET['PAGE'])) {
        
    $PAGE intval($_GET['PAGE']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } elseif (isset(
    $_SESSION['RETURN_LIST_OFFSET']) || $_SESSION['RETURN_LIST'] == 'listusers.php') {
        
    $PAGE intval($_SESSION['RETURN_LIST_OFFSET']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } else {
        
    $OFFSET 0;
        
    $PAGE 1;
    }
     
  4. david62311

    david62311 Well-Known Member

    Joined:
    Aug 29, 2013
    Messages:
    2,144
    Likes Received:
    246
    I switched the two codes around and it worked. The && makes the coding have to be exact that way. Between the && and the elseif, something in the code there is not perfectly working.

    I signed up a 31 users and retested with a delete.
    After deleting those users I created one more to retest.
    • I tried to use just switch the && to || on one of the two and then switched it back to && and then tried the same thing on the other one and it didn't work either way.
    • I did swap the RETURN_LIST_OFFSET around with the RETURN_LIST below and it works like this below but, I want to figure out why.

    Here's the code for the page limits. At the bottom coding you can get a better idea what the RETURN_LIST_OFFSET and the RETURN_LIST does.

    PHP:
    // get page limits
    if (isset($_GET['PAGE']) && is_numeric($_GET['PAGE'])) {
        
    $PAGE intval($_GET['PAGE']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } elseif (isset(
    $_SESSION['RETURN_LIST']) && $_SESSION['RETURN_LIST_OFFSET'] == 'listusers.php') {
        
    $PAGE intval($_SESSION['RETURN_LIST_OFFSET']);
        
    $OFFSET = ($PAGE 1) * $system->SETTINGS['perpage'];
    } else {
        
    $OFFSET 0;
        
    $PAGE 1;
    }

    $_SESSION['RETURN_LIST'] = 'listusers.php';
    $_SESSION['RETURN_LIST_OFFSET'] = $PAGE;
    $PAGES = ($TOTALUSERS == 0) ? ceil($TOTALUSERS $system->SETTINGS['perpage']);

    $params = array();
     
    nay27uk likes this.
  5. skyhigh

    skyhigh Member

    Joined:
    Sep 28, 2010
    Messages:
    449
    Likes Received:
    8
    thats nice have also noticed this i simply jist left it b.
     

Share This Page