]> git.mxchange.org Git - mailer.git/blobdiff - 0.2.1/inc/libs/rewrite_functions.php
win32 to unix line delimiters changed
[mailer.git] / 0.2.1 / inc / libs / rewrite_functions.php
index 8a8d41c2159b1cc90ba408c6a0fa925fdfd743bb..14343603a51ae43d28dd8a71c8c3fe4043f3645f 100644 (file)
-<?php\r
-/************************************************************************\r
- * MXChange v0.2.1                                    Start: 10/24/2004 *\r
- * ===============                              Last change: 11/14/2004 *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * File              : rewrite_functions.php                            *\r
- * -------------------------------------------------------------------- *\r
- * Short description : Special functions for rewrite extension          *\r
- * -------------------------------------------------------------------- *\r
- * Kurzbeschreibung  : Spezielle Funktion fuer rewrite-Erweiterung      *\r
- * -------------------------------------------------------------------- *\r
- *                                                                      *\r
- * -------------------------------------------------------------------- *\r
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *\r
- * For more information visit: http://www.mxchange.org                  *\r
- *                                                                      *\r
- * This program is free software; you can redistribute it and/or modify *\r
- * it under the terms of the GNU General Public License as published by *\r
- * the Free Software Foundation; either version 2 of the License, or    *\r
- * (at your option) any later version.                                  *\r
- *                                                                      *\r
- * This program is distributed in the hope that it will be useful,      *\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of       *\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *\r
- * GNU General Public License for more details.                         *\r
- *                                                                      *\r
- * You should have received a copy of the GNU General Public License    *\r
- * along with this program; if not, write to the Free Software          *\r
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *\r
- * MA  02110-1301  USA                                                  *\r
- ************************************************************************/\r
-\r
-// Some security stuff...\r
-if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))\r
-{\r
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";\r
-       require($INC);\r
-}\r
-\r
-//\r
-function REWRITE_LINKS($HTML)\r
-{\r
-       global $_GET, $CONFIG;\r
-\r
-       // Skip rewriting for the admin area (which search engine may enter here???)\r
-       if (ereg($GLOBALS['module'], $CONFIG['rewrite_skipped_mods'])) return $HTML;\r
-\r
-       // Strip slashes with double-backslashes for the preg_replace() function\r
-       $URL = str_replace("/", "\\/", URL);\r
-\r
-       // Generate target URL\r
-       $target = URL."/cms/";\r
-\r
-       // Convert modules.php?module=...\r
-       $test = preg_replace("/".$URL."\\/modules.php\\?module=/i", $target, $HTML);\r
-\r
-       if (eregi(SERVER_URL, $test))\r
-       {\r
-               // Konvert URLs from my server\r
-               $URL = str_replace("/", "\\/", SERVER_URL);\r
-               $test = preg_replace("/".$URL."\\/modules.php\\?module=/i", SERVER_URL."/cms/", $test);\r
-       }\r
-\r
-       // Strip slashes as above for the main URL\r
-       $target2 = str_replace("/", "\\/", $target);\r
-\r
-       // Action variable\r
-       $act = $target."\$1/act/";\r
-\r
-       // Convert &amp;|&action=...\r
-       $test = preg_replace("/".$target2."(.*)&amp;action=/i", $act, $test);\r
-\r
-       // "The same procedure as last variable"... now for &amp;what=\r
-       $wht = $target."\$1/wht/";\r
-       $target2 = str_replace("/", "\\/", $target);\r
-       $test = preg_replace("/".$target2."(.*)&amp;what=/i", $wht, $test);\r
-\r
-       if ((EXT_IS_ACTIVE("rallye")) && (eregi("rallye=", $test)))\r
-       {\r
-               // Replace data when rallye extension is active\r
-               // Add more if you need more like these entries\r
-               $REPLACE = array("rallye", "activate", "auto", "notify", "sub");\r
-               foreach ($REPLACE as $var)\r
-               {\r
-                       // This will replace "&amp;var=" to "/var/"\r
-                       $test = preg_replace("/&amp;".$var."=/i", "/".$var."/", $test);\r
-               }\r
-       }\r
-\r
-       // Simple from->to replacements\r
-       $REPLACE = array(\r
-               'search'  => array("u_id", "url", "page", "offset", "mid", "bid", "sub", "home"),\r
-               'replace' => array("u"   , "url", "page", "offset", "m"  , "b"  , "s"  , "h")\r
-       );\r
-\r
-       if ((EXT_IS_ACTIVE("admins")) && (eregi("admin=", $test)))\r
-       {\r
-               // Replace &amp;admin= with "/aid/"\r
-               $REPLACE['search'][]  = "admin";\r
-               $REPLACE['replace'][] = "aid";\r
-       }\r
-\r
-       // Replace all array elements through\r
-       foreach ($REPLACE['search'] as $k=>$v)\r
-       {\r
-               if (eregi("$v=", $test))\r
-               {\r
-                       // Replace &amp;u_id= with /u/\r
-                       $test = preg_replace("/&amp;".$v."=/i", "/".$REPLACE['replace'][$k]."/", $test);\r
-               }\r
-       }\r
-\r
-       // Repair missed &amp;what=??? entries\r
-       while (preg_match("/&amp;what=(.*)\/(.*)\/(.*)/i", $test))\r
-       {\r
-               $test = preg_replace("/&amp;what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $test);\r
-       }\r
-\r
-       // Return rewritten code\r
-       return $test;\r
-}\r
-//\r
-?>\r
+<?php
+/************************************************************************
+ * MXChange v0.2.1                                    Start: 10/24/2004 *
+ * ===============                              Last change: 11/14/2004 *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * File              : rewrite_functions.php                            *
+ * -------------------------------------------------------------------- *
+ * Short description : Special functions for rewrite extension          *
+ * -------------------------------------------------------------------- *
+ * Kurzbeschreibung  : Spezielle Funktion fuer rewrite-Erweiterung      *
+ * -------------------------------------------------------------------- *
+ *                                                                      *
+ * -------------------------------------------------------------------- *
+ * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * For more information visit: http://www.mxchange.org                  *
+ *                                                                      *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or    *
+ * (at your option) any later version.                                  *
+ *                                                                      *
+ * This program is distributed in the hope that it will be useful,      *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
+ * GNU General Public License for more details.                         *
+ *                                                                      *
+ * You should have received a copy of the GNU General Public License    *
+ * along with this program; if not, write to the Free Software          *
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
+ * MA  02110-1301  USA                                                  *
+ ************************************************************************/
+
+// Some security stuff...
+if (ereg(basename(__FILE__), $_SERVER['PHP_SELF']))
+{
+       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php";
+       require($INC);
+}
+
+//
+function REWRITE_LINKS($HTML)
+{
+       global $_GET, $CONFIG;
+
+       // Skip rewriting for the admin area (which search engine may enter here???)
+       if (ereg($GLOBALS['module'], $CONFIG['rewrite_skipped_mods'])) return $HTML;
+
+       // Strip slashes with double-backslashes for the preg_replace() function
+       $URL = str_replace("/", "\\/", URL);
+
+       // Generate target URL
+       $target = URL."/cms/";
+
+       // Convert modules.php?module=...
+       $test = preg_replace("/".$URL."\\/modules.php\\?module=/i", $target, $HTML);
+
+       if (eregi(SERVER_URL, $test))
+       {
+               // Konvert URLs from my server
+               $URL = str_replace("/", "\\/", SERVER_URL);
+               $test = preg_replace("/".$URL."\\/modules.php\\?module=/i", SERVER_URL."/cms/", $test);
+       }
+
+       // Strip slashes as above for the main URL
+       $target2 = str_replace("/", "\\/", $target);
+
+       // Action variable
+       $act = $target."\$1/act/";
+
+       // Convert &amp;|&action=...
+       $test = preg_replace("/".$target2."(.*)&amp;action=/i", $act, $test);
+
+       // "The same procedure as last variable"... now for &amp;what=
+       $wht = $target."\$1/wht/";
+       $target2 = str_replace("/", "\\/", $target);
+       $test = preg_replace("/".$target2."(.*)&amp;what=/i", $wht, $test);
+
+       if ((EXT_IS_ACTIVE("rallye")) && (eregi("rallye=", $test)))
+       {
+               // Replace data when rallye extension is active
+               // Add more if you need more like these entries
+               $REPLACE = array("rallye", "activate", "auto", "notify", "sub");
+               foreach ($REPLACE as $var)
+               {
+                       // This will replace "&amp;var=" to "/var/"
+                       $test = preg_replace("/&amp;".$var."=/i", "/".$var."/", $test);
+               }
+       }
+
+       // Simple from->to replacements
+       $REPLACE = array(
+               'search'  => array("u_id", "url", "page", "offset", "mid", "bid", "sub", "home"),
+               'replace' => array("u"   , "url", "page", "offset", "m"  , "b"  , "s"  , "h")
+       );
+
+       if ((EXT_IS_ACTIVE("admins")) && (eregi("admin=", $test)))
+       {
+               // Replace &amp;admin= with "/aid/"
+               $REPLACE['search'][]  = "admin";
+               $REPLACE['replace'][] = "aid";
+       }
+
+       // Replace all array elements through
+       foreach ($REPLACE['search'] as $k=>$v)
+       {
+               if (eregi("$v=", $test))
+               {
+                       // Replace &amp;u_id= with /u/
+                       $test = preg_replace("/&amp;".$v."=/i", "/".$REPLACE['replace'][$k]."/", $test);
+               }
+       }
+
+       // Repair missed &amp;what=??? entries
+       while (preg_match("/&amp;what=(.*)\/(.*)\/(.*)/i", $test))
+       {
+               $test = preg_replace("/&amp;what=(.*)\/(.*)\/(.*)/i", "/wht/\$1/\$2/\$3", $test);
+       }
+
+       // Return rewritten code
+       return $test;
+}
+//
+?>