@@ -99,6 +99,8 @@ public function login () {
9999 return false ;
100100 }
101101
102+ error_log ("Login Ticket: {$ login_ticket }" );
103+
102104 $ login_ticket_data = json_decode ($ login_ticket , true );
103105 if ($ login_ticket_data == null || $ login_ticket_data ['data ' ] == null ) {
104106 // Login failed.
@@ -169,7 +171,6 @@ private function action ($action_path, $http_method, $put_post_parameters = null
169171
170172 // Prepare cURL resource.
171173 $ prox_ch = curl_init ();
172- curl_setopt ($ prox_ch , CURLOPT_URL , "https:// {$ this ->hostname }: {$ this ->port }/api2/json {$ action_path }" );
173174
174175 $ put_post_http_headers = array ();
175176 $ put_post_http_headers [] = "CSRFPreventionToken: {$ this ->login_ticket ['CSRFPreventionToken ' ]}" ;
@@ -180,18 +181,21 @@ private function action ($action_path, $http_method, $put_post_parameters = null
180181 // request method was GET, but that doesn't seem to be the case any
181182 // longer, so we need to build them into the query string ourselves.
182183 $ action_postfields_string = http_build_query ($ put_post_parameters );
183- $ action_path .= (strpos ($ action_path , '? ' ) === FALSE ? '? ' : '& ' ) . $ action_postfields_string ;
184+ if ((strpos ($ action_path , '? ' ) === FALSE ) {
185+ $ action_path .= '? ' . $ action_postfields_string ;
186+ } else {
187+ $ action_path .= '& ' . $ action_postfields_string ;
188+ }
184189 unset($ action_postfields_string );
185-
186190 break ;
187191 case "PUT " :
188- curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "PUT " );
189-
190192 // Set "POST" data.
191193 $ action_postfields_string = http_build_query ($ put_post_parameters );
192194 curl_setopt ($ prox_ch , CURLOPT_POSTFIELDS , $ action_postfields_string );
193195 unset($ action_postfields_string );
194196
197+ curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "PUT " );
198+
195199 // Add required HTTP headers.
196200 curl_setopt ($ prox_ch , CURLOPT_HTTPHEADER , $ put_post_http_headers );
197201 break ;
@@ -207,8 +211,8 @@ private function action ($action_path, $http_method, $put_post_parameters = null
207211 curl_setopt ($ prox_ch , CURLOPT_HTTPHEADER , $ put_post_http_headers );
208212 break ;
209213 case "DELETE " :
210- curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "DELETE " );
211214 // No "POST" data required, the delete destination is specified in the URL.
215+ curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "DELETE " );
212216
213217 // Add required HTTP headers.
214218 curl_setopt ($ prox_ch , CURLOPT_HTTPHEADER , $ put_post_http_headers );
@@ -218,6 +222,7 @@ private function action ($action_path, $http_method, $put_post_parameters = null
218222 return false ;
219223 }
220224
225+ curl_setopt ($ prox_ch , CURLOPT_URL , "https:// {$ this ->hostname }: {$ this ->port }/api2/json {$ action_path }" );
221226 curl_setopt ($ prox_ch , CURLOPT_HEADER , true );
222227 curl_setopt ($ prox_ch , CURLOPT_RETURNTRANSFER , true );
223228 curl_setopt ($ prox_ch , CURLOPT_COOKIE , "PVEAuthCookie= " .$ this ->login_ticket ['ticket ' ]);
0 commit comments