froxlor / Froxlor

The server administration software for your needs - The official Froxlor development Git repository
http://www.froxlor.org
GNU General Public License v2.0
1.62k stars 455 forks source link

Admin Panel -> Traffic -> Customers: Table is using wrong ids for links #1236

Closed showp1984 closed 6 months ago

showp1984 commented 6 months ago

Describe the bug If I go to Traffic -> Customers and select the first customer by the link on their name I get an empty page. URL: https://froxlor/admin_customers.php?page=customers&action=su&id=0

But if I select any other customer I jump into the customer panel dashboard of another customer. (the "impersonate" feature, but for the wrong customer - not the one I clicked on.) eg: https://froxlor/admin_customers.php?page=customers&action=su&id=1

I found out that this is happening because there is no user with id 0 in my database. It seems to be a bug in the table, as it's simply enumerated from 0-n, instead of using the actual user's id. The same user having the link with id=0 above actually has id=7 in the database and in the link under Resources -> Customers, where the link works fine: https://froxlor/admin_customers.php?page=customers&action=su&sort=customerName&id=7 Same for the mismatched customer links. The ids are just ascending numbers no matter the name of the customer (as it seems).

mysql> select customerid from panel_customers;
+------------+
| customerid |
+------------+
|          1 |
|          2 |
|          3 |
|          5 |
|          6 |
|          7 |
+------------+

If I manually edit the link to: https://froxlor/admin_customers.php?page=customers&action=su&id=7 the link works as expected. So this seems to be a bug in the table, right?

Version: System information

To Reproduce (The steps in the description should be sufficient, but I imagine this would also work on a fresh install of froxlor, as far as I understand the issue now) Steps to reproduce the behavior:

  1. create a customer aone
  2. create another customer bone
  3. delete customer aone.
  4. go to: Traffic -> Customers
  5. Click on 'bone' in the traffic table
  6. You should see an empty page (the id of the customer isn't found in the database anymore)

Expected behavior Impersonate the clicked on customer, not another, nor show an empty page.

Logfiles n/a

Additional context Server was upgraded from ubuntu 18.04 to 20.04 to 22.04. Froxlor was uninstalled on 20.04 as it blocked the upgrade and reinstalled afterwards on 22.04. I couldn't test the issue on a new install yet.

d00p commented 6 months ago

Yea, found already, this originates from https://github.com/Froxlor/Froxlor/commit/bc1892d4ec05277a199537bb96fda0200cc3ef7d - the sorting does not keep the Array-Index values. Fix will follow shortly