]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/rewrite_functions.php
Naming convention applied, new wrapper introduced:
[mailer.git] / inc / libs / rewrite_functions.php
index 5b76d5a1b31859742baf55c5e72d3f37c8086820..a36cbbfe968435d81cb560a2234cdd8ac0aea40e 100644 (file)
@@ -43,29 +43,25 @@ if (!defined('__SECURITY')) {
 }
 
 // Rewrite links in HTML for better SEO (ugly part of mx!)
-function rewriteLinksInCode ($HTML) {
+function rewriteLinksInCode ($code) {
        // Skip rewriting for configured modules
-       if (isInStringIgnoreCase(getModule(), getConfig('rewrite_skip')) !== false) return $HTML;
+       if (isInStringIgnoreCase(getModule(), getConfig('rewrite_skip')) !== false) return $code;
 
        // Generate target URL
-       $target = '{?URL?}/cms/';
-
-       // Final eval()
-       $eval = '$output = "' . preCompileCode(escapeQuotes($HTML)) . '";';
-       eval($eval);
+       $target = getUrl() . '/cms/';
 
        // Convert modules.php?module=...
-       foreach (array(getConfig('URL'), '{?URL?}') as $rewrite) {
-               $output = str_replace($rewrite . '/modules.php?module=', $target, $output);
+       foreach (array(getUrl(), '{?URL?}') as $rewrite) {
+               $code = str_replace($rewrite . '/modules.php?module=', $target, $code);
        } // END - foreach
 
        // Do we have an URL linked to mxchange.org?
-       if (isInStringIgnoreCase(getConfig('SERVER_URL'), $output)) {
+       if (isInStringIgnoreCase(getServerUrl(), $code)) {
                // Convert URLs from my server
-               $output = str_replace('{?URL?}/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output);
+               $code = str_replace('{?URL?}/modules.php?module=', getServerUrl() . '/cms/', $code);
 
                // Convert URLs from my server
-               $output = str_replace(getConfig('URL') . '/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output);
+               $code = str_replace(getUrl() . '/modules.php?module=', getServerUrl() . '/cms/', $code);
        } // END - if
 
        // Strip slashes as above for the main URL
@@ -75,19 +71,19 @@ function rewriteLinksInCode ($HTML) {
        $action = $target . '$1/act/';
 
        // Convert &|&action=...
-       $output = preg_replace('/' . $target2 . '(.*)&action=/i', $action, $output);
+       $code = preg_replace('/' . $target2 . '(.*)&action=/i', $action, $code);
 
        // "The same procedure as last variable"... now for &what=
        $what = $target . '$1/wht/';
-       $output = preg_replace('/' . $target2 . '(.*)&what=/i', $what, $output);
+       $code = preg_replace('/' . $target2 . '(.*)&what=/i', $what, $code);
 
        // Repair missed &what=??? entries
-       while (preg_match("/&what=(.*)\/(.*)\/(.*)/i", $output)) {
-               $output = preg_replace("/&what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $output);
+       while (preg_match("/&what=(.*)\/(.*)\/(.*)/i", $code)) {
+               $code = preg_replace("/&what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $code);
        } // END - while
 
        // Return rewritten code
-       return $output;
+       return $code;
 }
 
 // [EOF]