@@ -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.
@@ -158,7 +160,6 @@ private function action ($action_path, $http_method, $put_post_parameters = null
158160
159161 // Prepare cURL resource.
160162 $ prox_ch = curl_init ();
161- curl_setopt ($ prox_ch , CURLOPT_URL , "https:// {$ this ->hostname }: {$ this ->port }/api2/json {$ action_path }" );
162163
163164 $ put_post_http_headers = array ();
164165 $ put_post_http_headers [] = "CSRFPreventionToken: {$ this ->login_ticket ['CSRFPreventionToken ' ]}" ;
@@ -169,18 +170,21 @@ private function action ($action_path, $http_method, $put_post_parameters = null
169170 // request method was GET, but that doesn't seem to be the case any
170171 // longer, so we need to build them into the query string ourselves.
171172 $ action_postfields_string = http_build_query ($ put_post_parameters );
172- $ action_path .= (strpos ($ action_path , '? ' ) === FALSE ? '? ' : '& ' ) . $ action_postfields_string ;
173+ if ((strpos ($ action_path , '? ' ) === FALSE ) {
174+ $ action_path .= '? ' . $ action_postfields_string ;
175+ } else {
176+ $ action_path .= '& ' . $ action_postfields_string ;
177+ }
173178 unset($ action_postfields_string );
174-
175179 break ;
176180 case "PUT " :
177- curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "PUT " );
178-
179181 // Set "POST" data.
180182 $ action_postfields_string = http_build_query ($ put_post_parameters );
181183 curl_setopt ($ prox_ch , CURLOPT_POSTFIELDS , $ action_postfields_string );
182184 unset($ action_postfields_string );
183185
186+ curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "PUT " );
187+
184188 // Add required HTTP headers.
185189 curl_setopt ($ prox_ch , CURLOPT_HTTPHEADER , $ put_post_http_headers );
186190 break ;
@@ -196,8 +200,8 @@ private function action ($action_path, $http_method, $put_post_parameters = null
196200 curl_setopt ($ prox_ch , CURLOPT_HTTPHEADER , $ put_post_http_headers );
197201 break ;
198202 case "DELETE " :
199- curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "DELETE " );
200203 // No "POST" data required, the delete destination is specified in the URL.
204+ curl_setopt ($ prox_ch , CURLOPT_CUSTOMREQUEST , "DELETE " );
201205
202206 // Add required HTTP headers.
203207 curl_setopt ($ prox_ch , CURLOPT_HTTPHEADER , $ put_post_http_headers );
@@ -207,6 +211,7 @@ private function action ($action_path, $http_method, $put_post_parameters = null
207211 return false ;
208212 }
209213
214+ curl_setopt ($ prox_ch , CURLOPT_URL , "https:// {$ this ->hostname }: {$ this ->port }/api2/json {$ action_path }" );
210215 curl_setopt ($ prox_ch , CURLOPT_HEADER , true );
211216 curl_setopt ($ prox_ch , CURLOPT_RETURNTRANSFER , true );
212217 curl_setopt ($ prox_ch , CURLOPT_COOKIE , "PVEAuthCookie= " .$ this ->login_ticket ['ticket ' ]);
0 commit comments