]> git.mxchange.org Git - mailer.git/blobdiff - inc/functions.php
Code-style applied, surfbar URLs can now be edited
[mailer.git] / inc / functions.php
index c73058b0a52d1d88e0751a55f50c02ad3f6f4d81..de2c08a4a07deeb568e4db45614a6c7dfda0a9a3 100644 (file)
@@ -719,7 +719,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") {
                $DATA[10]   = $UID;
 
                // Replace variables
-               foreach ($REPLACER as $key=>$value)
+               foreach ($REPLACER as $key => $value)
                {
                        if (isset($DATA[$key])) $content = str_replace($value, $DATA[$key], $content);
                }
@@ -769,7 +769,7 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") {
                $MAILID     = $DATA[11];
 
                // Replace variables
-               foreach ($REPLACER as $key=>$value)
+               foreach ($REPLACER as $key => $value)
                {
                        if (isset($DATA[$key])) $content = str_replace($value, $DATA[$key], $content);
                }
@@ -865,33 +865,30 @@ function LOAD_EMAIL_TEMPLATE($template, $content="", $UID="0") {
                $tmpl_file = @implode("", @file($file));
                $tmpl_file = addslashes($tmpl_file);
 
-               // Compile code
-               $tmpl_file = COMPILE_CODE($tmpl_file);
-
                // Run code
-               $tmpl_file = "\$content=\"".$tmpl_file."\";";
+               $tmpl_file = "\$newContent=\"".COMPILE_CODE($tmpl_file)."\";";
                eval($tmpl_file);
 
-               // Replace HTML confirm chars
-               $content = html_entity_decode($content);
+               // Replace HTML conform chars
+               $newContent = html_entity_decode($newContent);
        } elseif (!empty($template)) {
                // Template file not found!
-               $content = TEMPLATE_404.": ".$template."<br />
+               $newContent = TEMPLATE_404.": ".$template."<br />
 ".TEMPLATE_CONTENT."
-<PRE>".print_r($content, true)."</PRE>
+<PRE>".print_r($newContent, true)."</PRE>
 ".TEMPLATE_DATA."
 <PRE>".print_r($DATA, true)."</PRE>
 <br /><br />";
 
                // Debug mode not active? Then remove the HTML tags
-               if (!DEBUG_MODE) $content = strip_tags($content);
+               if (!DEBUG_MODE) $newContent = strip_tags($newContent);
        } else {
                // No template name supplied!
-               $content = NO_TEMPLATE_SUPPLIED;
+               $newContent = NO_TEMPLATE_SUPPLIED;
        }
 
        // Return compiled content
-       return COMPILE_CODE($content);
+       return COMPILE_CODE($newContent);
 }
 //
 function MAKE_TIME($H, $M, $S, $stamp) {
@@ -983,20 +980,21 @@ function COMPILE_CODE($code, $simple = false, $constants = true, $full = true) {
        if ((count($matches) > 0) && (count($matches[0]) > 0)) {
                // Replace all matches
                $matchesFound = array();
-               foreach ($matches[0] as $key=>$match) {
+               foreach ($matches[0] as $key => $match) {
                        // Avoid replacing matches multiple times
                        if (!isset($matchesFound[$match])) {
                                // Not yet replaced!
                                $code = str_replace($match, "\".".$match.".\"", $code);
                                $matchesFound[$match] = 1;
-                       }
+                       } // END - if
 
                        // Take all string elements
                        if (("".bigintval($matches[4][$key])."" != $matches[4][$key]) && (!isset($matchesFound[$key."_".$matches[4][$key]]))) {
                                // Replace it in the code
-                               $code = str_replace("[".$matches[4][$key]."]", "['".$matches[4][$key]."']", $code);
+                               $newMatch = str_replace("[".$matches[4][$key]."]", "['".$matches[4][$key]."']", $match);
+                               $code = str_replace($match, $newMatch, $code);
                                $matchesFound[$key."_".$matches[4][$key]] = 1;
-                       }
+                       } // END - if
                }
        }
 
@@ -1025,9 +1023,9 @@ function array_pk_sort(&$array, $a_sort, $primary_key = 0, $order = -1, $nums =
        $dummy = $array;
        while ($primary_key < count($a_sort))
        {
-               foreach ($dummy[$a_sort[$primary_key]] as $key=>$value)
+               foreach ($dummy[$a_sort[$primary_key]] as $key => $value)
                {
-                       foreach ($dummy[$a_sort[$primary_key]] as $key2=>$value2)
+                       foreach ($dummy[$a_sort[$primary_key]] as $key2 => $value2)
                        {
                                $match = false;
                                if (!$nums)
@@ -1044,7 +1042,7 @@ function array_pk_sort(&$array, $a_sort, $primary_key = 0, $order = -1, $nums =
                                if ($match)
                                {
                                        // We have found two different values, so let's sort whole array
-                                       foreach ($dummy as $sort_key=>$sort_val)
+                                       foreach ($dummy as $sort_key => $sort_val)
                                        {
                                                $t                       = $dummy[$sort_key][$key];
                                                $dummy[$sort_key][$key]  = $dummy[$sort_key][$key2];
@@ -1092,7 +1090,7 @@ function ADD_SELECTION($type, $DEFAULT, $prefix="", $id="0")
                break;
 
        case "month": // Month
-               foreach ($MONTH_DESCR as $month=>$descr)
+               foreach ($MONTH_DESCR as $month => $descr)
                {
                        $OUT .= "      <OPTION value=\"".$month."\"";
                        if ($DEFAULT == $month) $OUT .= " selected=\"selected\"";
@@ -1578,7 +1576,7 @@ function CREATE_FANCY_TIME($stamp) {
        // Get data array with years/months/weeks/days/...
        $data = CREATE_TIME_SELECTIONS($stamp, "", "", "", true);
        $ret = "";
-       foreach($data as $k=>$v) {
+       foreach($data as $k => $v) {
                if ($v > 0) {
                        // Value is greater than 0 "eval" data to return string
                        $eval = "\$ret .= \", \".\$v.\" \"._".strtoupper($k).";";
@@ -2402,23 +2400,26 @@ function HANDLE_EXTRA_VALUES ($filterFunction, $value, $extraValue) {
 
        // Do we have a special filter function?
        if (!empty($filterFunction)) {
-               // Do we have extra parameters here?
-               if (!empty($extraValue)) {
-                       // Put both parameters in one new array by default
-                       $args = array($value, $extraValue);
-
-                       // If we have an array simply use it and pre-extend it with our value
-                       if (is_array($extraValue)) {
-                               // Make the new args array
-                               $args = array_merge(array($value), $extraValue);
-                       } // END - if
-
-                       // Call the multi-parameter call-back
-                       $ret = call_user_func_array($filterFunction, $args);
-               } else {
-                       // One parameter call
-                       $ret = call_user_func($filterFunction, $value);
-               }
+               // Does the filter function exist?
+               if (function_exists($filterFunction)) {
+                       // Do we have extra parameters here?
+                       if (!empty($extraValue)) {
+                               // Put both parameters in one new array by default
+                               $args = array($value, $extraValue);
+
+                               // If we have an array simply use it and pre-extend it with our value
+                               if (is_array($extraValue)) {
+                                       // Make the new args array
+                                       $args = array_merge(array($value), $extraValue);
+                               } // END - if
+
+                               // Call the multi-parameter call-back
+                               $ret = call_user_func_array($filterFunction, $args);
+                       } else {
+                               // One parameter call
+                               $ret = call_user_func($filterFunction, $value);
+                       }
+               } // END - if
        } // END - if
 
        // Return the value
@@ -2459,6 +2460,11 @@ function CONVERT_SELECTIONS_TO_TIMESTAMP(&$POST, &$DATA, &$id, &$skip) {
                $skip = false; $TEST2 = "";
        }
 }
+// Reverts the german decimal comma into Computer decimal dot
+function REVERT_COMMA ($str) {
+       $float = (float)str_replace(",", ".", $str);
+       return $float;
+}
 //
 //////////////////////////////////////////////////
 //                                              //