feat: wire discord and paypal configs to panel settings
Agent-Logs-Url: https://github.com/GameServerPanel/GSP/sessions/6163aa0e-000d-4376-ad24-9f63a04f4d95 Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
c1d7c27b35
commit
428bccb6ac
14 changed files with 336 additions and 134 deletions
|
|
@ -77,6 +77,73 @@ function discordmsg($msg, $webhook) {
|
|||
}
|
||||
}
|
||||
|
||||
function ogp_setting_is_enabled($value, $default = false)
|
||||
{
|
||||
if ($value === null || $value === '') return $default;
|
||||
if (is_bool($value)) return $value;
|
||||
$value = strtolower(trim((string)$value));
|
||||
return in_array($value, array('1', 'true', 'yes', 'on'), true);
|
||||
}
|
||||
|
||||
function ogp_get_discord_settings($settings = array())
|
||||
{
|
||||
$settings = is_array($settings) ? $settings : array();
|
||||
$legacy_webhook = isset($settings['webhookurl']) ? trim((string)$settings['webhookurl']) : '';
|
||||
$webhook = isset($settings['discord_webhook_url']) ? trim((string)$settings['discord_webhook_url']) : '';
|
||||
if ($webhook === '' && $legacy_webhook !== '') {
|
||||
$webhook = $legacy_webhook;
|
||||
}
|
||||
|
||||
$has_explicit_flag = array_key_exists('discord_enabled', $settings);
|
||||
$enabled_default = $legacy_webhook !== '';
|
||||
|
||||
return array(
|
||||
'enabled' => ogp_setting_is_enabled($has_explicit_flag ? $settings['discord_enabled'] : null, $enabled_default),
|
||||
'webhook_url' => $webhook,
|
||||
'username' => isset($settings['discord_username']) ? trim((string)$settings['discord_username']) : '',
|
||||
'avatar_url' => isset($settings['discord_avatar_url']) ? trim((string)$settings['discord_avatar_url']) : '',
|
||||
'notify_orders' => ogp_setting_is_enabled(isset($settings['discord_notify_orders']) ? $settings['discord_notify_orders'] : null, true),
|
||||
'notify_server_events' => ogp_setting_is_enabled(isset($settings['discord_notify_server_events']) ? $settings['discord_notify_server_events'] : null, true),
|
||||
'notify_admin_events' => ogp_setting_is_enabled(isset($settings['discord_notify_admin_events']) ? $settings['discord_notify_admin_events'] : null, true),
|
||||
);
|
||||
}
|
||||
|
||||
function ogp_send_discord_notification($settings, $message, $toggle = '')
|
||||
{
|
||||
$discord = ogp_get_discord_settings($settings);
|
||||
if (!$discord['enabled'] || $discord['webhook_url'] === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($toggle !== '' && isset($discord[$toggle]) && !$discord[$toggle]) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!function_exists('curl_init')) {
|
||||
error_log('OGP Discord webhook skipped: PHP curl extension is not loaded.');
|
||||
return false;
|
||||
}
|
||||
|
||||
$payload = array('content' => (string)$message);
|
||||
if ($discord['username'] !== '') {
|
||||
$payload['username'] = $discord['username'];
|
||||
}
|
||||
if ($discord['avatar_url'] !== '') {
|
||||
$payload['avatar_url'] = $discord['avatar_url'];
|
||||
}
|
||||
|
||||
$ch = curl_init($discord['webhook_url']);
|
||||
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
curl_setopt($ch, CURLOPT_POST, 1);
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
//read_expire() converts a time stamp to a human readable form
|
||||
//Used as a count down to when the user's account expires
|
||||
|
|
@ -1131,4 +1198,3 @@ function deleteMysqlAddonDatabasesForGameServerHome($home_id){
|
|||
return false;
|
||||
}
|
||||
?>
|
||||
|
||||
|
|
|
|||
23
index.php
23
index.php
|
|
@ -297,28 +297,8 @@ function ogpHome()
|
|||
//NOTIFY DISCORD WHEN ADMIN LOGS IN
|
||||
$trust_admins = array("iaregamer","dimrod","CJB","Bebiano","Syru");
|
||||
if ($userInfo['users_role'] == "admin" && in_array($userInfo['users_login'], $trust_admins) == false) {
|
||||
//WEBHOOK Discord=======================================================================================
|
||||
// Create new webhook in your Discord channel settings and copy&paste URL
|
||||
//=======================================================================================================
|
||||
$webhookurl = "https://discord.com/api/webhooks/1087810639390576650/sspI3frko8FLD6ybvzG-_BXhG4wjH7yujFBxffgtTw34uAL_AdrDxY36C-khqs--cEMu";
|
||||
//========================================================================================================
|
||||
$msg = "Admin Login :warning: \nIP:".$client_ip." \nID:".$userInfo['user_id']." \nUser:".$userInfo['users_login'];
|
||||
$json_data = array ('content'=>"$msg");
|
||||
$make_json = json_encode($json_data);
|
||||
if(!function_exists('curl_init')){
|
||||
error_log("OGP Discord webhook skipped: PHP curl extension is not loaded.");
|
||||
}else{
|
||||
$ch = curl_init( $webhookurl );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
curl_setopt( $ch, CURLOPT_POST, 1);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec( $ch );
|
||||
curl_close($ch);
|
||||
}
|
||||
//end WEBHOOK Discord
|
||||
ogp_send_discord_notification($settings, $msg, 'notify_admin_events');
|
||||
}
|
||||
|
||||
$_SESSION['user_id'] = $userInfo['user_id'];
|
||||
|
|
@ -487,4 +467,3 @@ function ogpHome()
|
|||
?>
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -143,6 +143,46 @@ define('OGP_LANG_trusted_host_or_proxy_addresses_or_cidr', "Trusted Hosts or Pro
|
|||
define('OGP_LANG_trusted_forwarded_ip_addresses_or_cidr', "Trusted Forwarded IPs (IPv4/IPv6 Addresses or CIDR)");
|
||||
define('OGP_LANG_reset_game_server_order', "Reset Game Server Ordering");
|
||||
define('OGP_LANG_reset_game_server_order_info', "Resets game server ordering back to the default of using the server ID");
|
||||
define('OGP_LANG_discord_enabled', "Enable Discord Notifications");
|
||||
define('OGP_LANG_discord_enabled_info', "Enable or disable Discord webhook notifications globally.");
|
||||
define('OGP_LANG_discord_webhook_url', "Discord Webhook URL");
|
||||
define('OGP_LANG_discord_webhook_url_info', "Discord channel webhook endpoint used for panel notifications.");
|
||||
define('OGP_LANG_discord_username', "Discord Webhook Username");
|
||||
define('OGP_LANG_discord_username_info', "Optional username override for webhook messages.");
|
||||
define('OGP_LANG_discord_avatar_url', "Discord Webhook Avatar URL");
|
||||
define('OGP_LANG_discord_avatar_url_info', "Optional avatar URL override for webhook messages.");
|
||||
define('OGP_LANG_discord_notify_orders', "Discord Notify: Orders");
|
||||
define('OGP_LANG_discord_notify_orders_info', "Send Discord notifications for order/payment events.");
|
||||
define('OGP_LANG_discord_notify_server_events', "Discord Notify: Server Events");
|
||||
define('OGP_LANG_discord_notify_server_events_info', "Send Discord notifications for server provisioning/renewal/ticket events.");
|
||||
define('OGP_LANG_discord_notify_admin_events', "Discord Notify: Admin Events");
|
||||
define('OGP_LANG_discord_notify_admin_events_info', "Send Discord notifications for admin security and role-change events.");
|
||||
define('OGP_LANG_paypal_enabled', "Enable PayPal");
|
||||
define('OGP_LANG_paypal_enabled_info', "Enable or disable PayPal checkout and webhook processing.");
|
||||
define('OGP_LANG_paypal_mode', "PayPal Mode");
|
||||
define('OGP_LANG_paypal_mode_info', "Select sandbox for testing or live for production.");
|
||||
define('OGP_LANG_paypal_client_id', "PayPal Default Client ID");
|
||||
define('OGP_LANG_paypal_client_id_info', "Fallback client ID used when mode-specific IDs are not set.");
|
||||
define('OGP_LANG_paypal_client_secret', "PayPal Default Client Secret");
|
||||
define('OGP_LANG_paypal_client_secret_info', "Fallback client secret used when mode-specific secrets are not set.");
|
||||
define('OGP_LANG_paypal_sandbox_client_id', "PayPal Sandbox Client ID");
|
||||
define('OGP_LANG_paypal_sandbox_client_id_info', "Sandbox REST app client ID from PayPal Developer.");
|
||||
define('OGP_LANG_paypal_sandbox_client_secret', "PayPal Sandbox Client Secret");
|
||||
define('OGP_LANG_paypal_sandbox_client_secret_info', "Sandbox REST app client secret from PayPal Developer.");
|
||||
define('OGP_LANG_paypal_live_client_id', "PayPal Live Client ID");
|
||||
define('OGP_LANG_paypal_live_client_id_info', "Live REST app client ID from PayPal Developer.");
|
||||
define('OGP_LANG_paypal_live_client_secret', "PayPal Live Client Secret");
|
||||
define('OGP_LANG_paypal_live_client_secret_info', "Live REST app client secret from PayPal Developer.");
|
||||
define('OGP_LANG_paypal_email', "PayPal Merchant Email");
|
||||
define('OGP_LANG_paypal_email_info', "Optional merchant email used for payment records and reconciliation.");
|
||||
define('OGP_LANG_paypal_currency', "PayPal Currency");
|
||||
define('OGP_LANG_paypal_currency_info', "Default currency code used by checkout (for example: USD).");
|
||||
define('OGP_LANG_paypal_webhook_id', "PayPal Webhook ID");
|
||||
define('OGP_LANG_paypal_webhook_id_info', "Webhook ID used for PayPal signature verification.");
|
||||
define('OGP_LANG_paypal_return_url', "PayPal Return URL");
|
||||
define('OGP_LANG_paypal_return_url_info', "Optional return URL used after successful approval.");
|
||||
define('OGP_LANG_paypal_cancel_url', "PayPal Cancel URL");
|
||||
define('OGP_LANG_paypal_cancel_url_info', "Optional cancel URL used when checkout is canceled.");
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ function h($s){ return htmlspecialchars((string)$s, ENT_QUOTES, 'UTF-8'); }
|
|||
</ul>
|
||||
|
||||
<h3>Sandbox account (testing)</h3>
|
||||
<p>Use PayPal sandbox credentials when testing payments. Set your sandbox <code>client_id</code> and <code>client_secret</code> in the runtime config that the payment handlers use (for this site those are in the respective files under <code>_website/api/</code> or in a central config if you moved credentials).</p>
|
||||
<p>Use PayPal sandbox credentials when testing payments. Configure all PayPal fields in the panel settings page (<code>home.php?m=settings</code>) so billing endpoints read values from <code>ogp_settings</code>.</p>
|
||||
<ul>
|
||||
<li>Create a sandbox business account at <a href="https://developer.paypal.com">PayPal Developer</a> and obtain a sandbox client ID/secret.</li>
|
||||
<li>Update the payment handler config and restart the webserver if required.</li>
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
require_once(__DIR__ . '/../includes/config_loader.php');
|
||||
require_once(__DIR__ . '/../includes/runtime_settings.php');
|
||||
|
||||
// Prevent any output before JSON
|
||||
ob_start();
|
||||
|
|
@ -50,10 +51,16 @@ if (!$paypal_order_id) {
|
|||
log_payment('REQUEST_START', ['order_id' => $paypal_order_id]);
|
||||
|
||||
// PayPal API configuration
|
||||
$sandbox = true;
|
||||
$client_id = 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_nP5tOoxQSAHw8c';
|
||||
$client_secret = 'EJ216np9cAj9n7KSddez3fLVxGe-zi4oKKKl1YGqPp88XIikr4Qzbxh0XW2as-V6LgdX-upjtQAg9dC0';
|
||||
$api = $sandbox ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
|
||||
$paypalSettings = billing_get_paypal_settings();
|
||||
$client_id = $paypalSettings['client_id'];
|
||||
$client_secret = $paypalSettings['client_secret'];
|
||||
$api = $paypalSettings['api_base'];
|
||||
if (!billing_paypal_is_ready($paypalSettings)) {
|
||||
log_payment('PAYPAL_NOT_CONFIGURED', ['enabled' => $paypalSettings['enabled'] ?? false]);
|
||||
ob_clean();
|
||||
echo json_encode(['error' => 'paypal_not_configured', 'request_id' => $requestId]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Get OAuth token
|
||||
$ch = curl_init("$api/v1/oauth2/token");
|
||||
|
|
@ -366,4 +373,3 @@ echo json_encode([
|
|||
'provisioned' => $autoProvisionResult['provisioned_count'] ?? 0
|
||||
]);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,10 +9,12 @@ ini_set('display_errors', '0');
|
|||
error_reporting(E_ALL);
|
||||
|
||||
require_once(__DIR__ . '/../includes/config_loader.php');
|
||||
require_once(__DIR__ . '/../includes/runtime_settings.php');
|
||||
// create_order for PayPal — adapted to run from _website/api
|
||||
$sandbox = true; // flip to false for Live
|
||||
$client_id = 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_nP5tOoxQSAHw8c';
|
||||
$client_secret = 'EJ216np9cAj9n7KSddez3fLVxGe-zi4oKKKl1YGqPp88XIikr4Qzbxh0XW2as-V6LgdX-upjtQAg9dC0';
|
||||
$paypalSettings = billing_get_paypal_settings();
|
||||
$sandbox = !empty($paypalSettings['sandbox']);
|
||||
$client_id = $paypalSettings['client_id'];
|
||||
$client_secret = $paypalSettings['client_secret'];
|
||||
|
||||
// Setup comprehensive logging
|
||||
$logDir = __DIR__ . '/../logs';
|
||||
|
|
@ -62,7 +64,7 @@ if (!$in) {
|
|||
}
|
||||
|
||||
$amount_in = $in['amount'] ?? '0.00';
|
||||
$currency = $in['currency'] ?? 'USD';
|
||||
$currency = $in['currency'] ?? $paypalSettings['currency'];
|
||||
$invoice_id = $in['invoice_id'] ?? null;
|
||||
$custom_id = $in['custom_id'] ?? null;
|
||||
$description = $in['description'] ?? 'Order';
|
||||
|
|
@ -96,7 +98,7 @@ if ($items) {
|
|||
]);
|
||||
}
|
||||
|
||||
$api = $sandbox ? 'https://api-m.sandbox.paypal.com' : 'https://api-m.paypal.com';
|
||||
$api = $paypalSettings['api_base'];
|
||||
create_order_log('PAYPAL_API_CONFIG', [
|
||||
'sandbox_mode' => $sandbox,
|
||||
'api_base' => $api,
|
||||
|
|
@ -104,6 +106,13 @@ create_order_log('PAYPAL_API_CONFIG', [
|
|||
'has_client_secret' => !empty($client_secret)
|
||||
]);
|
||||
|
||||
if (!billing_paypal_is_ready($paypalSettings)) {
|
||||
create_order_log('PAYPAL_NOT_CONFIGURED', ['enabled' => $paypalSettings['enabled'] ?? false]);
|
||||
http_response_code(503);
|
||||
echo json_encode(['error' => 'paypal_not_configured', 'request_id' => $requestId]);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Step 1: Get OAuth token
|
||||
create_order_log('OAUTH_REQUEST_START', ['endpoint' => "$api/v1/oauth2/token"]);
|
||||
|
||||
|
|
@ -154,7 +163,7 @@ if (!$access) {
|
|||
create_order_log('OAUTH_SUCCESS', ['token_length' => strlen($access)]);
|
||||
|
||||
// Update site base URL to exclude 'modules/billing'
|
||||
$siteBaseUrl = 'http://gameservers.world';
|
||||
$siteBaseUrl = $paypalSettings['site_base'];
|
||||
|
||||
create_order_log('URL_PROCESSING_BEFORE', [
|
||||
'return_url' => $return_url,
|
||||
|
|
@ -163,11 +172,15 @@ create_order_log('URL_PROCESSING_BEFORE', [
|
|||
]);
|
||||
|
||||
// Ensure return_url and cancel_url are absolute URLs (relative to site root)
|
||||
if (strpos($return_url, 'http') !== 0) {
|
||||
$return_url = $siteBaseUrl . '/' . ltrim($return_url, '/');
|
||||
if (empty($return_url)) {
|
||||
$return_url = $paypalSettings['return_url'];
|
||||
} elseif (strpos($return_url, 'http') !== 0) {
|
||||
$return_url = billing_absolute_url($return_url, $siteBaseUrl);
|
||||
}
|
||||
if (strpos($cancel_url, 'http') !== 0) {
|
||||
$cancel_url = $siteBaseUrl . '/' . ltrim($cancel_url, '/');
|
||||
if (empty($cancel_url)) {
|
||||
$cancel_url = $paypalSettings['cancel_url'];
|
||||
} elseif (strpos($cancel_url, 'http') !== 0) {
|
||||
$cancel_url = billing_absolute_url($cancel_url, $siteBaseUrl);
|
||||
}
|
||||
|
||||
create_order_log('URL_PROCESSING_AFTER', [
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ if (session_status() === PHP_SESSION_NONE) {
|
|||
|
||||
// Load configuration
|
||||
require_once(__DIR__ . '/bootstrap.php');
|
||||
require_once(__DIR__ . '/includes/runtime_settings.php');
|
||||
|
||||
// Variables from config.inc.php (helps IDEs understand scope)
|
||||
/** @var string $db_host Database host */
|
||||
|
|
@ -251,8 +252,11 @@ if ($applied_coupon && $coupon_discount_percent > 0) {
|
|||
$final_amount = $total_amount - $discount_amount;
|
||||
|
||||
// PayPal configuration
|
||||
$sandbox = true;
|
||||
$client_id = 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_nP5tOoxQSAHw8c';
|
||||
$paypal_settings = billing_get_paypal_settings();
|
||||
$client_id = $paypal_settings['client_id'];
|
||||
$paypal_currency = $paypal_settings['currency'];
|
||||
$paypal_enabled = !empty($paypal_settings['enabled']);
|
||||
$paypal_ready = billing_paypal_is_ready($paypal_settings);
|
||||
|
||||
// Prepare PayPal items
|
||||
$paypal_items = [];
|
||||
|
|
@ -264,7 +268,7 @@ foreach ($invoices as $inv) {
|
|||
'description' => $inv['description'] ?? '',
|
||||
'quantity' => $qty,
|
||||
'unit_amount' => [
|
||||
'currency_code' => 'USD',
|
||||
'currency_code' => $paypal_currency,
|
||||
'value' => number_format(floatval($inv['amount']) / $qty, 2, '.', '')
|
||||
]
|
||||
];
|
||||
|
|
@ -507,8 +511,8 @@ $siteBase = $protocol . $host;
|
|||
<!-- Favicon -->
|
||||
<link rel="icon" href="images/logo-sm.png" type="image/png">
|
||||
<link rel="apple-touch-icon" href="images/logo-sm.png">
|
||||
<?php if (!$cart_empty): ?>
|
||||
<script src="https://www.paypal.com/sdk/js?client-id=<?php echo htmlspecialchars($client_id); ?>¤cy=USD&intent=capture"></script>
|
||||
<?php if (!$cart_empty && $paypal_ready): ?>
|
||||
<script src="https://www.paypal.com/sdk/js?client-id=<?php echo htmlspecialchars($client_id); ?>¤cy=<?php echo urlencode($paypal_currency); ?>&intent=capture"></script>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
<body>
|
||||
|
|
@ -623,9 +627,14 @@ $siteBase = $protocol . $host;
|
|||
<div class="checkout-section">
|
||||
<h3>Checkout with PayPal</h3>
|
||||
<p>Click the button below to complete your purchase securely through PayPal.</p>
|
||||
|
||||
<div id="paypal-button-container"></div>
|
||||
<div id="status-message" class="status-message"></div>
|
||||
<?php if (!$paypal_enabled): ?>
|
||||
<div class="alert alert-error">PayPal checkout is currently disabled by the administrator.</div>
|
||||
<?php elseif (!$paypal_ready): ?>
|
||||
<div class="alert alert-error">PayPal checkout is not configured yet. Please contact support.</div>
|
||||
<?php else: ?>
|
||||
<div id="paypal-button-container"></div>
|
||||
<div id="status-message" class="status-message"></div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="action-buttons">
|
||||
<a href="/order.php" class="btn btn-secondary">Continue Shopping</a>
|
||||
|
|
@ -633,6 +642,7 @@ $siteBase = $protocol . $host;
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ($paypal_ready): ?>
|
||||
<script>
|
||||
function setStatus(msg) {
|
||||
const statusDiv = document.getElementById('status-message');
|
||||
|
|
@ -646,17 +656,17 @@ $siteBase = $protocol . $host;
|
|||
return actions.order.create({
|
||||
purchase_units: [{
|
||||
amount: {
|
||||
currency_code: 'USD',
|
||||
currency_code: '<?php echo htmlspecialchars($paypal_currency); ?>',
|
||||
value: '<?php echo number_format($final_amount, 2, '.', ''); ?>',
|
||||
breakdown: {
|
||||
item_total: {
|
||||
currency_code: 'USD',
|
||||
currency_code: '<?php echo htmlspecialchars($paypal_currency); ?>',
|
||||
value: '<?php echo number_format($total_amount, 2, '.', ''); ?>'
|
||||
}
|
||||
<?php if ($discount_amount > 0): ?>
|
||||
,
|
||||
discount: {
|
||||
currency_code: 'USD',
|
||||
currency_code: '<?php echo htmlspecialchars($paypal_currency); ?>',
|
||||
value: '<?php echo number_format($discount_amount, 2, '.', ''); ?>'
|
||||
}
|
||||
<?php endif; ?>
|
||||
|
|
@ -708,10 +718,11 @@ $siteBase = $protocol . $host;
|
|||
|
||||
onCancel: function(data) {
|
||||
setStatus('Payment cancelled');
|
||||
window.location.href = '/payment_cancel.php';
|
||||
window.location.href = '<?php echo htmlspecialchars($paypal_settings['cancel_url']); ?>';
|
||||
}
|
||||
}).render('#paypal-button-container');
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<script>
|
||||
// Remove invoice via AJAX and perform a partial reload of the cart container
|
||||
function removeInvoice(invoiceId) {
|
||||
|
|
@ -760,4 +771,3 @@ $siteBase = $protocol . $host;
|
|||
<?php include(__DIR__ . '/includes/footer.php'); ?>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
|||
|
|
@ -146,21 +146,8 @@ function exec_ogp_module()
|
|||
//WEBHOOK Discord=======================================================================================
|
||||
|
||||
|
||||
$webhookurl = $settings['webhookurl'];
|
||||
|
||||
$msg = "The ". $home_name ." server ID #". $home_id . " has just been renewed.";
|
||||
$json_data = array ('content'=>"$msg");
|
||||
$make_json = json_encode($json_data);
|
||||
$ch = curl_init( $webhookurl );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
curl_setopt( $ch, CURLOPT_POST, 1);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec( $ch );
|
||||
//If you need to debug, or find out why you can't send message uncomment line below, and execute script.
|
||||
//echo $response;
|
||||
ogp_send_discord_notification($settings, $msg, 'notify_server_events');
|
||||
//end WEBHOOK Discord
|
||||
|
||||
}
|
||||
|
|
@ -310,24 +297,8 @@ function exec_ogp_module()
|
|||
|
||||
|
||||
//WEBHOOK Discord=======================================================================================
|
||||
|
||||
$webhookurl = "https://discord.com/api/webhooks/710275918274363412/g5Tr-EUdEnLfFryOlscxJ6FuPiSJuE6EMKRYmh9UGMiqTUxU5-y9CQrBlDJW7znr0Tol";
|
||||
//$settings['webhookurl'];
|
||||
|
||||
|
||||
$msg = "A new server, ". $home_name ." ID #". $home_id . ", has just been created.";
|
||||
$json_data = array ('content'=>"$msg");
|
||||
$make_json = json_encode($json_data);
|
||||
$ch = curl_init( $webhookurl );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
curl_setopt( $ch, CURLOPT_POST, 1);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec( $ch );
|
||||
//If you need to debug, or find out why you can't send message uncomment line below, and execute script.
|
||||
//echo $response;
|
||||
ogp_send_discord_notification($settings, $msg, 'notify_server_events');
|
||||
//end WEBHOOK Discord
|
||||
}
|
||||
// END EMAIL
|
||||
|
|
@ -449,4 +420,3 @@ function exec_ogp_module()
|
|||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
99
modules/billing/includes/runtime_settings.php
Normal file
99
modules/billing/includes/runtime_settings.php
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
<?php
|
||||
require_once(__DIR__ . '/panel_bridge.php');
|
||||
|
||||
if (!function_exists('billing_bool_setting')) {
|
||||
function billing_bool_setting($value, $default = false)
|
||||
{
|
||||
if ($value === null || $value === '') {
|
||||
return $default;
|
||||
}
|
||||
if (is_bool($value)) {
|
||||
return $value;
|
||||
}
|
||||
$value = strtolower(trim((string)$value));
|
||||
return in_array($value, array('1', 'true', 'yes', 'on'), true);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('billing_detect_site_base')) {
|
||||
function billing_detect_site_base()
|
||||
{
|
||||
$scheme = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? 'https' : 'http';
|
||||
$host = isset($_SERVER['HTTP_HOST']) ? trim((string)$_SERVER['HTTP_HOST']) : 'localhost';
|
||||
return $scheme . '://' . $host;
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('billing_absolute_url')) {
|
||||
function billing_absolute_url($url, $siteBase)
|
||||
{
|
||||
$url = trim((string)$url);
|
||||
if ($url === '') {
|
||||
return '';
|
||||
}
|
||||
if (preg_match('#^https?://#i', $url)) {
|
||||
return $url;
|
||||
}
|
||||
return rtrim($siteBase, '/') . '/' . ltrim($url, '/');
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('billing_get_paypal_settings')) {
|
||||
function billing_get_paypal_settings()
|
||||
{
|
||||
$panelSettings = billing_get_panel_settings();
|
||||
$mode = strtolower(trim((string)($panelSettings['paypal_mode'] ?? 'sandbox')));
|
||||
if (!in_array($mode, array('sandbox', 'live'), true)) {
|
||||
$mode = 'sandbox';
|
||||
}
|
||||
|
||||
$sandboxClientId = trim((string)($panelSettings['paypal_sandbox_client_id'] ?? ''));
|
||||
$sandboxClientSecret = trim((string)($panelSettings['paypal_sandbox_client_secret'] ?? ''));
|
||||
$liveClientId = trim((string)($panelSettings['paypal_live_client_id'] ?? ''));
|
||||
$liveClientSecret = trim((string)($panelSettings['paypal_live_client_secret'] ?? ''));
|
||||
$fallbackClientId = trim((string)($panelSettings['paypal_client_id'] ?? ''));
|
||||
$fallbackClientSecret = trim((string)($panelSettings['paypal_client_secret'] ?? ''));
|
||||
|
||||
$clientId = $mode === 'live' ? $liveClientId : $sandboxClientId;
|
||||
$clientSecret = $mode === 'live' ? $liveClientSecret : $sandboxClientSecret;
|
||||
if ($clientId === '') {
|
||||
$clientId = $fallbackClientId;
|
||||
}
|
||||
if ($clientSecret === '') {
|
||||
$clientSecret = $fallbackClientSecret;
|
||||
}
|
||||
|
||||
$currency = strtoupper(trim((string)($panelSettings['paypal_currency'] ?? 'USD')));
|
||||
if ($currency === '') {
|
||||
$currency = 'USD';
|
||||
}
|
||||
|
||||
$enabled = billing_bool_setting($panelSettings['paypal_enabled'] ?? null, ($clientId !== '' && $clientSecret !== ''));
|
||||
$siteBase = billing_detect_site_base();
|
||||
$returnUrl = billing_absolute_url($panelSettings['paypal_return_url'] ?? '/payment_success.php', $siteBase);
|
||||
$cancelUrl = billing_absolute_url($panelSettings['paypal_cancel_url'] ?? '/payment_cancel.php', $siteBase);
|
||||
|
||||
return array(
|
||||
'enabled' => $enabled,
|
||||
'mode' => $mode,
|
||||
'sandbox' => $mode !== 'live',
|
||||
'client_id' => $clientId,
|
||||
'client_secret' => $clientSecret,
|
||||
'currency' => $currency,
|
||||
'webhook_id' => trim((string)($panelSettings['paypal_webhook_id'] ?? '')),
|
||||
'email' => trim((string)($panelSettings['paypal_email'] ?? '')),
|
||||
'return_url' => $returnUrl,
|
||||
'cancel_url' => $cancelUrl,
|
||||
'site_base' => $siteBase,
|
||||
'api_base' => $mode === 'live' ? 'https://api-m.paypal.com' : 'https://api-m.sandbox.paypal.com',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (!function_exists('billing_paypal_is_ready')) {
|
||||
function billing_paypal_is_ready($settings)
|
||||
{
|
||||
return !empty($settings['enabled']) && !empty($settings['client_id']) && !empty($settings['client_secret']);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,16 +1,21 @@
|
|||
<?php
|
||||
require_once(__DIR__ . '/includes/config_loader.php');
|
||||
require_once(__DIR__ . '/includes/runtime_settings.php');
|
||||
if (is_file(__DIR__ . '/includes/log.php')) require_once(__DIR__ . '/includes/log.php');
|
||||
|
||||
$paypalSettings = billing_get_paypal_settings();
|
||||
$dataDir = rtrim(
|
||||
(defined('SITE_DATA_DIR') ? SITE_DATA_DIR : '') ?: ($SITE_DATA_DIR ?? ''),
|
||||
DIRECTORY_SEPARATOR
|
||||
);
|
||||
|
||||
$config = [
|
||||
'sandbox' => true,
|
||||
'client_id' => 'AfvY_C2zA_hTHxHq7TIhtOeub4xBdySYrt_Hjj3d_WYQwjWI9NfOAVOTeResx2rgZ_nP5tOoxQSAHw8c',
|
||||
'client_secret' => 'EJ216np9cAj9n7KSddez3fLVxGe-zi4oKKKl1YGqPp88XIikr4Qzbxh0XW2as-V6LgdX-upjtQAg9dC0',
|
||||
'webhook_id' => '6N620673281740730',
|
||||
'data_dir' => rtrim(
|
||||
(defined('SITE_DATA_DIR') ? SITE_DATA_DIR : '') ?: ($SITE_DATA_DIR ?? ''),
|
||||
DIRECTORY_SEPARATOR
|
||||
),
|
||||
'sandbox' => !empty($paypalSettings['sandbox']),
|
||||
'enabled' => !empty($paypalSettings['enabled']),
|
||||
'client_id' => $paypalSettings['client_id'],
|
||||
'client_secret' => $paypalSettings['client_secret'],
|
||||
'webhook_id' => $paypalSettings['webhook_id'],
|
||||
'data_dir' => $dataDir,
|
||||
'log_file' => __DIR__ . '/data/webhook.log',
|
||||
];
|
||||
|
||||
|
|
@ -24,6 +29,12 @@ function api_base(){global $config; return $config['sandbox'] ? 'https://api-m.s
|
|||
http_response_code(200);
|
||||
@mkdir($config['data_dir'], 0775, true);
|
||||
|
||||
if (empty($config['enabled']) || empty($config['client_id']) || empty($config['client_secret']) || empty($config['webhook_id'])) {
|
||||
if (function_exists('site_log_warn')) site_log_warn('paypal_webhook_not_configured', ['enabled' => $config['enabled']]);
|
||||
else log_line("PAYPAL_WEBHOOK_NOT_CONFIGURED");
|
||||
exit;
|
||||
}
|
||||
|
||||
$raw = file_get_contents('php://input');
|
||||
$headers = array_change_key_case(getallheaders() ?: [], CASE_UPPER);
|
||||
if (function_exists('site_log_info')) site_log_info('webhook_hit', ['ip'=>($_SERVER['REMOTE_ADDR']??''),'bytes'=>strlen($raw)]);
|
||||
|
|
|
|||
|
|
@ -72,7 +72,27 @@ function exec_ogp_module()
|
|||
"use_authorized_hosts" => $_REQUEST['use_authorized_hosts'],
|
||||
"allow_setting_cpu_affinity" => $_REQUEST['allow_setting_cpu_affinity'],
|
||||
"regex_invalid_file_name_chars" => addslashes($_REQUEST['regex_invalid_file_name_chars']),
|
||||
"login_ban_time" => $_REQUEST['login_ban_time']
|
||||
"login_ban_time" => $_REQUEST['login_ban_time'],
|
||||
"discord_enabled" => $_REQUEST['discord_enabled'],
|
||||
"discord_webhook_url" => $_REQUEST['discord_webhook_url'],
|
||||
"discord_username" => $_REQUEST['discord_username'],
|
||||
"discord_avatar_url" => $_REQUEST['discord_avatar_url'],
|
||||
"discord_notify_orders" => $_REQUEST['discord_notify_orders'],
|
||||
"discord_notify_server_events" => $_REQUEST['discord_notify_server_events'],
|
||||
"discord_notify_admin_events" => $_REQUEST['discord_notify_admin_events'],
|
||||
"paypal_enabled" => $_REQUEST['paypal_enabled'],
|
||||
"paypal_mode" => $_REQUEST['paypal_mode'],
|
||||
"paypal_client_id" => $_REQUEST['paypal_client_id'],
|
||||
"paypal_client_secret" => $_REQUEST['paypal_client_secret'],
|
||||
"paypal_sandbox_client_id" => $_REQUEST['paypal_sandbox_client_id'],
|
||||
"paypal_sandbox_client_secret" => $_REQUEST['paypal_sandbox_client_secret'],
|
||||
"paypal_live_client_id" => $_REQUEST['paypal_live_client_id'],
|
||||
"paypal_live_client_secret" => $_REQUEST['paypal_live_client_secret'],
|
||||
"paypal_email" => $_REQUEST['paypal_email'],
|
||||
"paypal_currency" => $_REQUEST['paypal_currency'],
|
||||
"paypal_webhook_id" => $_REQUEST['paypal_webhook_id'],
|
||||
"paypal_return_url" => $_REQUEST['paypal_return_url'],
|
||||
"paypal_cancel_url" => $_REQUEST['paypal_cancel_url']
|
||||
);
|
||||
|
||||
$db->setSettings($settings);
|
||||
|
|
@ -191,6 +211,29 @@ function exec_ogp_module()
|
|||
|
||||
// Add regex setting for file manager
|
||||
$ft->add_field('string','regex_invalid_file_name_chars',(@empty($row['regex_invalid_file_name_chars']) ? htmlentities('/[\^\$\*\+\?\(\)\[\{\\\\\\|\]!@#%&=~`,\\\'<>"}\s]/i', ENT_COMPAT | ENT_HTML401 | ENT_QUOTES) : htmlentities(@$row['regex_invalid_file_name_chars'], ENT_COMPAT | ENT_HTML401 | ENT_QUOTES)));
|
||||
|
||||
$ft->add_field('on_off','discord_enabled', isset($row['discord_enabled']) ? $row['discord_enabled'] : '0');
|
||||
$ft->add_field('string','discord_webhook_url',@$row['discord_webhook_url']);
|
||||
$ft->add_field('string','discord_username',@$row['discord_username']);
|
||||
$ft->add_field('string','discord_avatar_url',@$row['discord_avatar_url']);
|
||||
$ft->add_field('on_off','discord_notify_orders', isset($row['discord_notify_orders']) ? $row['discord_notify_orders'] : '1');
|
||||
$ft->add_field('on_off','discord_notify_server_events', isset($row['discord_notify_server_events']) ? $row['discord_notify_server_events'] : '1');
|
||||
$ft->add_field('on_off','discord_notify_admin_events', isset($row['discord_notify_admin_events']) ? $row['discord_notify_admin_events'] : '1');
|
||||
|
||||
$ft->add_field('on_off','paypal_enabled', isset($row['paypal_enabled']) ? $row['paypal_enabled'] : '0');
|
||||
$ft->add_custom_field('paypal_mode',
|
||||
create_drop_box_from_array(array('sandbox' => 'Sandbox', 'live' => 'Live'),"paypal_mode",isset($row['paypal_mode']) && !empty($row['paypal_mode']) ? $row['paypal_mode'] : 'sandbox',false));
|
||||
$ft->add_field('string','paypal_client_id',@$row['paypal_client_id']);
|
||||
$ft->add_field('password','paypal_client_secret',@$row['paypal_client_secret']);
|
||||
$ft->add_field('string','paypal_sandbox_client_id',@$row['paypal_sandbox_client_id']);
|
||||
$ft->add_field('password','paypal_sandbox_client_secret',@$row['paypal_sandbox_client_secret']);
|
||||
$ft->add_field('string','paypal_live_client_id',@$row['paypal_live_client_id']);
|
||||
$ft->add_field('password','paypal_live_client_secret',@$row['paypal_live_client_secret']);
|
||||
$ft->add_field('string','paypal_email',@$row['paypal_email']);
|
||||
$ft->add_field('string','paypal_currency',isset($row['paypal_currency']) && !empty($row['paypal_currency']) ? $row['paypal_currency'] : 'USD');
|
||||
$ft->add_field('string','paypal_webhook_id',@$row['paypal_webhook_id']);
|
||||
$ft->add_field('string','paypal_return_url',@$row['paypal_return_url']);
|
||||
$ft->add_field('string','paypal_cancel_url',@$row['paypal_cancel_url']);
|
||||
|
||||
// Add option to reset game server order to default
|
||||
$ft->add_field('checkbox','reset_game_server_order','0');
|
||||
|
|
|
|||
|
|
@ -48,16 +48,8 @@ function exec_ogp_module() {
|
|||
|
||||
|
||||
// URL FROM DISCORD WEBHOOK SETUP
|
||||
$webhook = "https://discordapp.com/api/webhooks/710275918274363412/g5Tr-EUdEnLfFryOlscxJ6FuPiSJuE6EMKRYmh9UGMiqTUxU5-y9CQrBlDJW7znr0Tol";
|
||||
$msg = json_decode('
|
||||
{
|
||||
"username":"I Are Gamer",
|
||||
"content":"SUPPORT TICKET CREATED: Login with the userid and password http://privateemail.com"
|
||||
|
||||
}
|
||||
', true);
|
||||
|
||||
discordmsg($msg, $webhook);
|
||||
$msg = "SUPPORT TICKET CREATED: Login with the userid and password http://privateemail.com";
|
||||
ogp_send_discord_notification($settings, $msg, 'notify_server_events');
|
||||
//end discord
|
||||
|
||||
$content = get_lang_f('support_email_content', $user['users_login'], $email, $gameserver, $message);
|
||||
|
|
|
|||
|
|
@ -94,24 +94,10 @@ function exec_ogp_module()
|
|||
|
||||
|
||||
|
||||
//WEBHOOK Discord=======================================================================================
|
||||
|
||||
$webhook = "https://discord.com/api/webhooks/1087807080657854484/yYtW8q63xKj3rTFYrNfW2LJk_GeC_WtuI8eJOyELxWbqTQ-uMzOO2I9qofoJCoHXFhC1";
|
||||
//$webhook = "https://discord.com/api/webhooks/710275918274363412/g5Tr-EUdEnLfFryOlscxJ6FuPiSJuE6EMKRYmh9UGMiqTUxU5-y9CQrBlDJW7znr0Tol";
|
||||
|
||||
//WEBHOOK Discord=======================================================================================
|
||||
$discord_settings = $db->getSettings();
|
||||
$msg = "Server support ticket created:\n"."ServerID: " .$_POST['ticket_service'] ."\n". "Subject: " .$_POST['ticket_subject'];
|
||||
$json_data = array ('content'=>"$msg");
|
||||
$make_json = json_encode($json_data);
|
||||
$ch = curl_init( $webhook );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
curl_setopt( $ch, CURLOPT_POST, 1);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec( $ch );
|
||||
//If you need to debug, or find out why you can't send message uncomment line below, and execute script.
|
||||
//echo $response;
|
||||
ogp_send_discord_notification($discord_settings, $msg, 'notify_server_events');
|
||||
//end WEBHOOK Discord
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -154,21 +154,8 @@ function exec_ogp_module() {
|
|||
if (isset($userInfo['users_role']) && isset($_POST['newrole']) && $userInfo['users_role'] != $_POST['newrole']) {
|
||||
$client_ip = getClientIPAddress();
|
||||
//WEBHOOK Discord=======================================================================================
|
||||
// Create new webhook in your Discord channel settings and copy&paste URL
|
||||
//=======================================================================================================
|
||||
$webhookurl = "https://discord.com/api/webhooks/1087810639390576650/sspI3frko8FLD6ybvzG-_BXhG4wjH7yujFBxffgtTw34uAL_AdrDxY36C-khqs--cEMu";
|
||||
//========================================================================================================
|
||||
$msg = "User Role Changed :warning: \nIP: ".$client_ip." \nUser: ".$login." \nUser Role: ".$userInfo['users_role']." \nNew Role: ".$_POST['newrole'];
|
||||
$json_data = array ('content'=>"$msg");
|
||||
$make_json = json_encode($json_data);
|
||||
$ch = curl_init( $webhookurl );
|
||||
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
|
||||
curl_setopt( $ch, CURLOPT_POST, 1);
|
||||
curl_setopt( $ch, CURLOPT_POSTFIELDS, $make_json);
|
||||
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_setopt( $ch, CURLOPT_HEADER, 0);
|
||||
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1);
|
||||
$response = curl_exec( $ch );
|
||||
ogp_send_discord_notification($settings, $msg, 'notify_admin_events');
|
||||
//end WEBHOOK Discord
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue