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
|
<?php
/**
* @package zpanelx
* @subpackage modules
* @author Bobby Allen (ballen@zpanelcp.com)
* @copyright ZPanel Project (http://www.zpanelcp.com/)
* @link http://www.zpanelcp.com/
* @license GPL (http://www.gnu.org/licenses/gpl.html)
*/
class webservice extends ws_xmws {
/**
* Get the full list of currently active domains on the server.
* @global type $zdbh
* @return type
*/
public function GetAllDomains() {
global $zdbh;
$response_xml = "\n";
$alldomains = module_controller::ListDomains();
foreach ($alldomains as $domain) {
$response_xml = $response_xml . ws_xmws::NewXMLContentSection('domain', array(
'id' => $domain['id'],
'uid' => $domain['uid'],
'domain' => $domain['name'],
'homedirectory' => $domain['directory'],
'active' => $domain['active'],
));
}
$dataobject = new runtime_dataobject();
$dataobject->addItemValue('response', '');
$dataobject->addItemValue('content', $response_xml);
return $dataobject->getDataObject();
}
/**
* Gets a list of all the domains that a user has configured on their hosting account (the user id needs to be sent in the <content> tag).
* @global type $zdbh
* @return type
*/
public function GetDomainsForUser() {
global $zdbh;
$request_data = $this->RawXMWSToArray($this->wsdata);
$response_xml = "\n";
$alldomains = module_controller::ListDomains($request_data['content']);
if (!fs_director::CheckForEmptyValue($alldomains)) {
foreach ($alldomains as $domain) {
$response_xml = $response_xml . ws_xmws::NewXMLContentSection('domain', array(
'id' => $domain['id'],
'uid' => $domain['uid'],
'domain' => $domain['name'],
'homedirectory' => $domain['directory'],
'active' => $domain['active'],
));
}
}
$dataobject = new runtime_dataobject();
$dataobject->addItemValue('response', '');
$dataobject->addItemValue('content', $response_xml);
return $dataobject->getDataObject();
}
/**
* Enables an authenticated user to create a domain on their hosting account.
* @return type
*/
public function CreateDomain() {
$request_data = $this->RawXMWSToArray($this->wsdata);
$dataobject = new runtime_dataobject();
$dataobject->addItemValue('response', '');
if (module_controller::ExecuteAddDomain(ws_generic::GetTagValue('uid', $request_data['content']), ws_generic::GetTagValue('domain', $request_data['content']), ws_generic::GetTagValue('destination', $request_data['content']), ws_generic::GetTagValue('autohome', $request_data['content']))) {
$dataobject->addItemValue('content', ws_xmws::NewXMLTag('domain', ws_generic::GetTagValue('domain', $request_data['content'])) . ws_xmws::NewXMLTag('created', 'true'));
} else {
$dataobject->addItemValue('content', ws_xmws::NewXMLTag('domain', ws_generic::GetTagValue('domain', $request_data['content'])) . ws_xmws::NewXMLTag('created', 'false'));
}
return $dataobject->getDataObject();
}
/**
* Delete a specified domain using the content <domainid> tag to pass the domain DB ID through.
* @return type
*/
public function DeleteDomain() {
$request_data = $this->RawXMWSToArray($this->wsdata);
$contenttags = $this->XMLDataToArray($request_data['content']);
$dataobject = new runtime_dataobject();
$dataobject->addItemValue('response', '');
if (module_controller::ExecuteDeleteDomain($contenttags['domainid'])) {
$dataobject->addItemValue('content', ws_xmws::NewXMLTag('domainid', $contenttags['domainid']) . ws_xmws::NewXMLTag('deleted', 'true'));
} else {
$dataobject->addItemValue('content', ws_xmws::NewXMLTag('domainid', $contenttags['domainid']) . ws_xmws::NewXMLTag('deleted', 'false'));
}
return $dataobject->getDataObject();
}
}
?>
|