Completed
Branch master (94e0e2)
by Joe
02:01
created
src/LiteSpeed.php 2 patches
Indentation   +325 added lines, -325 removed lines patch added patch discarded remove patch
@@ -17,350 +17,350 @@
 block discarded – undo
17 17
 class LiteSpeed
18 18
 {
19 19
 
20
-	public $login = '';
21
-	public $password = '';
22
-	public $use_post = true;
23
-	public $url = 'https://store.litespeedtech.com/reseller/LiteSpeed_eService.php';
24
-	public $version = '1.1';
25
-	public $params = [];
26
-	public $response = [];
27
-	public $valid_products = ['LSWS', 'LSLB'];
28
-	public $valid_cpu = ['1','2','4','8','V','U'];
29
-	public $valid_period = ['monthly','yearly','owned'];
30
-	public $valid_payment = ['credit', 'creditcard'];
31
-	public $raw_response;
20
+    public $login = '';
21
+    public $password = '';
22
+    public $use_post = true;
23
+    public $url = 'https://store.litespeedtech.com/reseller/LiteSpeed_eService.php';
24
+    public $version = '1.1';
25
+    public $params = [];
26
+    public $response = [];
27
+    public $valid_products = ['LSWS', 'LSLB'];
28
+    public $valid_cpu = ['1','2','4','8','V','U'];
29
+    public $valid_period = ['monthly','yearly','owned'];
30
+    public $valid_payment = ['credit', 'creditcard'];
31
+    public $raw_response;
32 32
 
33
-	/**
34
-	 * @param $login
35
-	 * @param $password
36
-	 */
37
-	public function __construct($login, $password) {
38
-		$this->login = $login;
39
-		$this->password = $password;
40
-		$this->reset_params();
41
-		function_requirements('xml2array');
42
-	}
33
+    /**
34
+     * @param $login
35
+     * @param $password
36
+     */
37
+    public function __construct($login, $password) {
38
+        $this->login = $login;
39
+        $this->password = $password;
40
+        $this->reset_params();
41
+        function_requirements('xml2array');
42
+    }
43 43
 
44
-	public function reset_params() {
45
-		$this->params = [];
46
-		$this->params['litespeed_store_login'] = rawurlencode($this->login);
47
-		$this->params['litespeed_store_pass'] = rawurlencode($this->password);
48
-		$this->params['eService_version'] = rawurlencode($this->version);
49
-	}
44
+    public function reset_params() {
45
+        $this->params = [];
46
+        $this->params['litespeed_store_login'] = rawurlencode($this->login);
47
+        $this->params['litespeed_store_pass'] = rawurlencode($this->password);
48
+        $this->params['eService_version'] = rawurlencode($this->version);
49
+    }
50 50
 
51
-	/**
52
-	 * @return mixed
53
-	 */
54
-	public function ping() {
55
-		return $this->req('Ping');
56
-	}
51
+    /**
52
+     * @return mixed
53
+     */
54
+    public function ping() {
55
+        return $this->req('Ping');
56
+    }
57 57
 
58
-	/**
59
-	* LiteSpeed Order License Return
60
-	* 		* 	If any errors occur during this process, <result> will contain “error” and <message>
61
-	* 	will contain a detailed description:
62
-	* 		<LiteSpeed_eService>
63
-	* 			<action>Order</action>
64
-	* 			<result>error</result>
65
-	* 			<message>Invalid cpu!</message>
66
-	* 		</LiteSpeed_eService>
67
-	* 	If the transaction cannot be completed, <result> will be “incomplete”. For example, if
68
-	* 	payment method is “credit”, but there is not enough credit in your account, or if payment method
69
-	* 	is “creditcard”, but the charge cannot go through, then the transaction will not be completed
70
-	* 	and <result> will display “incomplete”. <license_id> and <invoice> will be provided. You will
71
-	* 	need to login to LiteSpeed’s online store and pay the invoice to finish the order.
72
-	* 		If payment method is “credit”, but not enough credit is available to your account:
73
-	* 			<LiteSpeed_eService>
74
-	* 				<action>Order</action>
75
-	* 					<license_id>6066</license_id>
76
-	* 				<license_type>WS_L_V</license_type>
77
-	* 				<invoice_id>12466</invoice_id>
78
-	* 				<result>incomplete</result>
79
-	* 				<message>need to pay invoice first</message>
80
-	* 			</LiteSpeed_eService>
81
-	* 		If payment method is “creditcard”, but the attempted credit card payment failed:
82
-	* 			<LiteSpeed_eService>
83
-	* 				<action>Order</action>
84
-	* 				<license_id>9329</license_id>
85
-	* 				<license_type>WS_L_V</license_type>
86
-	* 				<invoice_id>20568</invoice_id>
87
-	* 				<result>incomplete</result>
88
-	* 				<message>need to pay invoice first, credit card payment failed</message>
89
-	* 			</LiteSpeed_eService>
90
-	* 	If the transaction is successful, which should happen for the majority of cases, you will get a
91
-	* 	serial number back. You can parse the message to get the serial number and create your own script
92
-	* 	for installation. You will still receive the same confirmation email and serial number emails as
93
-	* 	if you ordered online. There will be no <invoice_id> if the charge was paid with credit.
94
-	* 		<LiteSpeed_eService>
95
-	* 			<action>Order</action>
96
-	* 			< license_id>6067</ license_id>
97
-	* 			<license_type>WS_L_V</license_type>
98
-	* 			<invoice_id>12466</invoice_id>
99
-	* 			< license_serial>gv06-kXsU-SHBr-pL4N</license_serial>
100
-	* 			<result>success</result>
101
-	* 			<message>new order automatically accepted</message>
102
-	* 		</LiteSpeed_eService>
103
-	*
104
-	*/
58
+    /**
59
+     * LiteSpeed Order License Return
60
+     * 		* 	If any errors occur during this process, <result> will contain “error” and <message>
61
+     * 	will contain a detailed description:
62
+     * 		<LiteSpeed_eService>
63
+     * 			<action>Order</action>
64
+     * 			<result>error</result>
65
+     * 			<message>Invalid cpu!</message>
66
+     * 		</LiteSpeed_eService>
67
+     * 	If the transaction cannot be completed, <result> will be “incomplete”. For example, if
68
+     * 	payment method is “credit”, but there is not enough credit in your account, or if payment method
69
+     * 	is “creditcard”, but the charge cannot go through, then the transaction will not be completed
70
+     * 	and <result> will display “incomplete”. <license_id> and <invoice> will be provided. You will
71
+     * 	need to login to LiteSpeed’s online store and pay the invoice to finish the order.
72
+     * 		If payment method is “credit”, but not enough credit is available to your account:
73
+     * 			<LiteSpeed_eService>
74
+     * 				<action>Order</action>
75
+     * 					<license_id>6066</license_id>
76
+     * 				<license_type>WS_L_V</license_type>
77
+     * 				<invoice_id>12466</invoice_id>
78
+     * 				<result>incomplete</result>
79
+     * 				<message>need to pay invoice first</message>
80
+     * 			</LiteSpeed_eService>
81
+     * 		If payment method is “creditcard”, but the attempted credit card payment failed:
82
+     * 			<LiteSpeed_eService>
83
+     * 				<action>Order</action>
84
+     * 				<license_id>9329</license_id>
85
+     * 				<license_type>WS_L_V</license_type>
86
+     * 				<invoice_id>20568</invoice_id>
87
+     * 				<result>incomplete</result>
88
+     * 				<message>need to pay invoice first, credit card payment failed</message>
89
+     * 			</LiteSpeed_eService>
90
+     * 	If the transaction is successful, which should happen for the majority of cases, you will get a
91
+     * 	serial number back. You can parse the message to get the serial number and create your own script
92
+     * 	for installation. You will still receive the same confirmation email and serial number emails as
93
+     * 	if you ordered online. There will be no <invoice_id> if the charge was paid with credit.
94
+     * 		<LiteSpeed_eService>
95
+     * 			<action>Order</action>
96
+     * 			< license_id>6067</ license_id>
97
+     * 			<license_type>WS_L_V</license_type>
98
+     * 			<invoice_id>12466</invoice_id>
99
+     * 			< license_serial>gv06-kXsU-SHBr-pL4N</license_serial>
100
+     * 			<result>success</result>
101
+     * 			<message>new order automatically accepted</message>
102
+     * 		</LiteSpeed_eService>
103
+     *
104
+     */
105 105
 
106
-	/**
107
-	* Order a LiteSpeed License
108
-	*
109
-	* @param mixed $product  Product type. Available values: “LSWS” or “LSLB”.
110
-	* @param mixed $cpu What kind of license. Available values: “1”: 1-CPU license, “2”: 2-CPU license,  “4”: 4-CPU license, “8”: 8-CPU license, “V”: VPS license, “U”: Ultra-VPS license (Available LSWS 4.2.2 and above.), If <order_product> is “LSLB”, <order_cpu> is not required.
111
-	* @param mixed $period  Renewal period. Available values: “monthly”, “yearly”, “owned”.
112
-	* @param mixed $payment Payment method. Available values: “credit”: Use account credit. User can utilize “Add funds” function to pre-deposit money, which will show up as account credit.      “creditcard”: Use credit card to pay. The credit card is pre-defined in the account.  If there is available credit in the account, credit will be applied first, even when the payment method is set to “creditcard”.
113
-	* @param mixed $cvv  (optional) Credit card security code. Try not to set this field. Only if your bank requires this (meaning that the transaction will fail without it) should you then supply this field. CVV code is not stored in the system, so if you need to set it, you have to set this field every time. Other information from your credit card will be taken from your user account.
114
-	* @param mixed $promocode  (optional) Promotional code. If you have a pre-assigned promotional code registered to your account, then you can set it here. Promotional codes are exclusive to each client. If your account is entitled to discounts at the invoice level, you do not need a promotional code.
115
-	* @return array array with the output result. see above for description of output.
116
-	* 		array (
117
-	* 			'LiteSpeed_eService' => array (
118
-	* 				'action' => 'Order',
119
-	* 				'license_id' => '36514',
120
-	* 				'license_type' => 'WS_L_1',
121
-	* 				'invoice_id' => '86300',
122
-	* 				'result' => 'incomplete',
123
-	* 				'message' => 'Invoice 86300 not paid. ',
124
-	* 			),
125
-	* 		)
126
-	*/
127
-	public function order($product, $cpu = false, $period = 'monthly', $payment = 'credit', $cvv = false, $promocode = false) {
128
-		if (!in_array($product, $this->valid_products)) {
129
-			return array('error' => 'Invalid Product');
130
-		}
131
-		if ($product == 'LSWS' && !in_array($cpu, $this->valid_cpu)) {
132
-			return array('error' => 'Invalid CPU');
133
-		}
134
-		if (!in_array($period, $this->valid_period)) {
135
-			return array('error' => 'Invalid Billing Period');
136
-		}
137
-		if (!in_array($payment, $this->valid_payment)) {
138
-			return array('error' => 'Invalid Payment Method');
139
-		}
140
-		$this->params['order_product'] = $product;
141
-		if ($product != 'LSLB') {
142
-			$this->params['order_cpu'] = $cpu;
143
-		}
144
-		$this->params['order_period'] = $period;
145
-		$this->params['order_payment'] = $payment;
146
-		if ($cvv !== false) {
147
-			$this->params['order_cvv'] = $cvv;
148
-		}
149
-		if ($promocode !== false) {
150
-			$this->params['order_promocode'] = $promocode;
151
-		}
152
-		return $this->req('Order');
153
-	}
106
+    /**
107
+     * Order a LiteSpeed License
108
+     *
109
+     * @param mixed $product  Product type. Available values: “LSWS” or “LSLB”.
110
+     * @param mixed $cpu What kind of license. Available values: “1”: 1-CPU license, “2”: 2-CPU license,  “4”: 4-CPU license, “8”: 8-CPU license, “V”: VPS license, “U”: Ultra-VPS license (Available LSWS 4.2.2 and above.), If <order_product> is “LSLB”, <order_cpu> is not required.
111
+     * @param mixed $period  Renewal period. Available values: “monthly”, “yearly”, “owned”.
112
+     * @param mixed $payment Payment method. Available values: “credit”: Use account credit. User can utilize “Add funds” function to pre-deposit money, which will show up as account credit.      “creditcard”: Use credit card to pay. The credit card is pre-defined in the account.  If there is available credit in the account, credit will be applied first, even when the payment method is set to “creditcard”.
113
+     * @param mixed $cvv  (optional) Credit card security code. Try not to set this field. Only if your bank requires this (meaning that the transaction will fail without it) should you then supply this field. CVV code is not stored in the system, so if you need to set it, you have to set this field every time. Other information from your credit card will be taken from your user account.
114
+     * @param mixed $promocode  (optional) Promotional code. If you have a pre-assigned promotional code registered to your account, then you can set it here. Promotional codes are exclusive to each client. If your account is entitled to discounts at the invoice level, you do not need a promotional code.
115
+     * @return array array with the output result. see above for description of output.
116
+     * 		array (
117
+     * 			'LiteSpeed_eService' => array (
118
+     * 				'action' => 'Order',
119
+     * 				'license_id' => '36514',
120
+     * 				'license_type' => 'WS_L_1',
121
+     * 				'invoice_id' => '86300',
122
+     * 				'result' => 'incomplete',
123
+     * 				'message' => 'Invoice 86300 not paid. ',
124
+     * 			),
125
+     * 		)
126
+     */
127
+    public function order($product, $cpu = false, $period = 'monthly', $payment = 'credit', $cvv = false, $promocode = false) {
128
+        if (!in_array($product, $this->valid_products)) {
129
+            return array('error' => 'Invalid Product');
130
+        }
131
+        if ($product == 'LSWS' && !in_array($cpu, $this->valid_cpu)) {
132
+            return array('error' => 'Invalid CPU');
133
+        }
134
+        if (!in_array($period, $this->valid_period)) {
135
+            return array('error' => 'Invalid Billing Period');
136
+        }
137
+        if (!in_array($payment, $this->valid_payment)) {
138
+            return array('error' => 'Invalid Payment Method');
139
+        }
140
+        $this->params['order_product'] = $product;
141
+        if ($product != 'LSLB') {
142
+            $this->params['order_cpu'] = $cpu;
143
+        }
144
+        $this->params['order_period'] = $period;
145
+        $this->params['order_payment'] = $payment;
146
+        if ($cvv !== false) {
147
+            $this->params['order_cvv'] = $cvv;
148
+        }
149
+        if ($promocode !== false) {
150
+            $this->params['order_promocode'] = $promocode;
151
+        }
152
+        return $this->req('Order');
153
+    }
154 154
 
155
-	/**
156
-	 * @param bool   $serial
157
-	 * @param bool   $ip
158
-	 * @param string $now
159
-	 * @param bool   $reason
160
-	 * @return mixed
161
-	 */
162
-	public function cancel($serial = false, $ip = false, $now = 'Y', $reason = false) {
163
-		$this->params['license_serial'] = $serial;
164
-		$this->params['server_ip'] = $ip;
165
-		$this->params['cancel_now'] = $now;
166
-		$this->params['cancel_reason'] = $reason;
167
-		return $this->req('Cancel');
168
-	}
155
+    /**
156
+     * @param bool   $serial
157
+     * @param bool   $ip
158
+     * @param string $now
159
+     * @param bool   $reason
160
+     * @return mixed
161
+     */
162
+    public function cancel($serial = false, $ip = false, $now = 'Y', $reason = false) {
163
+        $this->params['license_serial'] = $serial;
164
+        $this->params['server_ip'] = $ip;
165
+        $this->params['cancel_now'] = $now;
166
+        $this->params['cancel_reason'] = $reason;
167
+        return $this->req('Cancel');
168
+    }
169 169
 
170
-	/**
171
-	 * @param $serial
172
-	 * @param $ip
173
-	 * @return mixed
174
-	 */
175
-	public function release($serial, $ip) {
176
-		$this->params['license_serial'] = $serial;
177
-		$this->params['server_ip'] = $ip;
178
-		return $this->req('ReleaseLicense');
179
-	}
170
+    /**
171
+     * @param $serial
172
+     * @param $ip
173
+     * @return mixed
174
+     */
175
+    public function release($serial, $ip) {
176
+        $this->params['license_serial'] = $serial;
177
+        $this->params['server_ip'] = $ip;
178
+        return $this->req('ReleaseLicense');
179
+    }
180 180
 
181
-	/**
182
-	 * Suspend a license.   This is a tool to temporarily suspend a particular user's license in special cases,
183
-	 *  like nonpayment or policy violation. The web server checks in with the license server at least once
184
-	 *  every 24 hours. It will shut down when it sees the license has been suspended. As a consequence, your
185
-	 *  client's web site will go down. Please note, though, that this license will continue to appear on
186
-	 *  your invoices. Once the issue is resolved, you can use an “unsuspend” action to reactivate the license;
187
-	 *  or you can request cancellation to permanently cancel it. Only requesting cancellation will take the
188
-	 *  license off your future invoices.
189
-	 *
190
-	 * @param mixed $serial optional (if you specify IP , but this is preferred) serial of the license
191
-	 * @param mixed $ip optional (if you specify serial) ip of the license, specifying bothserial and ip gives extra validation
192
-	 * @param mixed $reason optional reason for suspend/unsuspend
193
-	 * @return mixed
194
-	 */
195
-	public function suspend($serial = false, $ip = false, $reason = false) {
196
-		if ($serial !== false) {
197
-			$this->params['license_serial'] = $serial;
198
-		}
199
-		if ($ip !== false) {
200
-			$this->params['server_ip'] = $ip;
201
-		}
202
-		if ($reason !== false) {
203
-			$this->params['reason'] = $reason;
204
-		}
205
-		return $this->req('Suspend');
206
-	}
181
+    /**
182
+     * Suspend a license.   This is a tool to temporarily suspend a particular user's license in special cases,
183
+     *  like nonpayment or policy violation. The web server checks in with the license server at least once
184
+     *  every 24 hours. It will shut down when it sees the license has been suspended. As a consequence, your
185
+     *  client's web site will go down. Please note, though, that this license will continue to appear on
186
+     *  your invoices. Once the issue is resolved, you can use an “unsuspend” action to reactivate the license;
187
+     *  or you can request cancellation to permanently cancel it. Only requesting cancellation will take the
188
+     *  license off your future invoices.
189
+     *
190
+     * @param mixed $serial optional (if you specify IP , but this is preferred) serial of the license
191
+     * @param mixed $ip optional (if you specify serial) ip of the license, specifying bothserial and ip gives extra validation
192
+     * @param mixed $reason optional reason for suspend/unsuspend
193
+     * @return mixed
194
+     */
195
+    public function suspend($serial = false, $ip = false, $reason = false) {
196
+        if ($serial !== false) {
197
+            $this->params['license_serial'] = $serial;
198
+        }
199
+        if ($ip !== false) {
200
+            $this->params['server_ip'] = $ip;
201
+        }
202
+        if ($reason !== false) {
203
+            $this->params['reason'] = $reason;
204
+        }
205
+        return $this->req('Suspend');
206
+    }
207 207
 
208
-	/**
209
-	 * Unsuspend a license.
210
-	 *
211
-	 * @param mixed $serial optional (if you specify IP , but this is preferred) serial of the license
212
-	 * @param mixed $ip optional (if you specify serial) ip of the license, specifying bothserial and ip gives extra validation
213
-	 * @param mixed $reason optional reason for suspend/unsuspend
214
-	 * @return mixed
215
-	 */
216
-	public function unsuspend($serial = false, $ip = false, $reason = false) {
217
-		if ($serial !== false) {
218
-			$this->params['license_serial'] = $serial;
219
-		}
220
-		if ($ip !== false) {
221
-			$this->params['server_ip'] = $ip;
222
-		}
223
-		if ($reason !== false) {
224
-			$this->params['reason'] = $reason;
225
-		}
226
-		return $this->req('Unsuspend');
227
-	}
208
+    /**
209
+     * Unsuspend a license.
210
+     *
211
+     * @param mixed $serial optional (if you specify IP , but this is preferred) serial of the license
212
+     * @param mixed $ip optional (if you specify serial) ip of the license, specifying bothserial and ip gives extra validation
213
+     * @param mixed $reason optional reason for suspend/unsuspend
214
+     * @return mixed
215
+     */
216
+    public function unsuspend($serial = false, $ip = false, $reason = false) {
217
+        if ($serial !== false) {
218
+            $this->params['license_serial'] = $serial;
219
+        }
220
+        if ($ip !== false) {
221
+            $this->params['server_ip'] = $ip;
222
+        }
223
+        if ($reason !== false) {
224
+            $this->params['reason'] = $reason;
225
+        }
226
+        return $this->req('Unsuspend');
227
+    }
228 228
 
229
-	/**
230
-	 * @param bool   $serial
231
-	 * @param bool   $ip
232
-	 * @param        $cpu
233
-	 * @param string $payment
234
-	 * @param bool   $cvv
235
-	 * @return array|mixed
236
-	 */
237
-	public function upgrade($serial = false, $ip = false, $cpu, $payment = 'credit', $cvv = false) {
238
-		if ($serial !== false) {
239
-			$this->params['license_serial'] = $serial;
240
-		}
241
-		if ($ip !== false) {
242
-			$this->params['server_ip'] = $ip;
243
-		}
244
-		if (!in_array($cpu, $this->valid_cpu)) {
245
-			return array('error' => 'Invalid CPU');
246
-		}
247
-		if (!in_array($payment, $this->valid_payment)) {
248
-			return array('error' => 'Invalid Payment Method');
249
-		}
250
-		$this->params['upgrade_cpu'] = $cpu;
251
-		$this->params['order_payment'] = $payment;
252
-		if ($cvv !== false) {
253
-			$this->params['order_cvv'] = $cvv;
254
-		}
255
-		return $this->req('Upgrade');
256
-	}
229
+    /**
230
+     * @param bool   $serial
231
+     * @param bool   $ip
232
+     * @param        $cpu
233
+     * @param string $payment
234
+     * @param bool   $cvv
235
+     * @return array|mixed
236
+     */
237
+    public function upgrade($serial = false, $ip = false, $cpu, $payment = 'credit', $cvv = false) {
238
+        if ($serial !== false) {
239
+            $this->params['license_serial'] = $serial;
240
+        }
241
+        if ($ip !== false) {
242
+            $this->params['server_ip'] = $ip;
243
+        }
244
+        if (!in_array($cpu, $this->valid_cpu)) {
245
+            return array('error' => 'Invalid CPU');
246
+        }
247
+        if (!in_array($payment, $this->valid_payment)) {
248
+            return array('error' => 'Invalid Payment Method');
249
+        }
250
+        $this->params['upgrade_cpu'] = $cpu;
251
+        $this->params['order_payment'] = $payment;
252
+        if ($cvv !== false) {
253
+            $this->params['order_cvv'] = $cvv;
254
+        }
255
+        return $this->req('Upgrade');
256
+    }
257 257
 
258
-	/**
259
-	 * @param $field
260
-	 * @return mixed
261
-	 */
262
-	public function query($field) {
263
-		/**
264
-		 * query_field – Currently supported values:
265
-		 *	 	“AllActiveLicenses”
266
-		 * 		“LicenseDetail_IP:IP Address”
267
-		 * 	LicenseDetail_IP:xx.xxx.xxx.xxx (Please replace “IP Address” above with the IP address
268
-		 * 	you would like to look up. No space between tag, colon and IP address.)
269
-		 * 	If there is more than one active license associated with the query IP, “error” will be
270
-		 * 	returned.
271
-		 * 		“LicenseDetail_Serial:Serial Number” (Since Dec 16, 2011)
272
-		 * 	LicenseDetail_Serial:ccccccccccccc (Please replace “Serial Number” above with the
273
-		 * 	serial number you would like to look up. No space between tag, colon and serial
274
-		 * 	number.)
275
-		 * 	If there is no active license with the query serial number (including licenses that have
276
-		 * 	been canceled or terminated), “error” will be returned.
277
-		 * 	(If you have a specific function you'd like to see us implement, let us know. We'll do our
278
-		 * 	best to make the system more useful.)
279
-		 */
280
-		$this->params['query_field'] = $field;
281
-		return $this->req('Query');
282
-	}
258
+    /**
259
+     * @param $field
260
+     * @return mixed
261
+     */
262
+    public function query($field) {
263
+        /**
264
+         * query_field – Currently supported values:
265
+         *	 	“AllActiveLicenses”
266
+         * 		“LicenseDetail_IP:IP Address”
267
+         * 	LicenseDetail_IP:xx.xxx.xxx.xxx (Please replace “IP Address” above with the IP address
268
+         * 	you would like to look up. No space between tag, colon and IP address.)
269
+         * 	If there is more than one active license associated with the query IP, “error” will be
270
+         * 	returned.
271
+         * 		“LicenseDetail_Serial:Serial Number” (Since Dec 16, 2011)
272
+         * 	LicenseDetail_Serial:ccccccccccccc (Please replace “Serial Number” above with the
273
+         * 	serial number you would like to look up. No space between tag, colon and serial
274
+         * 	number.)
275
+         * 	If there is no active license with the query serial number (including licenses that have
276
+         * 	been canceled or terminated), “error” will be returned.
277
+         * 	(If you have a specific function you'd like to see us implement, let us know. We'll do our
278
+         * 	best to make the system more useful.)
279
+         */
280
+        $this->params['query_field'] = $field;
281
+        return $this->req('Query');
282
+    }
283 283
 
284
-	/**
285
-	 * sets whether or not to use POST for the request or GET (false)
286
-	 *
287
-	 * @param mixed $post TRUE for POST , FALSE for GET requests		*
288
-	 */
289
-	public function use_post($post = true) {
290
-		$this->use_post = $post;
291
-	}
284
+    /**
285
+     * sets whether or not to use POST for the request or GET (false)
286
+     *
287
+     * @param mixed $post TRUE for POST , FALSE for GET requests		*
288
+     */
289
+    public function use_post($post = true) {
290
+        $this->use_post = $post;
291
+    }
292 292
 
293
-	/**
294
-	 * performs a request to LiteSpeed
295
-	 *
296
-	 * @param string $action Can be one of Ping, Order, Cancel, ReleaseLicense, Suspend, Unsuspend, Upgrade, or Query
297
-	 * @return mixed
298
-	 */
299
-	public function req($action) {
300
-		$this->params['eService_action'] = rawurlencode($action);
301
-		// Set the curl parameters.
302
-		$ch = curl_init();
303
-		$url = $this->url;
304
-		if ($this->use_post !== false) {
305
-			curl_setopt($ch, CURLOPT_POST, true);
306
-			$pstring = '';
307
-			foreach ($this->params as $param => $value) {
308
-				$pstring .= '&' . $param . '=' . $value . '';
309
-			}
310
-			$pstring = mb_substr($pstring, 1);
311
-			curl_setopt($ch, CURLOPT_POSTFIELDS, $pstring);
312
-		} else {
313
-			curl_setopt($ch, CURLOPT_POST, false);
314
-			$pstring = '';
315
-			foreach ($this->params as $param => $value) {
316
-				$pstring .= '&' . $param . '=' . $value . '';
317
-			}
318
-			$pstring = mb_substr($pstring, 1);
319
-			$url .= '?' . $pstring;
320
-		}
321
-		myadmin_log('licenses', 'info', "LiteSpeed URL: $url\npstring: $pstring\n", __LINE__, __FILE__);
322
-		curl_setopt($ch, CURLOPT_URL, $url);
293
+    /**
294
+     * performs a request to LiteSpeed
295
+     *
296
+     * @param string $action Can be one of Ping, Order, Cancel, ReleaseLicense, Suspend, Unsuspend, Upgrade, or Query
297
+     * @return mixed
298
+     */
299
+    public function req($action) {
300
+        $this->params['eService_action'] = rawurlencode($action);
301
+        // Set the curl parameters.
302
+        $ch = curl_init();
303
+        $url = $this->url;
304
+        if ($this->use_post !== false) {
305
+            curl_setopt($ch, CURLOPT_POST, true);
306
+            $pstring = '';
307
+            foreach ($this->params as $param => $value) {
308
+                $pstring .= '&' . $param . '=' . $value . '';
309
+            }
310
+            $pstring = mb_substr($pstring, 1);
311
+            curl_setopt($ch, CURLOPT_POSTFIELDS, $pstring);
312
+        } else {
313
+            curl_setopt($ch, CURLOPT_POST, false);
314
+            $pstring = '';
315
+            foreach ($this->params as $param => $value) {
316
+                $pstring .= '&' . $param . '=' . $value . '';
317
+            }
318
+            $pstring = mb_substr($pstring, 1);
319
+            $url .= '?' . $pstring;
320
+        }
321
+        myadmin_log('licenses', 'info', "LiteSpeed URL: $url\npstring: $pstring\n", __LINE__, __FILE__);
322
+        curl_setopt($ch, CURLOPT_URL, $url);
323 323
 
324
-		// Turn off the server and peer verification (TrustManager Concept).
325
-		//curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
326
-		//curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
324
+        // Turn off the server and peer verification (TrustManager Concept).
325
+        //curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
326
+        //curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
327 327
 
328
-		curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
328
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
329 329
 
330
-		// Get response from the server.
331
-		$this->raw_response = curl_exec($ch);
330
+        // Get response from the server.
331
+        $this->raw_response = curl_exec($ch);
332 332
 
333
-		if (!$this->raw_response) {
334
-			$this->error[] = 'There was some error in connecting to Softaculous. This may be because of no internet connectivity at your end.';
335
-			return false;
336
-		}
333
+        if (!$this->raw_response) {
334
+            $this->error[] = 'There was some error in connecting to Softaculous. This may be because of no internet connectivity at your end.';
335
+            return false;
336
+        }
337 337
 
338
-		// Extract the response details.
339
-		$this->response = xml2array($this->raw_response);
340
-		myadmin_log('licenses', 'info', 'LiteSpeed Response ' . var_export($this->response, true), __LINE__, __FILE__);
341
-		if (empty($this->response['error'])) {
342
-			unset($this->response['error']);
343
-			return $this->response;
344
-		} else {
345
-			$this->error = array_merge($this->error, $this->response['error']);
346
-			return false;
347
-		}
338
+        // Extract the response details.
339
+        $this->response = xml2array($this->raw_response);
340
+        myadmin_log('licenses', 'info', 'LiteSpeed Response ' . var_export($this->response, true), __LINE__, __FILE__);
341
+        if (empty($this->response['error'])) {
342
+            unset($this->response['error']);
343
+            return $this->response;
344
+        } else {
345
+            $this->error = array_merge($this->error, $this->response['error']);
346
+            return false;
347
+        }
348 348
 
349
-	}
349
+    }
350 350
 
351
-	/**
352
-	 * LiteSpeed::r()
353
-	 *
354
-	 * @param mixed $r
355
-	 * @return void
356
-	 */
357
-	public function r($r) {
358
-		if (empty($r)) {
359
-			$r = $this->error;
360
-		}
361
-		echo '<pre>';
362
-		print_r($r);
363
-		echo '</pre>';
364
-	}
351
+    /**
352
+     * LiteSpeed::r()
353
+     *
354
+     * @param mixed $r
355
+     * @return void
356
+     */
357
+    public function r($r) {
358
+        if (empty($r)) {
359
+            $r = $this->error;
360
+        }
361
+        echo '<pre>';
362
+        print_r($r);
363
+        echo '</pre>';
364
+    }
365 365
 
366 366
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
 	public $params = [];
26 26
 	public $response = [];
27 27
 	public $valid_products = ['LSWS', 'LSLB'];
28
-	public $valid_cpu = ['1','2','4','8','V','U'];
29
-	public $valid_period = ['monthly','yearly','owned'];
28
+	public $valid_cpu = ['1', '2', '4', '8', 'V', 'U'];
29
+	public $valid_period = ['monthly', 'yearly', 'owned'];
30 30
 	public $valid_payment = ['credit', 'creditcard'];
31 31
 	public $raw_response;
32 32
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 			curl_setopt($ch, CURLOPT_POST, true);
306 306
 			$pstring = '';
307 307
 			foreach ($this->params as $param => $value) {
308
-				$pstring .= '&' . $param . '=' . $value . '';
308
+				$pstring .= '&'.$param.'='.$value.'';
309 309
 			}
310 310
 			$pstring = mb_substr($pstring, 1);
311 311
 			curl_setopt($ch, CURLOPT_POSTFIELDS, $pstring);
@@ -313,10 +313,10 @@  discard block
 block discarded – undo
313 313
 			curl_setopt($ch, CURLOPT_POST, false);
314 314
 			$pstring = '';
315 315
 			foreach ($this->params as $param => $value) {
316
-				$pstring .= '&' . $param . '=' . $value . '';
316
+				$pstring .= '&'.$param.'='.$value.'';
317 317
 			}
318 318
 			$pstring = mb_substr($pstring, 1);
319
-			$url .= '?' . $pstring;
319
+			$url .= '?'.$pstring;
320 320
 		}
321 321
 		myadmin_log('licenses', 'info', "LiteSpeed URL: $url\npstring: $pstring\n", __LINE__, __FILE__);
322 322
 		curl_setopt($ch, CURLOPT_URL, $url);
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 
338 338
 		// Extract the response details.
339 339
 		$this->response = xml2array($this->raw_response);
340
-		myadmin_log('licenses', 'info', 'LiteSpeed Response ' . var_export($this->response, true), __LINE__, __FILE__);
340
+		myadmin_log('licenses', 'info', 'LiteSpeed Response '.var_export($this->response, true), __LINE__, __FILE__);
341 341
 		if (empty($this->response['error'])) {
342 342
 			unset($this->response['error']);
343 343
 			return $this->response;
Please login to merge, or discard this patch.