Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #14

Merged
merged 2 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ jobs:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4' # Adjust the PHP version as needed

- name: Install Composer dependencies
run: composer install --no-progress --no-suggest --prefer-dist --optimize-autoloader

- name: Set up version file
id: setup_version
run: |
Expand Down
75 changes: 42 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,56 @@
# WHMCS Sample Provisioning Module #
## WHMCS

## Summary ##
WHMCS Module for the [Easy Panel](https://github.com/easypanel-io).

Provisioning Modules, also referred to as Product or Server Modules, allow you
to create modules that allow for the provisioning and management of products &
services in WHMCS.

The sample files here demonstrates how a provisioning module for WHMCS should
be structured and exercises all supported functionality.
## Configuration support

For more information, please refer to the documentation at:
https://developers.whmcs.com/provisioning-modules/
Please use the [EasyPanel Discord](https://discord.gg/SARw8nbpnZ) for configuration related support instead of GitHub issues.

## Recommended Module Content ##

The recommended structure of a provisioning module is as follows.
## Installation

```
provisioningmodule/
|- lib/
|- templates/
|- tests/
| hooks.php
| logo.png
| provisioningmodule.php
```

## Minimum Requirements ##
1. Download/Git clone this repository.
2. Move the ``easypanel/`` folder into ``<path to whmcs>/modules/servers/``.
3. Login to your Easypanel and Navigate to Settings > Users
4. Click ``Generate API Key``
5. Copy the API key by clicking the Clipboard Icon
4. In WHMCS 8+ navigate to System Settings → Servers. In WHMCS 7 or below navigate to Setup → Products/Services → Servers
5. Create new server, fill the name with anything you want, hostname as the url to the panel either as an IP or domain. For example: ``123.123.123.123`` or ``my.easypanel.com``
6. Change Server Type to EasyPanel, leave username empty, fill the password field with your generated API Key.
7. Tick the "Secure" option if your panel is using SSL.
8. Confirm that everything works by clicking the Test Connection button -> Save Changes.
9. Go back to the Servers screen and press Create New Group, name it anything you want and choose the created server and press the Add button, Save Changes.
10. Navigate to Setup > Products/Services > Products/Services
11. Create your desired product (and product group if you haven't already) with the type of Other and product name of anything -> Continue.
12. Click the Module Settings tab, choose for Module Name EasyPanel and for the Server Group the group you created in step 8.
13. Fill all non-optional fields, and you are good to go!

For the latest WHMCS minimum system requirements, please refer to
https://docs.whmcs.com/System_Requirements
## Credits

We recommend your module follows the same minimum requirements wherever
possible.
[Andrei](https://github.com/deiucanta) and [Mateus](https://github.com/mateuslacorte) involved in development of the Easy Panel and the WHMCS Module.

## Tests ##

We strongly encourage you to write unit tests for your work. Within this SDK we
provide a sample unit test based upon the widely used PHPUnit.
# FAQ

## Useful Resources
* [Developer Resources](https://developers.whmcs.com/)
* [Hook Documentation](https://developers.whmcs.com/hooks/)
* [API Documentation](https://developers.whmcs.com/api/)
## Overwriting values through configurable options

[WHMCS Limited](https://www.whmcs.com)
Overwriting values can be done through either Configurable Options or Custom Fields.

Their name should be exactly what you want to overwrite.
Valid options: ``id, service``

This also works for any name of environment variables

Useful trick: You can use the | seperator to change the display name of the variable like this:
service|Application => Will be displayed as "Application" but will work correctly.



## How to enable module debug log

1. In WHMCS 7 or below navigate to Utilities > Logs > Module Log. For WHMCS 8.x navigate to System Logs > Module Log in the left sidebar.
2. Click the Enable Debug Logging button.
3. Do the action that failed again and you will have required logs to debug the issue. All 404 errors can be ignored.
4. Remember to Disable Debug Logging if you are using this in production, as it's not recommended to have it enabled.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.0.0
1.0.2
3 changes: 1 addition & 2 deletions easypanel.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,8 @@ function ($table) {
} catch (\Exception $e) {
echo "Unable to create my_table: {$e->getMessage()}";
}
$clientId = $_SESSION['uid'] ?? throw new Exception('Client not logged in or not in client area.');
$client = Capsule::table('tblclients')
->where('id', $clientId)
->where('id', $params['userid'])
->first(['uuid']);
$clientId = $client->uuid;
$sdk = new EasyPanelSDK($params['configoption1'], $params['configoption2']);
Expand Down
6 changes: 6 additions & 0 deletions sdk.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<?php

require_once __DIR__ . '/vendor/autoload.php';

use Ramsey\Uuid\Uuid;
use WHMCS\Database\Capsule;
use Hackzilla\PasswordGenerator\Generator\ComputerPasswordGenerator;

class EasyPanelSDK {

function __construct($apiUrl, $authorizationToken) {
Expand Down
Loading