Need the XML field reference?
"; echo "
Open XML Notes
"; echo ""; /* show errors during setup */ @ini_set('display_errors','1'); error_reporting(E_ALL); function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); } function esc_mysqli($db, $v){ return $db->real_escape_string($v); } function fetch_all_assoc($db, $sql){ $res = $db->query($sql); return $res ? $res->fetch_all(MYSQLI_ASSOC) : []; } function col_exists($db, $table, $col){ $res = $db->query("SHOW COLUMNS FROM `$table` LIKE '".$db->real_escape_string($col)."'"); return ($res && $res->num_rows > 0); } function parse_id_list($s){ $tokens = preg_split('/\s+/', trim((string)$s)); $out = []; foreach ((array)$tokens as $t) { if ($t === '') continue; if (preg_match('/^\d+$/', $t)) $out[] = (int)$t; } return array_values(array_unique($out)); } /* URL helpers for image preview */ function is_abs_url($u){ return (bool)preg_match('~^(?:https?:)?//|^data:~i', (string)$u); } function join_base($base, $path){ $base = rtrim((string)$base, '/'); $path = ltrim((string)$path, '/'); return $base !== '' ? $base.'/'.$path : $path; } /* which column holds space-separated locations */ $locationCol = col_exists($db, "{$table_prefix}billing_services", 'remote_server_id') ? 'remote_server_id' : (col_exists($db, "{$table_prefix}billing_services", 'remote_server') ? 'remote_server' : 'remote_server_id'); $flash = []; /* A) Update global server location enable flags */ if (isset($_POST['update_remote_servers'])) { $enabledIds = array_map('intval', $_POST['rs'] ?? []); $enabledSet = array_flip($enabledIds); $allIds = fetch_all_assoc($db, "SELECT remote_server_id FROM {$table_prefix}remote_servers"); foreach ((array)$allIds as $row) { $id = (int)$row['remote_server_id']; $e = isset($enabledSet[$id]) ? 1 : 0; $db->query("UPDATE {$table_prefix}remote_servers SET enabled={$e} WHERE remote_server_id={$id}"); } $flash[] = "Server locations updated."; } /* helper: update one service row from posted array */ function update_service_row(mysqli $db, string $locationCol, int $sid, array $svc){ $name = esc_mysqli($db, trim($svc['service_name'] ?? '')); $priceMonthly = number_format((float)($svc['price_monthly'] ?? 0), 2, '.', ''); $priceYearly = number_format((float)($svc['price_year'] ?? 0), 2, '.', ''); $priceDaily = number_format((float)($svc['price_daily'] ?? 0), 2, '.', ''); $priceMonthEsc = esc_mysqli($db, $priceMonthly); $priceYearEsc = esc_mysqli($db, $priceYearly); $priceDailyEsc = esc_mysqli($db, $priceDaily); $img = esc_mysqli($db, trim($svc['img_url'] ?? '')); $en = !empty($svc['enabled']) ? 1 : 0; $minSlots = max(1, (int)($svc['slot_min_qty'] ?? 1)); $maxSlots = max($minSlots, (int)($svc['slot_max_qty'] ?? $minSlots)); $selected = []; if (!empty($svc['locations']) && is_array($svc['locations'])) { $selected = array_map('intval', $svc['locations']); $selected = array_values(array_unique($selected)); } $primary = isset($svc['primary_location']) ? (int)$svc['primary_location'] : 0; if ($primary && in_array($primary, $selected, true)) { $selected = array_values(array_diff($selected, [$primary])); array_unshift($selected, $primary); } $locList = implode(' ', $selected); $locListEsc = esc_mysqli($db, $locList); $sql = "UPDATE {$table_prefix}billing_services SET service_name='{$name}', `{$locationCol}`='{$locListEsc}', slot_min_qty={$minSlots}, slot_max_qty={$maxSlots}, price_daily='{$priceDailyEsc}', price_monthly='{$priceMonthEsc}', price_year='{$priceYearEsc}', img_url='{$img}', enabled={$en} WHERE service_id={$sid}"; $db->query($sql); } /* B1) PER-ROW UPDATE */ if (isset($_POST['update_single']) && isset($_POST['service']) && is_array($_POST['service'])) { $sid = (int)$_POST['update_single']; if (isset($_POST['service'][$sid])) { update_service_row($db, $locationCol, $sid, $_POST['service'][$sid]); $flash[] = "Service #{$sid} updated."; } } /* B2) BULK UPDATE (single button at bottom) */ if (isset($_POST['bulk_update']) && !empty($_POST['service']) && is_array($_POST['service'])) { foreach ((array)$_POST['service'] as $sid => $svc) { update_service_row($db, $locationCol, (int)$sid, (array)$svc); } $flash[] = "All edited services have been updated."; } /* C) Remove a service (separate small form) */ if (isset($_POST['remove_service'], $_POST['service_id_remove'])) { $sid = (int)$_POST['service_id_remove']; $db->query("DELETE FROM {$table_prefix}billing_services WHERE service_id={$sid}"); $flash[] = "Service #{$sid} removed."; } /* fetch data for UI */ $remoteServers = fetch_all_assoc($db, "SELECT remote_server_id, remote_server_name, enabled FROM {$table_prefix}remote_servers ORDER BY remote_server_name"); $services = fetch_all_assoc($db, "SELECT service_id, service_name, `{$locationCol}` AS locs, slot_min_qty, slot_max_qty, price_monthly, img_url, enabled FROM {$table_prefix}billing_services ORDER BY service_name"); ?>
".h($m)."
"; ?>
".h($m)."
"; ?>
Enable/Disable Server Locations (Global)
>
(ID: )
Update Enabled Servers
Update Enabled Servers
Current Services
No services found.
Enabled
Service Name
(ID below)
Min Slots
Max Slots
Price (Daily)
Price (Monthly)
Price (Year)
Thumbnail URL
Preview
Update Row
>
ID:
(no image)
Update Row
class="mr-6"> ()
>
Primary
[Globally disabled]
Update All
Remove a Service
(ID: )
Remove
Environment
Site Base URL
Data directory
PHP SAPI
Writable?
XML Reference
Open XML Notes