Hi im working on a autosignup script with remoting Has anyone any idea on howto create a co-domain with remoting ??
If I remember correctly the co-domain feature was never implemented So you might have to add also code in the server library.
Here is what I found at home, I can not guarantee that it works, nor that the patch still applies, but I hope it helps. Code: diff -U 3 -H -b -d -r -N -- classes_orig/ispconfig_web.lib.php classes/ispconfig_web.lib.php --- classes_orig/ispconfig_web.lib.php 2008-01-20 19:26:54.000000000 +0100 +++ classes/ispconfig_web.lib.php 2008-01-20 17:09:53.000000000 +0100 @@ -36,6 +36,7 @@ var $kunde_doctype_id = 1012; var $web_doctype_id = 1013; var $user_doctype_id = 1014; + var $domain_doctype_id = 1015; var $reseller_doctype_id = 1022; var $slave_doctype_id = 1028; var $datenbank_doctype_id = 1029; @@ -1845,6 +1847,64 @@ } + function domain_is_suspended($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters:domain_domain or domain_id are required.\r\n"; + return false; + } + + // Hole User ID + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + if($go_api->db->queryOneRecord("SELECT * FROM isp_nodes WHERE doc_id = '".$domain_id."' AND doctype_id = '".$this->domain_doctype_id."' AND status != '1'")){ + return true; + } else { + return false; + } + + } + + function domain_status_empty($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters:domain_domain or domain_id are required.\r\n"; + return false; + } + + // Hole User ID + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + if($go_api->db->queryOneRecord("SELECT * FROM isp_isp_domain WHERE doc_id = '".$domain_id."' AND status != ''")){ + return false; + } else { + return true; + } + + } + function datenbank_is_suspended($session,$params) { global $go_api, $go_info; @@ -1902,6 +1962,543 @@ } } + /* + ############################################################# + # Domains + ############################################################# + */ + + /* + Function: domain_list + Params: web_id oder web_title + Return: list of domains Array + */ + + function domain_list($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_query"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["web_title"]) && empty($params["web_id"])) { + $this->errorMessage .= "Parameters: web_title or web_id are required.\r\n"; + return false; + } + + // Hole Web ID + if(empty($params["web_id"])) { + $web_id = $this->web_get_id($session,$params); + } else { + $web_id = intval($params["web_id"]); + } + + if(empty($web_id)) { + $this->errorMessage .= "web_id cannot be resolved.\r\n"; + return false; + } + + $sql = "SELECT isp_isp_domain.* FROM isp_dep, isp_isp_domain WHERE isp_dep.parent_doc_id = $web_id AND isp_dep.parent_doctype_id = '".$this->web_doctype_id."' and isp_dep.child_doc_id = isp_isp_domain.doc_id and isp_dep.child_doctype_id = '".$this->domain_doctype_id."'"; + + // hole Domain + $domains = $go_api->db->queryAllRecords($sql); + + if(!empty($domains)){ + foreach($domains as $domain) { + $domain["domain_id"] = $domain["doc_id"]; + $out[$domain["domain_domain"]] = $domain; + + } + return $out; + } else { + $this->errorMessage .= "no records found\r\n"; + return false; + } + + } + + function domain_get_id($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_query"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + if(isset($params["domain_id"]) && !empty($params["domain_id"])) return intval($params["domain_id"]); + + // �berpr�fe Parameter + if(empty($params["domain_domain"])) { + $this->errorMessage .= "Parameter: domain_domain is required.\r\n"; + return false; + } + + // Hole Domain ID + $domain_host = addslashes($params["domain_host"]); + $domain_domain = addslashes($params["domain_domain"]); + + $this->debug("SELECT doc_id FROM isp_isp_domain WHERE domain_host = '$domain_host' AND domain_domain = '$domain_domain'"); + + if($domain = $go_api->db->queryOneRecord("SELECT doc_id FROM isp_isp_domain WHERE domain_host = '$domain_host' AND domain_domain = '$domain_domain'")){ + return $domain["doc_id"]; + } else { + return false; + } + + + } + + function domain_get($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_query"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters:domain_domain or domain_id are required.\r\n"; + return false; + } + + // Hole Domain ID + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + $domain = $go_api->db->queryOneRecord("SELECT * FROM isp_isp_domain WHERE doc_id = $domain_id"); + + // �berpr�fe, ob Domain gefunden wurde + if(!is_array($domain)) { + $this->errorMessage .= "no records found\r\n"; + return false; + } + + $domain["domain_id"] = $domain["doc_id"]; + $out = $domain; + + return $out; + } + + function domain_add($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_insert"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["web_title"]) && empty($params["web_id"])) { + $this->errorMessage .= "Parameters: web_title or web_id are required.\r\n"; + return false; + } + + // Hole Web ID + if(empty($params["web_id"])) { + $web_id = $this->web_get_id($session,$params); + } else { + $web_id = intval($params["web_id"]); + } + + if(empty($web_id)) { + $this->errorMessage .= "web_id cannot be resolved\r\n"; + return false; + } + + // �berpr�fe Parameter f�r Recor + if(!isset($params["domain_domain"])) $this->errorMessage .= "Parameter: domain_domain is required.\r\n"; + if(!isset($params["domain_ip"])) $this->errorMessage .= "Parameter: domain_ip is required.\r\n"; + + if($this->errorMessage != "") return false; + + if(empty($params["domain_local_mailserver"])) $params["domain_local_mailserver"] = 1; + + // Hole Daten zu Parent Record (Web) + $sql = "SELECT * FROM isp_nodes WHERE doc_id = $web_id and doctype_id = '".$this->web_doctype_id."'"; + $web_record = $go_api->db->queryOneRecord($sql); + $this->debug($sql); + + if(empty($web_record["userid"])) { + $this->errorMessage .= "web user cannot be resolved.\r\n"; + return false; + } + + // Checke ob Domain bereits existiert + $domain_id = $this->domain_get_id($session,$params); + if(!empty($domain_id)) { + $this->errorMessage .= "Domain: ".$params["domain_host"].".".$params["domain_domain"]." already exists\r\n"; + return false; + } + + // F�ge Domain ein + $sql = "INSERT INTO isp_isp_domain (doctype_id,domain_host,domain_dns,domain_dnsmail,domain_register,domain_weiterleitung,domain_domain,domain_ip,domain_local_mailserver) VALUES ('".$this->domain_doctype_id."','".addslashes($params["domain_host"])."','".addslashes($params["domain_dns"])."','".addslashes($params["domain_dnsmail"])."','".addslashes($params["domain_register"])."','".addslashes($params["domain_weiterleitung"])."','".addslashes($params["domain_domain"])."','".addslashes($params["domain_ip"])."','".addslashes($params["domain_local_mailserver"])."')"; + $go_api->db->query($sql); + $domain_id = $doc_id = $go_api->db->insertID(); + + // Node einf�gen + $sql = "INSERT INTO isp_nodes ( userid, groupid, parent, type, doctype_id, status, icon, modul, doc_id, title + ) VALUES ( + ".intval($web_record["userid"]).", + ".intval($web_record["groupid"]).", + '', + 'a', + '".$this->domain_doctype_id."', + '1', + '', + '', + $domain_id, + '' + )"; + + $go_api->db->query($sql); + $domain_tree_id = $go_api->db->insertID(); + + // DEP-Record einf�gen + $sql = "INSERT INTO isp_dep (userid, groupid, parent_doc_id, parent_doctype_id, parent_tree_id, child_doc_id, child_doctype_id, child_tree_id, status) + VALUES ( + ".intval($web_record["userid"]).", + ".intval($web_record["groupid"]).", + ".intval($web_record["doc_id"]).", + '".$this->web_doctype_id."', + ".intval($web_record["tree_id"]).", + $domain_id, + '".$this->domain_doctype_id."', + $domain_tree_id, + 1)"; + + $go_api->db->query($sql); + + ///////////////////////// + $go_api->uses('doc,auth,log'); + $go_info["user"]["licence"]["p"] = "42go_isp_pro"; + $go_info["user"]["perms"] = 'rw'; + $go_info["user"]["userid"] = 1; + $go_api->language = "en"; + + if(!$doc = $go_api->doc->doctype_get($this->domain_doctype_id)) $this->errorMessage .= $go_api->lng("error_doctype_nicht_vorhanden"); + + if($doc->event_class != "") { + $event_class = $doc->event_class; + + if(!class_exists($event_class)){ + $go_api->uses($doc->event_class); + } + + if($doc->event_insert != "") { + $event_insert = $doc->event_insert; + $this->errorMessage .= $go_api->$event_class->$event_insert($doc_id,$this->domain_doctype_id, 0); + } + + } + + ///////////////////////// + if($this->errorMessage != "") return false; + return $udomain_id; + + } + + function domain_update($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_update"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters:domain_domain or domain_id are required.\r\n"; + return false; + } + + // Hole Domain ID + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + // checke ob Domain schon existiert + $sql = "SELECT doc_id FROM isp_isp_domain where domain_host = '".addslashes($params["domain_host"])."' and domain_domain = '".addslashes($params["domain_domain"])."' and isp_isp_domain.doc_id != $domain_id"; + + $tmp = $go_api->db->queryOneRecord($sql); + if($tmp["doc_id"] > 0) { + $this->errorMessage .= "Domain alredy exists with other domain_id.\r\n"; + return false; + } + + // Liegt Objekt im Papierkorb? + if($this->domain_is_suspended($session,$params)){ + $this->errorMessage .= "This domain is suspended.\r\n"; + return false; + } + + // Ist Status-Feld leer (d.h., ist writeconf.php fertig)? + if(!$this->domain_status_empty($session,$params)){ + $this->errorMessage .= "Status field is not empty.\r\n"; + return false; + } + + $fields = $go_api->db->queryAllRecords("SHOW COLUMNS FROM isp_isp_domain"); + foreach($fields as $field){ + $field_arr[] = $field["Field"]; + } + + $changes = ""; + foreach($params as $key => $val){ + if($key != "domain_id" && $key != "doc_id" && $key != "doctype_id" && $key != "status" && in_array($key, $field_arr)) $changes .= $key." = '".addslashes($val)."',"; + } + $changes = substr($changes, 0, -1); + + $sql = "UPDATE isp_isp_udomain SET ".$changes." WHERE doc_id = ".$domain_id; + + if(!$go_api->db->query($sql)) $this->errorMessage .= "Database could not be updated.\r\n"; + if($this->errorMessage != '') return false; + + ///////////////////////// + $go_api->uses('doc,auth,log'); + $go_info["user"]["licence"]["p"] = "42go_isp_pro"; + $go_info["user"]["perms"] = 'rw'; + $go_info["user"]["userid"] = 1; + $go_api->language = "en"; + + if(!$doc = $go_api->doc->doctype_get($this->domain_doctype_id)) $this->errorMessage .= $go_api->lng("error_doctype_nicht_vorhanden"); + + if($doc->event_class != "") { + $event_class = $doc->event_class; + + if(!class_exists($event_class)){ + $go_api->uses($doc->event_class); + } + + if($doc->event_update != "") { + $event_update = $doc->event_update; + $this->errorMessage .= $go_api->$event_class->$event_update($domain_id,$this->domain_doctype_id, 0); + } + + } + + ///////////////////////// + if($this->errorMessage != "") return false; + + return $this->domain_get($session,$params); + + } + + function domain_suspend($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_update"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters: domain_domain or domain_id are required.\r\n"; + return false; + } + + // Hole Domain ID + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + if($this->domain_is_suspended($session,$params)) return true; + + // Ist Status-Feld leer (d.h., ist writeconf.php fertig)? + if(!$this->domain_status_empty($session,$params)){ + $this->errorMessage .= "Status field is not empty.\r\n"; + return false; + } + + // suspend durchf�hren + $sql = "UPDATE isp_nodes SET status = 0 WHERE doc_id = $domain_id and doctype_id = '".$this->domain_doctype_id."'"; + $go_api->db->query($sql); + + ///////////////////////// + $go_api->uses('doc,auth,log'); + $go_info["user"]["licence"]["p"] = "42go_isp_pro"; + $go_info["user"]["perms"] = 'rw'; + $go_info["user"]["userid"] = 1; + $go_api->language = "en"; + + if(!$doc = $go_api->doc->doctype_get($this->domain_doctype_id)) $this->errorMessage .= $go_api->lng("error_doctype_nicht_vorhanden"); + + if($doc->event_class != "") { + $event_class = $doc->event_class; + + if(!class_exists($event_class)){ + $go_api->uses($doc->event_class); + } + + if($doc->event_delete != "") { + $event_delete = $doc->event_delete; + $this->errorMessage .= $go_api->$event_class->$event_delete($domain_id,$this->domain_doctype_id, 'do', 0); + } + + } + ///////////////////////// + if($this->errorMessage != "") return false; + + return true; + } + + function domain_unsuspend($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_update"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters: domain_domain or domain_id are required.\r\n"; + return false; + } + + // Hole Domain ID + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + if(!$this->domain_is_suspended($session,$params)) return true; + + // Ist Status-Feld leer (d.h., ist writeconf.php fertig)? + if(!$this->domain_status_empty($session,$params)){ + $this->errorMessage .= "Status field is not empty.\r\n"; + return false; + } + + // unsuspend durchf�hren + $sql = "UPDATE isp_nodes SET status = 1 WHERE doc_id = $domain_id and doctype_id = '".$this->domain_doctype_id."'"; + $go_api->db->query($sql); + + ///////////////////////// + $go_api->uses('doc,auth,log'); + $go_info["user"]["licence"]["p"] = "42go_isp_pro"; + $go_info["user"]["perms"] = 'rw'; + $go_info["user"]["userid"] = 1; + $go_api->language = "en"; + + if(!$doc = $go_api->doc->doctype_get($this->domain_doctype_id)) $this->errorMessage .= $go_api->lng("error_doctype_nicht_vorhanden"); + + if($doc->event_class != "") { + $event_class = $doc->event_class; + + if(!class_exists($event_class)){ + $go_api->uses($doc->event_class); + } + + if($doc->event_delete != "") { + $event_delete = $doc->event_delete; + $this->errorMessage .= $go_api->$event_class->$event_delete($domain_id,$this->domain_doctype_id, 'undo', 0); + } + + } + ///////////////////////// + if($this->errorMessage != "") return false; + + return true; + } + + function domain_delete($session,$params) { + global $go_api, $go_info; + + // �berpr�fe Rechte + if($session["user"]["web_delete"] != 1) { + $this->errorMessage .= "method not allowed for user\r\n"; + return false; + } + + // �berpr�fe Parameter + if(empty($params["domain_domain"]) && empty($params["domain_id"])) { + $this->errorMessage .= "Parameters: domain_domain or domain_id are required.\r\n"; + return false; + } + + if(empty($params["domain_id"])) { + $domain_id = $this->domain_get_id($session,$params); + } else { + $domain_id = intval($params["domain_id"]); + } + if(empty($domain_id)) { + $this->errorMessage .= "domain_id cannot be resolved\r\n"; + return false; + } + + // Ist User suspended? + if(!$this->domain_is_suspended($session,$params)){ + $this->errorMessage .= "The record must be suspended before it can be deleted.\r\n"; + return false; + } + + // Ist Status-Feld leer (d.h., ist writeconf.php fertig)? + if(!$this->domain_status_empty($session,$params)){ + $this->errorMessage .= "Status field is not empty.\r\n"; + return false; + } + + // DELETE durchf�hren + $go_api->db->query("DELETE FROM isp_dep WHERE child_doc_id = '".$domain_id."' AND child_doctype_id = '".$this->domain_doctype_id."' AND parent_doctype_id = '".$this->web_doctype_id."'"); + $sql = "DELETE isp_nodes.*, isp_isp_domain.* FROM isp_nodes, isp_isp_domain WHERE isp_nodes.doc_id = '$domain_id' and isp_nodes.doctype_id = '".$this->domain_doctype_id."' and isp_nodes.status != '1' AND isp_nodes.doc_id = isp_isp_domain.doc_id AND isp_nodes.doctype_id = isp_isp_domain.doctype_id"; + return $go_api->db->query($sql); + } + } ?> \ No newline at end of file
and this in the Remoting script: Code: $params = array ( 'sid' => $session_id, 'module' => 'web', 'function' => 'domain_add', 'params' => array ( web_id => "$web_id", // web_title or web_id domain_host => "$my_hostname", domain_dns => '', domain_dnsmail => '', domain_register => '', domain_weiterleitung => "$my_path", domain_domain => "$my_domain_name", domain_ip => "$my_ip", domain_local_mailserver => 1));
Co-Domain with Forwarder Can this method be used to add a Co-Domain with a Forward URL? For example adding the Co-Domain "webmail" to the domain through the autosignup.php With the forwarding URL to: https://www.mydomain.com:81/roundcubemail I've tried different methods to do this but it's always weird, like not showing up in the ISPConfig panel correctly or some other funny stuff. I've been away for awhile but hopefully be able to add some development work soon. Also wanted to try out a fresh install of ispconfig 3 if they had an auto-account thing similar to the remoting framework. Still loving ISPConfig 2 on my personal servers. Thanks guys.