-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathapi.php
122 lines (111 loc) · 3.73 KB
/
api.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
<?php
/*
* API Wrapper for Cyberpanel
* by @jetchirag
*/
class CyberApi
{
private function callUrl($params, $url)
{
return (($params["serversecure"]) ? "https" : "http"). "://".$params["serverhostname"].":". $params['serverport'] ."/api/".$url;
}
private function call_cyberpanel($params,$url,$post = array())
{
$call = curl_init();
curl_setopt($call, CURLOPT_URL, $this->callUrl($params,$url));
curl_setopt($call, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
curl_setopt($call, CURLOPT_RETURNTRANSFER, true);
curl_setopt($call, CURLOPT_POST, true);
curl_setopt($call, CURLOPT_POSTFIELDS, json_encode($post));
curl_setopt($call, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($call, CURLOPT_SSL_VERIFYPEER, false);
// Fire api
$result = curl_exec($call);
$info = curl_getinfo($call);
curl_close($call);
$result = json_decode($result,true);
// Return data
return $result;
}
public function create_new_account($params)
{
$url = "createWebsite";
$postParams =
[
"adminUser" => $params["serverusername"],
"adminPass" => $params["serverpassword"],
"domainName" => $params["domain"],
"ownerEmail" => $params["clientsdetails"]["email"],
"packageName" => $params['configoption1'],
"websiteOwner" => $params["username"],
"ownerPassword" => $params["password"],
"acl" => $params['configoption2'],
];
$result = $this->call_cyberpanel($params, $url, $postParams);
return $result;
}
public function change_account_status($params)
{
$url = "submitWebsiteStatus";
$postParams =
[
"adminUser" => $params["serverusername"],
"adminPass" => $params["serverpassword"],
"websiteName" => $params["domain"],
"state" => $params["status"],
];
$result = $this->call_cyberpanel($params, $url, $postParams);
return $result;
}
// Test connection
public function verify_connection($params)
{
$url = "verifyConn";
$postParams =
[
"adminUser" => $params["serverusername"],
"adminPass" => $params["serverpassword"],
];
$result = $this->call_cyberpanel($params, $url, $postParams);
return $result;
}
public function terminate_account($params)
{
$url = "deleteWebsite";
$postParams =
[
"adminUser" => $params["serverusername"],
"adminPass" => $params["serverpassword"],
"domainName"=> $params["domain"]
];
$result = $this->call_cyberpanel($params, $url, $postParams);
return $result;
}
public function change_account_password($params)
{
$url = "changeUserPassAPI";
$postParams =
[
"adminUser" => $params["serverusername"],
"adminPass" => $params["serverpassword"],
"websiteOwner"=> $params["username"],
"ownerPassword"=> $params["password"]
];
$result = $this->call_cyberpanel($params, $url, $postParams);
return $result;
}
public function change_account_package($params)
{
$url = "changePackageAPI";
$postParams =
[
"adminUser" => $params["serverusername"],
"adminPass" => $params["serverpassword"],
"websiteName"=> $params["domain"],
"packageName"=> $params['configoption1']
];
$result = $this->call_cyberpanel($params, $url, $postParams);
return $result;
}
}
?>