Skip to content

Commit de80445

Browse files
committed
initial commit
1 parent f1683b1 commit de80445

1,005 files changed

Lines changed: 123378 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.idea/
2+
docker/

README.md

Lines changed: 87 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,87 @@
1-
# Hostinger WHMCS Plugin
1+
# Hostinger WHMCS Plugin
2+
3+
Integrate Hostinger VPS/Cloud services directly into your WHMCS billing system. Automate provisioning, management, and billing with seamless API connectivity. 🚀
4+
5+
## ✨ Features
6+
7+
- **Automated VPS provisioning** - Purchase new VPS instances
8+
- **Real-time management** - Restart, reinstall, password changes
9+
- **Usage tracking** - Disk space and bandwidth monitoring
10+
- **Backup & snapshots** - Create, restore, and manage backups
11+
- **DNS management** - Set nameservers and PTR records
12+
- **Client area integration** - Full VPS control panel for end users
13+
14+
## 📋 Requirements
15+
16+
- WHMCS 8.0 or higher
17+
- PHP 8.1+
18+
- Hostinger account and API token
19+
20+
## 🚀 Getting Started
21+
22+
### 1. Get your Hostinger API token 🔑
23+
24+
1. Login to [hPanel](https://hpanel.hostinger.com)
25+
2. Navigate to `Account Information` section or [click here]( https://hpanel.hostinger.com/profile/api)
26+
3. Click on `API` menu item
27+
4. Click `New token` button
28+
5. Fill in information and click `Generate` button
29+
30+
*Tip: Store the token securely. You’ll paste it in WHMCS as the server Password.*
31+
32+
**Security Note**: Use dedicated API tokens for WHMCS integration. Rotate tokens regularly and revoke unused ones. 🔒
33+
34+
### 2. Installation 📦
35+
36+
1. Download the latest release:
37+
https://github.com/hostinger/api-whmcs-plugin/releases
38+
2. Upload archive folder contents to your WHMCS installation root directory.
39+
3. Login to WHMCS admin panel.
40+
4. Navigate to `Apps & Integrations`
41+
5. Click `Browse` button and select `VPS/Cloud` or enter `Hostinger` in search field.
42+
6. Click `Create New Server`
43+
44+
### 3. Server Configuration ⚙️
45+
46+
Fill in the following fields:
47+
- Module: `Hostinger`
48+
- Hostname: `developers.hostinger.com`
49+
- Username: `<leave empty>`
50+
- Password `<your API token>`
51+
- Access Hash: `<leave empty>`
52+
-
53+
Click `Test Connection` to verify setup, then `Save Changes`.
54+
55+
### 4. Product Setup 📋
56+
57+
1. Create a new product in WHMCS
58+
2. Set product type to `Server / VPS`
59+
3. Choose `Hostinger` as the module
60+
4. Configure the module settings:
61+
- **Plan**: Select from available VPS plans
62+
- **Datacenter**: Choose default location (optional)
63+
- **OS Template**: Set default operating system (optional)
64+
65+
66+
Now you can add Hostinger VPS products. Refer to [WHMCS documentation](https://docs.whmcs.com/8-13/products/product-tutorials/create-a-product/) for more information.
67+
68+
## 📚 Support
69+
70+
- **API Documentation**: [Hostinger Developer Docs](https://developers.hostinger.com)
71+
- **Report Issues**: [Create a GitHub Issue](https://github.com/hostinger/api-whmcs-plugin/issues/new)
72+
- **Get Support**: [Browse existing issues](https://github.com/hostinger/api-whmcs-plugin/issues) or open a new one
73+
74+
## 🤝 Contributing
75+
76+
We welcome contributions! Please:
77+
1. Fork the repository
78+
2. Create a feature branch
79+
3. Submit a pull request with clear description
80+
81+
## 📄 License
82+
83+
This module is provided under the MIT license. See [LICENSE](https://github.com/hostinger/api-whmcs-plugin/blob/main/LICENSE) file for details.
84+
85+
---
86+
87+

modules/servers/hostinger/ajax.php

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
require_once __DIR__ . '/functions.php';
6+
require_once __DIR__ . '/../../../init.php';
7+
require_once __DIR__ . '/../../../includes/functions.php';
8+
9+
use WHMCS\Database\Capsule;
10+
11+
// Start session if not already started
12+
if (session_status() == PHP_SESSION_NONE) {
13+
session_start();
14+
}
15+
16+
// Verify the request - check CSRF token
17+
$token = $_POST['token'] ?? '';
18+
$sessionToken = $_SESSION['tkval'] ?? '';
19+
20+
if (!$token || !$sessionToken || $token !== $sessionToken) {
21+
die(json_encode(['success' => false, 'error' => 'Invalid token']));
22+
}
23+
24+
$action = $_POST['action'] ?? '';
25+
$productId = intval($_POST['product_id'] ?? 0);
26+
$params = resolveServerFromProductId($productId);
27+
28+
function resolveServerFromProductId(int $productId): array
29+
{
30+
$product = Capsule::table('tblproducts')
31+
->where('id', $productId)
32+
->first();
33+
34+
if ($product && $product->servergroup) {
35+
// Get first active server from the server group
36+
$server = Capsule::table('tblservers')
37+
->where('servergroup', $product->servergroup)
38+
->where('active', '1')
39+
->where('type', 'hostinger')
40+
->first();
41+
}
42+
43+
if (!isset($server) || !$server) {
44+
$server = Capsule::table('tblservers')
45+
->where('type', 'hostinger')
46+
->where('active', '1')
47+
->first();
48+
}
49+
50+
return [
51+
'serverid' => $server->id,
52+
];
53+
}
54+
55+
switch ($action) {
56+
case 'getDataCenters':
57+
handleGetDataCenters($params);
58+
break;
59+
60+
case 'getTemplates':
61+
handleGetTemplates($params);
62+
break;
63+
64+
default:
65+
die(json_encode(['success' => false, 'error' => 'Invalid action']));
66+
}
67+
68+
function handleGetDataCenters(array $params): void
69+
{
70+
try {
71+
$data = hostinger_DataCenterLoader($params);
72+
73+
echo json_encode([
74+
'success' => true,
75+
'data' => $data
76+
]);
77+
78+
} catch (Exception $e) {
79+
echo json_encode([
80+
'success' => false,
81+
'error' => $e->getMessage()
82+
]);
83+
}
84+
}
85+
86+
function handleGetTemplates(array $params): void
87+
{
88+
try {
89+
$data = hostinger_OSTemplateLoader($params);
90+
91+
echo json_encode([
92+
'success' => true,
93+
'data' => $data
94+
]);
95+
96+
} catch (Exception $e) {
97+
echo json_encode([
98+
'success' => false,
99+
'error' => $e->getMessage()
100+
]);
101+
}
102+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "hostinger/hostinger-whmcs-module",
3+
"description": "A WHMCS server module for Hostinger that enables service provisioning and management through the Hostinger API",
4+
"type": "project",
5+
"require": {
6+
"php": "^8.2",
7+
"hostinger/api-php-sdk": "^0.0.41"
8+
},
9+
"license": "MIT",
10+
"minimum-stability": "beta"
11+
}

0 commit comments

Comments
 (0)