]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/sponsor_functions.php
Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / libs / sponsor_functions.php
index 630db06a0f31aaeebab04cca1b0c97c9e0459d8a..983a46b9685115caef2efbedd2e14211a494e18c 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 04/23/2005 *
- * ===============                              Last change: 05/18/2008 *
+ * Mailer v0.2.1-FINAL                                Start: 04/23/2005 *
+ * ===================                          Last change: 05/18/2008 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : sponsor_functions.php                            *
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -122,7 +123,7 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
                // Save sponsor?
                if ($SAVE === true) {
                        // Default is no force even when a guest want to abuse this force switch
-                       if ((empty($postData['force'])) || (!isAdmin())) $postData['force'] = 0;
+                       if ((empty($postData['force'])) || (!isAdmin())) $postData['force'] = '0';
 
                        // SQL and message string is empty by default
                        $sql = ''; $message = '';
@@ -137,12 +138,12 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
 
                                // Remove last ", " from SQL string
                                $sql = substr($sql, 0, -2)." WHERE `id`='%s' LIMIT 1";
-                               $DATA['values'][] = bigintval(getRequestElement('id'));
+                               $DATA['values'][] = bigintval(getRequestParameter('id'));
 
                                // Generate message
                                $message = getMessageFromIndexedArray(getMessage('ADMIN_SPONSOR_UPDATED'), 'updated', $messageArray);
                                $ret = "updated";
-                       } elseif (($ALREADY === false) || (($postData['force'] == '1') && (isAdmin()))) {
+                       } elseif (($ALREADY === false) || (($postData['force'] == 1) && (isAdmin()))) {
                                // Add new sponsor, first add more data
                                $DATA['keys'][] = 'sponsor_created'; $DATA['values'][] = time();
                                $DATA['keys'][] = 'status';
@@ -161,24 +162,26 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
                                }
 
                                // Implode all data into strings
-                               $KEYS   = implode("`, `"  , $DATA['keys']);
-                               $valueS = str_repeat("%s', '", count($DATA['values']) - 1);
+                               $keyArray   = implode("`, `"  , $DATA['keys']);
+                               $valueArray = str_repeat("%s', '", count($DATA['values']) - 1);
 
                                // Generate string
-                               $sql = "INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_data` (`".$KEYS."`) VALUES ('".$valueS."%s')";
+                               $sql = "INSERT INTO `{?_MYSQL_PREFIX?}_sponsor_data` (`" . $keyArray . "`) VALUES ('" . $valueArray . "%s')";
 
                                // Generate message
-                               $message = getMessageFromIndexedArray(getMessage('ADMIN_SPONSOR_ADDED'), "added", $messageArray);
+                               $message = getMessageFromIndexedArray(getMessage('ADMIN_SPONSOR_ADDED'), 'added', $messageArray);
                                $ret = 'added';
                        } elseif (($update === true) && (isAdmin())) {
                                // Add all data as hidden data
                                $OUT = '';
                                foreach ($postData as $k => $v) {
                                        // Do not add 'force' !
-                                       if ($k != "force") {
-                                               $OUT .= "<input type=\"hidden\" name=\"".$k."\" value=\"".stripslashes($v)."\" />\n";
-                                       }
-                               }
+                                       if ($k != 'force') {
+                                               $OUT .= '<input type="hidden" name="' . secureString($k) . '" value="' . SQL_ESCAPE($v) . '" />';
+                                       } // END - if
+                               } // END - foreach
+
+                               // Remember data
                                $content['hidden'] = $OUT;
                                $content['email']  = $postData['email'];
 
@@ -187,7 +190,7 @@ function handlSponsorRequest (&$postData, $update=false, $messageArray=array(),
                                return;
                        } else {
                                // Already added!
-                               $message = sprintf(getMessage('SPONSOR_ALREADY_FOUND'), $postData['email']);
+                               $message = getMaskedMessage('SPONSOR_ALREADY_FOUND', $postData['email']);
                                $ret = 'already';
                        }
 
@@ -222,7 +225,7 @@ function sponsorTranslateUserStatus ($status) {
        } else {
                // Not found!
                logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown status %s detected.", $status));
-               $ret = sprintf(getMessage('UNKNOWN_STATUS'), $status);
+               $ret = getMaskedMessage('UNKNOWN_STATUS', $status);
        }
        return $ret;
 }
@@ -292,7 +295,7 @@ ORDER BY `sort`",
                                        $content = merge_array($content, $content2);
 
                                        // Check if current selected menu is matching the loaded one
-                                       if ($current == $content['sub_what']) $content['sub_title'] = "<strong>".$content['sub_title']."</strong>";
+                                       if ($current == $content['sub_what']) $content['sub_title'] = '<strong>' . $content['sub_title'] . '</strong>';
 
                                        // Prepare data for the sub template
                                        $content = array(
@@ -341,7 +344,7 @@ function addSponsorContent ($what) {
                loadIncludeOnce($INC);
        } else {
                // File not found!
-               $OUT .= loadTemplate('admin_settings_saved', true, sprintf(getMessage('SPONSOR_CONTENT_404'), $what));
+               $OUT .= loadTemplate('admin_settings_saved', true, getMaskedMessage('SPONSOR_CONTENT_404', $what));
        }
 
        // Return content
@@ -436,8 +439,7 @@ function saveSponsorData ($postData, $content) {
        $DATA[] = getSession('sponsorpass');
 
        // Saving data was completed... ufff...
-       switch (getWhat())
-       {
+       switch (getWhat()) {
                case 'account': // Change account data
                        if ($EMAIL === true) {
                                $message   = getMessage('SPONSOR_ACCOUNT_EMAIL_CHANGED');
@@ -463,12 +465,14 @@ function saveSponsorData ($postData, $content) {
 
                default: // Unknown sponsor what value!
                        logDebugMessage(__FUNCTION__, __LINE__, sprintf("Unknown sponsor module (what) %s detected.", getWhat()));
-                       $message = sprintf(getMessage('SPONSOR_UNKNOWN_WHAT'), getWhat());
+                       $message = getMaskedMessage('SPONSOR_UNKNOWN_WHAT', getWhat());
                        $templ = ''; $subj = '';
                        break;
-       }
+       } // END - switch
 
+       // Has an entry updated?
        if (SQL_AFFECTEDROWS() == 1) {
+               // Template and subject are set?
                if (!empty($templ) && !empty($subj)) {
                        // Run SQL command and check for success
                        $result = SQL_QUERY_ESC($sql, $DATA, __FUNCTION__, __LINE__);
@@ -476,7 +480,7 @@ function saveSponsorData ($postData, $content) {
                        // Add all data to content
                        $content['new_data'] = $postData;
 
-                       // Change some data
+                       // Translate some data
                        if (isset($content['gender']))             $content['gender']                  = translateGender($content['gender']);
                        if (isset($content['new_data']['gender'])) $content['new_data']['gender']      = translateGender($content['new_data']['gender']);
                        if (isset($content['receive_warnings']))   $content['new_data']['receive']     = translateYesNo($content['new_data']['receive_warnings']);