Skip to content

Conversation

@htn1491
Copy link
Collaborator

@htn1491 htn1491 commented Aug 17, 2022

This updates the code for PHP8 Compatiblity, tessted on HelloClan BFV / BF1942 servers.

No guarantee for full functionality.

No security issues fixed.

@htn1491 htn1491 added the enhancement New feature or request label Aug 17, 2022
@htn1491 htn1491 requested a review from toadle August 17, 2022 13:08
$searchresults = array();
$playername = $_REQUEST["search_name"];
$playername = mysql_real_escape_string($playername);
$playername = mysqli_real_escape_string(SQL_getconnection(), $playername);
Copy link
Owner

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.

Copy link
Collaborator Author

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.

Copy link
Owner

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.

@toadle
Copy link
Owner

toadle commented Aug 21, 2022

@htn1491 Do you by any chance know if these changes somehow limit the usable PHP-versions?
Meaning "you need at least PHP > X.Y" ?

@htn1491
Copy link
Collaborator Author

htn1491 commented Aug 21, 2022

Yes..Php 5.7 should be the minimum!
But it is also a quite old version, so it should be no problem

@toadle
Copy link
Owner

toadle commented Sep 22, 2022

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?

@htn1491
Copy link
Collaborator Author

htn1491 commented Oct 3, 2022

Great, thank you, everything fine!

@Retroprogram
Copy link

Hi guys, @htn1491 @toadle what's the latest and most stable version of MySQL, Java, and PHP is the project running on? And has it been improved further, perhaps by adding new registers or something like that?

And lastly, is it possible to run it on, for example, XAMPP?

@toadle
Copy link
Owner

toadle commented Nov 5, 2025

@Retroprogram I can't say. I haven't tried it in a long time.
If you can help answer that, that would be great.

@Retroprogram
Copy link

@Retroprograma No puedo decir. No lo he probado en mucho tiempo. Si puedes ayudar a responder a eso, sería genial.

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.

  • Regarding the stats, specifically the sections for player statistics like K/D, damage with specific weapons, vehicles, maps, etc., are they complete, or which ones are missing or were you planning to implement?

  • I see that this application only reached version "0.5," which was supposed to be included in versions 0.6, 0.7, etc.? What's the roadmap for that?

@toadle
Copy link
Owner

toadle commented Nov 6, 2025

@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.

@Retroprogram
Copy link

@Retroprogram Este proyecto ya no se mantiene activamente. El desarrollo ha terminado hace mucho tiempo. Este PR solo existe debido a la ayuda de @htn1491, que lo hizo funcionar bajo PHP8 con mucho trabajo.

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".

@toadle
Copy link
Owner

toadle commented Nov 6, 2025

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 :-)

@Retroprogram
Copy link

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.

@toadle
Copy link
Owner

toadle commented Nov 6, 2025

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.

@Retroprogram
Copy link

@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):

imagen

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):

imagen

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!

@htn1491
Copy link
Collaborator Author

htn1491 commented Nov 8, 2025

I just had a hour for work and fixed the problem.
I did not watch for the _setup.php PHP8 compatibility, because it was already installed in our environment.
I changed this PR and the php8_fix branch.
Also changed a template directory name to lower case, because it fails otherwise to find the template.

@Retroprogram
Copy link

Retroprogram commented Nov 8, 2025

Oh wow, for a moment I thought you were away, so I didn't bother you. Thank you so much for the fix. I haven't tried it yet, but I'll do it in a moment. I have another question.

I've been following the readme and documentation, and they mention the "bin" folder for running Java files. According to that, it should be in the main project "root," like in the image, but I can't find it. Could you attach it, please?

imagen

This is what's in the root folder for now:

imagen

I'll run the test again in a moment and let you know if everything works. Thanks again for your help and guidance.

@htn1491
Copy link
Collaborator Author

htn1491 commented Nov 8, 2025

You are correct, it is missing here. I added it from our envirnoment removed our config.xml
You find the config.xml in the root which you can copy and adjust.

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.

@Retroprogram
Copy link

Retroprogram commented Nov 8, 2025

You are correct, it is missing here. I added it from our envirnoment removed our config.xml You find the config.xml in the root which you can copy and adjust.

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:

511608019-15945e5e-3b8f-4ce6-9c76-48db360cc5c4

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.

imagen

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".

imagen

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!

imagen

However, when navigating between tabs, some are giving errors, such as broken code links, for example, the "Weapons" tab:

imagen

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.

imagen

Otherwise, excellent work you've done; it's truly impressive.

@toadle
Copy link
Owner

toadle commented Nov 8, 2025

@Retroprogram Are you in the branch of this PR https://github.com/toadle/selectbf/tree/php8_fix or are you on main.
The problems you are talking about seem as if you are on main.

@Retroprogram
Copy link

Retroprogram commented Nov 8, 2025

@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.

imagen

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?

@htn1491
Copy link
Collaborator Author

htn1491 commented Nov 9, 2025

I made a test before each count() function if the variable is countable and removed all short tags.
I hope it solved it.

@Retroprogram
Copy link

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.

@Retroprogram
Copy link

@htn1491 Hi! I just did a completely clean reinstall without any modifications, and here are the results:

  • I followed the steps in the documentation and was able to do it successfully.

  • I no longer needed to use the 'short tags' that were required in PHP v8, so congratulations, it works directly now.

  • I've already managed to initialize the website.

Problems:

  • The only issue I encountered was that it displays the paths or lines of code when it doesn't find values ​​in the selected tabs (I've attached screenshots of each tab). Would it be possible to prevent this and instead display nothing (empty) or show a message like "waiting to collect more data"?
imagen imagen imagen imagen
  • This error doesn't occur in the 'clan' and 'Character-Types' tabs.
imagen
  • If I enable 'Template' by default, I don't get those errors in most cases, but I do in 'Weapons', 'Vehicles', and 'Maps'.
imagen imagen imagen imagen imagen imagen
  • That's the only problem; otherwise, everything is fine.

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:
imagen

@Retroprogram
Copy link

Retroprogram commented Nov 10, 2025

Hi, I've been playing on my server for a while, and while some stats have loaded, others are missing and are associated with specific weapons. I've attached some screenshots to show the problem.

For example, this section doesn't show statistics for any weapon, nor the time spent using it, nor the number of kills.
It also doesn't show "Top Victims" or "Top Assassins."

imagen imagen
  • And if I go to the "Weapons" section, I have the same problem I mentioned in previous comments; no values ​​are displayed.
imagen
  • And when checking the "vehicles" tab, the deaths made with them are not shown, as the image shows:
imagen

I had Java 8 (1.8) installed, and since it was giving me these problems, I uninstalled it and installed Java JDK version 25, but I'm getting the same error. I tried using version 5 (1.5.0), but when I run the ".bat" file, it closes instantly, as if it doesn't recognize it (of course, after uninstalling all other versions and keeping only that one).

I hope you can help me :C

@htn1491
Copy link
Collaborator Author

htn1491 commented Nov 10, 2025

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.
If I get more time maybe I can take a look again.

I suggest you backup your software, the eventfiles, and the databases now so you can provide it here for more debugging information.

@Retroprogram
Copy link

Hi, I've been running some additional tests and I've also integrated the files from the "sample" folder included in the documentation to check if I was making a mistake. (I also tried deleting the statistics and adding only the files from the "sample" folder, all with the same result.)

I had made the changes with different versions of Java, thinking that some instruction wasn't compatible and that might be why certain statistics weren't loading, but I got the same result with all of them. Also, what you said about Java not being the problem, but PHP, confirms that (or at least it seems to confirm it).

As I mentioned before, I also ran tests with the "sample" folder, and so far I've obtained the same results. The statistics are being retrieved, but only for certain sections, as I'll describe in each tab with a reference image for better understanding. For example:

  • In the "Players" tab, the "Ranking" and "Last Games" are retrieved, so this tab is practically working correctly:
imagen
  • I'm not sure about the "Clans" tab, since I don't have a registered clan yet, but let's say that one is also working correctly:
imagen
  • In the "Character-Types" tab, "Character-Type Usage," "Repairs," and "Heals" are retrieved correctly, with their respective values:
imagen
  • The "Weapons" tab is the one where I'm getting an error. It's as if I'm not retrieving the data for the "Assault Rifles," "Rifles," "Explosives," "Helicopters," "Planes," "Knives," "Vehicles," and "Light Machine" sections. Guns:
imagen
  • The "Vehicles" tab does not correctly reflect kills:
imagen
  • The "Maps" tab appears to be working correctly:
imagen
  • When selecting a specific player, some statistics are displayed correctly. In this case, the sections that appear are "Player-Details," "Nicknames," "Character Types," "Favorite Vehicles," "Map Performance," and "Last Games." However, the sections that are missing or do not appear are: "Weapons," "Top Victims," ​​and "Top Assassins":
imagen

Some details I tested: I used the vanilla version of BF1942; I have no additional mods installed, not even the expansions.

So, I don't know if these statistics are only available in certain expansions or mods, and perhaps they handle event values ​​differently, which is why it's showing errors (but again, this is just a guess because I don't really know).

On the other hand, I'm also wondering if it's a bug, but I've tried to get bots to appear in the statistics, and I haven't been able to. I edited the "config.xml" file, specifically the line "
true" to true, but I'm not getting their data, only the players'.

By the way, I think this is why players who haven't eliminated other players, only bots, don't have their "Weapons," "Top Victims," ​​and "Top Assassins" statistics displayed, but it's just a theory; I don't really know if it's affecting anything. If I use the "Log" files where only bots have been played and upload them to the server, when I check the database, the "Weapons" sections have no data.

imagen imagen

The dedicated server version I'm using is v1.61b. I hope you can help me with this, and thanks again for your patience.

@htn1491
Copy link
Collaborator Author

htn1491 commented Nov 20, 2025

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.
The only thing I can maybe help with is with some eventlogs generated by our BFVietnam servers which are successfully parsed and read by our selectbf instance.
eventlogs_live_exmaples.zip

Maybe you can try parse them and see if they work. Because we publish the data anyway there is no secret information inside it.

@toadle
Copy link
Owner

toadle commented Nov 29, 2025

@htn1491 I'd say we merge this PR now and put more work on new PRs. WDYT?

@htn1491
Copy link
Collaborator Author

htn1491 commented Nov 30, 2025

I am fine with it. It seems to run at least everything fine on our servers.

@toadle toadle merged commit 5cbe91d into master Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants