Reset rewritten, SQL fixed, zeros are now numeric
[mailer.git] / inc / libs / sponsor_functions.php
index 6f43da5bb6f92b86db3eed27f3b3683915f865df..fdf4eb9f43b4bded1bc1104cc22545c38181eeb5 100644 (file)
@@ -54,7 +54,7 @@ function SPONSOR_HANDLE_SPONSOR(&$POST, $NO_UPDATE=false, $MSGs=array(), $RET_ST
        );
 
        // Check if sponsor already exists
        );
 
        // Check if sponsor already exists
-       foreach ($POST as $k=>$v)
+       foreach ($POST as $k => $v)
        {
                if (!(array_search($k, $SKIPPED) > -1))
                {
        {
                if (!(array_search($k, $SKIPPED) > -1))
                {
@@ -153,7 +153,7 @@ function SPONSOR_HANDLE_SPONSOR(&$POST, $NO_UPDATE=false, $MSGs=array(), $RET_ST
        if ($SAVE)
        {
                // Default is no force even when a guest want to abuse this force switch
        if ($SAVE)
        {
                // Default is no force even when a guest want to abuse this force switch
-               if ((empty($POST['force'])) || (!IS_ADMIN())) $POST['force'] = "0";
+               if ((empty($POST['force'])) || (!IS_ADMIN())) $POST['force'] = 0;
 
                // SQL and message string is empty by default
                $SQL = ""; $MSG = "";
 
                // SQL and message string is empty by default
                $SQL = ""; $MSG = "";
@@ -163,7 +163,7 @@ function SPONSOR_HANDLE_SPONSOR(&$POST, $NO_UPDATE=false, $MSGs=array(), $RET_ST
                {
                        // Update his data
                        $SQL = "UPDATE "._MYSQL_PREFIX."_sponsor_data SET ";
                {
                        // Update his data
                        $SQL = "UPDATE "._MYSQL_PREFIX."_sponsor_data SET ";
-                       foreach ($DATA['keys'] as $k=>$v)
+                       foreach ($DATA['keys'] as $k => $v)
                        {
                                $SQL .= $v."='%s', ";
                        }
                        {
                                $SQL .= $v."='%s', ";
                        }
@@ -213,7 +213,7 @@ function SPONSOR_HANDLE_SPONSOR(&$POST, $NO_UPDATE=false, $MSGs=array(), $RET_ST
                {
                        // Add all data as hidden data
                        $OUT = "";
                {
                        // Add all data as hidden data
                        $OUT = "";
-                       foreach ($POST as $k=>$v)
+                       foreach ($POST as $k => $v)
                        {
                                // Do not add 'force' !
                                if ($k != "force")
                        {
                                // Do not add 'force' !
                                if ($k != "force")
@@ -421,15 +421,12 @@ ORDER BY sort", array($action), __FILE__, __LINE__);
 function GENERATE_SPONSOR_CONTENT($what)
 {
        global $HTTP_POST_VARS, $_GET, $CONFIG;
 function GENERATE_SPONSOR_CONTENT($what)
 {
        global $HTTP_POST_VARS, $_GET, $CONFIG;
-       $FILE = PATH."inc/modules/sponsor/".$what.".php";
        $OUT = "";
        $OUT = "";
-       if (@file_exists($FILE))
-       {
+       $FILE = sprintf("%sinc/modules/sponsor/%s.php", PATH, $what);
+       if (FILE_READABLE($FILE)) {
                // Every sponsor action will output nothing directly. It will be written into $OUT!
                require_once($FILE);
                // Every sponsor action will output nothing directly. It will be written into $OUT!
                require_once($FILE);
-       }
-        else
-       {
+       } else {
                // File not found!
                $OUT .= LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_CONTENT_404_1.$what.SPONSOR_CONTENT_404_2);
        }
                // File not found!
                $OUT .= LOAD_TEMPLATE("admin_settings_saved", true, SPONSOR_CONTENT_404_1.$what.SPONSOR_CONTENT_404_2);
        }
@@ -481,13 +478,13 @@ function SPONSOR_SAVE_DATA($POST, $content)
        $MSG = SPONSOR_ACCOUNT_DATA_NOT_SAVED;
 
        // Check for submitted passwords
        $MSG = SPONSOR_ACCOUNT_DATA_NOT_SAVED;
 
        // Check for submitted passwords
-       if ((!empty($HTTP_POST_VARS['pass1'])) && (!empty($HTTP_POST_VARS['pass2'])))
+       if ((!empty($_POST['pass1'])) && (!empty($_POST['pass2'])))
        {
                // Are both passwords the same?
        {
                // Are both passwords the same?
-               if ($HTTP_POST_VARS['pass1'] == $HTTP_POST_VARS['pass2'])
+               if ($_POST['pass1'] == $_POST['pass2'])
                {
                        // Okay, then set password and remove pass1 and pass2
                {
                        // Okay, then set password and remove pass1 and pass2
-                       $HTTP_POST_VARS['password'] = md5($HTTP_POST_VARS['pass1']);
+                       $_POST['password'] = md5($_POST['pass1']);
                }
        }
 
                }
        }
 
@@ -503,7 +500,7 @@ function SPONSOR_SAVE_DATA($POST, $content)
 
        // Prepare SQL string
        $SQL = "UPDATE "._MYSQL_PREFIX."_sponsor_data SET";
 
        // Prepare SQL string
        $SQL = "UPDATE "._MYSQL_PREFIX."_sponsor_data SET";
-       foreach ($POST as $key=>$value)
+       foreach ($POST as $key => $value)
        {
                // Mmmmm, too less security here???
                $SQL   .= " ".strip_tags($key)."='%s',";
        {
                // Mmmmm, too less security here???
                $SQL   .= " ".strip_tags($key)."='%s',";
@@ -593,17 +590,7 @@ function SPONSOR_SAVE_DATA($POST, $content)
                        if (isset($content['warning_interval'])) $DATA['interval']    = CREATE_FANCY_TIME($POST['warning_interval']);
 
                        // Send email to admins
                        if (isset($content['warning_interval'])) $DATA['interval']    = CREATE_FANCY_TIME($POST['warning_interval']);
 
                        // Send email to admins
-                       if (GET_EXT_VERSION("admins") < "0.4.1")
-                       {
-                               // Use old method to send out
-                               $msg = LOAD_EMAIL_TEMPLATE($templ, $content);
-                               SEND_ADMIN_EMAILS($subj, $msg);
-                       }
-                        else
-                       {
-                               // Use new system to send out
-                               SEND_ADMIN_EMAILS_PRO($subj, $templ, $content);
-                       }
+                       SEND_ADMIN_NOTIFICATION($subj, $templ, $content);
 
                        // Shall we send mail to the sponsor's new email address?
                        if ($content['receive_warnings'] == "Y")
 
                        // Shall we send mail to the sponsor's new email address?
                        if ($content['receive_warnings'] == "Y")