]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
query debug output removed
[mailer.git] / inc / functions.php
index d675eca81b5abe6dba65c639bbfbf7f4d6f1f816..5c0d7da89b225f026349d799557127d31c281518 100644 (file)
@@ -89,19 +89,19 @@ function OPEN_TABLE($PERCENT = "", $CLASS = "", $ALIGN="left", $VALIGN="", $td_o
   <TD";
        if (!empty($ALIGN)) $OUT .=" align=\"".$ALIGN."\"";
        $OUT .= " class=\"".$CLASS."\">";
-       OUTPUT_HTML ($OUT);
+       OUTPUT_HTML($OUT);
 }
 // Close a table (you may want to add some footer stuff here)
 function CLOSE_TABLE($ADD="")
 {
-       OUTPUT_HTML ("  </TD>
+       OUTPUT_HTML("  </TD>
 </TR>");
-       if (!empty($ADD)) OUTPUT_HTML ($ADD);
-       OUTPUT_HTML ("</TABLE>");
+       if (!empty($ADD)) OUTPUT_HTML($ADD);
+       OUTPUT_HTML("</TABLE>");
 }
 
 // Output HTML code directly or "render" it. You addionally switch the new-line character off
-function OUTPUT_HTML ($HTML, $NEW_LINE = true) {
+function OUTPUT_HTML($HTML, $NEW_LINE = true) {
        // Some global variables
        global $OUTPUT, $FOOTER, $CSS;
 
@@ -342,7 +342,7 @@ function LOAD_TEMPLATE($template, $return=false, $content="")
                 else
                {
                        // Output direct
-                       OUTPUT_HTML ($ret);
+                       OUTPUT_HTML($ret);
                }
        }
         elseif (DEBUG_MODE)
@@ -353,7 +353,7 @@ function LOAD_TEMPLATE($template, $return=false, $content="")
 }
 
 // Send mail out to an email address
-function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML="N", $FROM="")
+function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML='N', $FROM="")
 {
        // Compile subject line (for POINTS constant etc.)
        $eval = "\$SUBJECT = \"".COMPILE_CODE(addslashes($SUBJECT))."\";";
@@ -397,7 +397,7 @@ function SEND_EMAIL($TO, $SUBJECT, $MSG, $HTML="N", $FROM="")
        }
 
        // Fix HTML parameter (default is no!)
-       if (empty($HTML)) $HTML = "N";
+       if (empty($HTML)) $HTML = 'N';
        if (DEBUG_MODE)
        {
                // In debug mode we want to display the mail instead of sending it away so we can debug this part
@@ -408,7 +408,7 @@ Subject : ".$SUBJECT."
 Message : ".$MSG."
 </PRE>\n";
        }
-        elseif (($HTML == "Y") && (EXT_IS_ACTIVE("html_mail", true)))
+        elseif (($HTML == 'Y') && (EXT_IS_ACTIVE("html_mail", true)))
        {
                // Send mail as HTML away
                SEND_HTML_EMAIL($TO, $SUBJECT, $MSG, $FROM);
@@ -421,7 +421,7 @@ Message : ".$MSG."
                // Send Mail away
                SEND_RAW_EMAIL(stripslashes($TO), COMPILE_CODE($SUBJECT), stripslashes($MSG), $FROM);
        }
-        elseif ($HTML == "N")
+        elseif ($HTML == 'N')
        {
                // Problem found!
                SEND_RAW_EMAIL(WEBMASTER, COMPILE_CODE($SUBJECT), stripslashes($MSG), $FROM);
@@ -662,9 +662,9 @@ function SELECTION_COUNT($array)
        return $ret;
 }
 //
-function IMG_CODE ($code, $TYPE, $DATA, $uid)
+function IMG_CODE ($code, $type, $DATA, $uid)
 {
-       return "<IMG border=\"0\" alt=\"Code\" src=\"".URL."/mailid_top.php?uid=".$uid."&amp;".$TYPE."=".$DATA."&amp;mode=img&amp;code=".$code."\">";
+       return "<IMG border=\"0\" alt=\"Code\" src=\"".URL."/mailid_top.php?uid=".$uid."&amp;".$type."=".$DATA."&amp;mode=img&amp;code=".$code."\">";
 }
 //
 function TRANSLATE_STATUS($status)
@@ -746,7 +746,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0")
 
        // Keept for backward-compatiblity (please replace these variables against our new {--CONST--} syntax!)
        $MAIN_TITLE = MAIN_TITLE; $URL = URL; $WEBMASTER = WEBMASTER;
-       $surname = ""; $family = ""; $nick = ""; $sex = "N";
+       $surname = ""; $family = ""; $nick = ""; $sex = 'N';
 
        // Prepare IP number and User Agent
        $REMOTE_ADDR = getenv('REMOTE_ADDR');
@@ -891,7 +891,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0")
         else
        {
                // Neutral sex and email address is default
-               $sex = "N";
+               $sex = 'N';
                $email = WEBMASTER;
        }
 
@@ -986,7 +986,7 @@ function MAKE_TIME($H, $M, $S, $stamp)
        // Extract day, month and year from given timestamp
        $DAY   = date("d", $stamp);
        $MONTH = date("m", $stamp);
-       $YEAR  = date("Y", $stamp);
+       $YEAR  = date('Y', $stamp);
 
        // Create timestamp for wished time which depends on extracted date
        return mktime($H, $M, $S, $MONTH, $DAY, $YEAR);
@@ -1005,14 +1005,14 @@ function LOAD_URL($URL, $addUrlData=true) {
                $URL = htmlentities(strip_tags($URL), ENT_QUOTES);
 
                // Output new location link as anchor
-               OUTPUT_HTML ("<A href=\"".$URL."\">".$URL."</A>\n");
+               OUTPUT_HTML("<A href=\"".$URL."\">".$URL."</A>\n");
        } elseif (!headers_sent()) {
                // Load URL when headers are not sent
                @header ("Location: ".str_replace("&amp;", "&", $URL));
        } else {
                // Output error message
                include(PATH."inc/header.php");
-               OUTPUT_HTML (LOAD_URL_ERROR_1.$URL.LOAD_URL_ERROR_2);
+               OUTPUT_HTML(LOAD_URL_ERROR_1.$URL.LOAD_URL_ERROR_2);
                include(PATH."inc/footer.php");
        }
        exit();
@@ -1132,24 +1132,24 @@ function array_pk_sort(&$array, $a_sort, $primary_key = 0, $order = -1, $nums =
        $array = $dummy;
 }
 //
-function ADD_SELECTION($TYPE, $DEFAULT, $PREFIX="", $id="0")
+function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0")
 {
        global $MONTH_DESCR; $OUT = "";
-       if ($TYPE == "yn")
+       if ($type == "yn")
        {
                // This is a yes/no selection only!
-               if ($id > 0) $PREFIX .= "[".$id."]";
-               $OUT .= "    <SELECT name=\"".$PREFIX."\" class=\"register_select\" size=\"1\">\n";
+               if ($id > 0) $prefix .= "[".$id."]";
+               $OUT .= "    <SELECT name=\"".$prefix."\" class=\"register_select\" size=\"1\">\n";
        }
         else
        {
                // Begin with regular selection box here
-               if (!empty($PREFIX)) $PREFIX .= "_";
-               $TYPE2 = $TYPE;
-               if ($id > 0) $TYPE2 .= "[".$id."]";
-               $OUT .= "    <SELECT name=\"".strtolower($PREFIX.$TYPE2)."\" class=\"register_select\" size=\"1\">\n";
+               if (!empty($prefix)) $prefix .= "_";
+               $type2 = $type;
+               if ($id > 0) $type2 .= "[".$id."]";
+               $OUT .= "    <SELECT name=\"".strtolower($prefix.$type2)."\" class=\"register_select\" size=\"1\">\n";
        }
-       switch ($TYPE)
+       switch ($type)
        {
        case "day": // Day
                for ($idx = 1; $idx < 32; $idx++)
@@ -1171,7 +1171,7 @@ function ADD_SELECTION($TYPE, $DEFAULT, $PREFIX="", $id="0")
 
        case "year": // Year
                // Get current year
-               $YEAR = date("Y", time());
+               $YEAR = date('Y', time());
 
                // Check if the default value is larger than minimum and bigger than actual year
                if (($DEFAULT > 1930) && ($DEFAULT >= $YEAR))
@@ -1195,7 +1195,7 @@ function ADD_SELECTION($TYPE, $DEFAULT, $PREFIX="", $id="0")
                {
                        // Get current year and subtract 16 (for erotic content)
                        $OUT .= "      <OPTION value=\"1929\">&lt;1930</OPTION>\n";
-                       $YEAR = date("Y", time()) - 16;
+                       $YEAR = date('Y', time()) - 16;
                        for ($idx = 1930; $idx <= $YEAR; $idx++)
                        {
                                $OUT .= "      <OPTION value=\"".$idx."\"";
@@ -1228,10 +1228,10 @@ function ADD_SELECTION($TYPE, $DEFAULT, $PREFIX="", $id="0")
 
        case "yn":
                $OUT .= "      <OPTION value=\"Y\"";
-               if ($DEFAULT == "Y") $OUT .= " selected=\"selected\"";
+               if ($DEFAULT == 'Y') $OUT .= " selected=\"selected\"";
                $OUT .= ">".YES."</OPTION>
       <OPTION value=\"N\"";
-               if ($DEFAULT == "N") $OUT .= " selected=\"selected\"";
+               if ($DEFAULT == 'N') $OUT .= " selected=\"selected\"";
                $OUT .= ">".NO."</OPTION>\n";
                break;
        }
@@ -1243,8 +1243,8 @@ function TRANSLATE_YESNO($yn)
 {
        switch ($yn)
        {
-               case "Y": $yn = YES; break;
-               case "N": $yn = NO; break;
+               case 'Y': $yn = YES; break;
+               case 'N': $yn = NO; break;
                default : $yn = "??? (".$yn.")"; break;
        }
        return $yn;
@@ -1372,7 +1372,7 @@ function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="cen
        $timestamp = round($timestamp / 15) * 15;
        // Do we have a leap year?
        $SWITCH = 0;
-       $TEST = date("Y", time()) / 4;
+       $TEST = date('Y', time()) / 4;
        $M1 = date("m", time());
        $M2 = date("m", (time() + $timestamp));
        // If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
@@ -1413,7 +1413,7 @@ function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="cen
                $OUT  = "<DIV align=\"".$align."\">\n";
                $OUT .= "<TABLE border=\"0\" cellspacing=\"0\" cellpadding=\"0\" class=\"admin_table dashed\">\n";
                $OUT .= "<TR>\n";
-               if (ereg("Y", $display) || (empty($display)))
+               if (ereg('Y', $display) || (empty($display)))
                {
                        $OUT .= "  <TD align=\"center\" class=\"admin_title bottom\"><STRONG class=\"tiny\">"._YEARS."</STRONG></TD>\n";
                }
@@ -1443,7 +1443,7 @@ function CREATE_TIME_SELECTIONS($timestamp, $prefix="", $display="", $align="cen
                }
                $OUT .= "</TR>\n";
                $OUT .= "<TR>\n";
-               if (ereg("Y", $display) || (empty($display)))
+               if (ereg('Y', $display) || (empty($display)))
                {
                        // Generate year selection
                        $OUT .= "  <TD align=\"center\"><SELECT class=\"mini_select\" name=\"".$prefix."_ye\" size=\"1\">\n";
@@ -1567,7 +1567,7 @@ function CREATE_TIMESTAMP_FROM_SELECTIONS($prefix, $POST) {
        $ret = "0";
        // Do we have a leap year?
        $SWITCH = 0;
-       $TEST = date("Y", time()) / 4;
+       $TEST = date('Y', time()) / 4;
        $M1   = date("m", time());
        // If so and if current time is before 02/29 and estimated time is after 02/29 then add 86400 seconds (one day)
        if ((floor($TEST) == $TEST) && ($M1 == "02") && ($POST[$prefix."_mo"] > "02"))  $SWITCH = ONE_DAY;
@@ -1718,12 +1718,25 @@ function ADD_EMAIL_NAV($PAGES, $offset, $show_form, $colspan, $return=false) {
 
 //
 function MXCHANGE_OPEN($script) {
+       // Compile the script name
+       $script = COMPILE_CODE($script);
+
+       // Use default SERVER_URL by default... ;) So?
+       $url = SERVER_URL;
+       if (substr($script, 0, 7) == "http://") {
+               // Use the hostname from script URL as new hostname
+               $url = substr($script, 7);
+               $extract = explode("/", $url);
+               $url = $extract[0];
+               // Done extracting the URL :)
+       }
+
        // Extract host name
-       $host = str_replace("http://", "", SERVER_URL);
+       $host = str_replace("http://", "", $url);
        if (ereg("/", $host)) $host = substr($host, 0, strpos($host, "/"));
 
        // Generate relative URL
-       $script = substr(SERVER_URL, (strpos(SERVER_URL, $host) + strlen($host)))."/".basename($script);
+       $script = substr($script, (strlen($url) + 7));
        if (substr($script, 0, 1) == "/") $script = substr($script, 1);
 
        // Open connection