fix: consolidate module schemas to db_version=1, fix billing admin undefined vars and prefix
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/35af6b7c-2518-4105-b4d2-ba1f3fe754cd Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
95e3f40021
commit
d8972fee16
10 changed files with 284 additions and 344 deletions
|
|
@ -2,6 +2,17 @@
|
|||
// Admin landing page
|
||||
require_once(__DIR__ . '/includes/admin_auth.php');
|
||||
require_once(__DIR__ . '/includes/config_loader.php');
|
||||
|
||||
// Ensure site variables are defined regardless of which config was loaded.
|
||||
// The panel config (loaded first by config_loader) does not define these, so
|
||||
// we fall back to safe defaults when they are absent.
|
||||
if (!isset($SITE_BASE_URL)) {
|
||||
$SITE_BASE_URL = '';
|
||||
}
|
||||
if (!isset($SITE_DATA_DIR)) {
|
||||
$SITE_DATA_DIR = realpath(__DIR__ . '/data') ?: (__DIR__ . '/data');
|
||||
}
|
||||
|
||||
include(__DIR__ . '/includes/top.php');
|
||||
include(__DIR__ . '/includes/menu.php');
|
||||
|
||||
|
|
|
|||
|
|
@ -57,21 +57,39 @@ function sync_billing_services(mysqli $db, string $prefix): array
|
|||
{
|
||||
$messages = [];
|
||||
|
||||
// Schema guard: verify billing_services has the expected columns before touching it.
|
||||
// Schema auto-repair: add any missing columns to billing_services before syncing.
|
||||
// col_exists() is provided by bootstrap.php.
|
||||
$requiredCols = ['home_cfg_id', 'mod_cfg_id', 'service_name', 'description',
|
||||
'remote_server_id', 'enabled', 'out_of_stock',
|
||||
'price_daily', 'price_monthly', 'price_year',
|
||||
'slot_min_qty', 'slot_max_qty', 'install_method'];
|
||||
$tableName = $prefix . 'billing_services';
|
||||
foreach ($requiredCols as $col) {
|
||||
|
||||
// Map of column => ALTER TABLE fragment to add it if missing.
|
||||
$autoRepairCols = [
|
||||
'description' => "ADD COLUMN `description` VARCHAR(1000) NOT NULL DEFAULT ''",
|
||||
'img_url' => "ADD COLUMN `img_url` VARCHAR(255) NOT NULL DEFAULT ''",
|
||||
'out_of_stock' => "ADD COLUMN `out_of_stock` VARCHAR(255) NOT NULL DEFAULT ''",
|
||||
'slot_min_qty' => "ADD COLUMN `slot_min_qty` INT(11) NOT NULL DEFAULT 0",
|
||||
'slot_max_qty' => "ADD COLUMN `slot_max_qty` INT(11) NOT NULL DEFAULT 0",
|
||||
'price_daily' => "ADD COLUMN `price_daily` FLOAT(15,4) NOT NULL DEFAULT 0",
|
||||
'price_monthly' => "ADD COLUMN `price_monthly` FLOAT(15,4) NOT NULL DEFAULT 0",
|
||||
'price_year' => "ADD COLUMN `price_year` FLOAT(15,4) NOT NULL DEFAULT 0",
|
||||
'remote_server_id' => "ADD COLUMN `remote_server_id` VARCHAR(255) NOT NULL DEFAULT ''",
|
||||
'install_method' => "ADD COLUMN `install_method` VARCHAR(255) NOT NULL DEFAULT 'steamcmd'",
|
||||
];
|
||||
|
||||
foreach ($autoRepairCols as $col => $alterFragment) {
|
||||
if (!col_exists($db, $tableName, $col)) {
|
||||
$messages[] = "⚠ Schema issue: column '{$col}' missing from {$tableName}. Run the billing module migration.";
|
||||
$t = $db->real_escape_string($tableName);
|
||||
if ($db->query("ALTER TABLE `{$t}` {$alterFragment}")) {
|
||||
$messages[] = "✔ Auto-repaired: added column '{$col}' to {$tableName}.";
|
||||
} else {
|
||||
$messages[] = "✖ Could not add column '{$col}' to {$tableName}: " . $db->error;
|
||||
}
|
||||
}
|
||||
}
|
||||
// If critical columns are missing, skip the sync to avoid SQL errors.
|
||||
|
||||
// If critical columns are still missing after repair, skip the sync to avoid SQL errors.
|
||||
foreach (['service_name', 'mod_cfg_id', 'enabled'] as $critical) {
|
||||
if (!col_exists($db, $tableName, $critical)) {
|
||||
$messages[] = "⚠ Critical column '{$critical}' missing from {$tableName}; skipping sync.";
|
||||
return $messages;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@
|
|||
// Module general information
|
||||
$module_title = "billing";
|
||||
$module_version = "3.2";
|
||||
$db_version = 4;
|
||||
$db_version = 1;
|
||||
$module_required = FALSE;
|
||||
// Module description
|
||||
$module_description = "Billing storefront / provisioning integration. Public ordering runs as a standalone site; panel pages provide provisioning and admin order management.";
|
||||
|
|
@ -39,151 +39,127 @@ $module_menus = array(
|
|||
|
||||
$install_queries = array();
|
||||
|
||||
// Version 1: Current schema - clean install with all tables and required columns
|
||||
// Baseline schema — all billing tables with their final column set.
|
||||
// This is the single source of truth for fresh installs.
|
||||
// All CREATE TABLE statements use IF NOT EXISTS so they are safe to re-run.
|
||||
// Existing installs at any previous db_version already have these tables and columns,
|
||||
// so no incremental ALTER chains are needed here.
|
||||
$install_queries[0] = array(
|
||||
// Billing Services - Available game server packages
|
||||
// Billing Services — available game server packages
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_services` (
|
||||
`service_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`home_cfg_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`mod_cfg_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`service_name` VARCHAR(255) NOT NULL,
|
||||
`remote_server_id` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`out_of_stock` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`slot_max_qty` INT(11) NOT NULL DEFAULT 0,
|
||||
`slot_min_qty` INT(11) NOT NULL DEFAULT 0,
|
||||
`price_daily` FLOAT(15,4) NOT NULL DEFAULT 0,
|
||||
`price_monthly` FLOAT(15,4) NOT NULL DEFAULT 0,
|
||||
`price_year` FLOAT(15,4) NOT NULL DEFAULT 0,
|
||||
`description` VARCHAR(1000) NOT NULL DEFAULT '',
|
||||
`img_url` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ftp` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`install_method` VARCHAR(255) NOT NULL DEFAULT 'steamcmd',
|
||||
`manual_url` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`access_rights` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`enabled` INT(11) NOT NULL DEFAULT 0,
|
||||
`service_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`home_cfg_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`mod_cfg_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`service_name` VARCHAR(255) NOT NULL,
|
||||
`description` VARCHAR(1000) NOT NULL DEFAULT '',
|
||||
`img_url` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`remote_server_id` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`out_of_stock` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`slot_max_qty` INT(11) NOT NULL DEFAULT 0,
|
||||
`slot_min_qty` INT(11) NOT NULL DEFAULT 0,
|
||||
`price_daily` FLOAT(15,4) NOT NULL DEFAULT 0,
|
||||
`price_monthly` FLOAT(15,4) NOT NULL DEFAULT 0,
|
||||
`price_year` FLOAT(15,4) NOT NULL DEFAULT 0,
|
||||
`ftp` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`install_method` VARCHAR(255) NOT NULL DEFAULT 'steamcmd',
|
||||
`manual_url` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`access_rights` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`enabled` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`service_id`),
|
||||
KEY `enabled` (`enabled`),
|
||||
KEY `mod_cfg_id` (`mod_cfg_id`)
|
||||
KEY `enabled` (`enabled`),
|
||||
KEY `mod_cfg_id` (`mod_cfg_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;",
|
||||
|
||||
// Billing Orders - Actual game server instances (ongoing services)
|
||||
|
||||
// Billing Orders — active game server instances
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_orders` (
|
||||
`order_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
`service_id` INT(11) NOT NULL,
|
||||
`home_name` VARCHAR(255) NOT NULL,
|
||||
`ip` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`qty` INT(11) NOT NULL DEFAULT 1,
|
||||
`invoice_duration` VARCHAR(16) NOT NULL DEFAULT 'month',
|
||||
`max_players` INT(11) NOT NULL DEFAULT 0,
|
||||
`price` FLOAT(15,2) NOT NULL DEFAULT 0,
|
||||
`order_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
`service_id` INT(11) NOT NULL,
|
||||
`home_name` VARCHAR(255) NOT NULL,
|
||||
`ip` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`qty` INT(11) NOT NULL DEFAULT 1,
|
||||
`invoice_duration` VARCHAR(16) NOT NULL DEFAULT 'month',
|
||||
`max_players` INT(11) NOT NULL DEFAULT 0,
|
||||
`price` FLOAT(15,2) NOT NULL DEFAULT 0,
|
||||
`remote_control_password` VARCHAR(255) NULL,
|
||||
`ftp_password` VARCHAR(255) NULL,
|
||||
`home_id` VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
`status` VARCHAR(16) NOT NULL DEFAULT 'in-cart',
|
||||
`order_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`end_date` DATETIME NULL,
|
||||
`payment_txid` VARCHAR(255) NULL,
|
||||
`paid_ts` DATETIME NULL,
|
||||
`coupon_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`ftp_password` VARCHAR(255) NULL,
|
||||
`home_id` VARCHAR(255) NOT NULL DEFAULT '0',
|
||||
`status` VARCHAR(16) NOT NULL DEFAULT 'in-cart',
|
||||
`order_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`end_date` DATETIME NULL,
|
||||
`payment_txid` VARCHAR(255) NULL,
|
||||
`paid_ts` DATETIME NULL,
|
||||
`coupon_id` INT(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`order_id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
KEY `status` (`status`),
|
||||
KEY `status` (`status`),
|
||||
KEY `home_id` (`home_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;",
|
||||
|
||||
// Billing Invoices - Created when user adds to cart, becomes order after payment
|
||||
|
||||
// Billing Invoices — created on cart add, paid after payment capture
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_invoices` (
|
||||
`invoice_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`order_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
`service_id` INT(11) NOT NULL,
|
||||
`home_name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ip` INT(11) NOT NULL DEFAULT 0,
|
||||
`max_players` INT(11) NOT NULL DEFAULT 0,
|
||||
`remote_control_password` VARCHAR(255) NULL,
|
||||
`ftp_password` VARCHAR(255) NULL,
|
||||
`customer_name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`customer_email` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`amount` FLOAT(15,2) NOT NULL DEFAULT 0,
|
||||
`currency` VARCHAR(3) NOT NULL DEFAULT 'USD',
|
||||
`status` VARCHAR(16) NOT NULL DEFAULT 'due',
|
||||
`invoice_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`due_date` DATETIME NULL,
|
||||
`paid_date` DATETIME NULL,
|
||||
`payment_txid` VARCHAR(255) NULL,
|
||||
`payment_method` VARCHAR(50) NULL,
|
||||
`description` VARCHAR(500) NOT NULL DEFAULT '',
|
||||
`invoice_duration` VARCHAR(16) NOT NULL DEFAULT 'month',
|
||||
`qty` INT(11) NOT NULL DEFAULT 1,
|
||||
`invoice_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`order_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`user_id` INT(11) NOT NULL,
|
||||
`service_id` INT(11) NOT NULL,
|
||||
`home_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`home_name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`ip` INT(11) NOT NULL DEFAULT 0,
|
||||
`max_players` INT(11) NOT NULL DEFAULT 0,
|
||||
`remote_control_password` VARCHAR(255) NULL,
|
||||
`ftp_password` VARCHAR(255) NULL,
|
||||
`customer_name` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`customer_email` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`amount` FLOAT(15,2) NOT NULL DEFAULT 0,
|
||||
`currency` VARCHAR(3) NOT NULL DEFAULT 'USD',
|
||||
`status` VARCHAR(16) NOT NULL DEFAULT 'due',
|
||||
`invoice_date` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`due_date` DATETIME NULL,
|
||||
`paid_date` DATETIME NULL,
|
||||
`payment_txid` VARCHAR(255) NULL,
|
||||
`payment_method` VARCHAR(50) NULL,
|
||||
`description` VARCHAR(500) NOT NULL DEFAULT '',
|
||||
`invoice_duration` VARCHAR(16) NOT NULL DEFAULT 'month',
|
||||
`rate_type` ENUM('daily','monthly','yearly') NOT NULL DEFAULT 'monthly',
|
||||
`rate_per_player` DECIMAL(15,4) NOT NULL DEFAULT 0,
|
||||
`players` INT(11) NOT NULL DEFAULT 0,
|
||||
`period_start` DATETIME NULL,
|
||||
`period_end` DATETIME NULL,
|
||||
`subtotal` DECIMAL(15,2) NOT NULL DEFAULT 0,
|
||||
`total_due` DECIMAL(15,2) NOT NULL DEFAULT 0,
|
||||
`payment_status` ENUM('unpaid','paid','cancelled','refunded') NOT NULL DEFAULT 'unpaid',
|
||||
`qty` INT(11) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`invoice_id`),
|
||||
KEY `order_id` (`order_id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
KEY `status` (`status`),
|
||||
KEY `due_date` (`due_date`),
|
||||
KEY `order_id` (`order_id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
KEY `status` (`status`),
|
||||
KEY `due_date` (`due_date`),
|
||||
KEY `service_id` (`service_id`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;"
|
||||
);
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8mb4;",
|
||||
|
||||
// Version 2: New columns on billing_invoices, transaction log table, service-to-node mapping
|
||||
// Each ALTER TABLE is a separate statement because ADD COLUMN IF NOT EXISTS requires MySQL 8.0+.
|
||||
// The module manager only runs these once (on db_version bump 1->2), so they do not need IF NOT EXISTS.
|
||||
$install_queries[1] = array(
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `home_id` INT(11) NOT NULL DEFAULT 0 AFTER `service_id`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `rate_type` ENUM('daily','monthly','yearly') NOT NULL DEFAULT 'monthly' AFTER `invoice_duration`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `rate_per_player` DECIMAL(15,4) NOT NULL DEFAULT 0 AFTER `rate_type`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `players` INT(11) NOT NULL DEFAULT 0 AFTER `rate_per_player`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `period_start` DATETIME NULL AFTER `players`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `period_end` DATETIME NULL AFTER `period_start`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `subtotal` DECIMAL(15,2) NOT NULL DEFAULT 0 AFTER `period_end`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `total_due` DECIMAL(15,2) NOT NULL DEFAULT 0 AFTER `subtotal`",
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_invoices` ADD COLUMN `payment_status` ENUM('unpaid','paid','cancelled','refunded') NOT NULL DEFAULT 'unpaid' AFTER `total_due`",
|
||||
|
||||
// Payment transaction log — immutable audit trail
|
||||
// Billing Transactions — immutable payment audit trail
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_transactions` (
|
||||
`transaction_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`invoice_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`user_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`home_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`payment_method` VARCHAR(50) NOT NULL DEFAULT 'paypal',
|
||||
`transaction_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`invoice_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`user_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`home_id` INT(11) NOT NULL DEFAULT 0,
|
||||
`payment_method` VARCHAR(50) NOT NULL DEFAULT 'paypal',
|
||||
`transaction_external_id` VARCHAR(255) NOT NULL DEFAULT '',
|
||||
`amount` DECIMAL(15,2) NOT NULL DEFAULT 0.00,
|
||||
`currency` VARCHAR(3) NOT NULL DEFAULT 'USD',
|
||||
`currency` VARCHAR(3) NOT NULL DEFAULT 'USD',
|
||||
`status` ENUM('pending','completed','failed','refunded') NOT NULL DEFAULT 'pending',
|
||||
`raw_response` MEDIUMTEXT NULL,
|
||||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
`raw_response` MEDIUMTEXT NULL,
|
||||
`created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`updated_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||
PRIMARY KEY (`transaction_id`),
|
||||
KEY `invoice_id` (`invoice_id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
KEY `home_id` (`home_id`),
|
||||
KEY `status` (`status`),
|
||||
KEY `invoice_id` (`invoice_id`),
|
||||
KEY `user_id` (`user_id`),
|
||||
KEY `home_id` (`home_id`),
|
||||
KEY `status` (`status`),
|
||||
KEY `payment_method` (`payment_method`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;",
|
||||
|
||||
// Service-to-remote-server mapping (admin can enable/disable per service)
|
||||
"CREATE TABLE IF NOT EXISTS `".OGP_DB_PREFIX."billing_service_remote_servers` (
|
||||
`id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`service_id` INT(11) NOT NULL,
|
||||
`remote_server_id` INT(11) NOT NULL,
|
||||
`enabled` TINYINT(1) NOT NULL DEFAULT 1,
|
||||
PRIMARY KEY (`id`),
|
||||
UNIQUE KEY `svc_rs` (`service_id`, `remote_server_id`),
|
||||
KEY `service_id` (`service_id`),
|
||||
KEY `remote_server_id` (`remote_server_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
|
||||
);
|
||||
|
||||
// Version 3 (array index 2, because install_queries is zero-indexed starting from version 1):
|
||||
// Add override_price to service-to-server mapping table
|
||||
$install_queries[2] = array(
|
||||
"ALTER TABLE `".OGP_DB_PREFIX."billing_service_remote_servers` ADD COLUMN `override_price` DECIMAL(10,2) NULL AFTER `enabled`"
|
||||
);
|
||||
|
||||
// Version 4 (array index 3): Remove the separate service-to-server mapping table.
|
||||
// remote_server_id on billing_services now stores a comma-separated list of server IDs.
|
||||
// The mapping table is no longer used; drop it if it still exists from older installs.
|
||||
$install_queries[3] = array(
|
||||
// Drop legacy mapping table if it still exists from older installs
|
||||
"DROP TABLE IF EXISTS `".OGP_DB_PREFIX."billing_service_remote_servers`"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ if (!$db) {
|
|||
echo "DB connect failed: " . mysqli_connect_error() . PHP_EOL;
|
||||
exit(1);
|
||||
}
|
||||
$user = $argv[1] ?? 'iaregamer';
|
||||
$prefix = isset($table_prefix) ? $table_prefix : '';
|
||||
$user = $argv[1] ?? 'iaregamer';
|
||||
$user_safe = mysqli_real_escape_string($db, $user);
|
||||
$has_shadow = false;
|
||||
$res_cols = mysqli_query($db, "SHOW COLUMNS FROM ogp_users LIKE 'users_pass_hash'");
|
||||
$res_cols = mysqli_query($db, "SHOW COLUMNS FROM `{$prefix}users` LIKE 'users_pass_hash'");
|
||||
if ($res_cols && mysqli_num_rows($res_cols) > 0) $has_shadow = true;
|
||||
$select_fields = 'user_id, users_login, users_passwd';
|
||||
if ($has_shadow) $select_fields .= ", users_pass_hash";
|
||||
$q = "SELECT $select_fields FROM ogp_users WHERE users_login = '$user_safe' LIMIT 1";
|
||||
$q = "SELECT $select_fields FROM `{$prefix}users` WHERE users_login = '$user_safe' LIMIT 1";
|
||||
$res = mysqli_query($db, $q);
|
||||
if (!$res) {
|
||||
echo "Query error: " . mysqli_error($db) . PHP_EOL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue