PDO::ERRMODE_EXCEPTION]); echo "SUCCESS!\n"; if (isset($_GET['fix']) && $_GET['fix'] === 'true') { echo "Updating .env to use host [$host]...\n"; $newEnv = "APP_URL=https://sales.sam.kr/\n"; $newEnv .= "DB_HOST=$host\n"; $newEnv .= "DB_NAME=$db_name\n"; $newEnv .= "DB_USER=$db_user\n"; $newEnv .= "DB_PASS=$db_pass\n"; $newEnv .= "DOCUMENT_ROOT=" . str_replace('\\', '/', __DIR__) . "\n"; if (file_put_contents($envPath, $newEnv)) { echo "Successfully wrote to .env\n"; } else { echo "FAILED to write to .env. Check permissions.\n"; } } break; } catch (Exception $e) { echo "FAILED: " . $e->getMessage() . "\n"; } } echo "\nUsage: Append ?fix=true to the URL to automatically create/update .env if a connection succeeds.\n"; echo "SECURITY: DELETE THIS FILE AFTER USE!\n";