X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=inc%2Flibs%2Frewrite_functions.php;h=83d131c421de7dfa1d6bd70f0bf3c44dd159aa08;hb=8def2eea23fae29ba4d86b4bf7df9307e62f61b7;hp=121f0c4579a3e063d6840658856b46b0f1bb0a25;hpb=face72cb9a435049e8d17196c1fa8434982701b4;p=mailer.git diff --git a/inc/libs/rewrite_functions.php b/inc/libs/rewrite_functions.php index 121f0c4579..83d131c421 100644 --- a/inc/libs/rewrite_functions.php +++ b/inc/libs/rewrite_functions.php @@ -17,7 +17,7 @@ * 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 * * For more information visit: http://www.mxchange.org * * * * This program is free software; you can redistribute it and/or modify * @@ -38,44 +38,44 @@ // Some security stuff... if (!defined('__SECURITY')) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; - require($INC); + die(); } -// -function REWRITE_LINKS ($HTML) { - // Skip rewriting for the admin area (which search engine may enter here???) - if (ereg($GLOBALS['module'], getConfig('rewrite_skip'))) return $HTML; - - // Strip slashes with double-backslashes for the preg_replace() function - $URL = str_replace("/", "\\/", constant('URL')); +// 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; // Generate target URL - $target = constant('URL')."/cms/"; + $target = '{?URL?}/cms/'; // Convert modules.php?module=... - $output = preg_replace("/".$URL."\\/modules.php\\?module=/i", $target, $HTML); + $output = str_replace(getConfig('URL') . '/modules.php?module=', $target, $HTML); - if (eregi(constant('SERVER_URL'), $output)) { - // Strip slashes with double-backslashes for the preg_replace() function - $URL = str_replace("/", "\\/", constant('SERVER_URL')); + // Convert modules.php?module=... + $output = str_replace('{?URL?}/modules.php?module=', $target, $output); + // Do we have an URL linked to mxchange.org? + if (eregi(getConfig('SERVER_URL'), $output)) { // Convert URLs from my server - $output = preg_replace("/".$URL."\\/modules.php\\?module=/i", constant('SERVER_URL')."/cms/", $output); + $output = str_replace('{?URL?}/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output); + + // Convert URLs from my server + $output = str_replace(getConfig('URL') . '/modules.php?module=', getConfig('SERVER_URL') . '/cms/', $output); } // END - if // Strip slashes as above for the main URL - $target2 = str_replace("/", "\\/", $target); + $target2 = preg_quote($target, '/'); // Action variable - $act = $target."\$1/act/"; + $action = $target . '$1/act/'; // Convert &|&action=... - $output = preg_replace("/".$target2."(.*)&action=/i", $act, $output); + $output = preg_replace('/' . $target2 . '(.*)&action=/i', $action, $output); // "The same procedure as last variable"... now for &what= - $wht = $target."\$1/wht/"; - $output = preg_replace("/".$target2."(.*)&what=/i", $wht, $output); + $what = $target.'$1/wht/'; + $output = preg_replace('/' . $target2 . '(.*)&what=/i', $what, $output); // Repair missed &what=??? entries while (preg_match("/&what=(.*)\/(.*)\/(.*)/i", $output)) { @@ -85,5 +85,6 @@ function REWRITE_LINKS ($HTML) { // Return rewritten code return $output; } -// + +// [EOF] ?>