feat: update php to 7+ and fix compatibility issues#6
feat: update php to 7+ and fix compatibility issues#6sale4319 wants to merge 9 commits intotarnus:masterfrom
Conversation
|
Hey, thanks for taking this on — the PHP 7+ compatibility fixes are solid work and definitely needed. I've got some notes before we can merge though: Repo hygiene:
Line endings: Behavioral changes that should be separate:
Minor stuff:
The core compat work is good — just needs some cleanup to get it mergeable. Happy to re-review once updated. |
- Add .gitattributes to enforce LF line endings going forward - Convert CRLF to LF across all backend/vendor library files (adodb_lite, adodbSQL_drivers, SwiftMailer, template_lite, libchart, pseudo-cron, phpfreechat, PHPMailer) - Replace deprecated `var` property declarations with `public` in adodb driver classes (PHP 7/8 compatibility) - No functional logic was changed in this commit
02e7a6e to
60230e4
Compare
Replace the manually-copied PHPMailer 5 tree with a Composer-managed v6 install. composer.json/composer.lock track the dependency; vendor/phpmailer/phpmailer/ contains the new source (PHPMailer.php, SMTP.php, POP3.php, Exception.php, DSNConfigurator.php, OAuth.php plus updated language files).
Update all class/*.inc files for PHP 7/8 compatibility: - Remove deprecated ereg/eregi → preg_match/preg_replace - Replace split() → explode() / preg_split() - Fix mysql_* → mysqli_* where still present - Remove magic_quotes assumptions - Add missing return types / strict comparisons where applicable
Apply ereg->preg, split->explode, mysql->mysqli and magic-quotes-removal to all non-class source files: - admin/, admin.php - casino/casino_roulette.inc - config/config.php, config/config_sched.php, config/windowscron.txt - contact_admin_thanks.php, create_game/, create_game.php - email_player.php, feedback.php, footer.php, global_funcs.php - globals/ (AAT_mbstring.inc, move_player_finish.inc, probe_detect.inc) - installer.php, installer/ (30.inc, 40.inc, 999.inc) - login_process.php, new_player_process.php, planet_report_ce.php - php.ini: raise memory_limit / max_execution_time defaults - scheduler.php, scheduler/ (sched_optimize, sched_repair, sched_tournament) - support/ (variables.inc, variables0.inc, log_data lang files, casino.ini) - team_chat.php - templates/ (footer.tpl, about_template_options.inc for all 6 themes)
…ove duplicate PHPMailer - Update .gitignore: replace 'templates_c/*.php' with 'templates_c/' (full dir), add vendor/ and composer.phar so they are never committed again - git rm --cached vendor/ composer.phar templates_c/index.html: untrack 88 files that should never have been committed; local copies preserved for dev use - git rm backends/PHPMailer/: delete manual copy of PHPMailer (Exception.php, PHPMailer.php, SMTP.php) — the composer-managed vendor/phpmailer/phpmailer/ is the canonical version; no code references the backends copy directly
- ini_set('session.use_trans_sid'): drop @ — ini_set never emits a
warning for valid session.* keys in PHP 7+
- get_magic_quotes_gpc(): already guarded by function_exists(), @ was
redundant; removed
- mysqli_get_server_info(): replace @ with an explicit instanceof mysqli
check so a missing/null connection ID surfaces early rather than
silently returning empty
- extension_loaded(): never throws; removed @ in config.php,
config_sched.php and installer/30.inc
2270d59 to
079b1da
Compare
Hi Tarnus, Thank you for such a detailed comment, I addressed all the issues that you pointed out, I reworked commit history so my changes should be easier to review. I also provided detailed change log in PR description so that we have it as documentation. There is still work in progress, I will QA the game locally to see if there are some bugs, and I will fix what I find. I will ping you (🔔 --> @tarnus) for review and we can decide what and if we merge. 😄 |
Root causes fixed:
- PHP/MySQL timezone mismatch (DST drift) caused UNIX_TIMESTAMP() vs time()
to disagree, triggering false idle logouts
- sessionStorage timer sync caused the footer countdown to jump backwards
on every page load instead of always starting from the server-authoritative value
- Heartbeat pings incremented refreshcount, making active players look idle
- Scheduler idle-logout query had no margin for heartbeat timing races
Changes:
config/config.php
- date_default_timezone_set('UTC') -- pins PHP to UTC
- SET time_zone='+00:00' on every DB connection -- pins MySQL to UTC
- Lag-delay guard now also checks REQUEST_URI and excludes ajax_processor.php
- Refresh-count tracking skips AJAX/heartbeat requests
- Track $_SESSION['currenturi'] alongside currentprogram
config/config_sched.php
- Same UTC anchors (date_default_timezone_set + SET time_zone) for scheduler
ajax/heartbeat.inc (new)
- Lightweight endpoint; checklogin() via ajax_processor.php already updates
last_login so no extra SQL is needed
footer.php
- Pass $idle_max to all templates
scheduler/sched_turns.inc
- Idle-logout threshold raised to ($idle_max + 2) min to absorb heartbeat
timing races without affecting per-request session enforcement
templates/*/footer.tpl (all 6 themes)
- Remove sessionStorage timer sync; trust server-provided seconds_until_update
- Add _sendHeartbeat(): fires at myi==10 (early warning), myi<=0 (tick),
every 2 min if user is active, and on visibility-change (tab resume)
- Idle gate on the 2-min interval: only sends heartbeat if user interacted
within the idle window, letting genuinely idle sessions expire naturally
- Move <table> before <script> so getElementById('myx') resolves immediately
support/variables0.inc
- Default player_online_timelimit set to 0 (unlimited) for new game installs
galaxy_map.php / templates (all 6 themes)
- Fix off-by-one: use < $endsector instead of <= so the last sector of
the previous page is not duplicated on the next page
- Fix map row rendering: emit bare <TR>/<TR> tags (sector icons are
rendered separately); pad incomplete last row with empty <TD>s so the
grid stays aligned
new_player_process.php
- Guard ban check against empty columns: wrap ban_mask match in
(ban_mask != '' AND ...) and email match in (email != '' AND ...) so
rows with one field blank do not cause false positive bans
templates/*/planet_unowned/planet_scan.tpl (all 6 themes)
- Fix broken resource icons: images live at images/{name}.png, not the
non-existent images/ports/{name}.png subdirectory
- Fix Smarty variable in default_menu_classic: {planettype} -> {$planettype}
support/variables0.inc
- Default account_creation_closed to 0 (open) for new installs
- Default enable_pseudo_cron to 0 (use real cron instead)
SCAN_ERROR() success branch previously returned the exact value; restore original behaviour where a successful scan returns a slightly fuzzy result: floor(correct_value * rand(99999999, 100999999) / 100000000) giving approximately 99-101% of the true value.
0101bd2 to
f30e2fc
Compare
|
Great work on the restructure — you addressed pretty much everything from the first review. The commit history is clean, repo hygiene is solid, and the timezone/heartbeat approach for the session desync is well thought out. One thing to fix before merge:
Other than that, this is ready to go. |
What did I do?
Branch:
feat-upgrade-php-versionPHP 7+ Compatibility & Dependency Upgrade
Goal: Modernize the codebase to run cleanly on PHP 7+.
Changes:
@error suppression replaced with proper conditional checks throughoutvendor/,composer.phar,templates_c/added to.gitignore/ untracked; duplicate PHPMailer removedCommits:
d606bb5chore: normalize CRLF→LF and modernize class syntax in backend libraries4400341feat: upgrade PHPMailer to v6 via Composer4bfbeacfix: PHP 7+ compat in core app, config, and support filesd1f0e40fix: PHP 7+ compat in game class files (102 files)f1f796bchore: repo hygiene — untrack vendor, composer.phar, templates_c; remove duplicate PHPMailer079b1dafix: replace @ error suppression with proper conditionalsPHP 7+ / 8+ Compatibility
get_magic_quotes_gpc()call behind aPHP_VERSION_ID < 80000 checkto avoid fatal errors on PHP 8=& new) syntax in SwiftMailer usage inlogin_process.php$HTTP_GET_VARS/$HTTP_POST_VARSsuperglobals with$_GET/$_POSTthroughout$arr[key]→$arr['key']) across core filesMySQL Compatibility
mysql_get_server_info()withmysqli_get_server_info($db->connectionId)SET SESSION sql_mode = 'NO_ENGINE_SUBSTITUTION'on connect to support MySQL 5.7+ strict mode (schema uses0000-00-00datetime defaults)PHPMailer Integration
composer.jsonrequiring phpmailer/phpmailer ^6.9composer.lockandvendorwith PHPMailer 6.x (namespaced PHPMailer\PHPMailer)⚙️php.iniOverhauleacceleratorandZendOptimizerextensions (incompatible with modern PHP)short_open_tag = Onto support legacy<?open tags used throughout the codebaseerror_reporting = E_ALL & ~E_DEPRECATED & ~E_NOTICE,display_errors = On,log_errors = OnBug Fixes
login_process.phpto guard against emptyban_mask/emailcolumns (prevents unintended wildcard matches)$create_game != 1guard inconfig.phpto suppress false "page loading" lag warnings during game creation$template_objectinitialisation inscheduler.phpto prevent fatal errors when running via CLIRefactoring / Code Quality
calc_scan_ratio()helper fromSCAN_SUCCESS()andSCAN_ERROR()to eliminate duplicated logicSCAN_ERROR()— on successful scan now returns the exact value instead of a near-value with 99–101% jitterget_dirlist()to usescandir()instead of the manualopendir()/readdir()/closedir()patternclose_database()— removed dead$db->close()call with explanatory comment$gameroottotemplate_display()global declarationFrontend
footer.tplfiles to persist the countdown timer insessionStorage, preventing it from resetting on every page navigationLine Ending Normalisation
adodb_lite,adodbSQL_drivers, libchart,pseudo-cron,template_lite, class files, etc.)Files Changed (across all branches)
global_sched_funcs.phpclass/(102 files)global_funcs.php, config, support filescomposer.json.gitignore