-
Notifications
You must be signed in to change notification settings - Fork 4
PHP8 Compatibility #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| $searchresults = array(); | ||
| $playername = $_REQUEST["search_name"]; | ||
| $playername = mysql_real_escape_string($playername); | ||
| $playername = mysqli_real_escape_string(SQL_getconnection(), $playername); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would fix the SQL injection in every other place too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be at least a minimal better solution, but have to find every query. Would suggest to make it in another change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, this should not be part of this PR.
|
@htn1491 Do you by any chance know if these changes somehow limit the usable PHP-versions? |
|
Yes..Php 5.7 should be the minimum! |
|
I've added a mention of you work @htn1491 here https://github.com/toadle/selectbf/blob/php8_fix/README.md Is that fine with you? |
|
Great, thank you, everything fine! |
|
@Retroprogram I can't say. I haven't tried it in a long time. |
I haven't tried installing and testing it yet, as I'm relatively new to all this (I'm still learning to program), but I've used XAMPP a couple of times (very little experience, to be honest). XAMPP uses PHP, MySQL, and Apache, but not Java, which is why I've been confused about its use. Even so, I'll give it a try. On another note, I'd like to ask you a few questions, and I hope you can answer them.
|
|
@Retroprogram This project is not actively maintained anymore. Development has long ended. This PR only exists because of @htn1491 help, who made it run under PHP8 with a lot of work. |
Yes, I understand that the project stopped receiving support a long time ago, but the questions are focused on the time when the application was being developed and active. That's why I'd like to know if you could share more details about what you planned to implement in later versions (when the project was active), to get an idea of what the final product would be like. This way I can better understand why it's called "v0.5" and not "v1.0". |
|
Well actually, it just was called 0.x because I was defensive about the maturity at that time. I was not sure if the installation process was finally good or if everything work in most of the situations. So it was more a stability concern rather than a features-thing :-) |
|
Oh, I understand. So, the application had already reached its maximum potential; all that remained was to polish out any defects that would arise or be reported by users, right? This leads me to another question regarding obtaining statistics. Were you able to extract all the data related to player statistics, or were there some missing? And lastly, do you perhaps have documentation for the project? I mean, how do you obtain the data to generate those statistics? What does each "part" of the program do? etc. I'd like to use your project as a learning experience and better understand all of this. By the way, thank you very much for taking the time to answer my questions :D, which might be very easy for many, but are important and difficult for me. |
|
Sorry, but I think discussing these questions and asking for tech coaching under a PR the deals with PHP8 compatibility is not the right spot to do it. You can move any questions over to https://github.com/toadle/selectbf/discussions if you want. |
|
@toadle Hello, I've been trying to configure the server with this package (in fact, I also tried with the old version with its respective v5 versions) but it doesn't work for me. When I enter "_setup" I get what you could call a flat table in the browser (image 1):
I researched it, and it seems to be because "php" is missing at the beginning of the file, or the other option is to enable short tags. I decided to enable short tags, which did improve things, but now I'm getting a different kind of error, which is the following: 'Fatal error: Uncaught Error: Class "vlibTemplate" not found in D:\Battlefield_1942\xampp_v8.2.12-0_x64\htdocs\selectbf\php_setup.php:139 Stack trace: #0 {main} thrown in D:\Battlefield_1942\xampp_v8.2.12-0_x64\htdocs\selectbf\php_setup.php on line 139 Investigating, it appears that the class or file is missing, but it is present (image 3):
Could you please help me solve this problem? I've already figured out how it gets the player data/values/statistics, and I've configured everything. By the way, your documentation is excellent. When I asked the questions, I expected very basic or nonexistent documentation, as is often the case, but your documentation is very complete and detailed. Congratulations! |
|
I just had a hour for work and fixed the problem. |
|
You are correct, it is missing here. I added it from our envirnoment removed our config.xml I am not writing much here, because I don't have much time, but I don't want an uncomplete task left, because if it says it works with PHP8 it should of course work from the beginning. |
Okay, let me tell you how it went. I deleted everything, all the configurations, and repeated the entire process (including php.ini). When I accessed "..._setup" through the browser, I got this again:
I added the word "php" to the beginning of the "_setup.php" file and got another error, but this time it was in "sql.php." It was practically the same issue; I needed to add "php" to some parts. I accessed it again through the browser, and this time I was able to access the setup and install the tables.
Now, when I clicked on "stats" or something similar after the tables finished installing, I had a problem with "http://localhost/selectbf/php/index.php".
I added the "php" again, and then I was able to access the homepage (And to avoid having to do that again, I reactivated the "short tags on" option in php.ini, but I imagine if that option isn't activated, I'd have to add "php" to practically all files with the ".php" extension.), but I got a lot of errors at the bottom (similar to the "weapon" tab problem I'll discuss later). I figured it was because the tables didn't yet contain any values, so I proceeded to run the scripts to load the data into the database (I even used the ones in the "samples" folder), and it worked!
However, when navigating between tabs, some are giving errors, such as broken code links, for example, the "Weapons" tab:
Could you help me solve or correct this error, please? To summarize, by correcting the previous error and fixing the "php" errors when short tags are not enabled (from what I've researched, short tags are disabled by default for security reasons, so it would be good to make the correction), the update and correction you made in this pull request would be fully functional. I'm available for any questions, and if you manage to make these corrections, please let me know, and I'll run a test again from scratch to confirm all the changes. By the way, the "config.xml" file is in the main root directory. It would be good if you could move it to the "bin" folder so it matches the documentation.
Otherwise, excellent work you've done; it's truly impressive. |
|
@Retroprogram Are you in the branch of this PR |
|
@toadle I'm in PR, I tried using the main function yesterday in PHP version 5 and it didn't work, so I tried again with PHP version 8 and this PR, and that's when I started reporting the problems. I think the errors occur when it can't find data in the profiles, and instead of displaying a message like "not enough data" or being empty, it ends up showing the code. Here's another example (map-performance statistics), using data from the "sample" folder.
This PR is almost ready; it just needs a few minor details polished, and then it will be updated for current versions. Could you help us with that? |
|
I made a test before each count() function if the variable is countable and removed all short tags. |
|
Thank you so much for all the changes, I'll start testing from scratch then. I'll let you know in a moment if everything is working. |
|
@htn1491 Hi! I just did a completely clean reinstall without any modifications, and here are the results:
Problems:
I wanted to ask for your help. How do I configure the 'Weapons' tab? I don't know what the available 'codes or commands' are under 'Datasource Name'. Could you give me an example of a populated table? Please, I mean this: |
|
First: The errors you see has nothing to do with the Java Part, it is always the PHP part. I added a check around before every count() so this error should not be appear any more. I really cannot see why it still happen. And I can only tell we use the same code in our environment and it works. I think the count() error will automatically disappear when more data is collected. I suggest you play more and build more statistic xml files that the software can collect. And be sure the round is ended, otherwise it may read uncomplete data. Unfortunatly I cannot help you any further. I have not that much time to fix this. I suggest you backup your software, the eventfiles, and the databases now so you can provide it here for more debugging information. |
|
I am sorry that you face those issues, because I cannot see why you have them. Especially it should not be the count error any more, because there is a check before every count() method. Maybe you can try parse them and see if they work. Because we publish the data anyway there is no secret information inside it. |
|
@htn1491 I'd say we merge this PR now and put more work on new PRs. WDYT? |
|
I am fine with it. It seems to run at least everything fine on our servers. |




































This updates the code for PHP8 Compatiblity, tessted on HelloClan BFV / BF1942 servers.
No guarantee for full functionality.
No security issues fixed.