Repository navigation
Expand file tree
/
Copy pathpathnet_module.php
More file actions
99 lines (82 loc) · 2.82 KB
/
Copy pathpathnet_module.php
File metadata and controls
99 lines (82 loc) · 2.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
if (!defined("WHMCS")) {
die("Direct access not allowed.");
}
function pathnet_module_config() {
return [
'name' => 'PathNet Module',
'description' => 'Module to manage PathNet in the Client Area.',
'version' => '1.0',
'author' => 'Hostealo.es',
'language' => 'spanish',
];
}
function pathnet_module_activate() {
return [
'status' => 'success',
'description' => 'PathNet Module activated successfully.',
];
}
function pathnet_module_deactivate() {
return [
'status' => 'success',
'description' => 'PathNet Module deactivated successfully.',
];
}
function pathnet_module_clientarea($vars) {
$clientId = isset($_SESSION['uid']) ? (int) $_SESSION['uid'] : 0;
$services = [];
if ($clientId) {
$command = 'GetClientsProducts';
$postData = [
'clientid' => $clientId,
'stats' => true,
];
$results = localAPI($command, $postData);
if ($results['result'] === 'success') {
$ipSet = [];
foreach ($results['products']['product'] as $prod) {
if (strtolower($prod['status']) !== 'active') {
continue;
}
$hostname = !empty($prod['domain']) ? $prod['domain'] : 'No hostname';
if (!empty($prod['dedicatedip'])) {
$ip = trim($prod['dedicatedip']);
if (strpos($ip, '45') === 0 && !isset($ipSet[$ip])) {
$services[] = ['ip' => $ip, 'hostname' => $hostname];
$ipSet[$ip] = true;
}
}
if (!empty($prod['assignedips'])) {
$extraIps = explode(',', $prod['assignedips']);
foreach ($extraIps as $ipVal) {
$ip = trim($ipVal);
if (strpos($ip, '45') === 0 && !isset($ipSet[$ip])) {
$services[] = ['ip' => $ip, 'hostname' => $hostname];
$ipSet[$ip] = true;
}
}
}
}
}
}
$language = $_SESSION['Language'];
$availableLanguages = ['spanish', 'english'];
if (!in_array($language, $availableLanguages)) {
$language = 'english';
}
include __DIR__ . '/lang/' . $language . '.php';
return [
'pagetitle' => 'Firewall Management - Path.net',
'breadcrumb' => [
'index.php?m=pathnet_module' => 'PathNet Module',
],
'templatefile' => 'overview',
'requirelogin' => true,
'vars' => [
'services' => $services,
'clientId' => $clientId,
'langModule' => $_ADDONLANG,
],
];
}