fix: handle fopen failure gracefully and improve dep check severity

Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/73ed1a44-9f9b-44d6-995a-706993bdef21

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-02 00:30:52 +00:00 committed by GitHub
parent d852a44a63
commit 2303175e56
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 61 additions and 21 deletions

View file

@ -221,8 +221,18 @@ function install() {
"\$db_type=\"".$db_type."\";\n".
"?>";
$temp = @fopen("includes/config.inc.php", "w");
if (!@fwrite($temp, $config)) {
$temp = fopen("includes/config.inc.php", "w");
if ($temp === false) {
print_failure(get_lang('unable_to_write_config') .
" &mdash; <code>includes/config.inc.php</code> could not be opened for writing. " .
"Please run: <code>sudo chmod 664 includes/config.inc.php &amp;&amp; sudo chown www-data:www-data includes/config.inc.php</code> " .
"(or <code>sudo chmod -R 775 includes/ &amp;&amp; sudo chown -R www-data:www-data includes/</code> if the file does not yet exist). " .
"You can also use the <a href='check.php'>Dependency Check</a> page for a full diagnostics report.");
echo "<p><a href='?step=1'>".get_lang('back')."</a></p>";
echo "</td></tr></table>\n";
return;
}
if (fwrite($temp, $config) === false) {
print_failure(get_lang('unable_to_write_config'));
echo "<p><a href='?step=1'>".get_lang('back')."</a></p>";
fclose($temp);