-
Notifications
You must be signed in to change notification settings - Fork 0
/
hooks.php
82 lines (77 loc) · 3.1 KB
/
hooks.php
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
<?php
/**
* DomainRegister Account Status Widget
*
* Documentation: https://github.com/DomainRegister/
*
* Copyright (c) PERSOLVO doo 2020
*
*/
add_hook('AdminHomeWidgets', 1, function() {
return new DomainRegisterWidgetasHook();
});
/**
* Sample Registrar Module Admin Dashboard Widget.
*
* @see https://developers.whmcs.com/addon-modules/admin-dashboard-widgets/
*/
class DomainRegisterWidgetasHook extends \WHMCS\Module\AbstractWidget
{
protected $title = 'DomainRegister Account Overview';
protected $description = 'v. 1.0';
protected $weight = 150;
protected $columns = 1;
protected $cache = false;
protected $cacheExpiry = 120;
protected $requiredPermission = '';
public function getData()
{
return array();
}
public function generateOutput($data)
{ require_once __DIR__ . '/../../../includes/registrarfunctions.php';
$params = getRegistrarConfigOptions('DomainRegister');
$data = array(
"action" => "CreditAmount",
"token" => $params['api_key'],
"authemail" => $params['api_email']
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://domainregister.international/domainsResellerAPI/api.php");
curl_setopt($ch, CURLOPT_TIMEOUT, 30);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
$result = array();
$result['response_body'] = curl_exec($ch);
$result['info'] = curl_getinfo($ch);
$curlHeaderSize = $result['info']['header_size'];
$result['headers'] = substr($result['response_body'], 0, $curlHeaderSize);
$result['response_body'] = substr($result['response_body'], $curlHeaderSize);
$res= json_decode($result['response_body'],true);
$balance=$res["value"];
curl_close($ch);
$logo_url = "https://domainregister.international/templates/dr3/assets/images/dr-logo.svg";
return (
'<div class="widget-billing">' .
'<div class="row" style="display: flex; flex-wrap: wrap; align-items: center;">' .
'<div class="col-sm-6 bordered-right">' .
'<div class="item text-right">' .
'<div class="data color-' . ($balance >= 100 ? "green" : "pink") . '"> € ' .
$balance .
'</div>' .
'<div class="note">Account Balance</div>' .
'</div>' .
'</div>' .
'<div class="col-sm-6 bordered-right">' .
($stats ? $stats : '<div class="text-center"><img src="' . $logo_url . '" width="125" height="40"/></div>') .
'</div>' .
'</div>' .
'</div>'
);
}
}