diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md index d927339..fdb867c 100644 --- a/README.md +++ b/README.md @@ -12,36 +12,34 @@ WHMCS module for integration with [WGDashboard](https://github.com/donaldzou/WGD ## 🚀 Installation 1. Upload the module files to the WHMCS directory: + ``` /modules/servers/wgdashboard/ ``` - 2. File structure: + ``` modules/server/wgdashboard/ ├── wgdashboard.php └── clientarea.tpl ``` - 3. In the WHMCS admin panel, navigate to: **Setup → Products/Services → Servers → Add New Server** - 4. Configure the server: + - **Hostname**: IP or domain of WGDashboard (e.g., `10.0.238.222` or `vpn.example.com`) - **Module**: WGDashboard - **Port**: API port (e.g., `10086`) - **Password**: WGDashboard API Key - 5. Click **Test Connection** to validate the configuration. ## ⚙️ Product Configuration 1. Create or edit a product in **Setup → Products/Services** - 2. In the **Module Settings** tab: + - **Module Name**: WGDashboard - **Server Group**: Select the configured server - 3. **Configuration Options**: - **Allowed IPs**: Allowed IPs for the peer (default: `0.0.0.0/0`) @@ -59,6 +57,7 @@ WHMCS module for integration with [WGDashboard](https://github.com/donaldzou/WGD ``` Available placeholders: + - `{{client_email}}` - Client's email - `{{domain}}` - Service domain - `{{serviceid}}` - Service ID in WHMCS @@ -82,7 +81,6 @@ Client Area: - 📄 **Formatted Configuration**: Ready-to-use WireGuard configuration file - 📋 **Download**: Button to download `.conf` file - ### Admin Panel In the client's service tab, the administrator views: @@ -95,7 +93,6 @@ In the client's service tab, the administrator views: - **Data Received**: Volume of data received From peer to server - **Data Sent**: Volume of data sent From server to peer - ## 🌐 WGDashboard Configuration To use this module, ensure the WGDashboard API is enabled: @@ -110,16 +107,19 @@ To use this module, ensure the WGDashboard API is enabled: ### Connection Test Fails **Error 401/403**: Verify API Key + ``` Solution: Confirm that the API Key is correct in the server's Password field ``` **Error 404**: Endpoint not found + ``` Solution: Check if your WGDashboard version supports the API ``` **Error 500**: WGDashboard internal error + ``` Solution: Check WGDashboard logs on the server ``` @@ -134,6 +134,7 @@ Solution: Check WGDashboard logs on the server ### QR Code Doesn't Appear Check: + - If JavaScript is enabled in the browser - Browser console for errors (F12) - If QRCode.js library is loading correctly @@ -144,14 +145,15 @@ The module uses WHMCS's **Server Port** field to define the API port. Do not include the port in the hostname, only in the dedicated field. ✅ **Correct**: + - Hostname: `10.0.0.55` - Port: `10086` ❌ **Incorrect**: + - Hostname: `10.0.0.55:10086` - Port: (empty) - ## 🔄 Compatibility - **WHMCS**: 7.0+ @@ -182,6 +184,7 @@ Contributions are welcome! To contribute: ## 📋 Changelog ### v1.0.0 + - ✨ Initial release - ✅ Peer creation, suspension, reactivation, and termination - 📱 Client area with QR code and formatted configuration @@ -189,4 +192,4 @@ Contributions are welcome! To contribute: - 🔐 Local WireGuard key generation - 📊 Admin panel with peer statistics ---- \ No newline at end of file +--- diff --git a/WGDashboard/clientarea.tpl b/WGDashboard/clientarea.tpl index 31a8a17..0e48f54 100644 --- a/WGDashboard/clientarea.tpl +++ b/WGDashboard/clientarea.tpl @@ -1,6 +1,6 @@ {if $error}
Escaneie este código QR com seu cliente WireGuard
+Scan this QR code with your WireGuard client
Configuração não disponível
+Configuration not available
{$formatted_config|escape}
Configuração não disponível
+Configuration not available
{/if}Falha na geração do QR Code: ' + error.message + '
'; + console.error('QR Code generation failed:', error); + qrCodeElement.innerHTML = 'QR Code generation failed: ' + error.message + '
'; } else { - console.log('QR Code gerado com sucesso'); + console.log('QR Code generated successfully'); } }); } catch (e) { - console.error('Exceção durante a geração do QR code:', e); - qrCodeElement.innerHTML = 'Erro na geração do QR Code: ' + e.message + '
'; + console.error('Exception during QR code generation:', e); + qrCodeElement.innerHTML = 'QR Code generation error: ' + e.message + '
'; } } else { - console.error('Falha na geração do QR Code: elemento ou configuração ausente'); + console.error('QR Code generation failed: element or config missing'); if (qrCodeElement) { - qrCodeElement.innerHTML = 'Configuração não disponível para QR code
'; + qrCodeElement.innerHTML = 'Configuration not available for QR code
'; } } } @@ -188,7 +187,6 @@ function generateQRCodeFallback(configText) { if (qrCodeElement && configText) { try { - // Create QR code using online service as fallback var qrUrl = 'https://api.qrserver.com/v1/create-qr-code/?size=250x250&data=' + encodeURIComponent(configText); var img = document.createElement('img'); img.src = qrUrl; @@ -199,18 +197,17 @@ function generateQRCodeFallback(configText) { console.log('Fallback QR code loaded successfully'); }; img.onerror = function() { - qrCodeElement.innerHTML = 'Falha ao gerar código QR
'; + qrCodeElement.innerHTML = 'Failed to generate QR code
'; }; qrCodeElement.innerHTML = ''; qrCodeElement.appendChild(img); } catch (e) { - console.error('Falha na geração do QR code de fallback:', e); - qrCodeElement.innerHTML = 'Falha na geração do código QR
'; + console.error('Fallback QR code generation failed:', e); + qrCodeElement.innerHTML = 'Failed to generate QR code
'; } } } -// Generate QR Code if formatted config is available {if $formatted_config} document.addEventListener('DOMContentLoaded', function() { configForQR = {$formatted_config|json_encode}; @@ -219,7 +216,6 @@ document.addEventListener('DOMContentLoaded', function() { generateQRCode(configForQR); } else { console.log('Waiting for QRCode library to load...'); - // Timeout fallback setTimeout(function() { if (!qrCodeLibraryLoaded && configForQR) { console.log('Timeout reached, using fallback QR generation'); @@ -229,7 +225,7 @@ document.addEventListener('DOMContentLoaded', function() { } }); {else} -console.log('No formatted config available for QR code'); +console.log('No configuration available for QR code'); {/if} function downloadFormattedConfig() { @@ -250,7 +246,7 @@ function copyFormattedConfig() { var config = {$formatted_config|json_encode}; if (navigator.clipboard && window.isSecureContext) { navigator.clipboard.writeText(config).then(function() { - alert('Configuração copiada para a área de transferência!'); + alert('Configuration copied to clipboard!'); }).catch(function(err) { fallbackCopyTextToClipboard(config); }); @@ -272,12 +268,12 @@ function fallbackCopyTextToClipboard(text) { try { var successful = document.execCommand('copy'); if (successful) { - alert('Configuração copiada para a área de transferência!'); + alert('Configuration copied to clipboard!'); } else { - alert('Falha ao copiar configuração. Por favor, copie manualmente.'); + alert('Failed to copy configuration. Please copy manually.'); } } catch (err) { - alert('Falha ao copiar configuração. Por favor, copie manualmente.'); + alert('Failed to copy configuration. Please copy manually.'); } document.body.removeChild(textArea); } @@ -303,9 +299,9 @@ function copyConfig() { textarea.select(); try { document.execCommand('copy'); - alert('Configuração copiada para a área de transferência!'); + alert('Configuration copied to clipboard!'); } catch (err) { - alert('Falha ao copiar configuração. Por favor, selecione e copie manualmente.'); + alert('Failed to copy configuration. Please select and copy manually.'); } } } diff --git a/WGDashboard/clientarea_ptBR.tpl b/WGDashboard/clientarea_ptBR.tpl new file mode 100644 index 0000000..31a8a17 --- /dev/null +++ b/WGDashboard/clientarea_ptBR.tpl @@ -0,0 +1,369 @@ +{if $error} +Escaneie este código QR com seu cliente WireGuard
+Configuração não disponível
+{$formatted_config|escape}
+ Configuração não disponível
+ {/if} +