Merge branch 'contrib' into 0.2.1-FINAL
[mailer.git] / inc / libs / wernis_functions.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 10/19/2003 *
4  * ===================                          Last change: 08/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-points.php                                  *
8  * -------------------------------------------------------------------- *
9  * Short description : All your collected points...                     *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : Alle Ihrer gesammelten Punkte                    *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * -------------------------------------------------------------------- *
18  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
19  * Copyright (c) 2009 - 2013 by Mailer Developer Team                   *
20  * For more information visit: http://mxchange.org                      *
21  *                                                                      *
22  * This program is free software; you can redistribute it and/or modify *
23  * it under the terms of the GNU General Public License as published by *
24  * the Free Software Foundation; either version 2 of the License, or    *
25  * (at your option) any later version.                                  *
26  *                                                                      *
27  * This program is distributed in the hope that it will be useful,      *
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
30  * GNU General Public License for more details.                         *
31  *                                                                      *
32  * You should have received a copy of the GNU General Public License    *
33  * along with this program; if not, write to the Free Software          *
34  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
35  * MA  02110-1301  USA                                                  *
36  ************************************************************************/
37
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
40         die();
41 } // END - if
42
43 // Sets a status message and code
44 function setWernisStatusMessage ($message, $status) {
45         $GLOBALS['wernis_data']['message'] = $message;
46         $GLOBALS['wernis_data']['status']  = $status;
47 }
48
49 // Get the status message
50 function getWernisErrorMessage () {
51         if (isset($GLOBALS['wernis_data']['message'])) {
52                 // Use raw message
53                 return $GLOBALS['wernis_data']['message'];
54         } elseif (isset($GLOBALS['wernis_data']['status'])) {
55                 // Fall-back to status
56                 return '{%message,WERNIS_ERROR_STATUS=' . $GLOBALS['wernis_data']['status'] . '%}';
57         } else {
58                 // Something bad happend
59                 return '{--WERNIS_UNKNOWN_ERROR--}';
60         }
61 }
62
63 // Get the status code
64 function getWernisErrorCode () {
65         if (isset($GLOBALS['wernis_data']['status'])) {
66                 // Use raw message
67                 return $GLOBALS['wernis_data']['status'];
68         } else {
69                 // Something bad happend
70                 return '{--WERNIS_UNKNOWN_ERROR--}';
71         }
72 }
73
74 // Sends out a request to the API and returns it's result
75 function sendWernisApiRequest ($scriptName, $requestData = array()) {
76         // Is the requestData an array?
77         if (!is_array($requestData)) {
78                 // Then abort here!
79                 return array(
80                         'status'  => 'failed_general',
81                         'message' => '{--WERNIS_API_REQUEST_DATA_INVALID--}'
82                 );
83         } // END - if
84
85         // Is the API id and MD5 hash there?
86         if ((getWernisApiId() == '') || (getWernisApiMd5() == '')) {
87                 // Abort here...
88                 return array(
89                         'status'  => 'failed_general',
90                         'message' => '{--WERNIS_API_REQUEST_DATA_MISSING--}'
91                 );
92         } // END - if
93
94         // Add more request data
95         $requestData['api_id']  = getWernisApiId();
96         $requestData['api_key'] = getWernisApiMd5();
97
98         // Is a purpose there?
99         if (!empty($requestData['purpose'])) {
100                 // Eval the purpose
101                 eval('$purpose = "' . doFinalCompilation($requestData['purpose'], FALSE) . '";');
102
103                 // Prepare the purpose, it needs encoding
104                 $requestData['purpose'] = encodeString($purpose);
105         } // END - if
106
107         // Construct the request string
108         $requestString = getWernisApiUrl() . $scriptName;
109
110         // Get the raw response from the lower function
111         $response = sendHttpPostRequest($requestString, $requestData);
112
113         // Check the response header if all is fine
114         if (!isHttpStatusOkay($response[0])) {
115                 // Something bad happend... :(
116                 return array(
117                         'status'  => 'request_error',
118                         'message' => '{%message,WERNIS_API_REQUEST_ERROR=' . $response[0] . '%}'
119                 );
120         } // END - if
121
122         // All (maybe) fine so remove the response header from server
123         $responseLine = '*INVALID*';
124         for ($idx = (count($response) - 1); $idx > 1; $idx--) {
125                 $line = trim($response[$idx]);
126                 if (!empty($line)) {
127                         $responseLine = $line;
128                         break;
129                 } // END - if
130         } // END - for
131
132         // Is the response leaded by a & symbol?
133         if (substr($responseLine, 0, 1) != '&') {
134                 // Something badly happened on server-side
135                 return array(
136                         'status'  => 'request_problem',
137                         'message' => sprintf(getMessage('WERNIS_API_REQUEST_PROBLEM'), $response[0], secureString($responseLine))
138                 );
139         } // END - if
140
141         // Remove the leading & (which can be used in Flash)
142         $responseLine = substr($responseLine, 1);
143
144         // Bring back the response
145         $data = explode('=', $responseLine);
146
147         // Default return array (should not stay empty)
148         $return = array();
149
150         // We use only the first two entries (which shall be fine)
151         if ($data[0] === 'error') {
152                 // The request has failed... :(
153                 switch ($data[1]) {
154                         case '404': // Invalid API id
155                         case 'AUTH': // Authorization has failed
156                                 $return = array(
157                                         'status'  => 'auth_failed',
158                                         'message' => '{--WERNIS_API_REQUEST_FAILED_AUTH--}'
159                                 );
160                                 break;
161
162                         case 'LOCKED': // User account is locked!
163                         case 'PASS': // Bad passphrase entered
164                         case 'USER': // Missing account or invalid password
165                                 $return = array(
166                                         'status'  => 'user_failed',
167                                         'message' => '{--WERNIS_API_REQUEST_FAILED_USER--}'
168                                 );
169                                 break;
170
171                         case 'OWN': // Transfer to own account
172                                 $return = array(
173                                         'status'  => 'own_failed',
174                                         'message' => '{--WERNIS_API_REQUEST_FAILED_OWN--}'
175                                 );
176                                 break;
177
178                         case 'AMOUNT': // Amount is depleted
179                                 $return = array(
180                                         'status'  => 'amount_failed',
181                                         'message' => '{--WERNIS_API_REQUEST_FAILED_AMOUNT--}'
182                                 );
183                                 break;
184
185                         case 'AMOUNT-SEND': // API amount is depleted
186                                 $return = array(
187                                         'status'  => 'api_amount_failed',
188                                         'message' => '{--WERNIS_API_REQUEST_FAILED_API_AMOUNT--}'
189                                 );
190                                 break;
191
192                         default: // Unknown error (maybe new?)
193                                 logDebugMessage(__FUNCTION__, __LINE__, sprintf('Unknown error %s from WDS66 API received.', $data[1]));
194                                 $return = array(
195                                         'status'  => 'request_failed',
196                                         'message' => '{%message,WERNIS_API_REQUEST_FAILED=' . $data[1] . '%}'
197                                 );
198                                 break;
199                 }
200         } else {
201                 // All fine here
202                 $return = array(
203                         'status'   => 'OK',
204                         'response' => $responseLine
205                 );
206         }
207
208         // Return the result
209         return $return;
210 }
211
212 // Tests the function by calling balance.php on the API
213 function doAdminTestWernisApi () {
214         // Only as admin
215         assert(isAdmin());
216
217         // Result is always failed
218         $result = FALSE;
219
220         // Prepare the request data
221         $requestData = array(
222                 't_uid'       => getWernisRefid(),
223                 't_md5'       => getWernisPassMd5()
224         );
225
226         // Return the result from the lower functions
227         $return = sendWernisApiRequest('balance.php', $requestData);
228
229         // Did it went smoothly?
230         if ($return['status'] == 'OK') {
231                 // All fine!
232                 $result = TRUE;
233         } else {
234                 // Status failure text
235                 setWernisStatusMessage($return['message'], $return['status']);
236         }
237
238         // Return result
239         return $result;
240 }
241
242 // Widthdraw this amount
243 function executeWernisWithdraw ($wdsId, $userMd5, $amount) {
244         // Is the sponsor extension installed?
245         if (!isWernisWithdrawActive()) {
246                 if (!isExtensionActive('sponsor')) {
247                         // No, abort here
248                         return FALSE;
249                 } elseif (!isSponsor()) {
250                         // No sponsor, not allowed to withdraw!
251                         return FALSE;
252                 }
253         } // END - if
254
255         // Default is failed attempt
256         $result = FALSE;
257
258         // Prepare the request data
259         $requestData = array(
260                 'sub_request' => 'receive',
261                 't_uid'       => bigintval($wdsId),
262                 't_md5'       => $userMd5,
263                 'r_uid'       => getWernisRefid(),
264                 'amount'      => bigintval($amount),
265                 'purpose'     => getMaskedMessage('WERNIS_API_PURPOSE_WITHDRAW', getMemberId())
266         );
267
268         // Return the result from the lower functions
269         $return = sendWernisApiRequest('book.php', $requestData);
270
271         if ($return['status'] == 'OK') {
272                 // All fine!
273                 $result = TRUE;
274
275                 // Log the transfer
276                 logWernisTransfer($wdsId, $amount, 'WITHDRAW');
277         } else {
278                 // Status failure text
279                 setWernisStatusMessage($return['message'], $return['status']);
280
281                 // Log the transfer
282                 logWernisTransfer($wdsId, $amount, 'FAILED', $return['message'], $return['status']);
283         }
284
285         // Return result
286         return $result;
287 }
288
289 // Payout this amount
290 function executeWernisPayout ($wdsId, $amount) {
291         // Default is failed attempt
292         $result = FALSE;
293
294         // Prepare the request data
295         $requestData = array(
296                 'sub_request' => 'send',
297                 't_uid'       => getWernisRefid(),
298                 't_md5'       => getWernisPassMd5(),
299                 'r_uid'       => bigintval($wdsId),
300                 'amount'      => bigintval($amount),
301                 'purpose'     => getMaskedMessage('WERNIS_API_PURPOSE_PAYOUT', getMemberId())
302         );
303
304         // Return the result from the lower functions
305         $return = sendWernisApiRequest('book.php', $requestData);
306
307         if ($return['status'] == 'OK') {
308                 // All fine!
309                 $result = TRUE;
310
311                 // Log the transfer
312                 logWernisTransfer($wdsId, $amount, 'PAYOUT');
313         } else {
314                 // Status failure text
315                 setWernisStatusMessage($return['message'], $return['status']);
316
317                 // Log the transfer
318                 logWernisTransfer($wdsId, $amount, 'FAILED', $return['message'], $return['status']);
319         }
320
321         // Return result
322         return $result;
323 }
324
325 // Execute auth.php request
326 function executeWernisAuth ($wernisId, $wernisPassword) {
327         // Prepare request data
328         $requestData = array(
329                 't_uid'       => bigintval($wernisId),
330                 't_md5'       => hashSha256($wernisPassword),
331         );
332
333         // Call auth.php
334         $return = sendWernisApiRequest('auth.php', $requestData);
335
336         // Return full array
337         return $return;
338 }
339
340 // Translate the status IN/OUT
341 function translateWernisTransferStatus ($status) {
342         // Default status is unknown
343         $return = '{%message,WERNIS_STATUS_UNKNWOWN=' . $status . '%}';
344
345         // Construct message id
346         $messageId = 'WERNIS_STATUS_' . $status;
347
348         // Is it there?
349         if (isMessageIdValid($messageId)) {
350                 // Then use it as message string
351                 $return = '{--' . $messageId . '--}';
352         } // END - if
353
354         // Return the status
355         return $return;
356 }
357
358 // Log the transfer
359 function logWernisTransfer ($wdsId, $amount, $type = 'FAILED', $message = '', $status = '') {
360         // Register this wernis movement
361         sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_user_wernis` (`userid`, `wernis_account`, `wernis_amount`, `wernis_timestamp`, `wernis_type`, `wernis_api_message`, `wernis_api_status`) VALUES (%s, %s, %s, UNIX_TIMESTAMP(), '%s', '%s', '%s')",
362                 array(
363                         getMemberId(),
364                         bigintval($wdsId),
365                         bigintval($amount),
366                         $type,
367                         $message,
368                         $status
369                 ), __FUNCTION__, __LINE__);
370 }
371
372 // Calulcate fees and factor
373 function calculateWernisFee ($points, $mode) {
374         // Payout or withdraw are allowed modes!
375         //* DEBUG: */ debugOutput('mode=' . $mode . ',points=' . $points);
376         if (!in_array($mode, array('payout', 'withdraw'))) {
377                 // Log error and abort
378                 logDebugMessage(__FUNCTION__, __LINE__, 'userid=' . getMemberId() . ',mode=' . $mode . ',points=' . $points . ' - unknown mode detected.');
379                 return FALSE;
380         } // END - if
381
382         // Is there a percentage or fixed fee?
383         if (getConfig('wernis_' . $mode . '_fee_percent') > 0) {
384                 // Percentage fee
385                 $points -= $points * getConfig('wernis_'.$mode.'_fee_percent') / 100;
386         } elseif (getConfig('wernis_' . $mode . '_fee_fix') > 0) {
387                 // Fixed fee
388                 $points -= getConfig('wernis_' . $mode . '_fee_fix');
389         }
390
391         // Divide/multiply the factor
392         if ($mode == 'payout') {
393                 // Divide for payout
394                 $points = $points / getWernisPayoutFactor();
395         } else {
396                 // Multiply for withdraw
397                 $points = $points * getWernisWithdrawFactor();
398         }
399
400         // Return value
401         //* DEBUG: */ debugOutput('mode=' . $mode . ',points=' . $points);
402         return $points;
403 }
404
405 // Add withdraw fees and factor
406 // @TODO Unused?
407 function calulcateWernisWithdrawFee ($points) {
408         // Is there a percentage or fixed fee?
409         if (getWernisWithdrawFeePercent() > 0) {
410                 // Percentage fee
411                 $points += $points * getWernisWithdrawFeePercent() / 100;
412         } elseif (getWernisWithdrawFeeFix() > 0) {
413                 // Fixed fee
414                 $points += getWernisWithdrawFeeFix();
415         }
416
417         // Return value
418         return $points;
419 }
420
421 // Displays registration form for WDS66 registration
422 function doDisplayWernisUserRegistrationForm () {
423         // Is the form sent?
424         if (isFormSent('register')) {
425                 // Is wernis_id set?
426                 if (!isPostRequestElementSet('wernis_id')) {
427                         // Id not set
428                         displayMessage('{--GUEST_WERNIS_REGISTRATION_ID_NOT_SET--}');
429                 } elseif (!isPostRequestElementSet('wernis_password')) {
430                         // Password not set
431                         displayMessage('{--GUEST_WERNIS_REGISTRATION_PASSWORD_NOT_SET--}');
432                 } else {
433                         // So far, all fine, then let's do the call-back on auth.php ...
434                         $response = executeWernisAuth(postRequestElement('wernis_id'), postRequestElement('wernis_password'));
435
436                         // Was the status okay?
437                         if ((isset($response['status'])) && ($response['status'] == 'OK') && (!empty($response['response']))) {
438                                 // All fine, then analyze response
439                                 $args = convertApiResponseToArray($response['response'], '&', '=');
440
441                                 // Is status set?
442                                 assert(isset($args['auth_status']));
443
444                                 // Add WDS66 userid
445                                 $args['wernis_userid'] = postRequestElement('wernis_id');
446
447                                 // "Detect" auth status
448                                 $callbackFunction = 'doWernisAuth' . capitalizeUnderscoreString($args['auth_status']);
449
450                                 // Is the call-back there?
451                                 if (!is_callable($callbackFunction, FALSE, $callableName)) {
452                                         // Not there, could be bad. :(
453                                         reportBug(__FUNCTION__, __LINE__, 'Unsupported auth_status=' . $args['auth_status'] . ',args()=' . count($args) . ',callbackFunction=' . $callbackFunction . ' detected.');
454                                 } // END - if
455
456                                 // Then call it
457                                 $status = call_user_func($callbackFunction, $args);
458                                 die(__FUNCTION__ . ': status[' . gettype($status) . ']=' . $status);
459                         } else {
460                                 // Something bad happened
461                                 displayMessage($response['message']);
462                         }
463                 }
464         } // END - if
465
466         // Is the form not sent? (E.g. missing form fields)
467         if ((isGetRequestElementSet('status')) && (isGetRequestElementSet('challenge')) && (isGetRequestElementSet('__challenge_response'))) {
468                 // Redirect from modules.php?module=auth, so validate challenge response ...
469                 // 1) Get first 24 characters = salt
470                 $salt = substr(getRequestElement('__challenge_response'), 0, 24);
471
472                 // 2) Generate hash again
473                 $response = $salt . hashSha256($salt . getWernisApiMd5() . getRequestElement('challenge'));
474
475                 // Is the response valid?
476                 if ($response != getRequestElement('__challenge_response')) {
477                         // Not valid
478                         displayMessage('{--GUEST_WERNIS_REGISTRATION_INVALID_CHALLENGE_RESPONSE--}');
479                         return;
480                 } // END - if
481
482                 /*
483                  * Now, that the challenge-response is the same, the challenge itself
484                  * is also the same. So get.php can be called.
485                  */
486                 die('!ojk');
487         } elseif (!isFormSent('register')) {
488                 // Form not send, so load form template
489                 loadTemplate('guest_wernis_registration_form');
490         } // END - if
491 }
492
493 //-----------------------------------------------------------------------------
494 //                      Auth status callback functions
495 //-----------------------------------------------------------------------------
496
497 // Handler for auth_status=PENDING
498 function doWernisAuthPending ($args) {
499         // auth_key must be set
500         assert(isset($args['auth_key']));
501
502         // Generate a challenge that will be added to the URL
503         $challenge = hashSha256(generatePassword(128));
504
505         // Search entry in database by auth_key
506         if (countSumTotalData($args['auth_key'], 'wernis_regs', 'id', 'api_auth_key', TRUE) == 0) {
507                 // "Register" this call
508                 sqlQueryEscaped("INSERT INTO `{?_MYSQL_PREFIX?}_wernis_regs` (
509         `wernis_userid`,
510         `api_auth_status`,
511         `api_auth_key`,
512         `api_redirect_challenge`
513 ) VALUES (
514         %s,
515         'PENDING',
516         '%s',
517         '%s'
518 )",
519                         array(
520                                 bigintval($args['wernis_userid']),
521                                 $args['auth_key'],
522                                 $challenge
523                         ), __FUNCTION__, __LINE__
524                 );
525
526                 // Should be inserted
527                 assert(sqlAffectedRows() == 1);
528         } else {
529                 // Update challenge
530                 sqlQueryEscaped("UPDATE
531         `{?_MYSQL_PREFIX?}_wernis_regs`
532 SET
533         `api_redirect_challenge`='%s'
534 WHERE
535         `api_auth_key`='%s' AND
536         `wernis_userid`=%s
537         `api_auth_status`='PENDING'
538 LIMIT 1",
539                         array(
540                                 $challenge,
541                                 $args['auth_key'],
542                                 bigintval($args['wernis_userid'])
543                         ), __FUNCTION__, __LINE__
544                 );
545
546                 // Should always be updated
547                 assert(sqlAffectedRows() == 1);
548         }
549
550         // Redirect to WDS66 module=auth ...
551         redirectToUrl(getWernisBaseUrl() . '/modules.php?module=auth&amp;auth_key=' . $args['auth_key'] . '&amp;params=' . urlencode(base64_encode('&module=' . getModule() . '&what=' . getWhat())) . '&amp;challenge=' . $challenge);
552 }
553
554 //-----------------------------------------------------------------------------
555 //                             Wrapper functions
556 //-----------------------------------------------------------------------------
557
558 // Wrapper function for 'wernis_refid'
559 function getWernisRefid () {
560         // Is there cache?
561         if (!isset($GLOBALS[__FUNCTION__])) {
562                 // Get config entry
563                 $GLOBALS[__FUNCTION__] = getConfig('wernis_refid');
564         } // END - if
565
566         // Return cache
567         return $GLOBALS[__FUNCTION__];
568 }
569
570 // Wrapper function for 'wernis_pass_md5'
571 function getWernisPassMd5 () {
572         // Is there cache?
573         if (!isset($GLOBALS[__FUNCTION__])) {
574                 // Get config entry
575                 $GLOBALS[__FUNCTION__] = getConfig('wernis_pass_md5');
576         } // END - if
577
578         // Return cache
579         return $GLOBALS[__FUNCTION__];
580 }
581
582 // Wrapper function for 'wernis_api_id'
583 function getWernisApiId () {
584         // Is there cache?
585         if (!isset($GLOBALS[__FUNCTION__])) {
586                 // Get config entry
587                 $GLOBALS[__FUNCTION__] = getConfig('wernis_api_id');
588         } // END - if
589
590         // Return cache
591         return $GLOBALS[__FUNCTION__];
592 }
593
594 // Wrapper function for 'wernis_api_md5'
595 function getWernisApiMd5 () {
596         // Is there cache?
597         if (!isset($GLOBALS[__FUNCTION__])) {
598                 // Get config entry
599                 $GLOBALS[__FUNCTION__] = getConfig('wernis_api_md5');
600         } // END - if
601
602         // Return cache
603         return $GLOBALS[__FUNCTION__];
604 }
605
606 // Wrapper function for 'wernis_api_url'
607 function getWernisApiUrl () {
608         // Is there cache?
609         if (!isset($GLOBALS[__FUNCTION__])) {
610                 // Get config entry
611                 $GLOBALS[__FUNCTION__] = getConfig('wernis_api_url');
612         } // END - if
613
614         // Return cache
615         return $GLOBALS[__FUNCTION__];
616 }
617
618 // Wrapper function for 'wernis_withdraw_active'
619 function getWernisWithdrawActive () {
620         // Is there cache?
621         if (!isset($GLOBALS[__FUNCTION__])) {
622                 // Get config entry
623                 $GLOBALS[__FUNCTION__] = getConfig('wernis_withdraw_active');
624         } // END - if
625
626         // Return cache
627         return $GLOBALS[__FUNCTION__];
628 }
629
630 // Wrapper function for 'wernis_payout_active'
631 function getWernisPayoutActive () {
632         // Is there cache?
633         if (!isset($GLOBALS[__FUNCTION__])) {
634                 // Get config entry
635                 $GLOBALS[__FUNCTION__] = getConfig('wernis_payout_active');
636         } // END - if
637
638         // Return cache
639         return $GLOBALS[__FUNCTION__];
640 }
641
642 // Wrapper function for 'wernis_withdraw_active'
643 function isWernisWithdrawActive () {
644         // Is there cache?
645         if (!isset($GLOBALS[__FUNCTION__])) {
646                 // Get config entry
647                 $GLOBALS[__FUNCTION__] = (getConfig('wernis_withdraw_active') == 'Y');
648         } // END - if
649
650         // Return cache
651         return $GLOBALS[__FUNCTION__];
652 }
653
654 // Wrapper function for 'wernis_payout_active'
655 function isWernisPayoutActive () {
656         // Is there cache?
657         if (!isset($GLOBALS[__FUNCTION__])) {
658                 // Get config entry
659                 $GLOBALS[__FUNCTION__] = (getConfig('wernis_payout_active') == 'Y');
660         } // END - if
661
662         // Return cache
663         return $GLOBALS[__FUNCTION__];
664 }
665
666 // Wrapper function for 'wernis_withdraw_factor'
667 function getWernisWithdrawFactor () {
668         // Is there cache?
669         if (!isset($GLOBALS[__FUNCTION__])) {
670                 // Get config entry
671                 $GLOBALS[__FUNCTION__] = getConfig('wernis_withdraw_factor');
672         } // END - if
673
674         // Return cache
675         return $GLOBALS[__FUNCTION__];
676 }
677
678 // Wrapper function for 'wernis_payout_factor'
679 function getWernisPayoutFactor () {
680         // Is there cache?
681         if (!isset($GLOBALS[__FUNCTION__])) {
682                 // Get config entry
683                 $GLOBALS[__FUNCTION__] = getConfig('wernis_payout_factor');
684         } // END - if
685
686         // Return cache
687         return $GLOBALS[__FUNCTION__];
688 }
689
690 // Wrapper function for 'wernis_withdraw_fee_percent'
691 function getWernisWithdrawFeePercent () {
692         // Is there cache?
693         if (!isset($GLOBALS[__FUNCTION__])) {
694                 // Get config entry
695                 $GLOBALS[__FUNCTION__] = getConfig('wernis_withdraw_fee_percent');
696         } // END - if
697
698         // Return cache
699         return $GLOBALS[__FUNCTION__];
700 }
701
702 // Wrapper function for 'wernis_withdraw_fee_fix'
703 function getWernisWithdrawFeeFix () {
704         // Is there cache?
705         if (!isset($GLOBALS[__FUNCTION__])) {
706                 // Get config entry
707                 $GLOBALS[__FUNCTION__] = getConfig('wernis_withdraw_fee_fix');
708         } // END - if
709
710         // Return cache
711         return $GLOBALS[__FUNCTION__];
712 }
713
714 // Wrapper function for 'wernis_payout_fee_percent'
715 function getWernisPayoutFeePercent () {
716         // Is there cache?
717         if (!isset($GLOBALS[__FUNCTION__])) {
718                 // Get config entry
719                 $GLOBALS[__FUNCTION__] = getConfig('wernis_payout_fee_percent');
720         } // END - if
721
722         // Return cache
723         return $GLOBALS[__FUNCTION__];
724 }
725
726 // Wrapper function for 'wernis_payout_fee_fix'
727 function getWernisPayoutFeeFix () {
728         // Is there cache?
729         if (!isset($GLOBALS[__FUNCTION__])) {
730                 // Get config entry
731                 $GLOBALS[__FUNCTION__] = getConfig('wernis_payout_fee_fix');
732         } // END - if
733
734         // Return cache
735         return $GLOBALS[__FUNCTION__];
736 }
737
738 // Wrapper function for 'wernis_min_payout'
739 function getWernisMinPayout () {
740         // Is there cache?
741         if (!isset($GLOBALS[__FUNCTION__])) {
742                 // Get config entry
743                 $GLOBALS[__FUNCTION__] = getConfig('wernis_min_payout');
744         } // END - if
745
746         // Return cache
747         return $GLOBALS[__FUNCTION__];
748 }
749
750 // Wrapper function for 'wernis_min_withdraw'
751 function getWernisMinWithdraw () {
752         // Is there cache?
753         if (!isset($GLOBALS[__FUNCTION__])) {
754                 // Get config entry
755                 $GLOBALS[__FUNCTION__] = getConfig('wernis_min_withdraw');
756         } // END - if
757
758         // Return cache
759         return $GLOBALS[__FUNCTION__];
760 }
761
762 // Wrapper function for 'wernis_base_url'
763 function getWernisBaseUrl () {
764         // Is there cache?
765         if (!isset($GLOBALS[__FUNCTION__])) {
766                 // Get config entry
767                 $GLOBALS[__FUNCTION__] = getConfig('wernis_base_url');
768         } // END - if
769
770         // Return cache
771         return $GLOBALS[__FUNCTION__];
772 }
773
774 // [EOF]
775 ?>