]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-order.php
More usage of GET_URL() than file()
[mailer.git] / inc / modules / member / what-order.php
index a85be7e4686e695d87866544fffe6f2ef4a6f76c..51c11ef419de7f4a493d4b32e21a536d02d9e822 100644 (file)
@@ -43,7 +43,7 @@ if (!defined('__SECURITY')) {
 }
 
 // Add description as navigation point
-ADD_DESCR("member", basename(__FILE__));
+ADD_DESCR("member", __FILE__);
 
 $URL = ""; $id = 0;
 $whereStatement = " WHERE visible='Y'";
@@ -53,14 +53,7 @@ if (empty($_GET['msg']))       $_GET['msg']       = "";
 if (empty($_POST['zip']))      $_POST['zip']      = "";
 if (empty($_POST['html']))     $_POST['html']     = "";
 if (empty($_POST['receiver'])) $_POST['receiver'] = "";
-if (is_admin()) $whereStatement = "";
-
-// Add slashes to every value
-foreach($_POST as $key => $value)
-{
-       // Skip submit buttons
-       if (($key != "data") && ($key != "frametester")) $_POST[$key] = addslashes($value);
-}
+if (IS_ADMIN()) $whereStatement = "";
 
 // Minimum mails / order
 define('__MIN_VALUE', $_CONFIG['order_min']);
@@ -96,16 +89,9 @@ if ($_CONFIG['order_max_full'] == "MAX") $ALLOWED = $MAXI;
 $HTML_EXT = EXT_IS_ACTIVE("html_mail");
 
 // Now check his points amount
-$result_p = SQL_QUERY_ESC("SELECT SUM(points) FROM "._MYSQL_PREFIX."_user_points WHERE userid=%s",
- array($GLOBALS['userid']), __FILE__, __LINE__);
-
-$TOTAL = 0;
-if (SQL_NUMROWS($result_p) > 0)
-{
-       // Load points
-       list($TOTAL) = SQL_FETCHROW($result_p);
-       SQL_FREERESULT($result_p);
+$TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points");
 
+if ($TOTAL > 0) {
        // And subtract his used points...
        $TOTAL -= GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");
 
@@ -113,14 +99,11 @@ if (SQL_NUMROWS($result_p) > 0)
        if (!ereg(".", $TOTAL)) $TOTAL .= ".00000";
 }
 
-if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3"))
-{
+if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3")) {
        // Holiday is active!
        SQL_FREERESULT($result_p);
        LOAD_TEMPLATE("admin_settings_saved", false, HOLIDAY_ORDER_NOT_POSSIBLE);
-}
- elseif ((!empty($_POST['frametester'])) && ($ALLOWED > 0) && ($_POST['receiver'] > 0))
-{
+} elseif ((!empty($_POST['frametester'])) && ($ALLOWED > 0) && ($_POST['receiver'] > 0)) {
        // Continue with the frametester, we first need to store the data temporary in the pool
        //
        // First we would like to store the data and get it's pool position back...
@@ -148,7 +131,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                                // URL found!
                                $URL = URL."/modules.php?module=login&what=order&msg=".CODE_URL_FOUND;
                        }
-                       $TEST = str_replace("\n", "", str_replace("\r", "", addslashes($_POST['text'])));
+                       $TEST = str_replace("\n", "", str_replace("\r", "", $_POST['text']));
                        if (strlen($TEST) > $_CONFIG['max_tlength'])
                        {
                                // Text is too long!
@@ -221,14 +204,16 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
        {
                // Check if category and number of receivers is okay
                $ADD = "";
-               if (($_CONFIG['order_multi_page'] == "Y") && (!empty($_POST['zip']))) $ADD = "AND d.zip LIKE '".bigintval($_POST['zip'])."{PER}'";
+               if (($_CONFIG['order_multi_page'] == "Y") && (!empty($_POST['zip']))) {
+                       // Choose recipients by ZIP code
+                       $ADD = " AND d.zip LIKE '".bigintval($_POST['zip'])."{PER}'";
+               } // END - if
 
                // Check for userids
                $result = SQL_QUERY_ESC("SELECT DISTINCT c.userid FROM "._MYSQL_PREFIX."_user_cats AS c
 LEFT JOIN "._MYSQL_PREFIX."_user_data AS d
 ON c.userid=d.userid
-WHERE c.cat_id=%s AND c.userid != '%s' AND d.status='CONFIRMED' AND d.receive_mails > 0
-".$ADD."
+WHERE c.cat_id=%s AND c.userid != '%s' AND d.status='CONFIRMED' AND d.receive_mails > 0".$ADD."
 ORDER BY d.%s %s",
  array(
        bigintval($_POST['cat']),
@@ -307,8 +292,8 @@ WHERE userid=%s AND holiday_start < UNIX_TIMESTAMP() AND holiday_end > UNIX_TIME
  VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')",
 array(
        $GLOBALS['userid'],
-       addslashes($_POST['subject']),
-       addslashes($_POST['text']),
+       $_POST['subject'],
+       $_POST['text'],
        $RECEIVER,
        bigintval($_POST['type']),
        $TIME,
@@ -326,8 +311,8 @@ array(
  VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s')",
 array(
        $GLOBALS['userid'],
-       addslashes($_POST['subject']),
-       addslashes($_POST['text']),
+       $_POST['subject'],
+       $_POST['text'],
        $RECEIVER,
        bigintval($_POST['type']),
        $TIME,
@@ -618,20 +603,20 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                        break;
 
                                default:
+                                       DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown error code %s detected.", $_GET['msg']));
                                        $MSG = UNKNOWN_CODE_1.$_GET['msg'].UNKNOWN_CODE_2;
                                        break;
                                }
-                               if (!empty($MSG))
-                               {
+
+                               if (!empty($MSG)) {
                                        // We got system message so we drop it out to the user
                                        LOAD_TEMPLATE("admin_settings_saved", false, $MSG);
-                               }
+                               } // END - if
 
                                // Load all email types...
-                               while ($typeS[] = SQL_FETCHROW($result))
-                               {
+                               while ($typeS[] = SQL_FETCHROW($result)) {
                                        // Nothing to do here... ;-)
-                               }
+                               } // END - while
 
                                // Free memory
                                SQL_FREERESULT($result);
@@ -649,6 +634,11 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                case "ORDER": // He is allowed to send as much as he setup the receiving value
                                        define('ORDER_MAX_VALUE', ORDER_ALLOWED_RECEIVE_1.$ALLOWED.ORDER_ALLOWED_RECEIVE_2.$MAXI.ORDER_ALLOWED_RECEIVE_3);
                                        break;
+
+                               default: // Unknown/invalid
+                                       DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown order_mas_full config detected.", $_CONFIG['order_max_full']));
+                                       define('ORDER_MAX_VALUE', ORDER_ALLOED_UNKNOWN);
+                                       break;
                                }
 
                                // Load final template