2 /************************************************************************
3 * Mailer v0.2.1-FINAL Start: 04/23/2005 *
4 * =================== Last change: 05/18/2008 *
6 * -------------------------------------------------------------------- *
7 * File : sponsor_functions.php *
8 * -------------------------------------------------------------------- *
9 * Short description : Functions for the sponsor area *
10 * -------------------------------------------------------------------- *
11 * Kurzbeschreibung : Funktionen fuer den Sponsorenbereich *
12 * -------------------------------------------------------------------- *
15 * $Tag:: 0.2.1-FINAL $ *
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 *
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. *
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. *
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, *
36 ************************************************************************/
38 // Some security stuff...
39 if (!defined('__SECURITY')) {
44 function handleSponsorRequest ($postData, $update=false, $messageArray = array(), $RET_STATUS=false) {
45 // Init a lot variables
54 'ok', 'edit', 'terms', 'pay_type'
63 // Check if sponsor already exists
64 foreach ($postData as $k => $v) {
65 if (!(array_search($k, $SKIPPED) > -1)) {
66 // Check only posted input entries not the submit button
70 if (!isEmailValid($v)) {
71 // Email address is not valid
74 // Add a new sponsor or update his data?
75 $result = sqlQueryEscaped("SELECT `id` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE email='%s' LIMIT 1",
76 array($postData['email']), __FUNCTION__, __LINE__);
78 // Is a sponsor alread in the db?
79 if (sqlNumRows($result) == 1) {
81 if ((getWhat() == 'add_sponsor') || ($update)) {
91 sqlFreeResult($result);
100 $k = 'password'; $v = md5($v);
104 if (!isUrlValid($v)) {
105 // Don't save the URL
111 // Test if there is are time selections
112 convertSelectionsToEpocheTime($postData, $DATA, $k, $skip);
116 if ((!empty($k)) && ($skip == FALSE)) {
118 array_push($DATA['keys'] , $k);
119 array_push($DATA['values'], $v);
125 if ($SAVE === TRUE) {
126 // Default is no force even when a guest want to abuse this force switch
127 if ((empty($postData['force'])) || (!isAdmin())) $postData['force'] = '0';
129 // SQL and message string is empty by default
130 $sql = ''; $message = '';
135 $sql = "UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET ";
136 foreach ($DATA['keys'] as $k => $v) {
137 $sql .= $v."='%s', ";
140 // Remove last ", " from SQL string
141 $sql = substr($sql, 0, -2)." WHERE `id`=%s LIMIT 1";
142 array_push($DATA['values'], bigintval(getRequestElement('id')));
145 $message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_UPDATED--}', 'updated', $messageArray);
147 } elseif (($ALREADY === FALSE) || (($postData['force'] == 1) && (isAdmin()))) {
148 // Add new sponsor, first add more data
149 array_push($DATA['keys'], 'status');
150 if (($update === TRUE) && (isAdmin()) && (getWhat() == 'add_sponsor')) {
151 // Only allowed for admin
152 array_push($DATA['values'], 'PENDING');
154 // Add remote IP address as well
155 array_push($DATA['keys'], 'remote_addr');
156 array_push($DATA['values'], detectRemoteAddr());
159 array_push($DATA['values'], 'UNCONFIRMED');
161 // Generate hash code
162 array_push($DATA['keys'], 'hash');
163 // @TODO Rewrite this to API function
164 array_push($DATA['values'], md5(session_id() . getEncryptSeparator() . $postData['email'] . getEncryptSeparator() . detectRemoteAddr() . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . time()));
165 array_push($DATA['keys'], 'remote_addr');
166 array_push($DATA['values'], detectRemoteAddr());
170 $key = array_search('force', $DATA['keys']);
172 // Remove force from both arrays
173 unset($DATA['keys'][$key]);
174 unset($DATA['values'][$key]);
176 // Implode all data into strings
177 $keyArray = implode('`, `' , $DATA['keys']);
178 $valueArray = str_repeat("%s', '", count($DATA['values']) - 1);
181 $sql = 'INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_data` (`' . $keyArray . "`) VALUES ('" . $valueArray . "%s')";
184 $message = getMessageFromIndexedArray('{--ADMIN_SPONSOR_ADDED--}', 'added', $messageArray);
186 } elseif (($update === TRUE) && (isAdmin())) {
187 // Add all data as hidden data
189 foreach ($postData as $k => $v) {
190 // Do not add 'force' !
192 $OUT .= '<input type="hidden" name="' . secureString($k) . '" value="' . sqlEscapeString($v) . '" />';
197 $content['hidden'] = $OUT;
198 $content['email'] = $postData['email'];
200 // Ask for adding a sponsor with same email address
201 loadTemplate('admin_add_sponsor_already', FALSE, $content);
205 $message = '{%message,SPONSOR_ALREADY_FOUND=' . $postData['email'] . '%}';
211 $result = sqlQueryEscaped($sql, $DATA['values'], __FUNCTION__, __LINE__);
215 $message = getMessageFromIndexedArray('{--SPONSOR_DATA_NOT_SAVED--}', 'failed', $messageArray);
216 displayMessage($message);
219 // Always return the status
223 // Translate the account status
224 function translateSponsorStatus ($status) {
225 // Construct constant name
226 $constantName = sprintf("ACCOUNT_STATUS_%s", $status);
228 // Is the constant there?
229 if (isMessageIdValid($constantName)) {
231 $ret = getMessage($constantName);
234 //* DEBUG: */ reportBug(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
235 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
236 $ret = '{%message,ACCOUNT_STATUS_UNKNOWN=' . $status . '%}';
243 // Search for an email address in the database
244 function isSponsorRegisteredWithEmail ($email) {
245 // Is there already the provided email address in database?
246 $ret = (countSumTotalData($email, 'sponsor_data', 'id', 'email', TRUE) == 1);
252 // Wether the current user is a sponsor
253 function isSponsor () {
259 (isSessionVariableSet('sponsor_id')) &&
260 (isSessionVariableSet('sponsor_pass')) &&
261 (fetchSponsorData(getSession('sponsor_id')))
269 function addSponsorMenu ($current) {
271 $WHERE = " AND `active`='Y'";
272 if (isAdmin()) $WHERE = '';
274 // Load main menu entries
275 $result_main = sqlQuery("SELECT
276 `action` AS `main_action`,
277 `title` AS `main_title`
279 `{?_MYSQL_PREFIX?}_sponsor_menu`
281 (`what`='' OR `what` IS NULL)
284 `sort` ASC", __FUNCTION__, __LINE__);
285 if (!ifSqlHasZeroNums($result_main)) {
286 // Load every menu and it's sub menus
287 while ($content = sqlFetchArray($result_main)) {
289 $result_sub = sqlQueryEscaped("SELECT
290 `what` AS `sub_what`,
291 `title` AS `sub_title`
293 `{?_MYSQL_PREFIX?}_sponsor_menu`
301 array($content['main_action']), __FUNCTION__, __LINE__);
302 if (!ifSqlHasZeroNums($result_sub)) {
305 while ($content2 = sqlFetchArray($result_sub)) {
306 // Check if current selected menu is matching the loaded one
307 if ($current == $content2['sub_what']) $content2['sub_title'] = '<strong>' . $content2['sub_title'] . '</strong>';
310 $SUB .= loadTemplate('sponsor_what', TRUE, $content2);
313 // Prepare data for the main template
314 $content['menu'] = $SUB;
316 // Load menu template
317 $OUT .= loadTemplate('sponsor_action', TRUE, $content);
319 // No sub menus active
320 $OUT .= displayMessage('{--SPONSOR_NO_SUB_MENUS_ACTIVE--}', TRUE);
324 sqlFreeResult($result_sub);
327 // No main menus active
328 $OUT .= displayMessage('{--SPONSOR_NO_MAIN_MENUS_ACTIVE--}', TRUE);
332 sqlFreeResult($result_main);
339 function addSponsorContent ($what) {
340 // Init sponsor content
341 $GLOBALS['sponsor_output'] = '';
343 // Generate IFN (Include FileName)
344 $INC = sprintf("inc/modules/sponsor/%s.php", $what);
345 if (isIncludeReadable($INC)) {
346 // Every sponsor action will output nothing directly. It will be written into $GLOBALS['sponsor_output']!
347 loadIncludeOnce($INC);
350 $GLOBALS['sponsor_output'] .= displayMessage('{%message,SPONSOR_CONTENT_404=' . $what . '%}', TRUE);
354 return $GLOBALS['sponsor_output'];
358 function updateSponsorLogin () {
364 // Update last online timestamp
365 sqlQueryEscaped("UPDATE
366 `{?_MYSQL_PREFIX?}_sponsor_data`
374 bigintval(getSession('sponsor_id')),
375 getSession('sponsor_pass')
376 ), __FUNCTION__, __LINE__);
378 // This update went fine?
379 $login = (!ifSqlHasZeroAffectedRows());
386 // Saves sponsor's data
387 function saveSponsorData ($postData, $content) {
390 // Unsecure data which we don't want
391 $UNSAFE = array('password', 'id', 'remote_addr', 'sponsor_created', 'last_online', 'status', 'ref_count',
392 'points_amount', 'points_used', 'refid', 'hash', 'last_payment', 'last_currency',
393 'pass_old', 'ok', 'password1', 'password2');
395 // Set default message ("not saved")
396 $message = '{--SPONSOR_ACCOUNT_DATA_NOT_SAVED--}';
398 // Check for submitted passwords
399 if ((!empty($postData['password1'])) && (!empty($postData['password2']))) {
400 // Are both passwords the same?
401 if ($postData['password1'] == $postData['password2']) {
402 // Okay, then set password and remove password1 and password2
403 $postData['password'] = md5($postData['password1']);
407 // Remove all (maybe spoofed) unsafe data from array
408 foreach ($UNSAFE as $remove) {
409 unset($postData[$remove]);
412 // This array is for the submitted data which we will use with the sqlQueryEscaped() function to
416 // Prepare SQL string
417 $sql = "UPDATE `{?_MYSQL_PREFIX?}_sponsor_data` SET";
418 foreach ($postData as $key => $value) {
419 // Mmmmm, too less security here???
420 $sql .= " `" . secureString($key) . "`='%s',";
422 // We will secure this later inside the sqlQueryEscaped() function
423 array_push($DATA, secureString($value));
426 // Check if email has changed
427 if ((!empty($content['email'])) && (!empty($postData['email']))) {
428 if ($content['email'] != $postData['email']) {
429 // Change email address
432 // Okay, has changed then add status with UNCONFIRMED and new hash code
433 $sql .= " `status`='EMAIL',`hash`='%s',";
435 // Generate hash code
436 // @TODO Rewrite this to API function
437 $HASH = md5(session_id() . getEncryptSeparator() . $postData['email'] . getEncryptSeparator() . detectRemoteAddr() . getEncryptSeparator() . detectUserAgent() . getEncryptSeparator() . time());
438 array_push($DATA, $HASH);
441 // Remove last commata
442 $sql = substr($sql, 0, -1);
445 $sql .= ',`last_change`=NOW()';
448 $sql .= " WHERE `id`=%s AND `password`='%s' LIMIT 1";
449 array_push($DATA, bigintval(getSession('sponsor_id')), getSession('sponsor_pass'));
451 // Saving data was completed... ufff...
453 case 'account': // Change account data
454 if ($EMAIL === TRUE) {
455 $message = '{--SPONSOR_ACCOUNT_EMAIL_CHANGED--}';
456 $templ = 'admin_sponsor_change_email';
457 $subject = '{--ADMIN_SPONSOR_ACC_EMAIL_SUBJECT--}';
459 $message = '{--SPONSOR_ACCOUNT_DATA_SAVED--}';
460 $templ = 'admin_sponsor_change_data';
461 $subject = '{--ADMIN_SPONSOR_ACC_DATA_SUBJECT--}';
465 case 'settings': // Change settings
466 // Set message template and subject for admin
467 $message = '{--SPONSOR_SETTINGS_SAVED--}';
468 $templ = 'admin_sponsor_settings';
469 $subject = '{--ADMIN_SPONSOR_SETTINGS_SUBJECT--}';
472 default: // Unknown sponsor what value!
473 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown sponsor module (what) %s detected.", getWhat()));
474 $message = '{--SPONSOR_UNKNOWN_WHAT--}';
480 // Has an entry updated?
481 if (!ifSqlHasZeroAffectedRows()) {
482 // Template and subject are set?
483 if (!empty($templ) && !empty($subject)) {
484 // Run SQL command and check for success
485 $result = sqlQueryEscaped($sql, $DATA, __FUNCTION__, __LINE__);
487 // Add all data to content
488 $content['new_data'] = $postData;
490 // Send email to admins
491 sendAdminNotification($subject, $templ, $content);
493 // Shall we send mail to the sponsor's new email address?
494 if ($content['receive_warnings'] == 'Y') {
496 * Okay send email with confirmation link to new address and with no confirmation link
497 * to the old address.
500 // First to old address
502 case 'account': // Change account data
503 $email_msg = loadEmailTemplate('sponsor_change_data', $content);
504 sendEmail($content['email'], '{--SPONSOR_ACC_DATA_SUBJECT--}', $email_msg);
506 if ($EMAIL === TRUE) {
507 // Add hash code to content array
508 $content['hash'] = $HASH;
510 // Second mail goes to the new address
511 $email_msg = loadEmailTemplate('sponsor_change_email', $content);
512 sendEmail($content['email'], '{--SPONSOR_ACC_EMAIL_SUBJECT--}', $email_msg);
516 case 'settings': // Change settings
518 $email_msg = loadEmailTemplate('sponsor_settings', $content);
519 sendEmail($content['email'], '{--SPONSOR_SETTINGS_SUBJECT--}', $email_msg);
526 // Return final message
530 // Create email link to sponsor's account
531 function generateSponsorEmailLink ($email, $mod = 'admin') {
532 // Show contact link only if sponsor is confirmed by default
533 $locked = " AND `status`='CONFIRMED'";
535 // But admins shall always see it
536 if (isAdmin()) $locked = '';
538 $result = sqlQueryEscaped("SELECT
541 `{?_MYSQL_PREFIX?}_sponsor_data`
546 array($email), __FUNCTION__, __LINE__);
547 if (sqlNumRows($result) == 1) {
549 list($sponsor_id) = sqlFetchRow($result);
551 // Rewrite email address to contact link
552 $email = '{%url=modules.php?module=' . $mod . '&what=sponsor_contct&sponsor_id=' . bigintval($sponsor_id) . '%}';
556 sqlFreeResult($result);
558 // Return rewritten (?) email address
562 // Processes a sponsor request and handles it
563 function doProcessSponsorFormRequest ($messageArray = array()) {
567 // Handle the request
568 $status = handleSponsorRequest(postRequestArray(), TRUE, $messageArray, TRUE);
570 // Check the status of the registration process
572 case 'added': // Sponsor successfully added with account status = UNCONFIRMED!
573 // Check for his id number
574 $result = sqlQueryEscaped("SELECT `id`, `hash` FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE '%s' REGEXP `email` LIMIT 1",
575 array(postRequestElement('email')), __FUNCTION__, __LINE__);
576 if (sqlNumRows($result) == 1) {
577 // id found so let's load it for the confirmation email
578 list($id, $hash) = sqlFetchRow($result);
580 // Prepare data for the email template
581 $content['id'] = $id;
582 $content['hash'] = $hash;
583 $content['email'] = postRequestElement('email');
584 $content['surname'] = postRequestElement('surname');
585 $content['family'] = postRequestElement('family');
586 $content['timestamp'] = generateDateTime(time(), 0);
587 $content['password'] = postRequestElement('password1');
589 // Generate email and send it to the new sponsor
590 $message = loadEmailTemplate('sponsor_confirm', $content, $id);
591 sendEmail(postRequestElement('email'), '{--SPONSOR_PLEASE_CONFIRM_SUBJECT--}', $message);
593 // Send mail to admin
594 sendAdminNotification('{--ADMIN_NEW_SPONSOR--}', 'admin_sponsor_reg', $content);
596 // Output message: DONE
597 $message = $messageArray['added'];
599 // Sponsor account not found???
600 $message = '{%message,SPONSOR_EMAIL_404=' . postRequestElement('email') . '%}';
604 sqlFreeResult($result);
608 logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
610 // Message for testing admin
611 $message = '{%message,ADMIN_SPONSOR_UNKNOWN_STATUS=' . $status . '%}';
613 // Message for the guest
614 $message = '{%message,SPONSOR_UNKNOWN_STATUS=' . $status . '%}';
623 // Expression call-back function for fetching sponsor data
624 function doExpressionSponsor ($data) {
625 // Use current sponsor_id by default
626 $functionName = 'getSponsorId()';
628 // Sponsor-related data, so is there a sponsor_id?
629 if (!empty($data['matches'][4][$data['key']])) {
630 // Is there a sponsor_id or $sponsor_id?
631 if ($data['matches'][4][$data['key']] == '$userid') {
633 $functionName = "getFetchedSponsorData('id', \$userid, '" . $data['callback'] . "')";
634 } elseif (!empty($data['matches'][4][$data['key']])) {
635 // Sponsor data found
636 $functionName = "getFetchedSponsorData('id', " . $data['matches'][4][$data['key']] . ", '" . $data['callback'] . "')";
638 } elseif ((!empty($data['callback'])) && (isValidSponsorData())) {
639 // "Call-back" alias column for current logged in sponsor's data
640 $functionName = "getSponsorData('" . $data['callback'] . "')";
643 // Is there another function to run (e.g. translations)
644 if (!empty($data['extra_func'])) {
645 // Surround the original function call with it
646 $functionName = $data['extra_func'] . '(' . $functionName . ')';
650 $replacer = '{DQUOTE} . ' . $functionName . ' . {DQUOTE}';
652 // Now replace the code
653 $code = replaceExpressionCode($data, $replacer);
655 // Return replaced code
659 // Fetch sponsor data for given sponsor id
660 function fetchSponsorData ($sponsor_id, $column = 'id') {
661 // If we should look for sponsor_id secure&set it here
662 if ($column == 'id') {
664 $sponsor_id = bigintval($sponsor_id);
667 setCurrentSponsorId($sponsor_id);
669 // Don't look for invalid sponsor_ids...
670 if (!isValidId($sponsor_id)) {
671 // Invalid, so abort here
672 reportBug(__FUNCTION__, __LINE__, 'Sponsor id ' . $sponsor_id . ' is invalid.');
673 } elseif (isValidSponsorData()) {
674 // Use cache, so it is fine
677 } elseif (isValidSponsorData()) {
678 // Use cache, so it is fine
682 // By default none was found
688 // Query for the sponsor
689 $result = sqlQueryEscaped("SELECT *".$ADD." FROM `{?_MYSQL_PREFIX?}_sponsor_data` WHERE `%s`='%s' LIMIT 1",
690 array($column, $sponsor_id), __FUNCTION__, __LINE__);
692 // Is there a record?
693 if (sqlNumRows($result) == 1) {
694 // Load data from cookies
695 $data = sqlFetchArray($result);
697 // Set the sponsor_id for later use
698 setCurrentSponsorId($data['id']);
699 $GLOBALS['sponsor_data'][getCurrentSponsorId()] = $data;
701 // Rewrite 'last_failure' if found
702 if (isset($GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure'])) {
703 // Backup the raw one and zero it
704 $GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure_raw'] = $GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure'];
705 $GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure'] = NULL;
708 if (!is_null($GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure_raw'])) {
709 // Seperate data/time
710 $array = explode(' ', $GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure_raw']);
712 // Seperate data and time again
713 $array['date'] = explode('-', $array[0]);
714 $array['time'] = explode(':', $array[1]);
716 // Now pass it to mktime()
717 $GLOBALS['sponsor_data'][getCurrentSponsorId()]['last_failure'] = mktime(
729 $found = isValidSponsorData();
733 sqlFreeResult($result);
739 // Wrapper for fetchSponsorData() and getSponsorData() calls
740 function getFetchedSponsorData ($keyColumn, $sponsor_id, $valueColumn) {
741 // Zero ids are not valid
742 if (!isValidId($sponsor_id)) {
744 reportBug(__FUNCTION__, __LINE__, 'Zero sponsor_id provided');
748 if (!isset($GLOBALS['sponsor_data_cache'][$sponsor_id][$keyColumn][$valueColumn])) {
752 // Can we fetch the sponsor data?
753 if ((isValidId($sponsor_id)) && (fetchSponsorData($sponsor_id, $keyColumn))) {
754 // Now get the data back
755 $data = getSponsorData($valueColumn);
759 /* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'cached:id=' . $sponsor_id . ',keyColumn=' . $keyColumn . ',valueColumn=' . $valueColumn . ',data=' . $data);
760 $GLOBALS['sponsor_data_cache'][$sponsor_id][$keyColumn][$valueColumn] = $data;
764 return $GLOBALS['sponsor_data_cache'][$sponsor_id][$keyColumn][$valueColumn];
767 // Checks if the sponsor data is valid, this may indicate that the sponsor has logged
768 // in, but you should use isMember() if you want to find that out.
769 function isValidSponsorData () {
770 // Sponsor id should not be zero so abort here
771 if (!isCurrentSponsorIdSet()) return FALSE;
774 if (!isset($GLOBALS['is_sponsor_data_valid'][getCurrentSponsorId()])) {
776 $GLOBALS['is_sponsor_data_valid'][getCurrentSponsorId()] = ((isset($GLOBALS['sponsor_data'][getCurrentSponsorId()])) && (count($GLOBALS['sponsor_data'][getCurrentSponsorId()]) > 1));
780 return $GLOBALS['is_sponsor_data_valid'][getCurrentSponsorId()];
783 // Setter for current sponsor_id
784 function setCurrentSponsorId ($sponsor_id) {
786 $GLOBALS['current_sponsor_id'] = bigintval($sponsor_id);
788 // Unset it to re-determine the actual state
789 unset($GLOBALS['is_sponsor_data_valid'][$sponsor_id]);
792 // Getter for current sponsor_id
793 function getCurrentSponsorId () {
794 // Sponsorid must be set before it can be used
795 if (!isCurrentSponsorIdSet()) {
797 reportBug(__FUNCTION__, __LINE__, 'Sponsor id is not set.');
800 // Return the sponsor_id
801 return $GLOBALS['current_sponsor_id'];
804 // Checks if current sponsor_id is set
805 function isCurrentSponsorIdSet () {
806 return ((isset($GLOBALS['current_sponsor_id'])) && (isValidId($GLOBALS['current_sponsor_id'])));
809 // Getter for sponsor data
810 function getSponsorData ($column) {
811 // Sponsor id should not be zero
812 if (!isValidId(getCurrentSponsorId())) {
813 reportBug(__FUNCTION__, __LINE__, 'Sponsor id is zero.');
817 return $GLOBALS['sponsor_data'][getCurrentSponsorId()][$column];
820 // Determines the country of the given sponsor id
821 function determineSponsorCountry ($sponsor_id) {
822 // Then handle it over
823 $country = getSponsorData('country');
829 // Destroy sponsor session
830 function destroySponsorSession () {
831 // Remove all user data from session
833 (setSession('sponsor_id', '')) &&
834 (setSession('sponsor_pass', '')) &&
836 ((isExtensionActive('theme')) && (setMailerTheme(''))) ||
837 (!isExtensionActive('theme'))
842 // Getter for sponsor_min_points
843 function getSponsorMinPoints () {
845 if (!isset($GLOBALS[__FUNCTION__])) {
847 $GLOBALS[__FUNCTION__] = getConfig('sponsor_min_points');
851 return $GLOBALS[__FUNCTION__];
854 // Getter for sponsor_ref_points
855 function getSponsorRefPoints () {
857 if (!isset($GLOBALS[__FUNCTION__])) {
859 $GLOBALS[__FUNCTION__] = getConfig('sponsor_ref_points');
863 return $GLOBALS[__FUNCTION__];