]> git.mxchange.org Git - mailer.git/blobdiff - inc/modules/member/what-order.php
Extensions 'admins' and 'task' are now always active
[mailer.git] / inc / modules / member / what-order.php
index eace0213cbae9e80d58104fab8836a8cd6b47a9a..7af82df4464c7888d41a8b8c72ef202b72814c86 100644 (file)
@@ -59,13 +59,10 @@ if (IS_ADMIN()) $whereStatement = "";
 define('__MIN_VALUE', getConfig('order_min'));
 
 // Count unconfirmed mails
-$result_links = SQL_QUERY_ESC("SELECT id FROM "._MYSQL_PREFIX."_user_links WHERE userid=%s",
- array($GLOBALS['userid']), __FILE__, __LINE__);
-$links = SQL_NUMROWS($result_links);
-SQL_FREERESULT($result_links);
+$links = GET_TOTAL_DATA($GLOBALS['userid'], "user_links", "id", "userid", true);
 
 // Does the user has more than 0 mails per day set?
-$HOLIDAY="userid";
+$HOLIDAY = "userid";
 if (GET_EXT_VERSION("holiday") >= "0.1.3") {
        // Fetch also holiday activation data
        $HOLIDAY = "holiday_active";
@@ -74,7 +71,7 @@ if (GET_EXT_VERSION("holiday") >= "0.1.3") {
 $result_mmails = SQL_QUERY_ESC("SELECT userid, receive_mails, mail_orders, ".$HOLIDAY."
 FROM "._MYSQL_PREFIX."_user_data
 WHERE userid=%s AND max_mails > 0 LIMIT 1",
- array($GLOBALS['userid']), __FILE__, __LINE__);
      array($GLOBALS['userid']), __FILE__, __LINE__);
 
 $mmails = SQL_NUMROWS($result_mmails);
 list($DMY, $MAXI, $ORDERS, $HOLIDAY) = SQL_FETCHROW($result_mmails);
@@ -84,23 +81,11 @@ if ($HOLIDAY == $DMY) $HOLIDAY='N';
 $ALLOWED = $MAXI - $ORDERS;
 if (getConfig('order_max_full') == "MAX") $ALLOWED = $MAXI;
 
-// Check HTML extension
-$HTML_EXT = EXT_IS_ACTIVE("html_mail");
-
 // Now check his points amount
-$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");
-
-       // Add (maybe) missing three zeros
-       if (!ereg(".", $TOTAL)) $TOTAL .= ".00000";
-} // END - if
+$TOTAL = GET_TOTAL_DATA($GLOBALS['userid'], "user_points", "points") - GET_TOTAL_DATA($GLOBALS['userid'], "user_data", "used_points");;
 
 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)) {
        // Continue with the frametester, we first need to store the data temporary in the pool
@@ -109,12 +94,13 @@ if (($HOLIDAY == "Y") && (GET_EXT_VERSION("holiday") >= "0.1.3")) {
        $result = SQL_QUERY_ESC("SELECT id, data_type
 FROM "._MYSQL_PREFIX."_pool
 WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
-        array($GLOBALS['userid'], $_POST['url'], getConfig('url_tlock')), __FILE__, __LINE__);
+               array($GLOBALS['userid'], $_POST['url'], getConfig('url_tlock')), __FILE__, __LINE__);
 
        $type = "TEMP"; $id = 0;
        if (SQL_NUMROWS($result) == 1) {
+               // Load id and mail type
                list($id, $type) = SQL_FETCHROW($result);
-       }
+       } // END - if
 
        // Free result
        SQL_FREERESULT($result);
@@ -153,15 +139,19 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                // And shall I check that his URL is not in the black list?
                if (getConfig('url_blacklist') == "Y") {
                        // Ok, I do that for you know...
-                       $result = SQL_QUERY_ESC("SELECT timestamp FROM "._MYSQL_PREFIX."_url_blist WHERE url='%s' LIMIT 1",
+                       $result = SQL_QUERY_ESC("SELECT UNIX_TIMESTAMP(`timestamp`) AS tstamp FROM `"._MYSQL_PREFIX."_url_blacklist` WHERE `url`='%s' LIMIT 1",
                                array($_POST['url']), __FILE__, __LINE__);
 
                        if (SQL_NUMROWS($result) == 1) {
                                // Jupp, we got one listed
                                list($blist) = SQL_FETCHROW($result);
-                               SQL_FREERESULT($result);
+
+                               // Create redirect-URL
                                $URL = URL."/modules.php?module=login&what=order&msg=".CODE_BLIST_URL."&blist=".$blist;
                        } // END - if
+
+                       // Free result
+                       SQL_FREERESULT($result);
                } // END - if
 
                // Enougth receivers entered?
@@ -177,7 +167,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                } // END - if
 
                // Probe for HTML extension
-               if ($HTML_EXT) {
+               if (EXT_IS_ACTIVE("html_mail")) {
                        // HTML or regular text mail?
                        if ($_POST['html'] == "Y") {
                                // Chek for valid HTML tags
@@ -276,7 +266,7 @@ WHERE userid=%s AND holiday_start < UNIX_TIMESTAMP() AND holiday_end > UNIX_TIME
                                if (($id == "0") || ($type != "TEMP")) {
                                        // New order
                                        $id = 0;
-                                       if ($HTML_EXT) {
+                                       if (EXT_IS_ACTIVE("html_mail")) {
                                                // HTML extension is active
                                                $result = SQL_QUERY_ESC("INSERT INTO "._MYSQL_PREFIX."_pool (sender, subject, text, receivers, payment_id, data_type, timestamp, url, cat_id, target_send, zip, html_msg)
  VALUES ('%s','%s','%s','%s','%s','TEMP','%s','%s','%s','%s','%s','%s')",
@@ -312,7 +302,7 @@ array(
                                        }
                                } else {
                                        // Change current order
-                                       if ($HTML_EXT) {
+                                       if (EXT_IS_ACTIVE("html_mail")) {
                                                // HTML extension is active
                                                $result = SQL_QUERY_ESC("UPDATE "._MYSQL_PREFIX."_pool SET
 subject='%s',
@@ -414,7 +404,7 @@ array(
 
                        // Enable HTML checking
                        $HTML = ""; $HOLIDAY = false; $HOL_STRING = "";
-                       if (($HTML_EXT) && ($_POST['html'] == "Y")) $HTML = " AND html='Y'";
+                       if ((EXT_IS_ACTIVE("html_mail")) && ($_POST['html'] == "Y")) $HTML = " AND html='Y'";
                        if (GET_EXT_VERSION("holiday") >= "0.1.3") {
                                // Extension's version is fine
                                $HOLIDAY = true; $HOL_STRING = " AND holiday_active='N'";
@@ -624,7 +614,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                }
 
                                // 01      2              21    12                                   2    23         443    3          3210
-                               if ((!empty($_POST['data'])) || ((getConfig('order_multi_page') == "N") && ((!IS_ADMIN()) && (!$HTML_EXT)))) {
+                               if ((!empty($_POST['data'])) || ((getConfig('order_multi_page') == "N") && ((!IS_ADMIN()) && (!EXT_IS_ACTIVE("html_mail"))))) {
                                        // Pre-output categories
                                        $CAT = "";
                                        foreach ($CATS['id'] as $key => $value) {
@@ -661,7 +651,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                        }
 
                                        // HTML extension
-                                       if (($HTML_EXT) && ($_POST['html'] == "Y")) {
+                                       if ((EXT_IS_ACTIVE("html_mail")) && ($_POST['html'] == "Y")) {
                                                // Extension is active so output valid HTML tags
                                                define('MEMBER_HTML_EXTENSION', LOAD_TEMPLATE("member_order-html_ext", true, HTML_ADD_VALID_TAGS()));
                                        } else {
@@ -674,7 +664,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                } else {
                                        // Remember maybe entered ZIP code in constant
                                        $ADD = "";
-                                       if ($HTML_EXT) {
+                                       if (EXT_IS_ACTIVE("html_mail")) {
                                                // Add some content when html extension is active
                                                if ((getConfig('order_multi_page') == "Y") || (IS_ADMIN())) $ADD = "<TR><TD colspan=\"2\" class=\"seperator bottom2\" height=\"5\">&nbsp;</TD></TR>\n";
                                                define('MEMBER_HTML_EXTENSION', LOAD_TEMPLATE("member_order-html_intro", true));