Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / libs / rewrite_functions.php
index c7ed9f91f5c66374cb3ba9162f3e1e3a7f07213d..5b76d5a1b31859742baf55c5e72d3f37c8086820 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
- * MXChange v0.2.1                                    Start: 10/24/2004 *
- * ===============                              Last change: 11/14/2004 *
+ * Mailer v0.2.1-FINAL                                Start: 10/24/2004 *
+ * ===================                          Last change: 11/14/2004 *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : rewrite_functions.php                            *
@@ -18,6 +18,7 @@
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
+ * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -44,19 +45,22 @@ if (!defined('__SECURITY')) {
 // Rewrite links in HTML for better SEO (ugly part of mx!)
 function rewriteLinksInCode ($HTML) {
        // Skip rewriting for configured modules
-       if (eregi(getModule(), getConfig('rewrite_skip')) !== false) return $HTML;
+       if (isInStringIgnoreCase(getModule(), getConfig('rewrite_skip')) !== false) return $HTML;
 
        // Generate target URL
        $target = '{?URL?}/cms/';
 
-       // Convert modules.php?module=...
-       $output = str_replace(getConfig('URL') . '/modules.php?module=', $target, $HTML);
+       // Final eval()
+       $eval = '$output = "' . preCompileCode(escapeQuotes($HTML)) . '";';
+       eval($eval);
 
        // Convert modules.php?module=...
-       $output = str_replace('{?URL?}/modules.php?module=', $target, $output);
+       foreach (array(getConfig('URL'), '{?URL?}') as $rewrite) {
+               $output = str_replace($rewrite . '/modules.php?module=', $target, $output);
+       } // END - foreach
 
        // Do we have an URL linked to mxchange.org?
-       if (eregi(getConfig('SERVER_URL'), $output)) {
+       if (isInStringIgnoreCase(getConfig('SERVER_URL'), $output)) {
                // Convert URLs from my server
                $output = str_replace('{?URL?}/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output);
 
@@ -68,13 +72,13 @@ function rewriteLinksInCode ($HTML) {
        $target2 = preg_quote($target, '/');
 
        // Action variable
-       $action = $target."\$1/act/";
+       $action = $target . '$1/act/';
 
        // Convert &amp;|&action=...
        $output = preg_replace('/' . $target2 . '(.*)&amp;action=/i', $action, $output);
 
        // "The same procedure as last variable"... now for &amp;what=
-       $what = $target."\$1/wht/";
+       $what = $target . '$1/wht/';
        $output = preg_replace('/' . $target2 . '(.*)&amp;what=/i', $what, $output);
 
        // Repair missed &amp;what=??? entries