├── lib
└── README.md
├── README
├── logo.png
├── templates
├── error.tpl
├── manage.tpl
└── overview.tpl
├── whatdoestheproxsay.php
├── hooks.php
└── foxyprox.php
/lib/README.md:
--------------------------------------------------------------------------------
1 | Include libraries and third party modules here.
2 |
--------------------------------------------------------------------------------
/README:
--------------------------------------------------------------------------------
1 | Free Open Proxmox Module
2 |
3 | Why? Well modulesgarden made me
4 |
--------------------------------------------------------------------------------
/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GenjiSwitchPlz/foxyprox/HEAD/logo.png
--------------------------------------------------------------------------------
/templates/error.tpl:
--------------------------------------------------------------------------------
1 |
Oops! Something went wrong.
2 |
3 |
4 |
Extra template variables work here too: {$usefulErrorHelper}
5 |
6 |
7 | Please go back and try again.
8 |
9 | If the problem persists, please contact support.
10 |
--------------------------------------------------------------------------------
/whatdoestheproxsay.php:
--------------------------------------------------------------------------------
1 | urlencode($username),'password' => urlencode($password),); //Set username & password
9 | foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } //url-ify the data for the POST
10 | rtrim($fields_string, '&'); //Cut to size, size 34 jeans are a little big for me
11 | $ch = curl_init(); // Initiate curl
12 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Will return the response, if false it print the response
13 | curl_setopt($ch, CURLOPT_URL,$url); // Set the url
14 | curl_setopt($ch,CURLOPT_POST, count($fields)); //Throw in some params
15 | curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);//What are the params
16 | $result=curl_exec($ch); // Execute
17 | curl_close($ch); // Closing
18 | var_dump(json_decode($result, true)); // Will dump a JSON
19 | }
20 |
21 | }
22 | ?>
--------------------------------------------------------------------------------
/templates/manage.tpl:
--------------------------------------------------------------------------------
1 | Custom Client Area Page
2 |
3 | This is an example of an additional custom page within a module's client area product management pages.
4 |
5 | Everything that is available in the overview is also available in this template file along with any custom defined template variables.
6 |
7 |
8 |
9 |
10 |
11 | {$LANG.orderproduct}
12 |
13 |
14 | {$groupname} - {$product}
15 |
16 |
17 |
18 |
19 |
20 | Extra Variable 1
21 |
22 |
23 | {$extraVariable1}
24 |
25 |
26 |
27 |
28 |
29 | Extra Variable 2
30 |
31 |
32 | {$extraVariable2}
33 |
34 |
35 |
36 |
37 |
38 |
49 |
--------------------------------------------------------------------------------
/hooks.php:
--------------------------------------------------------------------------------
1 | getChild('Services'))) {
69 | // Add a link to the module filter.
70 | $menu->getChild('Services')
71 | ->addChild(
72 | 'Provisioning Module Products',
73 | array(
74 | 'uri' => 'clientarea.php?action=services&module=provisioningmodule',
75 | 'order' => 15,
76 | )
77 | );
78 | }
79 | });
80 |
81 | /**
82 | * Render a custom sidebar panel in the secondary sidebar.
83 | *
84 | * Demonstrates the creation of an additional sidebar panel on any page where
85 | * the My Services Actions default panel appears and populates it with a title,
86 | * icon, body and footer html output and a child link. Also sets it to be in
87 | * front of any other panels defined up to this point.
88 | *
89 | * @param \WHMCS\View\Menu\Item $secondarySidebar
90 | */
91 | add_hook('ClientAreaSecondarySidebar', 1, function ($secondarySidebar)
92 | {
93 | // determine if we are on a page containing My Services Actions
94 | if (!is_null($secondarySidebar->getChild('My Services Actions'))) {
95 |
96 | // define new sidebar panel
97 | $customPanel = $secondarySidebar->addChild('Provisioning Module Sample Panel');
98 |
99 | // set panel attributes
100 | $customPanel->moveToFront()
101 | ->setIcon('fa-user')
102 | ->setBodyHtml(
103 | 'Your HTML output goes here...'
104 | )
105 | ->setFooterHtml(
106 | 'Footer HTML can go here...'
107 | );
108 |
109 | // define link
110 | $customPanel->addChild(
111 | 'Sample Link Menu Item',
112 | array(
113 | 'uri' => 'clientarea.php?action=services&module=provisioningmodule',
114 | 'icon' => 'fa-list-alt',
115 | 'order' => 2,
116 | )
117 | );
118 |
119 | }
120 | });
121 |
--------------------------------------------------------------------------------
/templates/overview.tpl:
--------------------------------------------------------------------------------
1 | Overview
2 |
3 | Overview output goes here...
4 |
5 | Please Remember: When overriding the default product overview output, it is important to provide the product details and information that are normally displayed on this page. These are provided below.
6 |
7 |
8 | Any variables you define inside the ClientArea module function can also be accessed and used here, for example: {$extraVariable1} & {$extraVariable2}
9 |
10 |
11 | {$LANG.clientareaproductdetails}
12 |
13 |
14 |
15 |
16 |
17 | {$LANG.clientareahostingregdate}
18 |
19 |
20 | {$regdate}
21 |
22 |
23 |
24 |
25 |
26 | {$LANG.orderproduct}
27 |
28 |
29 | {$groupname} - {$product}
30 |
31 |
32 |
33 | {if $type eq "server"}
34 | {if $domain}
35 |
36 |
37 | {$LANG.serverhostname}
38 |
39 |
40 | {$domain}
41 |
42 |
43 | {/if}
44 | {if $dedicatedip}
45 |
46 |
47 | {$LANG.primaryIP}
48 |
49 |
50 | {$dedicatedip}
51 |
52 |
53 | {/if}
54 | {if $assignedips}
55 |
56 |
57 | {$LANG.assignedIPs}
58 |
59 |
60 | {$assignedips|nl2br}
61 |
62 |
63 | {/if}
64 | {if $ns1 || $ns2}
65 |
66 |
67 | {$LANG.domainnameservers}
68 |
69 |
70 | {$ns1} {$ns2}
71 |
72 |
73 | {/if}
74 | {else}
75 | {if $domain}
76 |
77 |
78 | {$LANG.orderdomain}
79 |
80 |
84 |
85 | {/if}
86 | {if $username}
87 |
88 |
89 | {$LANG.serverusername}
90 |
91 |
92 | {$username}
93 |
94 |
95 | {/if}
96 | {if $serverdata}
97 |
98 |
99 | {$LANG.servername}
100 |
101 |
102 | {$serverdata.hostname}
103 |
104 |
105 |
106 |
107 | {$LANG.domainregisternsip}
108 |
109 |
110 | {$serverdata.ipaddress}
111 |
112 |
113 | {if $serverdata.nameserver1 || $serverdata.nameserver2 || $serverdata.nameserver3 || $serverdata.nameserver4 || $serverdata.nameserver5}
114 |
115 |
116 | {$LANG.domainnameservers}
117 |
118 |
119 | {if $serverdata.nameserver1}{$serverdata.nameserver1} ({$serverdata.nameserver1ip}) {/if}
120 | {if $serverdata.nameserver2}{$serverdata.nameserver2} ({$serverdata.nameserver2ip}) {/if}
121 | {if $serverdata.nameserver3}{$serverdata.nameserver3} ({$serverdata.nameserver3ip}) {/if}
122 | {if $serverdata.nameserver4}{$serverdata.nameserver4} ({$serverdata.nameserver4ip}) {/if}
123 | {if $serverdata.nameserver5}{$serverdata.nameserver5} ({$serverdata.nameserver5ip}) {/if}
124 |
125 |
126 | {/if}
127 | {/if}
128 | {/if}
129 |
130 | {if $dedicatedip}
131 |
132 |
133 | {$LANG.domainregisternsip}
134 |
135 |
136 | {$dedicatedip}
137 |
138 |
139 | {/if}
140 |
141 | {foreach from=$configurableoptions item=configoption}
142 |
143 |
144 | {$configoption.optionname}
145 |
146 |
147 | {if $configoption.optiontype eq 3}
148 | {if $configoption.selectedqty}
149 | {$LANG.yes}
150 | {else}
151 | {$LANG.no}
152 | {/if}
153 | {elseif $configoption.optiontype eq 4}
154 | {$configoption.selectedqty} x {$configoption.selectedoption}
155 | {else}
156 | {$configoption.selectedoption}
157 | {/if}
158 |
159 |
160 | {/foreach}
161 |
162 | {foreach from=$productcustomfields item=customfield}
163 |
164 |
165 | {$customfield.name}
166 |
167 |
168 | {$customfield.value}
169 |
170 |
171 | {/foreach}
172 |
173 | {if $lastupdate}
174 |
175 |
176 | {$LANG.clientareadiskusage}
177 |
178 |
179 | {$diskusage}MB / {$disklimit}MB ({$diskpercent})
180 |
181 |
182 |
183 |
184 | {$LANG.clientareabwusage}
185 |
186 |
187 | {$bwusage}MB / {$bwlimit}MB ({$bwpercent})
188 |
189 |
190 | {/if}
191 |
192 |
193 |
194 | {$LANG.orderpaymentmethod}
195 |
196 |
197 | {$paymentmethod}
198 |
199 |
200 |
201 |
202 |
203 | {$LANG.firstpaymentamount}
204 |
205 |
206 | {$firstpaymentamount}
207 |
208 |
209 |
210 |
211 |
212 | {$LANG.recurringamount}
213 |
214 |
215 | {$recurringamount}
216 |
217 |
218 |
219 |
220 |
221 | {$LANG.clientareahostingnextduedate}
222 |
223 |
224 | {$nextduedate}
225 |
226 |
227 |
228 |
229 |
230 | {$LANG.orderbillingcycle}
231 |
232 |
233 | {$billingcycle}
234 |
235 |
236 |
237 |
238 |
239 | {$LANG.clientareastatus}
240 |
241 |
242 | {$status}
243 |
244 |
245 |
246 | {if $suspendreason}
247 |
248 |
249 | {$LANG.suspendreason}
250 |
251 |
252 | {$suspendreason}
253 |
254 |
255 | {/if}
256 |
257 |
258 |
259 |
260 |
261 |
268 |
269 |
270 | {if $packagesupgrade}
271 |
276 | {/if}
277 |
278 |
287 |
288 |
--------------------------------------------------------------------------------
/foxyprox.php:
--------------------------------------------------------------------------------
1 | 'FoxyProx',
39 | 'APIVersion' => '1.1', // Use API Version 1.1
40 | 'RequiresServer' => true, // Set true if module requires a server to work
41 | 'DefaultSSLPort' => '8006', // Default SSL Connection Port
42 | 'ServiceSingleSignOnLabel' => 'Login to Panel as User',
43 | 'AdminSingleSignOnLabel' => 'Login to Panel as Admin',
44 | );
45 | }
46 |
47 | /**
48 | * Define product configuration options.
49 | *
50 | * The values you return here define the configuration options that are
51 | * presented to a user when configuring a product for use with the module. These
52 | * values are then made available in all module function calls with the key name
53 | * configoptionX - with X being the index number of the field from 1 to 24.
54 | *
55 | * You can specify up to 24 parameters, with field types:
56 | * * text
57 | * * password
58 | * * yesno
59 | * * dropdown
60 | * * radio
61 | * * textarea
62 | *
63 | * Examples of each and their possible configuration parameters are provided in
64 | * this sample function.
65 | *
66 | * @return array
67 | */
68 | function foxyprox_ConfigOptions()
69 | {
70 | return array(
71 | /*// a text field type allows for single line text input
72 | 'Text Field' => array(
73 | 'Type' => 'text',
74 | 'Size' => '25',
75 | 'Default' => '1024',
76 | 'Description' => 'Enter in megabytes',
77 | ),
78 | // a password field type allows for masked text input
79 | 'Password Field' => array(
80 | 'Type' => 'password',
81 | 'Size' => '25',
82 | 'Default' => '',
83 | 'Description' => 'Enter secret value here',
84 | ),
85 | // the yesno field type displays a single checkbox option
86 | 'Checkbox Field' => array(
87 | 'Type' => 'yesno',
88 | 'Description' => 'Tick to enable',
89 | ),
90 | // the dropdown field type renders a select menu of options
91 | 'Dropdown Field' => array(
92 | 'Type' => 'dropdown',
93 | 'Options' => array(
94 | 'option1' => 'Display Value 1',
95 | 'option2' => 'Second Option',
96 | 'option3' => 'Another Option',
97 | ),
98 | 'Description' => 'Choose one',
99 | ),
100 | // the radio field type displays a series of radio button options
101 | 'Radio Field' => array(
102 | 'Type' => 'radio',
103 | 'Options' => 'First Option,Second Option,Third Option',
104 | 'Description' => 'Choose your option!',
105 | ),
106 | // the textarea field type allows for multi-line text input
107 | 'Textarea Field' => array(
108 | 'Type' => 'textarea',
109 | 'Rows' => '3',
110 | 'Cols' => '60',
111 | 'Description' => 'Freeform multi-line text input field',
112 | ),*/
113 | );
114 | }
115 |
116 | /**
117 | * Provision a new instance of a product/service.
118 | *
119 | * Attempt to provision a new instance of a given product/service. This is
120 | * called any time provisioning is requested inside of WHMCS. Depending upon the
121 | * configuration, this can be any of:
122 | * * When a new order is placed
123 | * * When an invoice for a new order is paid
124 | * * Upon manual request by an admin user
125 | *
126 | * @param array $params common module parameters
127 | *
128 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
129 | *
130 | * @return string "success" or an error message
131 | */
132 | function foxyprox_CreateAccount(array $params)
133 | {
134 | try {
135 | require_once("whatdoestheproxsay.php");
136 | // Call the service's provisioning function, using the values provided
137 | // by WHMCS in `$params`.
138 | //
139 | // A sample `$params` array may be defined as:
140 | //
141 | // ```
142 | // array(
143 | // 'domain' => 'The domain of the service to provision',
144 | // 'username' => 'The username to access the new service',
145 | // 'password' => 'The password to access the new service',
146 | // 'configoption1' => 'The amount of disk space to provision',
147 | // 'configoption2' => 'The new services secret key',
148 | // 'configoption3' => 'Whether or not to enable FTP',
149 | // ...
150 | // )
151 | // ```
152 | $class = new ProxSays;
153 | $result = $class->authServer($params['serverusername'], $params['serverpassword'], $params['serverip'], "443");
154 | logModuleCall('foxyprox', __FUNCTION__, $params, $result,);
155 | } catch (Exception $e) {
156 | // Record the error in WHMCS's module log.
157 | logModuleCall(
158 | 'foxyprox',
159 | __FUNCTION__,
160 | $params,
161 | $e->getMessage(),
162 | $e->getTraceAsString()
163 | );
164 |
165 | return $e->getMessage();
166 | }
167 |
168 | return 'success';
169 | }
170 |
171 | /**
172 | * Suspend an instance of a product/service.
173 | *
174 | * Called when a suspension is requested. This is invoked automatically by WHMCS
175 | * when a product becomes overdue on payment or can be called manually by admin
176 | * user.
177 | *
178 | * @param array $params common module parameters
179 | *
180 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
181 | *
182 | * @return string "success" or an error message
183 | */
184 | function foxyprox_SuspendAccount(array $params)
185 | {
186 | try {
187 | // Call the service's suspend function, using the values provided by
188 | // WHMCS in `$params`.
189 | } catch (Exception $e) {
190 | // Record the error in WHMCS's module log.
191 | logModuleCall(
192 | 'foxyprox',
193 | __FUNCTION__,
194 | $params,
195 | $e->getMessage(),
196 | $e->getTraceAsString()
197 | );
198 |
199 | return $e->getMessage();
200 | }
201 |
202 | return 'success';
203 | }
204 |
205 | /**
206 | * Un-suspend instance of a product/service.
207 | *
208 | * Called when an un-suspension is requested. This is invoked
209 | * automatically upon payment of an overdue invoice for a product, or
210 | * can be called manually by admin user.
211 | *
212 | * @param array $params common module parameters
213 | *
214 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
215 | *
216 | * @return string "success" or an error message
217 | */
218 | function foxyprox_UnsuspendAccount(array $params)
219 | {
220 | try {
221 | // Call the service's unsuspend function, using the values provided by
222 | // WHMCS in `$params`.
223 | } catch (Exception $e) {
224 | // Record the error in WHMCS's module log.
225 | logModuleCall(
226 | 'foxyprox',
227 | __FUNCTION__,
228 | $params,
229 | $e->getMessage(),
230 | $e->getTraceAsString()
231 | );
232 |
233 | return $e->getMessage();
234 | }
235 |
236 | return 'success';
237 | }
238 |
239 | /**
240 | * Terminate instance of a product/service.
241 | *
242 | * Called when a termination is requested. This can be invoked automatically for
243 | * overdue products if enabled, or requested manually by an admin user.
244 | *
245 | * @param array $params common module parameters
246 | *
247 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
248 | *
249 | * @return string "success" or an error message
250 | */
251 | function foxyprox_TerminateAccount(array $params)
252 | {
253 | try {
254 | // Call the service's terminate function, using the values provided by
255 | // WHMCS in `$params`.
256 | } catch (Exception $e) {
257 | // Record the error in WHMCS's module log.
258 | logModuleCall(
259 | 'foxyprox',
260 | __FUNCTION__,
261 | $params,
262 | $e->getMessage(),
263 | $e->getTraceAsString()
264 | );
265 |
266 | return $e->getMessage();
267 | }
268 |
269 | return 'success';
270 | }
271 |
272 | /**
273 | * Change the password for an instance of a product/service.
274 | *
275 | * Called when a password change is requested. This can occur either due to a
276 | * client requesting it via the client area or an admin requesting it from the
277 | * admin side.
278 | *
279 | * This option is only available to client end users when the product is in an
280 | * active status.
281 | *
282 | * @param array $params common module parameters
283 | *
284 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
285 | *
286 | * @return string "success" or an error message
287 | */
288 | function foxyprox_ChangePassword(array $params)
289 | {
290 | try {
291 | // Call the service's change password function, using the values
292 | // provided by WHMCS in `$params`.
293 | //
294 | // A sample `$params` array may be defined as:
295 | //
296 | // ```
297 | // array(
298 | // 'username' => 'The service username',
299 | // 'password' => 'The new service password',
300 | // )
301 | // ```
302 | } catch (Exception $e) {
303 | // Record the error in WHMCS's module log.
304 | logModuleCall(
305 | 'foxyprox',
306 | __FUNCTION__,
307 | $params,
308 | $e->getMessage(),
309 | $e->getTraceAsString()
310 | );
311 |
312 | return $e->getMessage();
313 | }
314 |
315 | return 'success';
316 | }
317 |
318 | /**
319 | * Upgrade or downgrade an instance of a product/service.
320 | *
321 | * Called to apply any change in product assignment or parameters. It
322 | * is called to provision upgrade or downgrade orders, as well as being
323 | * able to be invoked manually by an admin user.
324 | *
325 | * This same function is called for upgrades and downgrades of both
326 | * products and configurable options.
327 | *
328 | * @param array $params common module parameters
329 | *
330 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
331 | *
332 | * @return string "success" or an error message
333 | */
334 | function foxyprox_ChangePackage(array $params)
335 | {
336 | try {
337 | // Call the service's change password function, using the values
338 | // provided by WHMCS in `$params`.
339 | //
340 | // A sample `$params` array may be defined as:
341 | //
342 | // ```
343 | // array(
344 | // 'username' => 'The service username',
345 | // 'configoption1' => 'The new service disk space',
346 | // 'configoption3' => 'Whether or not to enable FTP',
347 | // )
348 | // ```
349 | } catch (Exception $e) {
350 | // Record the error in WHMCS's module log.
351 | logModuleCall(
352 | 'foxyprox',
353 | __FUNCTION__,
354 | $params,
355 | $e->getMessage(),
356 | $e->getTraceAsString()
357 | );
358 |
359 | return $e->getMessage();
360 | }
361 |
362 | return 'success';
363 | }
364 |
365 | /**
366 | * Test connection with the given server parameters.
367 | *
368 | * Allows an admin user to verify that an API connection can be
369 | * successfully made with the given configuration parameters for a
370 | * server.
371 | *
372 | * When defined in a module, a Test Connection button will appear
373 | * alongside the Server Type dropdown when adding or editing an
374 | * existing server.
375 | *
376 | * @param array $params common module parameters
377 | *
378 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
379 | *
380 | * @return array
381 | */
382 | function foxyprox_TestConnection(array $params)
383 | {
384 | try {
385 | // Call the service's connection test function.
386 |
387 | $success = true;
388 | $errorMsg = '';
389 | } catch (Exception $e) {
390 | // Record the error in WHMCS's module log.
391 | logModuleCall(
392 | 'foxyprox',
393 | __FUNCTION__,
394 | $params,
395 | $e->getMessage(),
396 | $e->getTraceAsString()
397 | );
398 |
399 | $success = false;
400 | $errorMsg = $e->getMessage();
401 | }
402 |
403 | return array(
404 | 'success' => $success,
405 | 'error' => $errorMsg,
406 | );
407 | }
408 |
409 | /**
410 | * Additional actions an admin user can invoke.
411 | *
412 | * Define additional actions that an admin user can perform for an
413 | * instance of a product/service.
414 | *
415 | * @see foxyprox_buttonOneFunction()
416 | *
417 | * @return array
418 | */
419 | function foxyprox_AdminCustomButtonArray()
420 | {
421 | return array(
422 | "Button 1 Display Value" => "buttonOneFunction",
423 | "Button 2 Display Value" => "buttonTwoFunction",
424 | );
425 | }
426 |
427 | /**
428 | * Additional actions a client user can invoke.
429 | *
430 | * Define additional actions a client user can perform for an instance of a
431 | * product/service.
432 | *
433 | * Any actions you define here will be automatically displayed in the available
434 | * list of actions within the client area.
435 | *
436 | * @return array
437 | */
438 | function foxyprox_ClientAreaCustomButtonArray()
439 | {
440 | return array(
441 | "Action 1 Display Value" => "actionOneFunction",
442 | "Action 2 Display Value" => "actionTwoFunction",
443 | );
444 | }
445 |
446 | /**
447 | * Custom function for performing an additional action.
448 | *
449 | * You can define an unlimited number of custom functions in this way.
450 | *
451 | * Similar to all other module call functions, they should either return
452 | * 'success' or an error message to be displayed.
453 | *
454 | * @param array $params common module parameters
455 | *
456 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
457 | * @see foxyprox_AdminCustomButtonArray()
458 | *
459 | * @return string "success" or an error message
460 | */
461 | function foxyprox_buttonOneFunction(array $params)
462 | {
463 | try {
464 | // Call the service's function, using the values provided by WHMCS in
465 | // `$params`.
466 | } catch (Exception $e) {
467 | // Record the error in WHMCS's module log.
468 | logModuleCall(
469 | 'foxyprox',
470 | __FUNCTION__,
471 | $params,
472 | $e->getMessage(),
473 | $e->getTraceAsString()
474 | );
475 |
476 | return $e->getMessage();
477 | }
478 |
479 | return 'success';
480 | }
481 |
482 | /**
483 | * Custom function for performing an additional action.
484 | *
485 | * You can define an unlimited number of custom functions in this way.
486 | *
487 | * Similar to all other module call functions, they should either return
488 | * 'success' or an error message to be displayed.
489 | *
490 | * @param array $params common module parameters
491 | *
492 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
493 | * @see foxyprox_ClientAreaCustomButtonArray()
494 | *
495 | * @return string "success" or an error message
496 | */
497 | function foxyprox_actionOneFunction(array $params)
498 | {
499 | try {
500 | // Call the service's function, using the values provided by WHMCS in
501 | // `$params`.
502 | } catch (Exception $e) {
503 | // Record the error in WHMCS's module log.
504 | logModuleCall(
505 | 'foxyprox',
506 | __FUNCTION__,
507 | $params,
508 | $e->getMessage(),
509 | $e->getTraceAsString()
510 | );
511 |
512 | return $e->getMessage();
513 | }
514 |
515 | return 'success';
516 | }
517 |
518 | /**
519 | * Admin services tab additional fields.
520 | *
521 | * Define additional rows and fields to be displayed in the admin area service
522 | * information and management page within the clients profile.
523 | *
524 | * Supports an unlimited number of additional field labels and content of any
525 | * type to output.
526 | *
527 | * @param array $params common module parameters
528 | *
529 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
530 | * @see foxyprox_AdminServicesTabFieldsSave()
531 | *
532 | * @return array
533 | */
534 | function foxyprox_AdminServicesTabFields(array $params)
535 | {
536 | try {
537 | // Call the service's function, using the values provided by WHMCS in
538 | // `$params`.
539 | $response = array();
540 |
541 | // Return an array based on the function's response.
542 | return array(
543 | 'Number of Apples' => (int) $response['numApples'],
544 | 'Number of Oranges' => (int) $response['numOranges'],
545 | 'Last Access Date' => date("Y-m-d H:i:s", $response['lastLoginTimestamp']),
546 | 'Something Editable' => ' '
548 | . ' ',
550 | );
551 | } catch (Exception $e) {
552 | // Record the error in WHMCS's module log.
553 | logModuleCall(
554 | 'foxyprox',
555 | __FUNCTION__,
556 | $params,
557 | $e->getMessage(),
558 | $e->getTraceAsString()
559 | );
560 |
561 | // In an error condition, simply return no additional fields to display.
562 | }
563 |
564 | return array();
565 | }
566 |
567 | /**
568 | * Execute actions upon save of an instance of a product/service.
569 | *
570 | * Use to perform any required actions upon the submission of the admin area
571 | * product management form.
572 | *
573 | * It can also be used in conjunction with the AdminServicesTabFields function
574 | * to handle values submitted in any custom fields which is demonstrated here.
575 | *
576 | * @param array $params common module parameters
577 | *
578 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
579 | * @see foxyprox_AdminServicesTabFields()
580 | */
581 | function foxyprox_AdminServicesTabFieldsSave(array $params)
582 | {
583 | // Fetch form submission variables.
584 | $originalFieldValue = isset($_REQUEST['foxyprox_original_uniquefieldname'])
585 | ? $_REQUEST['foxyprox_original_uniquefieldname']
586 | : '';
587 |
588 | $newFieldValue = isset($_REQUEST['foxyprox_uniquefieldname'])
589 | ? $_REQUEST['foxyprox_uniquefieldname']
590 | : '';
591 |
592 | // Look for a change in value to avoid making unnecessary service calls.
593 | if ($originalFieldValue != $newFieldValue) {
594 | try {
595 | // Call the service's function, using the values provided by WHMCS
596 | // in `$params`.
597 | } catch (Exception $e) {
598 | // Record the error in WHMCS's module log.
599 | logModuleCall(
600 | 'foxyprox',
601 | __FUNCTION__,
602 | $params,
603 | $e->getMessage(),
604 | $e->getTraceAsString()
605 | );
606 |
607 | // Otherwise, error conditions are not supported in this operation.
608 | }
609 | }
610 | }
611 |
612 | /**
613 | * Perform single sign-on for a given instance of a product/service.
614 | *
615 | * Called when single sign-on is requested for an instance of a product/service.
616 | *
617 | * When successful, returns a URL to which the user should be redirected.
618 | *
619 | * @param array $params common module parameters
620 | *
621 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
622 | *
623 | * @return array
624 | */
625 | function foxyprox_ServiceSingleSignOn(array $params)
626 | {
627 | try {
628 | // Call the service's single sign-on token retrieval function, using the
629 | // values provided by WHMCS in `$params`.
630 | $response = array();
631 |
632 | return array(
633 | 'success' => true,
634 | 'redirectTo' => $response['redirectUrl'],
635 | );
636 | } catch (Exception $e) {
637 | // Record the error in WHMCS's module log.
638 | logModuleCall(
639 | 'foxyprox',
640 | __FUNCTION__,
641 | $params,
642 | $e->getMessage(),
643 | $e->getTraceAsString()
644 | );
645 |
646 | return array(
647 | 'success' => false,
648 | 'errorMsg' => $e->getMessage(),
649 | );
650 | }
651 | }
652 |
653 | /**
654 | * Perform single sign-on for a server.
655 | *
656 | * Called when single sign-on is requested for a server assigned to the module.
657 | *
658 | * This differs from ServiceSingleSignOn in that it relates to a server
659 | * instance within the admin area, as opposed to a single client instance of a
660 | * product/service.
661 | *
662 | * When successful, returns a URL to which the user should be redirected to.
663 | *
664 | * @param array $params common module parameters
665 | *
666 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
667 | *
668 | * @return array
669 | */
670 | function foxyprox_AdminSingleSignOn(array $params)
671 | {
672 | try {
673 | // Call the service's single sign-on admin token retrieval function,
674 | // using the values provided by WHMCS in `$params`.
675 | $response = array();
676 |
677 | return array(
678 | 'success' => true,
679 | 'redirectTo' => $response['redirectUrl'],
680 | );
681 | } catch (Exception $e) {
682 | // Record the error in WHMCS's module log.
683 | logModuleCall(
684 | 'foxyprox',
685 | __FUNCTION__,
686 | $params,
687 | $e->getMessage(),
688 | $e->getTraceAsString()
689 | );
690 |
691 | return array(
692 | 'success' => false,
693 | 'errorMsg' => $e->getMessage(),
694 | );
695 | }
696 | }
697 |
698 | /**
699 | * Client area output logic handling.
700 | *
701 | * This function is used to define module specific client area output. It should
702 | * return an array consisting of a template file and optional additional
703 | * template variables to make available to that template.
704 | *
705 | * The template file you return can be one of two types:
706 | *
707 | * * tabOverviewModuleOutputTemplate - The output of the template provided here
708 | * will be displayed as part of the default product/service client area
709 | * product overview page.
710 | *
711 | * * tabOverviewReplacementTemplate - Alternatively using this option allows you
712 | * to entirely take control of the product/service overview page within the
713 | * client area.
714 | *
715 | * Whichever option you choose, extra template variables are defined in the same
716 | * way. This demonstrates the use of the full replacement.
717 | *
718 | * Please Note: Using tabOverviewReplacementTemplate means you should display
719 | * the standard information such as pricing and billing details in your custom
720 | * template or they will not be visible to the end user.
721 | *
722 | * @param array $params common module parameters
723 | *
724 | * @see http://docs.whmcs.com/Provisioning_Module_SDK_Parameters
725 | *
726 | * @return array
727 | */
728 | function foxyprox_ClientArea(array $params)
729 | {
730 | // Determine the requested action and set service call parameters based on
731 | // the action.
732 | $requestedAction = isset($_REQUEST['customAction']) ? $_REQUEST['customAction'] : '';
733 |
734 | if ($requestedAction == 'manage') {
735 | $serviceAction = 'get_usage';
736 | $templateFile = 'templates/manage.tpl';
737 | } else {
738 | $serviceAction = 'get_stats';
739 | $templateFile = 'templates/overview.tpl';
740 | }
741 |
742 | try {
743 | // Call the service's function based on the request action, using the
744 | // values provided by WHMCS in `$params`.
745 | $response = array();
746 |
747 | $extraVariable1 = 'abc';
748 | $extraVariable2 = '123';
749 |
750 | return array(
751 | 'tabOverviewReplacementTemplate' => $templateFile,
752 | 'templateVariables' => array(
753 | 'extraVariable1' => $extraVariable1,
754 | 'extraVariable2' => $extraVariable2,
755 | ),
756 | );
757 | } catch (Exception $e) {
758 | // Record the error in WHMCS's module log.
759 | logModuleCall(
760 | 'foxyprox',
761 | __FUNCTION__,
762 | $params,
763 | $e->getMessage(),
764 | $e->getTraceAsString()
765 | );
766 |
767 | // In an error condition, display an error page.
768 | return array(
769 | 'tabOverviewReplacementTemplate' => 'error.tpl',
770 | 'templateVariables' => array(
771 | 'usefulErrorHelper' => $e->getMessage(),
772 | ),
773 | );
774 | }
775 | }
776 |
--------------------------------------------------------------------------------