Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/50299e05-4ee0-4b5b-80e4-bc5f872c106e Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
4.7 KiB
Website Configuration Guide
Overview
The _website folder is now a standalone site with centralized database configuration. All database connection settings are managed in a single location: includes/config.inc.php.
Directory Structure
_website/
├── includes/
│ ├── config.inc.php # Central database configuration
│ └── README.md # Documentation for includes directory
├── db.php # Database connection (loads config.inc.php)
├── login.php # Uses db.php
├── logout.php # Uses db.php
├── cart.php # Uses db.php
├── order.php # Uses db.php
├── serverlist.php # Uses db.php
└── ...other files
Configuration File
Location
_website/includes/config.inc.php
Contents
<?php
$db_host="localhost"; // Database server hostname
$db_user="localuser"; // Database username
$db_pass="password"; // Database password
$db_name="panel"; // Database name
$table_prefix="ogp_"; // Table prefix
$db_type="mysql"; // Database type
?>
How It Works
-
Configuration Loading
- Website files include
db.php db.phploadsincludes/config.inc.php- Configuration variables are available to all files
- Website files include
-
Configuration Flow
includes/config.inc.php → db.php → website files -
Database Connection
db.phpuses the configuration variables to establish a connection- Returns
$dbvariable containing the mysqli connection
Setup Instructions
For Standalone Use
- Copy the _website folder to your web server
- Edit configuration:
nano _website/includes/config.inc.php - Update database credentials:
- Set
$db_hostto your database server - Set
$db_userto your database username - Set
$db_passto your database password - Set
$db_nameto your database name
- Set
- Verify permissions:
chmod 600 _website/includes/config.inc.php
For Panel Integration
The configuration in _website/includes/config.inc.php should match the panel's configuration in /includes/config.inc.php to ensure both the website and panel access the same database.
Security Best Practices
-
File Permissions: Set
config.inc.phpto read-only for the web server userchmod 600 includes/config.inc.php -
Web Server Configuration: Ensure the
includes/directory is not directly accessible via HTTP<Directory "/path/to/_website/includes"> Require all denied </Directory> -
Backup Configuration: Keep a secure backup of your configuration file
Troubleshooting
Connection Errors
If you see database connection errors:
- Verify credentials in
includes/config.inc.php - Check database server is running
- Verify database exists
- Check user permissions in the database
File Not Found Errors
If you see errors about missing config.inc.php:
- Verify the file exists at
_website/includes/config.inc.php - Check file permissions are readable by the web server
- Verify path in
db.phpuses__DIR__for relative paths
Include Errors
If website files can't include db.php:
- Check file paths are correct
- Verify
db.phpexists in the_website/root - Check PHP include paths in php.ini if needed
Migration from Old Configuration
The old db.php had hardcoded credentials:
// OLD (hardcoded)
$servername = "panel.iaregamer.com";
$username = "remoteuser";
The new db.php uses centralized config:
// NEW (centralized)
require_once(__DIR__ . '/includes/config.inc.php');
$servername = $db_host;
$username = $db_user;
No changes needed to files that include db.php - they work automatically with the new configuration.
Files Using Database Connection
The following files include db.php and use the centralized configuration:
login.php- User authenticationlogout.php- Session terminationcart.php- Shopping cartorder.php- Order processingserverlist.php- Server listingsadminserverlist.php- Admin server managementtest_db_connection.php- Database testing
Benefits
- Single Source of Truth: All database settings in one file
- Easy Configuration: Change settings in one place
- Portable: Copy folder and update one config file
- Secure: Configuration separate from code
- Maintainable: Easy to update and manage
Support
For issues or questions about the configuration, please refer to:
includes/README.md- Detailed information about includes directory- Main project documentation
- Panel configuration at
/includes/config.inc.php