diff --git a/helper_scripts/dns_export_to_bind.php b/helper_scripts/dns_export_to_bind.php
index 9ce662bf44b49ce0ff7f45b156e6314c748bb3cd..56628d77c12f86f33b541d9326df7d035a4fec91 100644
--- a/helper_scripts/dns_export_to_bind.php
+++ b/helper_scripts/dns_export_to_bind.php
@@ -1,72 +1,72 @@
-0)
- {
- $arr3[$xx1]=$arr2[$xx1].$row2['2']." ".$row2['3']."\n";
- }
- else
- {
- $arr3[$xx1]=$arr2[$xx1].$row2['3']."\n";
- }
- $xx1=$xx1+1;
- }
- $f = fopen("/var/cache/bind/$varx11", "a+");
- foreach($arr3 as $values) fputs($f, $values);
- fclose($f);
- $arr2=array();
- $arr3=array();
-### ENDE Primärer Nameserver ###########################################################################################################
-
-### Hier ALLES Aktivieren bei Secondary Nameserver ######################################################################################
-# $tmp1 = substr($row["ns"],0,-1);
-# $tmp2 = substr($row["origin"],0,-1);
-# $nsip = hostname2ipfunktion($tmp1);
-# if ($nsip == $tmp1) # {
-# echo "$tmp2 $tmp1 Not a valid Nameserver";
-# echo "\n";
-# }
-# else # {
-# $arr1[$x11]="zone \"".$tmp2."\" in { type slave; file \"".$tmp2."\"; masters {".$nsip."; }; };\n";
-# $x11=$x11+1;
-# }
-### ENDE Secondary Nameserver ###########################################################################################################
- }
-
-unlink ("/etc/bind/named.conf.local");
-$fx = fopen("/etc/bind/named.conf.local", "a+");
-foreach($arr1 as $values) fputs($fx, $values);
-fclose($fx);
-exec("/etc/init.d/bind9 reload");
+0)
+ {
+ $arr3[$xx1]=$arr2[$xx1].$row2['2']." ".$row2['3']."\n";
+ }
+ else
+ {
+ $arr3[$xx1]=$arr2[$xx1].$row2['3']."\n";
+ }
+ $xx1=$xx1+1;
+ }
+ $f = fopen("/var/cache/bind/$varx11", "a+");
+ foreach($arr3 as $values) fputs($f, $values);
+ fclose($f);
+ $arr2=array();
+ $arr3=array();
+### ENDE Primärer Nameserver ###########################################################################################################
+
+### Hier ALLES Aktivieren bei Secondary Nameserver ######################################################################################
+# $tmp1 = substr($row["ns"],0,-1);
+# $tmp2 = substr($row["origin"],0,-1);
+# $nsip = hostname2ipfunktion($tmp1);
+# if ($nsip == $tmp1) # {
+# echo "$tmp2 $tmp1 Not a valid Nameserver";
+# echo "\n";
+# }
+# else # {
+# $arr1[$x11]="zone \"".$tmp2."\" in { type slave; file \"".$tmp2."\"; masters {".$nsip."; }; };\n";
+# $x11=$x11+1;
+# }
+### ENDE Secondary Nameserver ###########################################################################################################
+ }
+
+unlink ("/etc/bind/named.conf.local");
+$fx = fopen("/etc/bind/named.conf.local", "a+");
+foreach($arr1 as $values) fputs($fx, $values);
+fclose($fx);
+exec("/etc/init.d/bind9 reload");
?>
\ No newline at end of file
diff --git a/interface/lib/classes/remoting.inc.php b/interface/lib/classes/remoting.inc.php
index 07b28f36f4eef9ec8718228129df2a8dda23479e..7e4256e9c2bb929c6d643e40ad8b25070091f324 100644
--- a/interface/lib/classes/remoting.inc.php
+++ b/interface/lib/classes/remoting.inc.php
@@ -1,7 +1,7 @@
checkPerm($session_id, 'client_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../client/form/client.tform.php');
+ return $app->remoting_lib->getDataRecord($client_id);
+ }
+
+
+ public function client_add($session_id, $reseller_id, $params)
{
if (!$this->checkPerm($session_id, 'client_add'))
{
$this->server->fault('permission_denied','You do not have the permissions to access this function.');
return false;
}
- $affected_rows = $this->klientadd('../client/form/client.tform.php',$domain_id, $client_id, $params);
+ $affected_rows = $this->klientadd('../client/form/client.tform.php',$reseller_id, $params);
return $affected_rows;
}
+
+ public function client_update($session_id, $reseller_id, $client_id, $params)
+ {
+ global $app;
+
+ if (!$this->checkPerm($session_id, 'client_update'))
+ {
+ $this->server->fault('permission_denied','You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../client/form/client.tform.php', $reseller_id, $client_id, $params);
+
+ $app->remoting_lib->ispconfig_sysuser_update($params,$client_id);
+
+ return $affected_rows;
+ }
+ public function client_delete($session_id,$client_id)
+ {
+ global $app;
+
+ if (!$this->checkPerm($session_id, 'client_delete'))
+ {
+ $this->server->fault('permission_denied','You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../client/form/client.tform.php',$client_id);
+
+ $app->remoting_lib->ispconfig_sysuser_delete($client_id);
+
+ return $affected_rows;
+ }
+
+ // Website functions ---------------------------------------------------------------------------------------
+
+ //* Get cron details
+ public function sites_cron_get($session_id, $cron_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_cron_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/cron.tform.php');
+ return $app->remoting_lib->getDataRecord($cron_id);
+ }
+
+ //* Add a cron record
+ public function sites_cron_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_cron_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/cron.tform.php',$client_id,$params);
+ }
+
+ //* Update cron record
+ public function sites_cron_update($session_id, $client_id, $cron_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_cron_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/cron.tform.php',$client_id,$cron_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete cron record
+ public function sites_cron_delete($session_id, $cron_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_cron_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/cron.tform.php',$cron_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_database_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_database_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/database.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_database_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_database_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/database.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function sites_database_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_database_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/database.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_database_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_database_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/database.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_ftp_user_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_ftp_user_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/ftp_user.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_ftp_user_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_ftp_user_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/ftp_user.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function sites_ftp_user_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_ftp_user_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/ftp_user.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_ftp_user_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_ftp_user_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/ftp_user.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_shell_user_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_shell_user_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/shell_user.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_shell_user_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_shell_user_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/shell_user.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function sites_shell_user_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_shell_user_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/shell_user.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_shell_user_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_shell_user_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/shell_user.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_web_domain_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_web_domain_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/web_domain.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_web_domain_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_domain_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/web_domain.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function sites_web_domain_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_domain_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/web_domain.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_web_domain_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_domain_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/web_domain.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // -----------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_web_aliasdomain_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/web_aliasdomain.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_web_aliasdomain_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/web_aliasdomain.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function sites_web_aliasdomain_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/web_aliasdomain.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_web_aliasdomain_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_aliasdomain_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/web_aliasdomain.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function sites_web_subdomain_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../sites/form/web_subdomain.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function sites_web_subdomain_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../sites/form/web_subdomain.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function sites_web_subdomain_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../sites/form/web_subdomain.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function sites_web_subdomain_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'sites_web_subdomain_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../sites/form/web_subdomain.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+
+ // DNS Function --------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_zone_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_zone_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_soa.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_zone_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_zone_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_soa.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_zone_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_zone_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_soa.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_zone_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_zone_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_soa.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_aaaa_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_aaaa_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_aaaa.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_aaaa_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_aaaa_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_aaaa.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_aaaa_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_aaaa_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_aaaa.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_aaaa_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_aaaa_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_aaaa.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_a_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_a_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_a.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_a_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_a_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_a.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_a_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_a_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_a.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_a_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_a_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_a.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_alias_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_alias_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_alias.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_alias_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_alias_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_alias.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_alias_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_alias_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_alias.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_alias_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_alias_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_alias.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_cname_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_cname_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_cname.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_cname_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_cname_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_cname.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_cname_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_cname_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_cname.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_cname_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_cname_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_cname.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_hinfo_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_hinfo_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_hinfo.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_hinfo_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_hinfo_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_hinfo.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_hinfo_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_hinfo_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_hinfo.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_hinfo_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_hinfo_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_hinfo.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_mx_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_mx_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_mx.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_mx_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_mx_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_mx.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_mx_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_mx_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_mx.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_mx_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_mx_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_mx.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_ns_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_ns_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_ns.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_ns_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_ns_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_ns.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_ns_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_ns_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_ns.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_ns_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_ns_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_ns.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_ptr_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_ptr_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_ptr.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_ptr_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_ptr_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_ptr.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_ptr_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_ptr_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_ptr.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_ptr_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_ptr_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_ptr.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_rp_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_rp_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_rp.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_rp_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_rp_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_rp.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_rp_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_rp_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_rp.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_rp_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_rp_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_rp.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_srv_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_srv_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_srv.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_srv_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_srv_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_srv.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_srv_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_srv_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_srv.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_srv_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_srv_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_srv.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ //* Get record details
+ public function dns_txt_get($session_id, $primary_id)
+ {
+ global $app;
+
+ if(!$this->checkPerm($session_id, 'dns_txt_get')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $app->uses('remoting_lib');
+ $app->remoting_lib->loadFormDef('../dns/form/dns_txt.tform.php');
+ return $app->remoting_lib->getDataRecord($primary_id);
+ }
+
+ //* Add a record
+ public function dns_txt_add($session_id, $client_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_txt_add')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ return $this->insertQuery('../dns/form/dns_txt.tform.php',$client_id,$params);
+ }
+
+ //* Update a record
+ public function dns_txt_update($session_id, $client_id, $primary_id, $params)
+ {
+ if(!$this->checkPerm($session_id, 'dns_txt_update')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->updateQuery('../dns/form/dns_txt.tform.php',$client_id,$primary_id,$params);
+ return $affected_rows;
+ }
+
+ //* Delete a record
+ public function dns_txt_delete($session_id, $primary_id)
+ {
+ if(!$this->checkPerm($session_id, 'dns_txt_delete')) {
+ $this->server->fault('permission_denied', 'You do not have the permissions to access this function.');
+ return false;
+ }
+ $affected_rows = $this->deleteQuery('../dns/form/dns_txt.tform.php',$primary_id);
+ return $affected_rows;
+ }
+
+
+
+
+
+
+
+
+
+
@@ -892,7 +1860,7 @@ class remoting {
- private function klientadd($formdef_file, $client_id, $params)
+ private function klientadd($formdef_file, $reseller_id, $params)
{
global $app, $tform, $remoting_lib;
$app->uses('remoting_lib');
@@ -901,7 +1869,7 @@ class remoting {
$app->remoting_lib->loadFormDef($formdef_file);
//* load the user profile of the client
- $app->remoting_lib->loadUserProfile($client_id);
+ $app->remoting_lib->loadUserProfile($reseller_id);
//* Get the SQL query
$sql = $app->remoting_lib->getSQL($params,'INSERT',0);
@@ -926,7 +1894,7 @@ class remoting {
$new_rec = $app->remoting_lib->getDataRecord($insert_id);
$app->remoting_lib->datalogSave('INSERT',$primary_id,array(),$new_rec);
- $app->remoting_lib->dodaj_usera($params,$insert_id);
+ $app->remoting_lib->ispconfig_sysuser_add($params,$insert_id);
}
diff --git a/interface/lib/classes/remoting_lib.inc.php b/interface/lib/classes/remoting_lib.inc.php
index a85b8feeed0998fc5ef5934daadbd6adbfe092fc..f5b88a5f6ec9f8145c49ebd5211f7a7a08a13174 100644
--- a/interface/lib/classes/remoting_lib.inc.php
+++ b/interface/lib/classes/remoting_lib.inc.php
@@ -1,731 +1,748 @@
-formDef = $form;
- unset($this->formDef['tabs']);
-
- //* Copy all fields from all tabs into one form definition
- foreach($form['tabs'] as $tab) {
- foreach($tab['fields'] as $key => $value) {
- $this->formDef['fields'][$key] = $value;
- }
- }
- unset($form);
-
- return true;
- }
-
- //* Load the user profile
- function loadUserProfile($client_id = 0) {
- global $app,$conf;
-
- $client_id = intval($client_id);
-
- if($client_id == 0) {
- $this->sys_username = 'admin';
- $this->sys_userid = 1;
- $this->sys_default_group = 1;
- $this->sys_groups = 1;
- } else {
- //* Load the client data
- $client = $app->db->queryOneRecord("SELECT username FROM client WHERE client_id = $client_id");
- if($client["username"] == '') {
- $this->errorMessage .= 'No client with ID $client_id found.';
- return false;
- }
- //* load system user
- $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = '".$app->db->quote($client["username"])."'");
- if(empty($user["userid"])) {
- $this->errorMessage .= 'No user with the username '.$client['username'].' found.';
- return false;
- }
- $this->sys_username = $user['username'];
- $this->sys_userid = $user['userid'];
- $this->sys_default_group = $user['default_group'];
- $this->sys_groups = $user['groups'];
- }
-
- return true;
-
- }
-
-
- /**
- * Converts data in human readable form
- *
- * @param record
- * @return record
- */
- function decode($record) {
- $new_record = '';
- if(is_array($record)) {
- foreach($this->formDef['fields'] as $key => $field) {
- switch ($field['datatype']) {
- case 'VARCHAR':
- $new_record[$key] = stripslashes($record[$key]);
- break;
-
- case 'TEXT':
- $new_record[$key] = stripslashes($record[$key]);
- break;
-
- case 'DATE':
- if($record[$key] > 0) {
- $new_record[$key] = date($this->dateformat,$record[$key]);
- }
- break;
-
- case 'INTEGER':
- $new_record[$key] = intval($record[$key]);
- break;
-
- case 'DOUBLE':
- $new_record[$key] = $record[$key];
- break;
-
- case 'CURRENCY':
- $new_record[$key] = number_format($record[$key], 2, ',', '');
- break;
-
- default:
- $new_record[$key] = stripslashes($record[$key]);
- }
- }
-
- }
-
- return $new_record;
- }
-
- /**
- * Get the key => value array of a form filled from a datasource definitiom
- *
- * @param field = array with field definition
- * @param record = Dataset as array
- * @return key => value array for the value field of a form
- */
-
- function getDatasourceData($field, $record) {
- global $app;
-
- $values = array();
-
- if($field["datasource"]["type"] == 'SQL') {
-
- // Preparing SQL string. We will replace some
- // common placeholders
- $querystring = $field["datasource"]["querystring"];
- $querystring = str_replace("{USERID}",$this->sys_userid,$querystring);
- $querystring = str_replace("{GROUPID}",$this->sys_default_group,$querystring);
- $querystring = str_replace("{GROUPS}",$this->sys_groups,$querystring);
- $table_idx = $this->formDef['db_table_idx'];
-
- $tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0;
- $querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring);
- unset($tmp_recordid);
-
- $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring);
-
- // Getting the records
- $tmp_records = $app->db->queryAllRecords($querystring);
- if($app->db->errorMessage != '') die($app->db->errorMessage);
- if(is_array($tmp_records)) {
- $key_field = $field["datasource"]["keyfield"];
- $value_field = $field["datasource"]["valuefield"];
- foreach($tmp_records as $tmp_rec) {
- $tmp_id = $tmp_rec[$key_field];
- $values[$tmp_id] = $tmp_rec[$value_field];
- }
- }
- }
-
- if($field["datasource"]["type"] == 'CUSTOM') {
- // Calls a custom class to validate this record
- if($field["datasource"]['class'] != '' and $field["datasource"]['function'] != '') {
- $datasource_class = $field["datasource"]['class'];
- $datasource_function = $field["datasource"]['function'];
- $app->uses($datasource_class);
- $values = $app->$datasource_class->$datasource_function($field, $record);
- } else {
- $this->errorMessage .= "Custom datasource class or function is empty
\r\n";
- }
- }
-
- return $values;
-
- }
-
- /**
- * Converts the data in a format to store it in the database table
- *
- * @param record = Datensatz als Array
- * @return record
- */
- function encode($record) {
-
- if(is_array($record)) {
- foreach($this->formDef['fields'] as $key => $field) {
-
- if(isset($field['validators']) && is_array($field['validators'])) $this->validateField($key, (isset($record[$key]))?$record[$key]:'', $field['validators']);
-
- switch ($field['datatype']) {
- case 'VARCHAR':
- if(!@is_array($record[$key])) {
- $new_record[$key] = (isset($record[$key]))?mysql_real_escape_string($record[$key]):'';
- } else {
- $new_record[$key] = implode($field['separator'],$record[$key]);
- }
- break;
- case 'TEXT':
- if(!is_array($record[$key])) {
- $new_record[$key] = mysql_real_escape_string($record[$key]);
- } else {
- $new_record[$key] = implode($field['separator'],$record[$key]);
- }
- break;
- case 'DATE':
- if($record[$key] > 0) {
- list($tag,$monat,$jahr) = explode('.',$record[$key]);
- $new_record[$key] = mktime(0,0,0,$monat,$tag,$jahr);
- } else {
- $new_record[$key] = 0;
- }
- break;
- case 'INTEGER':
- $new_record[$key] = (isset($record[$key]))?intval($record[$key]):0;
- //if($new_record[$key] != $record[$key]) $new_record[$key] = $field['default'];
- //if($key == 'refresh') die($record[$key]);
- break;
- case 'DOUBLE':
- $new_record[$key] = mysql_real_escape_string($record[$key]);
- break;
- case 'CURRENCY':
- $new_record[$key] = str_replace(",",".",$record[$key]);
- break;
- }
-
- // The use of the field value is deprecated, use validators instead
- if(isset($field['regex']) && $field['regex'] != '') {
- // Enable that "." matches also newlines
- $field['regex'] .= 's';
- if(!preg_match($field['regex'], $record[$key])) {
- $errmsg = $field['errmsg'];
- $this->errorMessage .= $errmsg."\r\n";
- }
- }
-
-
- }
- }
- return $new_record;
- }
-
- /**
- * process the validators for a given field.
- *
- * @param field_name = Name of the field
- * @param field_value = value of the field
- * @param validatoors = Array of validators
- * @return record
- */
-
- function validateField($field_name, $field_value, $validators) {
-
- global $app;
-
- $escape = '`';
-
- // loop trough the validators
- foreach($validators as $validator) {
-
- switch ($validator['type']) {
- case 'REGEX':
- $validator['regex'] .= 's';
- if(!preg_match($validator['regex'], $field_value)) {
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- break;
- case 'UNIQUE':
- if($this->action == 'NEW') {
- $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."'");
- if($num_rec["number"] > 0) {
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- } else {
- $num_rec = $app->db->queryOneRecord("SELECT count(*) as number FROM ".$escape.$this->formDef['db_table'].$escape. " WHERE $field_name = '".$app->db->quote($field_value)."' AND ".$this->formDef['db_table_idx']." != ".$this->primary_id);
- if($num_rec["number"] > 0) {
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- }
- break;
- case 'NOTEMPTY':
- if(empty($field_value)) {
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- break;
- case 'ISEMAIL':
- if(!preg_match("/^\w+[\w.-]*\w+@\w+[\w.-]*\w+\.[a-z]{2,10}$/i", $field_value)) {
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- break;
- case 'ISINT':
- $tmpval = intval($field_value);
- if($tmpval === 0 and !empty($field_value)) {
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- break;
- case 'ISPOSITIVE':
- if(!is_numeric($field_value) || $field_value <= 0){
- $errmsg = $validator['errmsg'];
- if(isset($this->wordbook[$errmsg])) {
- $this->errorMessage .= $this->wordbook[$errmsg]."
\r\n";
- } else {
- $this->errorMessage .= $errmsg."
\r\n";
- }
- }
- break;
- case 'CUSTOM':
- // Calls a custom class to validate this record
- if($validator['class'] != '' and $validator['function'] != '') {
- $validator_class = $validator['class'];
- $validator_function = $validator['function'];
- $app->uses($validator_class);
- $this->errorMessage .= $app->$validator_class->$validator_function($field_name, $field_value, $validator);
- } else {
- $this->errorMessage .= "Custom validator class or function is empty
\r\n";
- }
- break;
- default:
- $this->errorMessage .= "Unknown Validator: ".$validator['type'];
- break;
- }
-
-
- }
-
- return true;
- }
-
- /**
- * Create SQL statement
- *
- * @param record = Datensatz als Array
- * @param action = INSERT oder UPDATE
- * @param primary_id
- * @return record
- */
- function getSQL($record, $action = 'INSERT', $primary_id = 0, $sql_ext_where = '') {
-
- global $app;
-
- $this->action = $action;
- $this->primary_id = $primary_id;
-
- $record = $this->encode($record,$tab);
- $sql_insert_key = '';
- $sql_insert_val = '';
- $sql_update = '';
-
- if(!is_array($this->formDef)) $app->error("No form definition found.");
-
- // gehe durch alle Felder des Tabs
- if(is_array($record)) {
- foreach($this->formDef['fields'] as $key => $field) {
- // Wenn es kein leeres Passwortfeld ist
- if (!($field['formtype'] == 'PASSWORD' and $record[$key] == '')) {
- // Erzeuge Insert oder Update Quelltext
- if($action == "INSERT") {
- if($field['formtype'] == 'PASSWORD') {
- $sql_insert_key .= "`$key`, ";
- if($field['encryption'] == 'CRYPT') {
- $salt="$1$";
- for ($n=0;$n<8;$n++) {
- $salt.=chr(mt_rand(64,126));
- }
- $salt.="$";
- // $salt = substr(md5(time()),0,2);
- $record[$key] = crypt($record[$key],$salt);
- } else {
- $record[$key] = md5($record[$key]);
- }
- $sql_insert_val .= "'".$record[$key]."', ";
- } elseif ($field['formtype'] == 'CHECKBOX') {
- $sql_insert_key .= "`$key`, ";
- if($record[$key] == '') {
- // if a checkbox is not set, we set it to the unchecked value
- $sql_insert_val .= "'".$field['value'][0]."', ";
- $record[$key] = $field['value'][0];
- } else {
- $sql_insert_val .= "'".$record[$key]."', ";
- }
- } else {
- $sql_insert_key .= "`$key`, ";
- $sql_insert_val .= "'".$record[$key]."', ";
- }
- } else {
- if($field['formtype'] == 'PASSWORD') {
- if($field['encryption'] == 'CRYPT') {
- $salt="$1$";
- for ($n=0;$n<8;$n++) {
- $salt.=chr(mt_rand(64,126));
- }
- $salt.="$";
- // $salt = substr(md5(time()),0,2);
- $record[$key] = crypt($record[$key],$salt);
- } else {
- $record[$key] = md5($record[$key]);
- }
- $sql_update .= "`$key` = '".$record[$key]."', ";
- } elseif ($field['formtype'] == 'CHECKBOX') {
- if($record[$key] == '') {
- // if a checkbox is not set, we set it to the unchecked value
- $sql_update .= "`$key` = '".$field['value'][0]."', ";
- $record[$key] = $field['value'][0];
- } else {
- $sql_update .= "`$key` = '".$record[$key]."', ";
- }
- } else {
- $sql_update .= "`$key` = '".$record[$key]."', ";
- }
- }
- } else {
- // we unset the password filed, if empty to tell the datalog function
- // that the password has not been changed
- unset($record[$key]);
- }
- }
- }
-
-
-
- if(stristr($this->formDef['db_table'],'.')) {
- $escape = '';
- } else {
- $escape = '`';
- }
-
-
- if($action == "INSERT") {
- if($this->formDef['auth'] == 'yes') {
- // Setze User und Gruppe
- $sql_insert_key .= "`sys_userid`, ";
- $sql_insert_val .= ($this->formDef["auth_preset"]["userid"] > 0)?"'".$this->formDef["auth_preset"]["userid"]."', ":"'".$this->sys_userid."', ";
- $sql_insert_key .= "`sys_groupid`, ";
- $sql_insert_val .= ($this->formDef["auth_preset"]["groupid"] > 0)?"'".$this->formDef["auth_preset"]["groupid"]."', ":"'".$this->sys_default_group."', ";
- $sql_insert_key .= "`sys_perm_user`, ";
- $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_user"]."', ";
- $sql_insert_key .= "`sys_perm_group`, ";
- $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_group"]."', ";
- $sql_insert_key .= "`sys_perm_other`, ";
- $sql_insert_val .= "'".$this->formDef["auth_preset"]["perm_other"]."', ";
- }
- $sql_insert_key = substr($sql_insert_key,0,-2);
- $sql_insert_val = substr($sql_insert_val,0,-2);
- $sql = "INSERT INTO ".$escape.$this->formDef['db_table'].$escape." ($sql_insert_key) VALUES ($sql_insert_val)";
- } else {
- if($primary_id != 0) {
- $sql_update = substr($sql_update,0,-2);
- $sql = "UPDATE ".$escape.$this->formDef['db_table'].$escape." SET ".$sql_update." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
- if($sql_ext_where != '') $sql .= " and ".$sql_ext_where;
- } else {
- $app->error("Primary ID fehlt!");
- }
- }
-
- return $sql;
- }
-
- function getDeleteSQL($primary_id) {
-
- if(stristr($this->formDef['db_table'],'.')) {
- $escape = '';
- } else {
- $escape = '`';
- }
-
- $sql = "DELETE FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
- return $sql;
- }
-
-
- function getDataRecord($primary_id) {
- global $app;
- $escape = '`';
- if(@is_numeric($primary_id)) {
- $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$this->formDef['db_table_idx']." = ".$primary_id;
- return $app->db->queryOneRecord($sql);
- } elseif (@is_array($primary_id)) {
- $sql_where = '';
- foreach($primary_id as $key => $val) {
- $key = $app->db->quote($key);
- $val = $app->db->quote($val);
- $sql_where .= "$key = '$val' AND ";
- }
- $sql_where = substr($sql_where,0,-5);
- $sql = "SELECT * FROM ".$escape.$this->formDef['db_table'].$escape." WHERE ".$sql_where;
- return $app->db->queryAllRecords($sql);
- } else {
- $this->errorMessage = 'The ID must be either an integer or an array.';
- return array();
- }
-
-
- }
-
- function dodaj_usera($params,$insert_id){
- global $app,$sql1;
- $username = $params["username"];
- $password = $params["password"];
- $modules = 'mail,sites,dns,tools';
- $startmodule = 'mail';
- $usertheme = $params["usertheme"];
- $type = 'user';
- $active = 1;
- $language = $params["language"];
- $groupid = $app->db->datalogInsert('sys_group', "(name,description,client_id) VALUES ('$username','','$insert_id')", 'groupid');
- $groups = $groupid;
- $sql1 = "INSERT INTO sys_user (username,passwort,modules,startmodule,app_theme,typ,active,language,groups,default_group,client_id)
- VALUES ('$username',md5('$password'),'$modules','$startmodule','$usertheme','$type','$active','$language',$groups,$groupid,$insert_id)";
- $app->db->query($sql1);
- }
-
- function datalogSave($action,$primary_id, $record_old, $record_new) {
- global $app,$conf;
-
- if(stristr($this->formDef['db_table'],'.')) {
- $escape = '';
- } else {
- $escape = '`';
- }
-
- $diffrec = array();
-
- if(is_array($record_new) && count($record_new) > 0) {
- foreach($record_new as $key => $val) {
- if($record_old[$key] != $val) {
- // Record has changed
- $diffrec[$key] = array('old' => $record_old[$key],
- 'new' => $val);
- }
- }
- } elseif(is_array($record_old)) {
- foreach($record_old as $key => $val) {
- if($record_new[$key] != $val) {
- // Record has changed
- $diffrec[$key] = array('new' => $record_new[$key],
- 'old' => $val);
- }
- }
- }
- $this->diffrec = $diffrec;
-
-
- // Full diff records for ISPConfig, they have a different format then the simple diffrec
- $diffrec_full = array();
-
- if(is_array($record_old) && count($record_old) > 0) {
- foreach($record_old as $key => $val) {
- if(isset($record_new[$key]) && $record_new[$key] != $val) {
- // Record has changed
- $diffrec_full['old'][$key] = $val;
- $diffrec_full['new'][$key] = $record_new[$key];
- } else {
- $diffrec_full['old'][$key] = $val;
- $diffrec_full['new'][$key] = $val;
- }
- }
- } elseif(is_array($record_new)) {
- foreach($record_new as $key => $val) {
- if(isset($record_new[$key]) && $record_old[$key] != $val) {
- // Record has changed
- $diffrec_full['new'][$key] = $val;
- $diffrec_full['old'][$key] = $record_old[$key];
- } else {
- $diffrec_full['new'][$key] = $val;
- $diffrec_full['old'][$key] = $val;
- }
- }
- }
-
- /*
- echo "
"; - print_r($diffrec_full); - echo ""; - */ - - // Insert the server_id, if the record has a server_id - $server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0; - if(isset($record_new["server_id"])) $server_id = $record_new["server_id"]; - - if(count($this->diffrec) > 0) { - $diffstr = $app->db->quote(serialize($diffrec_full)); - $username = $app->db->quote($this->sys_username); - $dbidx = $this->formDef['db_table_idx'].":".$primary_id; - // $action = ($action == 'INSERT')?'i':'u'; - - if($action == 'INSERT') $action = 'i'; - if($action == 'UPDATE') $action = 'u'; - if($action == 'DELETE') $action = 'd'; - $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$this->formDef['db_table']."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')"; - $app->db->query($sql); - } - - return true; - - } - -} - -?> +formDef = $form; + unset($this->formDef['tabs']); + + //* Copy all fields from all tabs into one form definition + foreach($form['tabs'] as $tab) { + foreach($tab['fields'] as $key => $value) { + $this->formDef['fields'][$key] = $value; + } + } + unset($form); + + return true; + } + + //* Load the user profile + function loadUserProfile($client_id = 0) { + global $app,$conf; + + $client_id = intval($client_id); + + if($client_id == 0) { + $this->sys_username = 'admin'; + $this->sys_userid = 1; + $this->sys_default_group = 1; + $this->sys_groups = 1; + } else { + //* Load the client data + $client = $app->db->queryOneRecord("SELECT username FROM client WHERE client_id = $client_id"); + if($client["username"] == '') { + $this->errorMessage .= 'No client with ID $client_id found.'; + return false; + } + //* load system user + $user = $app->db->queryOneRecord("SELECT * FROM sys_user WHERE username = '".$app->db->quote($client["username"])."'"); + if(empty($user["userid"])) { + $this->errorMessage .= 'No user with the username '.$client['username'].' found.'; + return false; + } + $this->sys_username = $user['username']; + $this->sys_userid = $user['userid']; + $this->sys_default_group = $user['default_group']; + $this->sys_groups = $user['groups']; + } + + return true; + + } + + + /** + * Converts data in human readable form + * + * @param record + * @return record + */ + function decode($record) { + $new_record = ''; + if(is_array($record)) { + foreach($this->formDef['fields'] as $key => $field) { + switch ($field['datatype']) { + case 'VARCHAR': + $new_record[$key] = stripslashes($record[$key]); + break; + + case 'TEXT': + $new_record[$key] = stripslashes($record[$key]); + break; + + case 'DATE': + if($record[$key] > 0) { + $new_record[$key] = date($this->dateformat,$record[$key]); + } + break; + + case 'INTEGER': + $new_record[$key] = intval($record[$key]); + break; + + case 'DOUBLE': + $new_record[$key] = $record[$key]; + break; + + case 'CURRENCY': + $new_record[$key] = number_format($record[$key], 2, ',', ''); + break; + + default: + $new_record[$key] = stripslashes($record[$key]); + } + } + + } + + return $new_record; + } + + /** + * Get the key => value array of a form filled from a datasource definitiom + * + * @param field = array with field definition + * @param record = Dataset as array + * @return key => value array for the value field of a form + */ + + function getDatasourceData($field, $record) { + global $app; + + $values = array(); + + if($field["datasource"]["type"] == 'SQL') { + + // Preparing SQL string. We will replace some + // common placeholders + $querystring = $field["datasource"]["querystring"]; + $querystring = str_replace("{USERID}",$this->sys_userid,$querystring); + $querystring = str_replace("{GROUPID}",$this->sys_default_group,$querystring); + $querystring = str_replace("{GROUPS}",$this->sys_groups,$querystring); + $table_idx = $this->formDef['db_table_idx']; + + $tmp_recordid = (isset($record[$table_idx]))?$record[$table_idx]:0; + $querystring = str_replace("{RECORDID}",$tmp_recordid,$querystring); + unset($tmp_recordid); + + $querystring = str_replace("{AUTHSQL}",$this->getAuthSQL('r'),$querystring); + + // Getting the records + $tmp_records = $app->db->queryAllRecords($querystring); + if($app->db->errorMessage != '') die($app->db->errorMessage); + if(is_array($tmp_records)) { + $key_field = $field["datasource"]["keyfield"]; + $value_field = $field["datasource"]["valuefield"]; + foreach($tmp_records as $tmp_rec) { + $tmp_id = $tmp_rec[$key_field]; + $values[$tmp_id] = $tmp_rec[$value_field]; + } + } + } + + if($field["datasource"]["type"] == 'CUSTOM') { + // Calls a custom class to validate this record + if($field["datasource"]['class'] != '' and $field["datasource"]['function'] != '') { + $datasource_class = $field["datasource"]['class']; + $datasource_function = $field["datasource"]['function']; + $app->uses($datasource_class); + $values = $app->$datasource_class->$datasource_function($field, $record); + } else { + $this->errorMessage .= "Custom datasource class or function is empty
"; + print_r($diffrec_full); + echo ""; + */ + + // Insert the server_id, if the record has a server_id + $server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0; + if(isset($record_new["server_id"])) $server_id = $record_new["server_id"]; + + if(count($this->diffrec) > 0) { + $diffstr = $app->db->quote(serialize($diffrec_full)); + $username = $app->db->quote($this->sys_username); + $dbidx = $this->formDef['db_table_idx'].":".$primary_id; + // $action = ($action == 'INSERT')?'i':'u'; + + if($action == 'INSERT') $action = 'i'; + if($action == 'UPDATE') $action = 'u'; + if($action == 'DELETE') $action = 'd'; + $sql = "INSERT INTO sys_datalog (dbtable,dbidx,server_id,action,tstamp,user,data) VALUES ('".$this->formDef['db_table']."','$dbidx','$server_id','$action','".time()."','$username','$diffstr')"; + $app->db->query($sql); + } + + return true; + + } + +} + +?> diff --git a/interface/web/admin/form/remote_user.tform.php b/interface/web/admin/form/remote_user.tform.php index ad5b561f08661d9ca7163817d422cbde227bed48..d89cccfd3b8bc79b6e2079f3a4c6acd36a39345a 100644 --- a/interface/web/admin/form/remote_user.tform.php +++ b/interface/web/admin/form/remote_user.tform.php @@ -33,35 +33,42 @@ */ -$lista_funkcji = array(); -$lista_funkcji['mail_domain_get,mail_domain_add,mail_domain_update,mail_domain_delete'] = 'Mail domain functions