@@ -30,8 +30,7 @@ discard block |
||
30 | 30 | if ($format != "xml" && $format != "json" && $format != "yaml" && $format != "simplexml") { |
31 | 31 | error_log("set_format requires that the format is xml, json, yaml or simplexml"); |
32 | 32 | return; |
33 | - } |
|
34 | - else { |
|
33 | + } else { |
|
35 | 34 | $this->format = $format; |
36 | 35 | } |
37 | 36 | } |
@@ -62,8 +61,7 @@ discard block |
||
62 | 61 | $result = $result[str_replace('.cgi', '', $function)]; |
63 | 62 | $result = $this->format_result($result); |
64 | 63 | return $result; |
65 | - } |
|
66 | - else { |
|
64 | + } else { |
|
67 | 65 | return $result; |
68 | 66 | } |
69 | 67 | } |
@@ -86,8 +84,7 @@ discard block |
||
86 | 84 | private function validateID ($id) { |
87 | 85 | if (preg_match("/^(L|P|G)?\d*$/", $id)) { |
88 | 86 | return 1; |
89 | - } |
|
90 | - else { |
|
87 | + } else { |
|
91 | 88 | return 0; |
92 | 89 | } |
93 | 90 | } |
@@ -271,11 +268,9 @@ discard block |
||
271 | 268 | $xml_obj = (array) $xml_obj; |
272 | 269 | if (array_key_exists("packages", $xml_obj)) { |
273 | 270 | $type = "packages"; |
274 | - } |
|
275 | - else if (array_key_exists("groups", $xml_obj)) { |
|
271 | + } else if (array_key_exists("groups", $xml_obj)) { |
|
276 | 272 | $type = "groups"; |
277 | - } |
|
278 | - else { |
|
273 | + } else { |
|
279 | 274 | error_log("cPanelLicensing::findKey with an object that is not groups or packages"); |
280 | 275 | return; |
281 | 276 | } |
@@ -7,63 +7,63 @@ discard block |
||
7 | 7 | public $curl; |
8 | 8 | public $opts; |
9 | 9 | |
10 | - public function __construct ($user, $pass) { |
|
10 | + public function __construct ($user, $pass) { |
|
11 | 11 | $this->opts = []; |
12 | - $this->format = "simplexml"; |
|
13 | - $this->setCredentials($user, $pass); |
|
14 | - $this->setopt(CURLOPT_RETURNTRANSFER,1); |
|
15 | - $this->setopt(CURLOPT_USERAGENT, 'cPanel Licensing Agent (php) 3.5' ); |
|
16 | - } |
|
12 | + $this->format = "simplexml"; |
|
13 | + $this->setCredentials($user, $pass); |
|
14 | + $this->setopt(CURLOPT_RETURNTRANSFER,1); |
|
15 | + $this->setopt(CURLOPT_USERAGENT, 'cPanel Licensing Agent (php) 3.5' ); |
|
16 | + } |
|
17 | 17 | |
18 | 18 | public function setopt($option, $value) { |
19 | 19 | $this->opts[$option] = $value; |
20 | 20 | } |
21 | 21 | |
22 | - public function setCredentials ($user, $pass) { |
|
23 | - $this->setopt(CURLOPT_USERPWD, $user . ":" . $pass); |
|
24 | - } |
|
22 | + public function setCredentials ($user, $pass) { |
|
23 | + $this->setopt(CURLOPT_USERPWD, $user . ":" . $pass); |
|
24 | + } |
|
25 | 25 | |
26 | - public function set_format ($format) { |
|
27 | - if ($format != "xml" && $format != "json" && $format != "yaml" && $format != "simplexml") { |
|
28 | - error_log("set_format requires that the format is xml, json, yaml or simplexml"); |
|
29 | - return; |
|
30 | - } |
|
31 | - else { |
|
32 | - $this->format = $format; |
|
33 | - } |
|
34 | - } |
|
26 | + public function set_format ($format) { |
|
27 | + if ($format != "xml" && $format != "json" && $format != "yaml" && $format != "simplexml") { |
|
28 | + error_log("set_format requires that the format is xml, json, yaml or simplexml"); |
|
29 | + return; |
|
30 | + } |
|
31 | + else { |
|
32 | + $this->format = $format; |
|
33 | + } |
|
34 | + } |
|
35 | 35 | |
36 | - private function get ($function, $args = array()) { |
|
37 | - if (!$function) { |
|
38 | - error_log("cPanelLicensing::get requires that a function is defined"); |
|
39 | - return; |
|
40 | - } |
|
41 | - if ($this->format != "simplexml") { |
|
42 | - $args['output'] = $this->format; |
|
43 | - } |
|
44 | - $query = "https://manage2.cpanel.net/" . $function . "?" . http_build_query($args); |
|
45 | - $this->setopt(CURLOPT_URL, $query); |
|
36 | + private function get ($function, $args = array()) { |
|
37 | + if (!$function) { |
|
38 | + error_log("cPanelLicensing::get requires that a function is defined"); |
|
39 | + return; |
|
40 | + } |
|
41 | + if ($this->format != "simplexml") { |
|
42 | + $args['output'] = $this->format; |
|
43 | + } |
|
44 | + $query = "https://manage2.cpanel.net/" . $function . "?" . http_build_query($args); |
|
45 | + $this->setopt(CURLOPT_URL, $query); |
|
46 | 46 | $this->curl = curl_init(); |
47 | 47 | foreach ($this->opts as $option => $value) { |
48 | 48 | curl_setopt($this->curl, $option, $value); |
49 | 49 | } |
50 | - $result = curl_exec($this->curl); |
|
50 | + $result = curl_exec($this->curl); |
|
51 | 51 | curl_close($this->curl); |
52 | - if ($result == false) { |
|
53 | - error_log("cPanelLicensing::get failed: \"" . curl_error($this->curl) . "\""); |
|
54 | - return; |
|
55 | - } |
|
56 | - if ($this->format == "simplexml") { |
|
52 | + if ($result == false) { |
|
53 | + error_log("cPanelLicensing::get failed: \"" . curl_error($this->curl) . "\""); |
|
54 | + return; |
|
55 | + } |
|
56 | + if ($this->format == "simplexml") { |
|
57 | 57 | function_requirements('xml2array'); |
58 | 58 | $result = xml2array($result, 1, 'attribute'); |
59 | 59 | $result = $result[str_replace('.cgi', '', $function)]; |
60 | 60 | $result = $this->format_result($result); |
61 | 61 | return $result; |
62 | - } |
|
63 | - else { |
|
64 | - return $result; |
|
65 | - } |
|
66 | - } |
|
62 | + } |
|
63 | + else { |
|
64 | + return $result; |
|
65 | + } |
|
66 | + } |
|
67 | 67 | |
68 | 68 | /** |
69 | 69 | * formats the response |
@@ -85,210 +85,210 @@ discard block |
||
85 | 85 | return $result; |
86 | 86 | } |
87 | 87 | |
88 | - private function validateID ($id) { |
|
89 | - if (preg_match("/^(L|P|G)?\d*$/", $id)) { |
|
90 | - return 1; |
|
91 | - } |
|
92 | - else { |
|
93 | - return 0; |
|
94 | - } |
|
95 | - } |
|
88 | + private function validateID ($id) { |
|
89 | + if (preg_match("/^(L|P|G)?\d*$/", $id)) { |
|
90 | + return 1; |
|
91 | + } |
|
92 | + else { |
|
93 | + return 0; |
|
94 | + } |
|
95 | + } |
|
96 | 96 | |
97 | - private function validateIP ($ip) { |
|
98 | - return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ip); |
|
99 | - } |
|
97 | + private function validateIP ($ip) { |
|
98 | + return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ip); |
|
99 | + } |
|
100 | 100 | |
101 | - public function reactivateLicense ($args) { |
|
102 | - if (!array_key_exists('liscid', $args)) { |
|
103 | - error_log("cpanelLicensing::reactivateLicense requires that the argument array contains element liscid"); |
|
104 | - return; |
|
105 | - } |
|
106 | - if (!$this->validateID($args['liscid'])) { |
|
107 | - error_log("The liscid passed to cpanelLicenseing::reactivateLicense was invalid"); |
|
108 | - return; |
|
109 | - } |
|
110 | - return $this->get("XMLlicenseReActivate.cgi", $args); |
|
111 | - } |
|
101 | + public function reactivateLicense ($args) { |
|
102 | + if (!array_key_exists('liscid', $args)) { |
|
103 | + error_log("cpanelLicensing::reactivateLicense requires that the argument array contains element liscid"); |
|
104 | + return; |
|
105 | + } |
|
106 | + if (!$this->validateID($args['liscid'])) { |
|
107 | + error_log("The liscid passed to cpanelLicenseing::reactivateLicense was invalid"); |
|
108 | + return; |
|
109 | + } |
|
110 | + return $this->get("XMLlicenseReActivate.cgi", $args); |
|
111 | + } |
|
112 | 112 | |
113 | - public function expireLicense ($args) { |
|
114 | - if (!array_key_exists("liscid", $args)) { |
|
115 | - error_log("cPanelLicensing::expireLicense requires that liscid elements exists in the array passed to it"); |
|
116 | - return; |
|
117 | - } |
|
118 | - if (!$this->validateID($args['liscid'])) { |
|
119 | - error_log("the liscense ID passed to cpanelLicensing::expireLiscense was invalid"); |
|
120 | - return; |
|
121 | - } |
|
122 | - return $this->get("XMLlicenseExpire.cgi", $args); |
|
123 | - } |
|
113 | + public function expireLicense ($args) { |
|
114 | + if (!array_key_exists("liscid", $args)) { |
|
115 | + error_log("cPanelLicensing::expireLicense requires that liscid elements exists in the array passed to it"); |
|
116 | + return; |
|
117 | + } |
|
118 | + if (!$this->validateID($args['liscid'])) { |
|
119 | + error_log("the liscense ID passed to cpanelLicensing::expireLiscense was invalid"); |
|
120 | + return; |
|
121 | + } |
|
122 | + return $this->get("XMLlicenseExpire.cgi", $args); |
|
123 | + } |
|
124 | 124 | |
125 | - public function extendOnetimeUpdates ($args) { |
|
126 | - if (!array_key_exists("ip", $args)) { |
|
127 | - error_log("cpanelLicensing::extendOnetimeUpdates requires that the element ip exists in the array is passed to it"); |
|
128 | - return; |
|
129 | - } |
|
130 | - if (!$this->validateIP($args['ip'])) { |
|
131 | - error_log("cpanelLicensing::extendOnetimeUpdates was passed an invalid ip"); |
|
132 | - return; |
|
133 | - } |
|
134 | - return $this->get( "XMLonetimeext.cgi", $args ); |
|
135 | - } |
|
125 | + public function extendOnetimeUpdates ($args) { |
|
126 | + if (!array_key_exists("ip", $args)) { |
|
127 | + error_log("cpanelLicensing::extendOnetimeUpdates requires that the element ip exists in the array is passed to it"); |
|
128 | + return; |
|
129 | + } |
|
130 | + if (!$this->validateIP($args['ip'])) { |
|
131 | + error_log("cpanelLicensing::extendOnetimeUpdates was passed an invalid ip"); |
|
132 | + return; |
|
133 | + } |
|
134 | + return $this->get( "XMLonetimeext.cgi", $args ); |
|
135 | + } |
|
136 | 136 | |
137 | - public function changeip ($args) { |
|
138 | - if (!array_key_exists("oldip", $args) || !array_key_exists("newip", $args)) { |
|
139 | - error_log("cpanelLicensing::changeip requires that oldip and newip elements exist in the array passed to it"); |
|
140 | - return; |
|
141 | - } |
|
142 | - if (!$this->validateIP($args["newip"])) { |
|
143 | - error_log("the newip passed to cpanelLicensing::changeip was invalid"); |
|
144 | - return; |
|
145 | - } |
|
146 | - return $this->get("XMLtransfer.cgi", $args); |
|
147 | - } |
|
137 | + public function changeip ($args) { |
|
138 | + if (!array_key_exists("oldip", $args) || !array_key_exists("newip", $args)) { |
|
139 | + error_log("cpanelLicensing::changeip requires that oldip and newip elements exist in the array passed to it"); |
|
140 | + return; |
|
141 | + } |
|
142 | + if (!$this->validateIP($args["newip"])) { |
|
143 | + error_log("the newip passed to cpanelLicensing::changeip was invalid"); |
|
144 | + return; |
|
145 | + } |
|
146 | + return $this->get("XMLtransfer.cgi", $args); |
|
147 | + } |
|
148 | 148 | |
149 | - public function requestTransfer ($args) { |
|
150 | - if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args ) || !array_key_exists("packagegroup", $args)) { |
|
151 | - error_log("cpanelLicensing::requestTransfer requires that ip, groupid and packageid elements exist in the array passed to it"); |
|
152 | - return; |
|
153 | - } |
|
154 | - if (!$this->validateID($args["groupid"])) { |
|
155 | - error_log("The groupid passed to cpanelLicensing::requestTransfer is invalid"); |
|
156 | - return; |
|
157 | - } |
|
158 | - if (!$this->validateID( $args["packageid"])) { |
|
159 | - error_log("The package id passed to cpanelLicensing::requestTransfer is invalid"); |
|
160 | - return; |
|
161 | - } |
|
162 | - if (!$this->validateIP($args['ip'])) { |
|
163 | - error_log("the ip passed to cpanelLicensing::requestTransfer was invalid"); |
|
164 | - return; |
|
165 | - } |
|
166 | - return $this->get("XMLtransferRequest.cgi", $args); |
|
167 | - } |
|
149 | + public function requestTransfer ($args) { |
|
150 | + if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args ) || !array_key_exists("packagegroup", $args)) { |
|
151 | + error_log("cpanelLicensing::requestTransfer requires that ip, groupid and packageid elements exist in the array passed to it"); |
|
152 | + return; |
|
153 | + } |
|
154 | + if (!$this->validateID($args["groupid"])) { |
|
155 | + error_log("The groupid passed to cpanelLicensing::requestTransfer is invalid"); |
|
156 | + return; |
|
157 | + } |
|
158 | + if (!$this->validateID( $args["packageid"])) { |
|
159 | + error_log("The package id passed to cpanelLicensing::requestTransfer is invalid"); |
|
160 | + return; |
|
161 | + } |
|
162 | + if (!$this->validateIP($args['ip'])) { |
|
163 | + error_log("the ip passed to cpanelLicensing::requestTransfer was invalid"); |
|
164 | + return; |
|
165 | + } |
|
166 | + return $this->get("XMLtransferRequest.cgi", $args); |
|
167 | + } |
|
168 | 168 | |
169 | - public function activateLicense ($args) { |
|
170 | - if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args) || !array_key_exists("packageid", $args)) { |
|
171 | - error_log("cpanelLicensing::activateLicense requires that ip, groupid and packageid elements exist in the array passed to it"); |
|
172 | - return; |
|
173 | - } |
|
174 | - if (!$this->validateID($args['groupid'])) { |
|
175 | - error_log("cpanelLicensing::acivateLicense was passed an invalid groupid"); |
|
176 | - return; |
|
177 | - } |
|
178 | - if (!$this->validateIP($args['ip'])) { |
|
179 | - error_log("cpanelLicensing::activateLicense was passed an invalid IP"); |
|
180 | - return; |
|
181 | - } |
|
182 | - if (!$this->validateID($args['packageid'])) { |
|
183 | - error_log("cpanelLicensing::activateLicense was passed an invalid packageid"); |
|
184 | - return; |
|
185 | - } |
|
186 | - $args['legal'] = 1; |
|
187 | - return $this->get("XMLlicenseAdd.cgi", $args); |
|
188 | - } |
|
169 | + public function activateLicense ($args) { |
|
170 | + if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args) || !array_key_exists("packageid", $args)) { |
|
171 | + error_log("cpanelLicensing::activateLicense requires that ip, groupid and packageid elements exist in the array passed to it"); |
|
172 | + return; |
|
173 | + } |
|
174 | + if (!$this->validateID($args['groupid'])) { |
|
175 | + error_log("cpanelLicensing::acivateLicense was passed an invalid groupid"); |
|
176 | + return; |
|
177 | + } |
|
178 | + if (!$this->validateIP($args['ip'])) { |
|
179 | + error_log("cpanelLicensing::activateLicense was passed an invalid IP"); |
|
180 | + return; |
|
181 | + } |
|
182 | + if (!$this->validateID($args['packageid'])) { |
|
183 | + error_log("cpanelLicensing::activateLicense was passed an invalid packageid"); |
|
184 | + return; |
|
185 | + } |
|
186 | + $args['legal'] = 1; |
|
187 | + return $this->get("XMLlicenseAdd.cgi", $args); |
|
188 | + } |
|
189 | 189 | |
190 | - public function addPickupPass ($args) { |
|
191 | - if (!array_key_exists("pickup", $args)) { |
|
192 | - error_log("cPanelLicensing::addPickupPass requires a pickup param"); |
|
193 | - return; |
|
194 | - } |
|
195 | - return $this->get("XMLaddPickupPass.cgi", $args); |
|
196 | - } |
|
190 | + public function addPickupPass ($args) { |
|
191 | + if (!array_key_exists("pickup", $args)) { |
|
192 | + error_log("cPanelLicensing::addPickupPass requires a pickup param"); |
|
193 | + return; |
|
194 | + } |
|
195 | + return $this->get("XMLaddPickupPass.cgi", $args); |
|
196 | + } |
|
197 | 197 | |
198 | - public function registerAuth ($args) { |
|
199 | - if (!array_key_exists("user", $args)) { |
|
200 | - error_log("cPanelLicensing::registerAuth requires a user param"); |
|
201 | - return; |
|
202 | - } |
|
203 | - if (!array_key_exists("pickup", $args)) { |
|
204 | - error_log("cPanelLicensing::registerAuth requires a pickup param"); |
|
205 | - return; |
|
206 | - } |
|
207 | - if (!array_key_exists("service", $args)) { |
|
208 | - error_log("cPanelLicensing::registerAuth requires a service param"); |
|
209 | - return; |
|
210 | - } |
|
211 | - $response = $this->get("XMLregisterAuth.cgi", $args); |
|
212 | - if ($this->format == "simplexml") { |
|
213 | - $this->setCredentials($args["user"], $response["key"]); |
|
214 | - } |
|
215 | - return $response; |
|
216 | - } |
|
198 | + public function registerAuth ($args) { |
|
199 | + if (!array_key_exists("user", $args)) { |
|
200 | + error_log("cPanelLicensing::registerAuth requires a user param"); |
|
201 | + return; |
|
202 | + } |
|
203 | + if (!array_key_exists("pickup", $args)) { |
|
204 | + error_log("cPanelLicensing::registerAuth requires a pickup param"); |
|
205 | + return; |
|
206 | + } |
|
207 | + if (!array_key_exists("service", $args)) { |
|
208 | + error_log("cPanelLicensing::registerAuth requires a service param"); |
|
209 | + return; |
|
210 | + } |
|
211 | + $response = $this->get("XMLregisterAuth.cgi", $args); |
|
212 | + if ($this->format == "simplexml") { |
|
213 | + $this->setCredentials($args["user"], $response["key"]); |
|
214 | + } |
|
215 | + return $response; |
|
216 | + } |
|
217 | 217 | |
218 | - public function fetchGroups () { |
|
219 | - return $this->get("XMLgroupInfo.cgi"); |
|
220 | - } |
|
218 | + public function fetchGroups () { |
|
219 | + return $this->get("XMLgroupInfo.cgi"); |
|
220 | + } |
|
221 | 221 | |
222 | - public function fetchLicenseRiskData ($args) { |
|
223 | - if (!array_key_exists("ip", $args)) { |
|
224 | - error_log("cpanelLicensing::fetchLicenseRiskData requires that ip exists as an element in the array is passed to it"); |
|
225 | - return; |
|
226 | - } |
|
227 | - if (!$this->validateIP($args['ip'])) { |
|
228 | - error_log("cpanelLicensing::fetchLicenseRiskData was passed an invalid ip"); |
|
229 | - return; |
|
230 | - } |
|
231 | - return $this->get("XMLsecverify.cgi", $args); |
|
232 | - } |
|
222 | + public function fetchLicenseRiskData ($args) { |
|
223 | + if (!array_key_exists("ip", $args)) { |
|
224 | + error_log("cpanelLicensing::fetchLicenseRiskData requires that ip exists as an element in the array is passed to it"); |
|
225 | + return; |
|
226 | + } |
|
227 | + if (!$this->validateIP($args['ip'])) { |
|
228 | + error_log("cpanelLicensing::fetchLicenseRiskData was passed an invalid ip"); |
|
229 | + return; |
|
230 | + } |
|
231 | + return $this->get("XMLsecverify.cgi", $args); |
|
232 | + } |
|
233 | 233 | |
234 | - public function fetchLicenseRaw ($args) { |
|
235 | - $args = array_merge(array("all" => 1), $args); |
|
236 | - if (!array_key_exists("ip", $args)) { |
|
237 | - error_log("cpanelLicesning::fetchLicenseRaw requires that ip exists as an element in the array is passed to it"); |
|
238 | - return; |
|
239 | - } |
|
240 | - if (!$this->validateIP($args['ip'])) { |
|
241 | - error_log("cpanelLicensing::fetchLicenseRaw was passed an invalid ip"); |
|
242 | - return; |
|
243 | - } |
|
244 | - return $this->get("XMLRawlookup.cgi", $args); |
|
245 | - } |
|
234 | + public function fetchLicenseRaw ($args) { |
|
235 | + $args = array_merge(array("all" => 1), $args); |
|
236 | + if (!array_key_exists("ip", $args)) { |
|
237 | + error_log("cpanelLicesning::fetchLicenseRaw requires that ip exists as an element in the array is passed to it"); |
|
238 | + return; |
|
239 | + } |
|
240 | + if (!$this->validateIP($args['ip'])) { |
|
241 | + error_log("cpanelLicensing::fetchLicenseRaw was passed an invalid ip"); |
|
242 | + return; |
|
243 | + } |
|
244 | + return $this->get("XMLRawlookup.cgi", $args); |
|
245 | + } |
|
246 | 246 | |
247 | - public function fetchLicenseId ($args) { |
|
248 | - $args = array_merge(array("all" => 1), $args); |
|
249 | - if (!array_key_exists('ip', $args)) { |
|
250 | - error_log("cpanelLicensing::getLicenseId requires that an IP is passed to it"); |
|
251 | - return; |
|
252 | - } |
|
253 | - if (!$this->validateIP($args['ip'])) { |
|
254 | - error_log("cpanelLicensing::fetchLicenseId was passed an invalid ip"); |
|
255 | - return; |
|
256 | - } |
|
257 | - return $this->get("XMLlookup.cgi", $args); |
|
258 | - } |
|
247 | + public function fetchLicenseId ($args) { |
|
248 | + $args = array_merge(array("all" => 1), $args); |
|
249 | + if (!array_key_exists('ip', $args)) { |
|
250 | + error_log("cpanelLicensing::getLicenseId requires that an IP is passed to it"); |
|
251 | + return; |
|
252 | + } |
|
253 | + if (!$this->validateIP($args['ip'])) { |
|
254 | + error_log("cpanelLicensing::fetchLicenseId was passed an invalid ip"); |
|
255 | + return; |
|
256 | + } |
|
257 | + return $this->get("XMLlookup.cgi", $args); |
|
258 | + } |
|
259 | 259 | |
260 | - public function fetchPackages () { |
|
261 | - return $this->get("XMLpackageInfo.cgi"); |
|
262 | - } |
|
260 | + public function fetchPackages () { |
|
261 | + return $this->get("XMLpackageInfo.cgi"); |
|
262 | + } |
|
263 | 263 | |
264 | - public function fetchLicenses () { |
|
265 | - return $this->get("XMLlicenseInfo.cgi"); |
|
266 | - } |
|
264 | + public function fetchLicenses () { |
|
265 | + return $this->get("XMLlicenseInfo.cgi"); |
|
266 | + } |
|
267 | 267 | |
268 | - public function fetchExpiredLicenses () { |
|
269 | - return $this->get("XMLlicenseInfo.cgi", array("expired" => '1')); |
|
270 | - } |
|
268 | + public function fetchExpiredLicenses () { |
|
269 | + return $this->get("XMLlicenseInfo.cgi", array("expired" => '1')); |
|
270 | + } |
|
271 | 271 | |
272 | - public function findKey ($search, $xml_obj) { |
|
273 | - $xml_obj = (array) $xml_obj; |
|
274 | - if (array_key_exists("packages", $xml_obj)) { |
|
275 | - $type = "packages"; |
|
276 | - } |
|
277 | - else if (array_key_exists("groups", $xml_obj)) { |
|
278 | - $type = "groups"; |
|
279 | - } |
|
280 | - else { |
|
281 | - error_log("cPanelLicensing::findKey with an object that is not groups or packages"); |
|
282 | - return; |
|
283 | - } |
|
284 | - foreach ((array) $xml_obj[$type] as $element) { |
|
285 | - foreach ((array) $element as $key => $value) { |
|
286 | - if ((string) $value == $search) { |
|
287 | - return (string)$key; |
|
288 | - } |
|
289 | - } |
|
290 | - } |
|
291 | - error_log("Could not find $type that matches $search"); |
|
292 | - } |
|
272 | + public function findKey ($search, $xml_obj) { |
|
273 | + $xml_obj = (array) $xml_obj; |
|
274 | + if (array_key_exists("packages", $xml_obj)) { |
|
275 | + $type = "packages"; |
|
276 | + } |
|
277 | + else if (array_key_exists("groups", $xml_obj)) { |
|
278 | + $type = "groups"; |
|
279 | + } |
|
280 | + else { |
|
281 | + error_log("cPanelLicensing::findKey with an object that is not groups or packages"); |
|
282 | + return; |
|
283 | + } |
|
284 | + foreach ((array) $xml_obj[$type] as $element) { |
|
285 | + foreach ((array) $element as $key => $value) { |
|
286 | + if ((string) $value == $search) { |
|
287 | + return (string)$key; |
|
288 | + } |
|
289 | + } |
|
290 | + } |
|
291 | + error_log("Could not find $type that matches $search"); |
|
292 | + } |
|
293 | 293 | } |
294 | 294 |
@@ -7,23 +7,23 @@ discard block |
||
7 | 7 | public $curl; |
8 | 8 | public $opts; |
9 | 9 | |
10 | - public function __construct ($user, $pass) { |
|
10 | + public function __construct($user, $pass) { |
|
11 | 11 | $this->opts = []; |
12 | 12 | $this->format = "simplexml"; |
13 | 13 | $this->setCredentials($user, $pass); |
14 | - $this->setopt(CURLOPT_RETURNTRANSFER,1); |
|
15 | - $this->setopt(CURLOPT_USERAGENT, 'cPanel Licensing Agent (php) 3.5' ); |
|
14 | + $this->setopt(CURLOPT_RETURNTRANSFER, 1); |
|
15 | + $this->setopt(CURLOPT_USERAGENT, 'cPanel Licensing Agent (php) 3.5'); |
|
16 | 16 | } |
17 | 17 | |
18 | 18 | public function setopt($option, $value) { |
19 | 19 | $this->opts[$option] = $value; |
20 | 20 | } |
21 | 21 | |
22 | - public function setCredentials ($user, $pass) { |
|
23 | - $this->setopt(CURLOPT_USERPWD, $user . ":" . $pass); |
|
22 | + public function setCredentials($user, $pass) { |
|
23 | + $this->setopt(CURLOPT_USERPWD, $user.":".$pass); |
|
24 | 24 | } |
25 | 25 | |
26 | - public function set_format ($format) { |
|
26 | + public function set_format($format) { |
|
27 | 27 | if ($format != "xml" && $format != "json" && $format != "yaml" && $format != "simplexml") { |
28 | 28 | error_log("set_format requires that the format is xml, json, yaml or simplexml"); |
29 | 29 | return; |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | } |
34 | 34 | } |
35 | 35 | |
36 | - private function get ($function, $args = array()) { |
|
36 | + private function get($function, $args = array()) { |
|
37 | 37 | if (!$function) { |
38 | 38 | error_log("cPanelLicensing::get requires that a function is defined"); |
39 | 39 | return; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | if ($this->format != "simplexml") { |
42 | 42 | $args['output'] = $this->format; |
43 | 43 | } |
44 | - $query = "https://manage2.cpanel.net/" . $function . "?" . http_build_query($args); |
|
44 | + $query = "https://manage2.cpanel.net/".$function."?".http_build_query($args); |
|
45 | 45 | $this->setopt(CURLOPT_URL, $query); |
46 | 46 | $this->curl = curl_init(); |
47 | 47 | foreach ($this->opts as $option => $value) { |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | $result = curl_exec($this->curl); |
51 | 51 | curl_close($this->curl); |
52 | 52 | if ($result == false) { |
53 | - error_log("cPanelLicensing::get failed: \"" . curl_error($this->curl) . "\""); |
|
53 | + error_log("cPanelLicensing::get failed: \"".curl_error($this->curl)."\""); |
|
54 | 54 | return; |
55 | 55 | } |
56 | 56 | if ($this->format == "simplexml") { |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | return $result; |
86 | 86 | } |
87 | 87 | |
88 | - private function validateID ($id) { |
|
88 | + private function validateID($id) { |
|
89 | 89 | if (preg_match("/^(L|P|G)?\d*$/", $id)) { |
90 | 90 | return 1; |
91 | 91 | } |
@@ -94,11 +94,11 @@ discard block |
||
94 | 94 | } |
95 | 95 | } |
96 | 96 | |
97 | - private function validateIP ($ip) { |
|
97 | + private function validateIP($ip) { |
|
98 | 98 | return preg_match("/^\d*\.\d*\.\d*\.\d*$/", $ip); |
99 | 99 | } |
100 | 100 | |
101 | - public function reactivateLicense ($args) { |
|
101 | + public function reactivateLicense($args) { |
|
102 | 102 | if (!array_key_exists('liscid', $args)) { |
103 | 103 | error_log("cpanelLicensing::reactivateLicense requires that the argument array contains element liscid"); |
104 | 104 | return; |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | return $this->get("XMLlicenseReActivate.cgi", $args); |
111 | 111 | } |
112 | 112 | |
113 | - public function expireLicense ($args) { |
|
113 | + public function expireLicense($args) { |
|
114 | 114 | if (!array_key_exists("liscid", $args)) { |
115 | 115 | error_log("cPanelLicensing::expireLicense requires that liscid elements exists in the array passed to it"); |
116 | 116 | return; |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | return $this->get("XMLlicenseExpire.cgi", $args); |
123 | 123 | } |
124 | 124 | |
125 | - public function extendOnetimeUpdates ($args) { |
|
125 | + public function extendOnetimeUpdates($args) { |
|
126 | 126 | if (!array_key_exists("ip", $args)) { |
127 | 127 | error_log("cpanelLicensing::extendOnetimeUpdates requires that the element ip exists in the array is passed to it"); |
128 | 128 | return; |
@@ -131,10 +131,10 @@ discard block |
||
131 | 131 | error_log("cpanelLicensing::extendOnetimeUpdates was passed an invalid ip"); |
132 | 132 | return; |
133 | 133 | } |
134 | - return $this->get( "XMLonetimeext.cgi", $args ); |
|
134 | + return $this->get("XMLonetimeext.cgi", $args); |
|
135 | 135 | } |
136 | 136 | |
137 | - public function changeip ($args) { |
|
137 | + public function changeip($args) { |
|
138 | 138 | if (!array_key_exists("oldip", $args) || !array_key_exists("newip", $args)) { |
139 | 139 | error_log("cpanelLicensing::changeip requires that oldip and newip elements exist in the array passed to it"); |
140 | 140 | return; |
@@ -146,8 +146,8 @@ discard block |
||
146 | 146 | return $this->get("XMLtransfer.cgi", $args); |
147 | 147 | } |
148 | 148 | |
149 | - public function requestTransfer ($args) { |
|
150 | - if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args ) || !array_key_exists("packagegroup", $args)) { |
|
149 | + public function requestTransfer($args) { |
|
150 | + if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args) || !array_key_exists("packagegroup", $args)) { |
|
151 | 151 | error_log("cpanelLicensing::requestTransfer requires that ip, groupid and packageid elements exist in the array passed to it"); |
152 | 152 | return; |
153 | 153 | } |
@@ -155,7 +155,7 @@ discard block |
||
155 | 155 | error_log("The groupid passed to cpanelLicensing::requestTransfer is invalid"); |
156 | 156 | return; |
157 | 157 | } |
158 | - if (!$this->validateID( $args["packageid"])) { |
|
158 | + if (!$this->validateID($args["packageid"])) { |
|
159 | 159 | error_log("The package id passed to cpanelLicensing::requestTransfer is invalid"); |
160 | 160 | return; |
161 | 161 | } |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | return $this->get("XMLtransferRequest.cgi", $args); |
167 | 167 | } |
168 | 168 | |
169 | - public function activateLicense ($args) { |
|
169 | + public function activateLicense($args) { |
|
170 | 170 | if (!array_key_exists("ip", $args) || !array_key_exists("groupid", $args) || !array_key_exists("packageid", $args)) { |
171 | 171 | error_log("cpanelLicensing::activateLicense requires that ip, groupid and packageid elements exist in the array passed to it"); |
172 | 172 | return; |
@@ -187,7 +187,7 @@ discard block |
||
187 | 187 | return $this->get("XMLlicenseAdd.cgi", $args); |
188 | 188 | } |
189 | 189 | |
190 | - public function addPickupPass ($args) { |
|
190 | + public function addPickupPass($args) { |
|
191 | 191 | if (!array_key_exists("pickup", $args)) { |
192 | 192 | error_log("cPanelLicensing::addPickupPass requires a pickup param"); |
193 | 193 | return; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | return $this->get("XMLaddPickupPass.cgi", $args); |
196 | 196 | } |
197 | 197 | |
198 | - public function registerAuth ($args) { |
|
198 | + public function registerAuth($args) { |
|
199 | 199 | if (!array_key_exists("user", $args)) { |
200 | 200 | error_log("cPanelLicensing::registerAuth requires a user param"); |
201 | 201 | return; |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | return $response; |
216 | 216 | } |
217 | 217 | |
218 | - public function fetchGroups () { |
|
218 | + public function fetchGroups() { |
|
219 | 219 | return $this->get("XMLgroupInfo.cgi"); |
220 | 220 | } |
221 | 221 | |
222 | - public function fetchLicenseRiskData ($args) { |
|
222 | + public function fetchLicenseRiskData($args) { |
|
223 | 223 | if (!array_key_exists("ip", $args)) { |
224 | 224 | error_log("cpanelLicensing::fetchLicenseRiskData requires that ip exists as an element in the array is passed to it"); |
225 | 225 | return; |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | return $this->get("XMLsecverify.cgi", $args); |
232 | 232 | } |
233 | 233 | |
234 | - public function fetchLicenseRaw ($args) { |
|
234 | + public function fetchLicenseRaw($args) { |
|
235 | 235 | $args = array_merge(array("all" => 1), $args); |
236 | 236 | if (!array_key_exists("ip", $args)) { |
237 | 237 | error_log("cpanelLicesning::fetchLicenseRaw requires that ip exists as an element in the array is passed to it"); |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | return $this->get("XMLRawlookup.cgi", $args); |
245 | 245 | } |
246 | 246 | |
247 | - public function fetchLicenseId ($args) { |
|
247 | + public function fetchLicenseId($args) { |
|
248 | 248 | $args = array_merge(array("all" => 1), $args); |
249 | 249 | if (!array_key_exists('ip', $args)) { |
250 | 250 | error_log("cpanelLicensing::getLicenseId requires that an IP is passed to it"); |
@@ -257,19 +257,19 @@ discard block |
||
257 | 257 | return $this->get("XMLlookup.cgi", $args); |
258 | 258 | } |
259 | 259 | |
260 | - public function fetchPackages () { |
|
260 | + public function fetchPackages() { |
|
261 | 261 | return $this->get("XMLpackageInfo.cgi"); |
262 | 262 | } |
263 | 263 | |
264 | - public function fetchLicenses () { |
|
264 | + public function fetchLicenses() { |
|
265 | 265 | return $this->get("XMLlicenseInfo.cgi"); |
266 | 266 | } |
267 | 267 | |
268 | - public function fetchExpiredLicenses () { |
|
268 | + public function fetchExpiredLicenses() { |
|
269 | 269 | return $this->get("XMLlicenseInfo.cgi", array("expired" => '1')); |
270 | 270 | } |
271 | 271 | |
272 | - public function findKey ($search, $xml_obj) { |
|
272 | + public function findKey($search, $xml_obj) { |
|
273 | 273 | $xml_obj = (array) $xml_obj; |
274 | 274 | if (array_key_exists("packages", $xml_obj)) { |
275 | 275 | $type = "packages"; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | foreach ((array) $xml_obj[$type] as $element) { |
285 | 285 | foreach ((array) $element as $key => $value) { |
286 | 286 | if ((string) $value == $search) { |
287 | - return (string)$key; |
|
287 | + return (string) $key; |
|
288 | 288 | } |
289 | 289 | } |
290 | 290 | } |
@@ -49,7 +49,7 @@ |
||
49 | 49 | } |
50 | 50 | $result = curl_exec($this->curl); |
51 | 51 | curl_close($this->curl); |
52 | - if ($result == false) { |
|
52 | + if ($result == FALSE) { |
|
53 | 53 | error_log("cPanelLicensing::get failed: \"" . curl_error($this->curl) . "\""); |
54 | 54 | return; |
55 | 55 | } |
@@ -3,7 +3,7 @@ |
||
3 | 3 | function_requirements('xml2array'); |
4 | 4 | include("../cpl.inc.php"); |
5 | 5 | |
6 | -$cpl = new \Detain\Cpanel\Cpanel($_SERVER['argv'][1],$_SERVER['argv'][2]); |
|
6 | +$cpl = new \Detain\Cpanel\Cpanel($_SERVER['argv'][1], $_SERVER['argv'][2]); |
|
7 | 7 | |
8 | 8 | $licenses = $cpl->fetchLicenses(); |
9 | 9 | print_r($licenses); |
@@ -10,8 +10,8 @@ |
||
10 | 10 | |
11 | 11 | |
12 | 12 | $status = (array)$cpl->fetchLicenseRiskData(array( |
13 | - "ip" => $ip |
|
14 | - ) |
|
13 | + "ip" => $ip |
|
14 | + ) |
|
15 | 15 | ); |
16 | 16 | |
17 | 17 | if ($status["@attributes"]["status"] == 1) { |
@@ -9,16 +9,16 @@ |
||
9 | 9 | # |
10 | 10 | |
11 | 11 | |
12 | -$status = (array)$cpl->fetchLicenseRiskData(array( |
|
12 | +$status = (array) $cpl->fetchLicenseRiskData(array( |
|
13 | 13 | "ip" => $ip |
14 | 14 | ) |
15 | 15 | ); |
16 | 16 | |
17 | 17 | if ($status["@attributes"]["status"] == 1) { |
18 | 18 | print "Risk Scores for $ip:\n"; |
19 | - print "aggregate : " . $status["@attributes"]["riskscore.aggregate.score"] . "\n"; |
|
20 | - print "directorder : " . $status["@attributes"]["riskscore.directorder.score"] . "\n"; |
|
21 | - print "main : " . $status["@attributes"]["riskscore.main.score"] . "\n"; |
|
19 | + print "aggregate : ".$status["@attributes"]["riskscore.aggregate.score"]."\n"; |
|
20 | + print "directorder : ".$status["@attributes"]["riskscore.directorder.score"]."\n"; |
|
21 | + print "main : ".$status["@attributes"]["riskscore.main.score"]."\n"; |
|
22 | 22 | } else { |
23 | 23 | print "Failed to fetch risk data\n"; |
24 | 24 | } |
@@ -7,8 +7,8 @@ |
||
7 | 7 | $newip = "__DESTINATIONIP__"; |
8 | 8 | |
9 | 9 | $response = (array)$cpl->changeip( array( |
10 | - "oldip" => $oldip, |
|
11 | - "newip" => $newip |
|
10 | + "oldip" => $oldip, |
|
11 | + "newip" => $newip |
|
12 | 12 | ) ); |
13 | 13 | |
14 | 14 | print_r($response)."\n"; |
@@ -6,10 +6,10 @@ |
||
6 | 6 | $oldip = "__SOURCEIP__"; |
7 | 7 | $newip = "__DESTINATIONIP__"; |
8 | 8 | |
9 | -$response = (array)$cpl->changeip( array( |
|
9 | +$response = (array) $cpl->changeip(array( |
|
10 | 10 | "oldip" => $oldip, |
11 | 11 | "newip" => $newip |
12 | -) ); |
|
12 | +)); |
|
13 | 13 | |
14 | 14 | print_r($response)."\n"; |
15 | 15 |
@@ -8,10 +8,10 @@ |
||
8 | 8 | $package = $cpl->findKey("__PACKAGE_NAME__", $cpl->fetchPackages() ); |
9 | 9 | |
10 | 10 | $result = (array)$cpl->requestTransfer( array( |
11 | - "ip" => $ip, |
|
12 | - "groupid" => $group, |
|
13 | - "packageid" => $package |
|
14 | - ) |
|
11 | + "ip" => $ip, |
|
12 | + "groupid" => $group, |
|
13 | + "packageid" => $package |
|
14 | + ) |
|
15 | 15 | ); |
16 | 16 | |
17 | 17 | print $result["@attributes"]['reason'] . "\n"; |
@@ -4,15 +4,15 @@ |
||
4 | 4 | |
5 | 5 | $ip = "__IP_TO_TRANSFER__"; |
6 | 6 | |
7 | -$group = $cpl->findKey("__GROUP_NAME__", $cpl->fetchGroups() ); |
|
8 | -$package = $cpl->findKey("__PACKAGE_NAME__", $cpl->fetchPackages() ); |
|
7 | +$group = $cpl->findKey("__GROUP_NAME__", $cpl->fetchGroups()); |
|
8 | +$package = $cpl->findKey("__PACKAGE_NAME__", $cpl->fetchPackages()); |
|
9 | 9 | |
10 | -$result = (array)$cpl->requestTransfer( array( |
|
10 | +$result = (array) $cpl->requestTransfer(array( |
|
11 | 11 | "ip" => $ip, |
12 | 12 | "groupid" => $group, |
13 | 13 | "packageid" => $package |
14 | 14 | ) |
15 | 15 | ); |
16 | 16 | |
17 | -print $result["@attributes"]['reason'] . "\n"; |
|
17 | +print $result["@attributes"]['reason']."\n"; |
|
18 | 18 |
@@ -4,9 +4,9 @@ |
||
4 | 4 | |
5 | 5 | $cpl = new \Detain\Cpanel\Cpanel("", ""); |
6 | 6 | $response = $cpl->registerAuth(array( |
7 | - "user" => $_SERVER['argv'][1], |
|
8 | - "pickup" => "__PHRASE__", |
|
9 | - "service" => "__SERVICE__")); |
|
7 | + "user" => $_SERVER['argv'][1], |
|
8 | + "pickup" => "__PHRASE__", |
|
9 | + "service" => "__SERVICE__")); |
|
10 | 10 | |
11 | 11 | echo $response; |
12 | 12 |
@@ -10,19 +10,19 @@ |
||
10 | 10 | $packageid = $cpl->findKey("__PACKAGENAME__", $cpl->fetchPackages() ); |
11 | 11 | |
12 | 12 | $lisc = (array)$cpl->activateLicense(array( |
13 | - "ip" => $ip, |
|
14 | - "groupid" => $groupid, |
|
15 | - "packageid" => $packageid, |
|
16 | - "force" => 1, |
|
13 | + "ip" => $ip, |
|
14 | + "groupid" => $groupid, |
|
15 | + "packageid" => $packageid, |
|
16 | + "force" => 1, |
|
17 | 17 | #If 0 the license will not be activated if you would be billed a reactivation fee |
18 | 18 | #If 1 the license will be activated if a fee is required (at the time of this writing, licenses reactivated within 72 hours of billing) |
19 | - "reactivateok" => 1 |
|
20 | - ) |
|
19 | + "reactivateok" => 1 |
|
20 | + ) |
|
21 | 21 | ); |
22 | 22 | |
23 | 23 | if ($lisc['@attributes']['status'] > 0) { |
24 | - print "license added with id: ". $lisc['@attributes']['licenseid'] . "\n"; |
|
24 | + print "license added with id: ". $lisc['@attributes']['licenseid'] . "\n"; |
|
25 | 25 | } else { |
26 | - print "License add failed: " . $lisc['@attributes']['reason'] . "\n"; |
|
26 | + print "License add failed: " . $lisc['@attributes']['reason'] . "\n"; |
|
27 | 27 | } |
28 | 28 |
@@ -2,14 +2,14 @@ discard block |
||
2 | 2 | |
3 | 3 | include("../cpl.inc.php"); |
4 | 4 | |
5 | -$cpl = new \Detain\Cpanel\Cpanel( $_SERVER['argv'][1], $_SERVER['argv'][2] ); |
|
5 | +$cpl = new \Detain\Cpanel\Cpanel($_SERVER['argv'][1], $_SERVER['argv'][2]); |
|
6 | 6 | |
7 | 7 | $ip = "__IP__"; |
8 | 8 | |
9 | -$groupid = $cpl->findKey("__GROUPNAME__", $cpl->fetchGroups() ); |
|
10 | -$packageid = $cpl->findKey("__PACKAGENAME__", $cpl->fetchPackages() ); |
|
9 | +$groupid = $cpl->findKey("__GROUPNAME__", $cpl->fetchGroups()); |
|
10 | +$packageid = $cpl->findKey("__PACKAGENAME__", $cpl->fetchPackages()); |
|
11 | 11 | |
12 | -$lisc = (array)$cpl->activateLicense(array( |
|
12 | +$lisc = (array) $cpl->activateLicense(array( |
|
13 | 13 | "ip" => $ip, |
14 | 14 | "groupid" => $groupid, |
15 | 15 | "packageid" => $packageid, |
@@ -21,8 +21,8 @@ discard block |
||
21 | 21 | ); |
22 | 22 | |
23 | 23 | if ($lisc['@attributes']['status'] > 0) { |
24 | - print "license added with id: ". $lisc['@attributes']['licenseid'] . "\n"; |
|
24 | + print "license added with id: ".$lisc['@attributes']['licenseid']."\n"; |
|
25 | 25 | } else { |
26 | - print "License add failed: " . $lisc['@attributes']['reason'] . "\n"; |
|
26 | + print "License add failed: ".$lisc['@attributes']['reason']."\n"; |
|
27 | 27 | } |
28 | 28 |
@@ -7,9 +7,9 @@ |
||
7 | 7 | $id = $lisc['licenseid']; |
8 | 8 | $id = is_array($id) ? $id[0] : $id; |
9 | 9 | if ($id) { |
10 | - print "The license id for $ip is $id\n"; |
|
10 | + print "The license id for $ip is $id\n"; |
|
11 | 11 | } else { |
12 | - print "No valid license exists for $ip\n"; |
|
12 | + print "No valid license exists for $ip\n"; |
|
13 | 13 | } |
14 | 14 | |
15 | 15 |
@@ -8,15 +8,15 @@ |
||
8 | 8 | $liscid = $lisc["@attributes"]["licenseid"]; |
9 | 9 | |
10 | 10 | if ( $liscid > 0 ) { |
11 | - $expire = (array)$cpl->expireLicense(array( |
|
12 | - liscid => $liscid, |
|
13 | - reason => "Automagic Expiration", |
|
14 | - expcode => "normal" |
|
15 | - ) |
|
16 | - ); |
|
17 | - print $expire["@attributes"]["result"] . "\n"; |
|
11 | + $expire = (array)$cpl->expireLicense(array( |
|
12 | + liscid => $liscid, |
|
13 | + reason => "Automagic Expiration", |
|
14 | + expcode => "normal" |
|
15 | + ) |
|
16 | + ); |
|
17 | + print $expire["@attributes"]["result"] . "\n"; |
|
18 | 18 | } else { |
19 | - print "There is no valid license for $ip\n"; |
|
19 | + print "There is no valid license for $ip\n"; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 |
@@ -4,17 +4,17 @@ |
||
4 | 4 | |
5 | 5 | $ip = "__IP__"; |
6 | 6 | |
7 | -$lisc = (array)$cpl->fetchLicenseId( array( "ip" => $ip ) ); |
|
7 | +$lisc = (array) $cpl->fetchLicenseId(array("ip" => $ip)); |
|
8 | 8 | $liscid = $lisc["@attributes"]["licenseid"]; |
9 | 9 | |
10 | -if ( $liscid > 0 ) { |
|
11 | - $expire = (array)$cpl->expireLicense(array( |
|
10 | +if ($liscid > 0) { |
|
11 | + $expire = (array) $cpl->expireLicense(array( |
|
12 | 12 | liscid => $liscid, |
13 | 13 | reason => "Automagic Expiration", |
14 | 14 | expcode => "normal" |
15 | 15 | ) |
16 | 16 | ); |
17 | - print $expire["@attributes"]["result"] . "\n"; |
|
17 | + print $expire["@attributes"]["result"]."\n"; |
|
18 | 18 | } else { |
19 | 19 | print "There is no valid license for $ip\n"; |
20 | 20 | } |