@@ -44,7 +44,8 @@ class cpanelAPI
4444 protected $ eno ;
4545 protected $ emes ;
4646 protected $ token = FALSE ;
47-
47+ protected $ httpMethod = 'GET ' ;
48+ protected $ postData = '' ;
4849 /**
4950 * @param $user
5051 * @param $pass
@@ -75,6 +76,12 @@ protected function set2Fa()
7576 public function __get ($ name )
7677 {
7778 switch (strtolower ($ name )) {
79+ case 'get ' :
80+ $ this ->httpMethod = 'GET ' ;
81+ break ;
82+ case 'post ' :
83+ $ this ->httpMethod = 'POST ' ;
84+ break ;
7885 case 'api2 ' :
7986 $ this ->setApi ('api2 ' );
8087 break ;
@@ -168,10 +175,14 @@ protected function APIcall($name, $arguments)
168175 default :
169176 throw new Exception ('$this->api is not set or is incorrectly set. The only available options are \'uapi \' or \'api2 \'' );
170177 }
171- foreach ($ arguments as $ key => $ value ) {
172- $ this ->requestUrl .= $ key . "= " . urlencode ($ value ) . "& " ;
178+ if ($ this ->httpMethod == 'GET ' ) {
179+ $ this ->requestUrl .= http_build_query ($ arguments );
180+ }
181+ if ($ this ->httpMethod == 'POST ' ){
182+ $ this ->postData = http_build_query ($ arguments );
173183 }
174184
185+ print $ this ->postData ;
175186 return $ this ->curl_request ($ this ->requestUrl );
176187 }
177188
@@ -187,6 +198,10 @@ protected function curl_request($url)
187198 $ httpHeaders [] = "X-CPANEL-OTP: " . $ this ->token ;
188199 }
189200 $ ch = curl_init ();
201+ if ($ this ->httpMethod == 'POST ' ){
202+ $ httpHeaders [] = "Content-type: multipart/form-data " ;
203+ curl_setopt ($ ch ,CURLOPT_POSTFIELDS , $ this ->postData );
204+ }
190205 curl_setopt ($ ch , CURLOPT_SSL_VERIFYHOST , 0 );
191206 curl_setopt ($ ch , CURLOPT_SSL_VERIFYPEER , 0 );
192207 curl_setopt ($ ch , CURLOPT_HEADER , 0 );
0 commit comments