Even more rewrites/fixes from EL branch (please report any broken part after you...
[mailer.git] / inc / libs / rewrite_functions.php
index 236b440a3c213843401217d5ef643a1506ec1f01..5b76d5a1b31859742baf55c5e72d3f37c8086820 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /************************************************************************
 <?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                            *
  *                                                                      *
  * -------------------------------------------------------------------- *
  * File              : rewrite_functions.php                            *
@@ -17,7 +17,8 @@
  * Needs to be in all Files and every File needs "svn propset           *
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Needs to be in all Files and every File needs "svn propset           *
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * 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 *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
-       require($INC);
+       die();
 }
 
 // Rewrite links in HTML for better SEO (ugly part of mx!)
 }
 
 // Rewrite links in HTML for better SEO (ugly part of mx!)
-function REWRITE_LINKS ($HTML) {
+function rewriteLinksInCode ($HTML) {
        // Skip rewriting for configured modules
        // Skip rewriting for configured modules
-       if (eregi($GLOBALS['module'], getConfig('rewrite_skip')) !== false) return $HTML;
+       if (isInStringIgnoreCase(getModule(), getConfig('rewrite_skip')) !== false) return $HTML;
 
        // Generate target URL
 
        // Generate target URL
-       $target = "{!URL!}/cms/";
+       $target = '{?URL?}/cms/';
 
 
-       // Convert modules.php?module=...
-       $output = str_replace(constant('URL') . "/modules.php?module=", $target, $HTML);
+       // Final eval()
+       $eval = '$output = "' . preCompileCode(escapeQuotes($HTML)) . '";';
+       eval($eval);
 
        // Convert modules.php?module=...
 
        // 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?
 
        // Do we have an URL linked to mxchange.org?
-       if (eregi(constant('SERVER_URL'), $output)) {
+       if (isInStringIgnoreCase(getConfig('SERVER_URL'), $output)) {
                // Convert URLs from my server
                // Convert URLs from my server
-               $output = str_replace("{!URL!}/modules.php?module=", constant('SERVER_URL')."/cms/", $output);
+               $output = str_replace('{?URL?}/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output);
 
                // Convert URLs from my server
 
                // Convert URLs from my server
-               $output = str_replace(constant('URL') . "/modules.php?module=", constant('SERVER_URL')."/cms/", $output);
+               $output = str_replace(getConfig('URL') . '/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output);
        } // END - if
 
        // Strip slashes as above for the main URL
        } // END - if
 
        // Strip slashes as above for the main URL
-       $target2 = preg_quote($target, "/");
+       $target2 = preg_quote($target, '/');
 
        // Action variable
 
        // Action variable
-       $act = $target."\$1/act/";
+       $action = $target . '$1/act/';
 
        // Convert &amp;|&action=...
 
        // Convert &amp;|&action=...
-       $output = preg_replace("/" . $target2 . "(.*)&amp;action=/i", $act, $output);
+       $output = preg_replace('/' . $target2 . '(.*)&amp;action=/i', $action, $output);
 
        // "The same procedure as last variable"... now for &amp;what=
 
        // "The same procedure as last variable"... now for &amp;what=
-       $wht = $target."\$1/wht/";
-       $output = preg_replace("/" . $target2 . "(.*)&amp;what=/i", $wht, $output);
+       $what = $target . '$1/wht/';
+       $output = preg_replace('/' . $target2 . '(.*)&amp;what=/i', $what, $output);
 
        // Repair missed &amp;what=??? entries
        while (preg_match("/&amp;what=(.*)\/(.*)\/(.*)/i", $output)) {
 
        // Repair missed &amp;what=??? entries
        while (preg_match("/&amp;what=(.*)\/(.*)\/(.*)/i", $output)) {
@@ -86,5 +89,6 @@ function REWRITE_LINKS ($HTML) {
        // Return rewritten code
        return $output;
 }
        // Return rewritten code
        return $output;
 }
-//
+
+// [EOF]
 ?>
 ?>