Continue link added, contributed by profi-concept. Partly resolves #3
[mailer.git] / inc / modules / member / what-order.php
index f1627a9584533e4d15b66977e978bce25aeac4a1..ae81c826143ee0476456f42a2ae8b8dd3e791e49 100644 (file)
@@ -113,7 +113,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                        // Test submitted text against some filters (length, URLs in text etc.)
                        if ((strpos(strtolower($_POST['text']), "https://") > -1) || (strpos(strtolower($_POST['text']), "http://") > -1) || (strpos(strtolower($_POST['text']), "www") > -1)) {
                                // URL found!
-                               $URL = "modules.php?module=login&what=order&msg=".CODE_URL_FOUND;
+                               $URL = "modules.php?module=login&what=order&msg=".constant('CODE_URL_FOUND');
                        } // END - if
 
                        // Remove new-line and carriage-return characters
@@ -122,7 +122,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                        // Text length within allowed length?
                        if (strlen($TEST) > getConfig('max_tlength')) {
                                // Text is too long!
-                               $URL = "modules.php?module=login&what=order&msg=".CODE_OVERLENGTH;
+                               $URL = "modules.php?module=login&what=order&msg=".constant('CODE_OVERLENGTH');
                        } // END - if
                } // END - if
 
@@ -132,7 +132,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                        $_POST['subject'] = str_replace("\\", "[nl]", substr($_POST['subject'], 0, 200));
                        if ((strpos(strtolower($_POST['subject']), "http://") > -1) || (strpos(strtolower($_POST['subject']), "www") > -1)) {
                                // URL in subject found
-                               $URL = "modules.php?module=login&what=order&msg=".CODE_SUBJ_URL;
+                               $URL = "modules.php?module=login&what=order&msg=".constant('CODE_SUBJ_URL');
                        } // END - if
                } // END - if
 
@@ -147,7 +147,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                                list($blist) = SQL_FETCHROW($result);
 
                                // Create redirect-URL
-                               $URL = "modules.php?module=login&what=order&msg=".CODE_BLIST_URL."&blist=".$blist;
+                               $URL = "modules.php?module=login&what=order&msg=".constant('CODE_BLIST_URL')."&blist=".$blist;
                        } // END - if
 
                        // Free result
@@ -157,13 +157,13 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                // Enougth receivers entered?
                if (($_POST['receiver'] < getConfig('order_min')) && (!IS_ADMIN())) {
                        // Less than allowed receivers entered!
-                       $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_MORE_RECEIVERS3;
+                       $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_MORE_RECEIVERS3');
                } // END - if
 
                // Validate URL
                if (!VALIDATE_URL($_POST['url'])) {
                        // URL is invalid!
-                       $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_INVALID_URL;
+                       $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_INVALID_URL');
                } // END - if
 
                // Probe for HTML extension
@@ -174,7 +174,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                                $_POST['text'] = HTML_CHECK_TAGS($_POST['text']);
 
                                // Maybe invalid tags found?
-                               if (empty($_POST['text'])) $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_INVALID_TAGS."&amp;id=".$id;
+                               if (empty($_POST['text'])) $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_INVALID_TAGS')."&amp;id=".$id;
                        } else {
                                // Remove any HTML code
                                $_POST['text'] = str_replace("<", "{OPEN_HTML}", str_replace(">", "{CLOSE_HTML}", $_POST['text']));
@@ -182,7 +182,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                }
        } elseif (!IS_ADMIN()) {
                // He has already sent a mail within a specific time
-               $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_URL_TLOCK."&amp;id=".$id;
+               $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_URL_TLOCK')."&amp;id=".$id;
        }
 
        // Still no error?
@@ -198,7 +198,7 @@ WHERE sender=%s AND url='%s' AND timestamp > (UNIX_TIMESTAMP() - %s) LIMIT 1",
                $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']),
@@ -374,19 +374,19 @@ array(
                                $URL = "modules.php?module=frametester&amp;order=".$id."";
                        } elseif ($MAX_SEND == 0) {
                                // Not enougth receivers found which can receive mails
-                               $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_MORE_RECEIVERS2;
+                               $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_MORE_RECEIVERS2');
                        } else {
                                // No enougth points left!
-                               $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_MORE_POINTS;
+                               $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_MORE_POINTS');
                        }
                } else  {
                        // Ordered more mails than he can send in this category
-                       $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_NO_RECS_LEFT;
+                       $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_NO_RECS_LEFT');
                }
        }
 } elseif ($_POST['receiver'] == "0") {
        // Not enougth receivers selected
-       $URL = "modules.php?module=login&amp;what=order&amp;msg=".CODE_MORE_RECEIVERS1;
+       $URL = "modules.php?module=login&amp;what=order&amp;msg=".constant('CODE_MORE_RECEIVERS1');
 } elseif (($ALLOWED == 0) && (getConfig('order_max_full') == "ORDER")) {
        // No more mail orders allowed
        LOAD_TEMPLATE("admin_settings_saved", false, getMessage('MEMBER_ORDER_ALLOWED_EXHAUSTED'));
@@ -417,7 +417,7 @@ array(
 
                                // Select users in current category
                                $result_uids = SQL_QUERY_ESC("SELECT userid FROM `{!_MYSQL_PREFIX!}_user_cats` WHERE cat_id=%s AND userid != '%s' ORDER BY userid",
-                                array(bigintval($id), $GLOBALS['userid']), __FILE__, __LINE__);
+                                       array(bigintval($id), $GLOBALS['userid']), __FILE__, __LINE__);
 
                                $uid_cnt = 0;
                                while (list($ucat) = SQL_FETCHROW($result_uids)) {
@@ -428,7 +428,7 @@ array(
                                                $result_holiday = SQL_QUERY_ESC("SELECT DISTINCT d.userid FROM `{!_MYSQL_PREFIX!}_user_data` AS d
 LEFT JOIN `{!_MYSQL_PREFIX!}_user_holidays` AS h
 ON d.userid=h.userid
-WHERE d.userid=%s AND d.receive_mails > 0 AND d.status='CONFIRMED' AND d.holiday_active='Y'
+WHERE d.userid=%s AND d.receive_mails > 0 AND d.`status`='CONFIRMED' AND d.holiday_active='Y'
 AND h.holiday_start < UNIX_TIMESTAMP() AND h.holiday_end > UNIX_TIMESTAMP()
 LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                                if (SQL_NUMROWS($result_holiday) == 1) {
@@ -442,7 +442,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
 
                                        if (!$HOL_ACTIVE) {
                                                // Check if the user want's to receive mails?
-                                               $result_ver = SQL_QUERY_ESC("SELECT zip FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s".$HTML." AND receive_mails > 0 AND status='CONFIRMED' LIMIT 1",
+                                               $result_ver = SQL_QUERY_ESC("SELECT zip FROM `{!_MYSQL_PREFIX!}_user_data` WHERE userid=%s".$HTML." AND receive_mails > 0 AND `status`='CONFIRMED' LIMIT 1",
                                                        array(bigintval($ucat)), __FILE__, __LINE__);
 
                                                if ((SQL_NUMROWS($result_ver) == 1) && (!empty($_POST['zip'])) && (getConfig('order_multi_page') == "Y")) {
@@ -476,7 +476,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                $MSG = "";
                                switch ($_GET['msg'])
                                {
-                               case CODE_URL_TLOCK:
+                               case constant('CODE_URL_TLOCK'):
                                        $result = SQL_QUERY_ESC("SELECT timestamp FROM `{!_MYSQL_PREFIX!}_pool` WHERE id=%s LIMIT 1",
                                         array(bigintval($_GET['id'])), __FILE__, __LINE__);
 
@@ -497,53 +497,54 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                        $SEC = getConfig('url_tlock') - $STD * 60 * 60 - $MIN * 60;
 
                                        // Finally contruct the message
-                                       $MSG = MEMBER_URL_TIME_LOCK."<br />".CONFIG_URL_TLOCK." ".$STD." ".
-                                               _HOURS.", ".$MIN." "._MINUTES." "._AND." ".$SEC." "._SECONDS."<br />".
-                                               MEMBER_LAST_TLOCK.": ".$LORDER;
+                                       // @TODO Rewrite this old lost code to a template
+                                       $MSG = "{!MEMBER_URL_TIME_LOCK!}<br />{!CONFIG_URL_TLOCK!} ".$STD."
+                                               {!_HOURS!}, ".$MIN." {!_MINUTES!} {!_AND!} ".$SEC." {!_SECONDS!}<br />
+                                               {!MEMBER_LAST_TLOCK!}: ".$LORDER;
                                        break;
 
-                               case CODE_OVERLENGTH:
-                                       $MSG = MEMBER_TEXT_OVERLENGTH;
+                               case constant('CODE_OVERLENGTH'):
+                                       $MSG = getMessage('MEMBER_TEXT_OVERLENGTH');
                                        break;
 
-                               case CODE_URL_FOUND:
-                                       $MSG = MEMBER_TEXT_CONTAINS_URL;
+                               case constant('CODE_URL_FOUND'):
+                                       $MSG = getMessage('MEMBER_TEXT_CONTAINS_URL');
                                        break;
 
-                               case CODE_SUBJ_URL:
-                                       $MSG = MEMBER_SUBJ_CONTAINS_URL;
+                               case constant('CODE_SUBJ_URL'):
+                                       $MSG = getMessage('MEMBER_SUBJ_CONTAINS_URL');
                                        break;
 
-                               case CODE_BLIST_URL:
-                                       $MSG = MEMBER_URL_BLACK_LISTED."<br />\n".MEMBER_BLIST_TIME.": ".MAKE_DATETIME($_GET['blist'], "0");
+                               case constant('CODE_BLIST_URL'):
+                                       $MSG = "{!MEMBER_URL_BLACK_LISTED!}<br />\n{!MEMBER_BLIST_TIME!}: ".MAKE_DATETIME($_GET['blist'], "0");
                                        break;
 
-                               case CODE_NO_RECS_LEFT:
-                                       $MSG = MEMBER_SELECTED_MORE_RECS;
+                               case constant('CODE_NO_RECS_LEFT'):
+                                       $MSG = getMessage('MEMBER_SELECTED_MORE_RECS');
                                        break;
 
-                               case CODE_INVALID_TAGS:
-                                       $MSG = MEMBER_HTML_INVALID_TAGS;
+                               case constant('CODE_INVALID_TAGS'):
+                                       $MSG = getMessage('MEMBER_HTML_INVALID_TAGS');
                                        break;
 
-                               case CODE_MORE_POINTS:
-                                       $MSG = MEMBER_MORE_POINTS_NEEDED;
+                               case constant('CODE_MORE_POINTS'):
+                                       $MSG = getMessage('MEMBER_MORE_POINTS_NEEDED');
                                        break;
 
-                               case CODE_MORE_RECEIVERS1:
-                                       $MSG = MEMBER_ENTER_MORE_RECEIVERS;
+                               case constant('CODE_MORE_RECEIVERS1'):
+                                       $MSG = getMessage('MEMBER_ENTER_MORE_RECEIVERS');
                                        break;
 
-                               case CODE_MORE_RECEIVERS2:
-                                       $MSG = MEMBER_NO_MORE_RECEIVERS_FOUND;
+                               case constant('CODE_MORE_RECEIVERS2'):
+                                       $MSG = getMessage('MEMBER_NO_MORE_RECEIVERS_FOUND');
                                        break;
 
-                               case CODE_MORE_RECEIVERS3:
-                                       $MSG = MEMBER_ENTER_MORE_MIN_RECEIVERS_1.getConfig('order_min').MEMBER_ENTER_MORE_MIN_RECEIVERS_2;
+                               case constant('CODE_MORE_RECEIVERS3'):
+                                       $MSG = "{!MEMBER_ENTER_MORE_MIN_RECEIVERS_1!}".getConfig('order_min')."{!MEMBER_ENTER_MORE_MIN_RECEIVERS_2!}";
                                        break;
 
-                               case CODE_INVALID_URL:
-                                       $MSG = MEMBER_ENTER_INVALID_URL;
+                               case constant('CODE_INVALID_URL'):
+                                       $MSG = getMessage('MEMBER_ENTER_INVALID_URL');
                                        break;
 
                                case "": // When no error code is included in the URL we do not need to output an error message as well...
@@ -551,7 +552,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
 
                                default:
                                        DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown error code %s detected.", $_GET['msg']));
-                                       $MSG = UNKNOWN_CODE_1.$_GET['msg'].UNKNOWN_CODE_2;
+                                       $MSG = "{!UNKNOWN_CODE_1!}".$_GET['msg']."{!UNKNOWN_CODE_2!}";
                                        break;
                                }
 
@@ -575,7 +576,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                switch (getConfig('order_max_full'))
                                {
                                case "MAX": // He is allowed to send as much as possible
-                                       define('ORDER_MAX_VALUE', ORDER_ALLOED_MAX);
+                                       define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOWED_MAX'));
                                        break;
 
                                case "ORDER": // He is allowed to send as much as he setup the receiving value
@@ -584,7 +585,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
 
                                default: // Unknown/invalid
                                        DEBUG_LOG(__FILE__, __LINE__, sprintf("Unknown order_mas_full config detected.", getConfig('order_max_full')));
-                                       define('ORDER_MAX_VALUE', ORDER_ALLOED_UNKNOWN);
+                                       define('ORDER_MAX_VALUE', getMessage('ORDER_ALLOWED_UNKNOWN'));
                                        break;
                                }
 
@@ -622,7 +623,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                        foreach ($CATS['id'] as $key => $value) {
                                                $CAT .= "      <option value=\"".$value."\"";
                                                if (($OLD_ORDER) && ($cat == $value)) $CAT .= " selected=\"selected\"";
-                                               $CAT .= ">".$CATS['name'][$key]." (".$CATS['uids'][$key]." ".USER_IN_CAT.")</option>\n";
+                                               $CAT .= ">".$CATS['name'][$key]." (".$CATS['uids'][$key]." {!USER_IN_CAT!})</option>\n";
                                        } // END - foreach
 
                                        // Mail type
@@ -633,7 +634,7 @@ LIMIT 1", array(bigintval($ucat)), __FILE__, __LINE__);
                                                        // Output option line
                                                        $type .= "      <option value=\"".$typeS[$key][0]."\"";
                                                        if (($OLD_ORDER) && ($payment == $typeS[$key][0])) $type .= " selected=\"selected\"";
-                                                       $type .= ">".$P." ".PER_MAIL." - ".$typeS[$key][3]." - ".round($typeS[$key][2])." ".PAYMENT."</option>\n";
+                                                       $type .= ">".$P." {!PER_MAIL!} - ".$typeS[$key][3]." - ".round($typeS[$key][2])." {!PAYMENT!}</option>\n";
                                                } // END - if
                                        } // END - foreach