diff --git a/.gitignore b/.gitignore index 3ce5adb..7fb7980 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .idea vendor +/nbproject/private/ \ No newline at end of file diff --git a/nbproject/project.properties b/nbproject/project.properties new file mode 100644 index 0000000..67f7bd3 --- /dev/null +++ b/nbproject/project.properties @@ -0,0 +1,7 @@ +include.path=${php.global.include.path} +php.version=PHP_72 +source.encoding=UTF-8 +src.dir=. +tags.asp=false +tags.short=false +web.root=. diff --git a/nbproject/project.xml b/nbproject/project.xml new file mode 100644 index 0000000..a644d9b --- /dev/null +++ b/nbproject/project.xml @@ -0,0 +1,9 @@ + + + org.netbeans.modules.php.project + + + Wrapper + + + diff --git a/src/Http/HttpClient.php b/src/Http/HttpClient.php index fc95e00..daaf601 100644 --- a/src/Http/HttpClient.php +++ b/src/Http/HttpClient.php @@ -109,7 +109,7 @@ class HttpClient implements HttpClientInterface { private function processResponse() { $this->responseMessage = json_decode($this->response->getBody()->getContents()); // TODO delete var_dump. - var_dump($this->responseMessage); + // var_dump($this->responseMessage); ("deleted" var dump as per TODO) if ($this->responseMessage->status == "success") return true; return false; } diff --git a/src/Managers/Server/VirtualServerManager.php b/src/Managers/Server/VirtualServerManager.php index fe6ddb9..699773b 100644 --- a/src/Managers/Server/VirtualServerManager.php +++ b/src/Managers/Server/VirtualServerManager.php @@ -111,6 +111,42 @@ class VirtualServerManager extends BaseManager implements VirtualServerManagerIn return $this->httpClient->sendRequest(); } + + /** + * + * Creates a Virtual Server (Not an alias). + * Might be missing two params. + * This method is the same as the CreateSubserver, but without the alias arg. Can overload original method. + * + * @param string $domain The new domain + * @param string $password The password + * @param string $description The description + * @param array $options Any other needed options + * @return bool True if success, false otherwise + */ + public function createServer(string $domain, string $password, string $description, array $options = array()): bool { + + // sets all necessary params + $this->httpClient->queryStringBuilder()->addParameter("program", "create-domain"); + $this->httpClient->queryStringBuilder()->addParameter("domain", $domain); + $this->httpClient->queryStringBuilder()->addParameter("password", $password); + $this->httpClient->queryStringBuilder()->addParameter("desc", $description); + + // fetches each element inside the options array, in order to feed them to string builder, that then is used to make the URL + foreach ($options as $key => $value) { + if (is_numeric($key)) { + $this->httpClient->queryStringBuilder()->addParameter($value); + } else { + $this->httpClient->queryStringBuilder()->addParameter($key, $value); + } + } + + // web and dir can be specified inside options. + + return $this->httpClient->sendRequest(); + + + } /** * Retrieving single virtual server. diff --git a/src/Managers/Server/VirtualServerManagerInterface.php b/src/Managers/Server/VirtualServerManagerInterface.php index 6d1c205..2484f53 100644 --- a/src/Managers/Server/VirtualServerManagerInterface.php +++ b/src/Managers/Server/VirtualServerManagerInterface.php @@ -39,6 +39,19 @@ interface VirtualServerManagerInterface { */ public function createSubServer(string $domain, string $parentDomain, string $description, array $options = []) : bool; + + /** + * Create a new Virtual Server. + * + * @param string $domain The new domain name. + * @param string $password The user's password. + * @param string $description The server's description + * @param array $options Additional options for the server's creation, expressed in an array. + * @return bool True on completion, false on error + * + */ + public function createServer(string $domain, string $password, string $description, array $options = []) : bool; + /** * Creates Virtual Server alias. *