Possible fix for error 'Empty delimiter,errfile=wrapper-functions.php,errline=1050'
[mailer.git] / inc / libs / rewrite_functions.php
index ef3d16ea36445974c1cf49162523be6b46788600..ae1854d4d2289ff2afb853884b96c80d37b3b5a7 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                            *
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * 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 - 2011 by Mailer Developer Team                   *
  * 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')) {
-       $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!)
-function REWRITE_LINKS ($HTML) {
-       // Skip rewriting for configured modules
-       if (eregi($GLOBALS['module'], getConfig('rewrite_skip')) !== false) return $HTML;
+function rewriteLinksInCode ($code) {
+       // Skip rewriting for configured or empty modules
+       if ((getModule() == '') || (isInStringIgnoreCase(getModule(), getConfig('rewrite_skip')) !== false)) {
+               return $code;
+       } // END - if
 
        // Generate target URL
-       $target = "{!URL!}/cms/";
-
-       // Convert modules.php?module=...
-       $output = str_replace(constant('URL') . "/modules.php?module=", $target, $HTML);
+       $target = getUrl() . '/cms/';
 
        // Convert modules.php?module=...
-       $output = str_replace("{!URL!}/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 (eregi(constant('SERVER_URL'), $output)) {
+       if (isInStringIgnoreCase(getServerUrl(), $code)) {
                // Convert URLs from my server
-               $output = str_replace("{!URL!}/modules.php?module=", constant('SERVER_URL')."/cms/", $output);
+               $code = str_replace('{?URL?}/modules.php?module=', getServerUrl() . '/cms/', $code);
 
                // Convert URLs from my server
-               $output = str_replace(constant('URL') . "/modules.php?module=", constant('SERVER_URL')."/cms/", $output);
+               $code = str_replace(getUrl() . '/modules.php?module=', getServerUrl() . '/cms/', $code);
        } // END - if
 
        // Strip slashes as above for the main URL
-       $target2 = preg_quote($target, "/");
+       $target2 = preg_quote($target, '/');
 
        // Action variable
-       $act = $target."\$1/act/";
+       $action = $target . '$1/act/';
 
        // Convert &amp;|&action=...
-       $output = preg_replace("/" . $target2 . "(.*)&amp;action=/i", $act, $output);
+       $code = preg_replace('/' . $target2 . '(.*)&amp;action=/i', $action, $code);
 
        // "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/';
+       $code = preg_replace('/' . $target2 . '(.*)&amp;what=/i', $what, $code);
 
        // Repair missed &amp;what=??? entries
-       while (preg_match("/&amp;what=(.*)\/(.*)\/(.*)/i", $output)) {
-               $output = preg_replace("/&amp;what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $output);
+       while (preg_match("/&amp;what=(.*)\/(.*)\/(.*)/i", $code)) {
+               $code = preg_replace("/&amp;what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $code);
        } // END - while
 
        // Return rewritten code
-       return $output;
+       return $code;
 }
-//
+
+// [EOF]
 ?>