Skip to content

Commit 6e3c7ed

Browse files
committed
Adding extra remote API functions
1 parent 52e900e commit 6e3c7ed

File tree

3 files changed

+193
-0
lines changed

3 files changed

+193
-0
lines changed

interface/lib/classes/remote.d/dns.inc.php

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,65 @@ public function dns_zone_set_status($session_id, $primary_id, $status) {
882882
}
883883
}
884884

885+
// ----------------------------------------------------------------------------------------------------------------
886+
887+
//* Get record by name / Useful for Dynamic DNS
888+
public function dns_a_get_by_name($session_id, $params)
889+
{
890+
global $app;
891+
892+
if(!$this->checkPerm($session_id, 'dns_a_get')) {
893+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
894+
return false;
895+
}
896+
897+
if(!empty($params)) {
898+
$zone = $app->functions->intval($params['zone']);
899+
$name = $params['name'];
900+
$sql = "SELECT id, zone, name, type, data, active FROM dns_rr WHERE zone = ? AND name = ? ";
901+
$result = $app->db->queryOneRecord($sql,$zone,$name);
902+
return $result;
903+
904+
}
905+
return false;
906+
}
907+
908+
// Get master zone by ispconfig client id
909+
public function dns_zone_get_status_by_user($session_id, $client_id, $server_id) {
910+
global $app;
911+
if(!$this->checkPerm($session_id, 'dns_zone_get')) {
912+
$this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
913+
return false;
914+
}
915+
916+
if (!empty($client_id)) {
917+
$server_id = $app->functions->intval($server_id);
918+
$client_id = $app->functions->intval($client_id);
919+
$sql = "SELECT id, origin, d.active FROM dns_soa d INNER JOIN sys_user s on (d.sys_groupid = s.default_group) WHERE client_id = ? AND server_id = ? ORDER BY origin ASC";
920+
$result = $app->db->queryAllRecords($sql, $client_id, $server_id);
921+
return $result;
922+
}
923+
return false;
924+
}
925+
926+
// Get slave zone by ispconfig client id
927+
public function dnz_zone_get_slave_by_user($session_id, $client_id, $server_id){
928+
global $app;
929+
if(!$this->checkPerm($session_id, 'dns_zone_get')) {
930+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
931+
return false;
932+
}
933+
934+
if (!empty($client_id)) {
935+
$server_id = $app->functions->intval($server_id);
936+
$client_id = $app->functions->intval($client_id);
937+
$sql = "SELECT d.id, d.origin, d.ns, d.active FROM dns_slave d INNER JOIN sys_user s on (d.sys_groupid = s.default_group) WHERE client_id = ? AND server_id = ? ORDER BY origin ASC";
938+
$result = $app->db->queryAllRecords($sql, $client_id, $server_id);
939+
return $result;
940+
}
941+
return false;
942+
}
943+
885944
}
886945

887946
?>

interface/lib/classes/remote.d/mail.inc.php

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,84 @@ public function mailquota_get_by_user($session_id, $client_id)
11041104

11051105
return $app->quota_lib->get_mailquota_data($client_id, false);
11061106
}
1107+
1108+
// ----------------------------------------------------------------------------------------------------------------
1109+
1110+
1111+
// Get domain zone by ispconfig id
1112+
public function mail_domain_get_by_user($session_id, $client_id)
1113+
{
1114+
global $app;
1115+
1116+
if(!$this->checkPerm($session_id, 'mail_domain_get')) {
1117+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1118+
return false;
1119+
}
1120+
1121+
if (!empty($client_id)) {
1122+
$client_id = $app->functions->intval($client_id);
1123+
$sql = "SELECT domain_id, domain, m.active, m.server_id, svr.server_name FROM mail_domain m INNER JOIN sys_user s on(m.sys_groupid = s.default_group) INNER JOIN server AS svr ON (m.server_id = svr.server_id) WHERE client_id = ? ORDER BY domain ASC";
1124+
$result = $app->db->queryAllRecords($sql, $client_id);
1125+
return $result;
1126+
}
1127+
return false;
1128+
}
1129+
1130+
// Get email by ispconfig client id
1131+
public function mail_users_get_by_user($session_id, $client_id, $domain)
1132+
{
1133+
global $app;
1134+
1135+
if(!$this->checkPerm($session_id, 'mail_user_get')) {
1136+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1137+
return false;
1138+
}
1139+
1140+
if (!empty($client_id)) {
1141+
$client_id = $app->functions->intval($client_id);
1142+
$sql = "SELECT mailuser_id, email, cc, quota, server_id, postfix as active FROM mail_user m INNER JOIN sys_user s on(m.sys_groupid = s.default_group) WHERE client_id = ? AND email LIKE ? ORDER BY email ASC";
1143+
$result = $app->db->queryAllRecords($sql,$client_id, '%@'.$domain);
1144+
return $result;
1145+
}
1146+
return false;
1147+
}
11071148

1149+
// Get alias or forward by ispconfig client id
1150+
public function mail_fw_alias_get_by_user($session_id, $client_id, $domain)
1151+
{
1152+
global $app;
1153+
1154+
if(!$this->checkPerm($session_id, 'mail_user_get')) {
1155+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1156+
return false;
1157+
}
1158+
1159+
if (!empty($client_id) ) {
1160+
$client_id = $app->functions->intval($client_id);
1161+
$sql = "SELECT forwarding_id, source, destination, type, m.active FROM mail_forwarding m INNER JOIN sys_user s on(m.sys_groupid = s.default_group) WHERE client_id = ? AND source LIKE ? ORDER BY type ASC, source ASC" ;
1162+
$result = $app->db->queryAllRecords($sql, $client_id, '%@'.$domain);
1163+
return $result;
1164+
}
1165+
return false;
1166+
}
1167+
1168+
// Get email id by email
1169+
public function mail_user_get_by_email($session_id, $email)
1170+
{
1171+
global $app;
1172+
1173+
if(!$this->checkPerm($session_id, 'mail_user_get')) {
1174+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1175+
return false;
1176+
}
1177+
1178+
if (!empty($email)) {
1179+
$sql = "SELECT mailuser_id FROM mail_user WHERE email = ?";
1180+
$result = $app->db->queryOneRecord($sql, $email);
1181+
return $result["mailuser_id"];
1182+
}
1183+
return false;
1184+
}
11081185
}
11091186

11101187
?>

interface/lib/classes/remote.d/sites.inc.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,64 @@ public function databasequota_get_by_user($session_id, $client_id)
10081008
return $app->quota_lib->get_databasequota_data($client_id, false);
10091009
}
10101010

1011+
// ----------------------------------------------------------------------------------------------------------------
1012+
1013+
// Get ftp user by ispconfig client id and site id
1014+
public function sites_web_ftp_get_by_id($session_id, $client_id, $parent_domain_id)
1015+
{
1016+
global $app;
1017+
1018+
if(!$this->checkPerm($session_id, 'sites_ftp_user_get')) {
1019+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1020+
return false;
1021+
}
1022+
1023+
if (!empty($client_id) ) {
1024+
$client_id = $app->functions->intval($client_id);
1025+
$parent_domain_id = $app->functions->intval($parent_domain_id);
1026+
$sql = "SELECT ftp_user_id, f.username, f.active FROM ftp_user f INNER JOIN sys_user s on(f.sys_groupid = s.default_group) WHERE client_id = ? AND parent_domain_id = ? ORDER BY f.username ASC" ;
1027+
$result = $app->db->queryAllRecords($sql,$client_id, $parent_domain_id);
1028+
return $result;
1029+
}
1030+
return false;
1031+
}
10111032

1033+
// Get site by ispconfig client id
1034+
public function sites_web_domain_get_by_id($session_id, $client_id)
1035+
{
1036+
global $app;
1037+
1038+
if(!$this->checkPerm($session_id, 'sites_web_domain_get')) {
1039+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1040+
return false;
1041+
}
1042+
1043+
if (!empty($client_id) ) {
1044+
$client_id = $app->functions->intval($client_id);
1045+
$sql = "SELECT w.domain_id, w.domain, w.type, w.hd_quota, w.active, w.parent_domain_id, svr.server_name FROM web_domain w INNER JOIN sys_user AS s ON(w.sys_groupid = s.default_group) INNER JOIN server AS svr ON (w.server_id = svr.server_id) WHERE s.client_id = ? ORDER BY domain ASC" ;
1046+
$result = $app->db->queryAllRecords($sql,$client_id);
1047+
return $result;
1048+
}
1049+
return false;
1050+
}
1051+
1052+
// Get id website by name
1053+
public function website_get_id_by_name($session_id, $params)
1054+
{
1055+
global $app;
1056+
1057+
if(!$this->checkPerm($session_id, 'sites_web_domain_get')) {
1058+
throw new SoapFault('permission_denied', 'You do not have the permissions to access this function.');
1059+
return false;
1060+
}
1061+
if(!empty($params)) {
1062+
$sql = "SELECT domain_id FROM web_domain WHERE domain = ?";
1063+
$result = $app->db->queryOneRecord($sql, $params);
1064+
return $result;
1065+
1066+
}
1067+
return false;
1068+
}
10121069
}
10131070

10141071
?>

0 commit comments

Comments
 (0)