Reset rewritten, SQL fixed, zeros are now numeric
[mailer.git] / inc / modules / admin / what-send_bonus.php
index 5445bec1fc4c1cd06ed92c404eb1a91eed93dc38..799d6069691fe78c4e993ec36e1739aa7bdd001d 100644 (file)
@@ -43,8 +43,8 @@ if ((ereg(basename(__FILE__), $_SERVER['PHP_SELF'])) || (!IS_ADMIN())) {
 // Add description as navigation point
 ADD_DESCR("admin", basename(__FILE__));
 
-$WHERE = " WHERE visible='Y'";
-if (is_admin()) $WHERE = "";
+$whereStatement = " WHERE visible='Y'";
+if (is_admin()) $whereStatement = "";
 $EXT_HTML = EXT_IS_ACTIVE("html_mail");
 if (empty($_GET['mode'])) $_GET['mode'] = "select";
 
@@ -57,7 +57,7 @@ if (isset($_POST['ok']))
                // Select category
                $CAT_TABS  = "LEFT JOIN "._MYSQL_PREFIX."_user_cats AS c ON d.userid=c.userid";
                $cat = bigintval($_POST['cat']);
-               $CAT_WHERE = " AND c.cat_id=%d";
+               $CAT_WHERE = " AND c.cat_id=%s";
        }
        if (GET_EXT_VERSION("holiday") >= "0.1.3")
        {
@@ -69,13 +69,13 @@ if (isset($_POST['ok']))
        {
                // Only include HTML receivers
                $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED' AND d.html='Y'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
-                array($cat, $CONFIG['order_select'], $CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
+                array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
        }
         else
        {
                // Include all
                $result = SQL_QUERY_ESC("SELECT d.userid FROM "._MYSQL_PREFIX."_user_data AS d ".$CAT_TABS." WHERE d.status='CONFIRMED'".$CAT_WHERE." ORDER BY d.%s %s LIMIT %s",
-                array($cat, $CONFIG['order_select'], $CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
+                array($cat, $_CONFIG['order_select'], $_CONFIG['order_mode'], bigintval($_POST['receiver'])), __FILE__, __LINE__);
        }
        if ((SQL_NUMROWS($result) == $_POST['receiver']) && ($_POST['receiver'] > 0))
        {
@@ -93,8 +93,8 @@ if (isset($_POST['ok']))
                // Gettings points is oka, so we can add $USED later from
                if ($EXT_HTML)
                {
-                       $HTML = 'N';
-                       if ($_GET['mode'] == "html") $HTML = 'Y';
+                       $HTML = "N";
+                       if ($_GET['mode'] == "html") $HTML = "Y";
                        $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_bonus
 (subject, text, receivers, points, time, data_type, timestamp, url, cat_id, target_send, mails_sent, html_msg)
 VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s', '%s', '%s')",
@@ -143,7 +143,7 @@ VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s',
                LOAD_URL($URL);
        }
 } else {
-       $result = SQL_QUERY("SELECT id, cat FROM "._MYSQL_PREFIX."_cats".$WHERE." ORDER BY sort", __FILE__, __LINE__);
+       $result = SQL_QUERY("SELECT id, cat FROM "._MYSQL_PREFIX."_cats".$whereStatement." ORDER BY sort", __FILE__, __LINE__);
        if (SQL_NUMROWS($result) > 0)
        {
                $MORE = "";
@@ -167,13 +167,13 @@ VALUES ('%s', '%s', '%s', '%s', '%s', 'NEW', UNIX_TIMESTAMP(), '%s', '%s', '%s',
                {
                        $CATS['id'][]   = $id;
                        $CATS['name'][] = $cat;
-                       $result_uids = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%d",
+                       $result_uids = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_cats WHERE cat_id=%s",
                         array(bigintval($id)), __FILE__, __LINE__);
-                       $uid_cnt = "0";
+                       $uid_cnt = 0;
                        while (list($ucat) = SQL_FETCHROW($result_uids))
                        {
                                $result_ver = SQL_QUERY_ESC("SELECT userid FROM "._MYSQL_PREFIX."_user_data
-WHERE userid=%d AND status='CONFIRMED' AND receive_mails > 0".$MORE." LIMIT 1",
+WHERE userid=%s AND status='CONFIRMED' AND receive_mails > 0".$MORE." LIMIT 1",
  array(bigintval($ucat)), __FILE__, __LINE__);
                                $uid_cnt += SQL_NUMROWS($result_ver);
 
@@ -207,7 +207,7 @@ WHERE userid=%d AND status='CONFIRMED' AND receive_mails > 0".$MORE." LIMIT 1",
 
                // Generate options
                $OUT = "";
-               foreach ($CATS['id'] as $key=>$value)
+               foreach ($CATS['id'] as $key => $value)
                {
                        if (strlen($CATS['name'][$key]) > 20) $CATS['name'][$key] = substr($CATS['name'][$key], 0, 17)."...";
                        $OUT .= "      <OPTION value=\"".$value."\">".$CATS['name'][$key]." (".$CATS['uids'][$key]." ".USER_IN_CAT.")</OPTION>\n";