Znote / ZnoteAAC

Developement repository for the Znote AAC project. A website portal to represent and manage your Open Tibia server.
MIT License
145 stars 127 forks source link

Issue with Support In-Game and Characterprofile.php #386

Closed deviljin112 closed 4 years ago

deviljin112 commented 4 years ago

Hello,

Firstly, Support In-Game. It displays GOD character at the very bottom but also spits out an error on the side :

Notice: Undefined offset: 0 in C:\xampp\htdocs\engine\function\users.php on line 142

Notice: Undefined offset: 1 in C:\xampp\htdocs\engine\function\users.php on line 142

Notice: Undefined offset: 2 in C:\xampp\htdocs\engine\function\users.php on line 142

Notice: Undefined offset: 3 in C:\xampp\htdocs\engine\function\users.php on line 142

Notice: Undefined offset: 4 in C:\xampp\htdocs\engine\function\users.php on line 142

Notice: Undefined offset: 5 in C:\xampp\htdocs\engine\function\users.php on line 142

Notice: Undefined index: group_id in C:\xampp\htdocs\support.php on line 16

But at the very bottom of the page, it shows the table with Group, Name and Status. Very weird.

Other issue is with CharacterProfile.php. I couldn't find any fix for it as it seems fine, DB has the correct tables etc and the code appears correct. Error:

string(98) "SELECT SUM(`value`) AS `sum` FROM `player_storage` WHERE `key` LIKE '30___' AND `player_id`=(int)7"
(query - SQL error)
Type: select_single (select single row from database)

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'int)7' at line 1

I've tried playing around with it, but the error persists.

EDIT1: Running Master-branch of ZnoteACC as well as TFS1.3 if that is important

Thank you, D3v

Znote commented 4 years ago

https://github.com/Znote/ZnoteAAC/blob/35e2ff7f43a3be8774db945d5a11c097120b651f/characterprofile.php#L27

Try to replace this line with: (I remove the space between (int) and $user_id).

                $user_id = (int)$user_id; 

I'm not sure why this cast is weird, more strict in the new PHP update perhaps.

As for the support.php file, I confirm the same issue. You can disable warnings there for now while I look for a patch.

deviljin112 commented 4 years ago

The characterprofile.php issue was with the layout i had, i had an old file within layout and it was causing glitches, i never realised until now. I have fixed that issue now. But the support.php persists.

I have disabled all warnings for support.php for now, looking forward to seeing a fix. EDIT: Disabled the module basically... that's all :)

I (not a php expert) thing the issue may lay with how it pulls the config('ingame_positions') in support.php. As it would appear that it iterates through every group and fails to find (in the databse) a coresponding account with this group therefore failing to index it correctly, as GOD is group 6 and that group is not in the error. I again am not an expert, but in python and other languages this could be fixed with a "try:" function. Maybe that can be implemented here, where it "tries" to find that index in the DB if fails then continue else index as online. Rather than having an index error spit into the html. But thats just my theory, im not a web developer :D just a programmer.

EDIT2: After looking through the db and support.php + users.php and all the functions. I might not be understanding this correctly, but ForgottenServer has only 3 levels of player group_id Player/GM/GOD, but account has 6 types, and the ingame_positions have 6 different types too. So, maybe its pulling some information incorrectly as i also noticed characterprofile.php to pull the group_id, so even though i've set my character to be GOD on server, the website prints "Senior Tutor" on character profile. So (again not a php dev) my theory is that the support/user.php is just confused about what is what. Because in the support list it says I'm "GOD" but on character "Senior Tutor". Or maybe I dont have enough levels set up in my TFS.

P.S. Sorry for long comment just want to help out with the improvement.

EDIT3: Also found an issue, when $config['EnableQuests'] = true in config.php when player has not yet been index'ed into the db i.e. not started any quest etc. It spits out lots of errors in characterprofile.php

I would add a check to see if $sqlquests is not empty.

characterprofile.php at line 840:

if (isset($config['quests']) && !empty($config['quests']) && !empty($sqlquests))
Znote commented 4 years ago

Please create separate issues so they can be individually tracked on github.

The support list should be fixed in the above commit. A better approach than a try-catch for something as small as this, is to just check if an array key is set. isset(value). (Although try-catches and exception handeling do exist in PHP). The problem here was that some characters from staff accounts was not a staff and thus omitted from the staff list after-the-fact, and the staff list was not re-indexed so the keys was wrong during the for loop.