=================================================================== RCS file: /home/cvsd/home/cvs/Metafox/rewrite.php,v retrieving revision 1.5 retrieving revision 1.9 diff -u -p -r1.5 -r1.9 --- Metafox/rewrite.php 2012/10/07 15:45:58 1.5 +++ Metafox/rewrite.php 2012/10/10 18:54:38 1.9 @@ -43,7 +43,7 @@ $link = $_GET['link']; require_once 'cfgldr.inc.php'; -ezin_cgi_parse(); +//ezin_cgi_parse(); trouble with link type 1 and redirects, for link type 2 no need $link_file_type = -1; @@ -108,22 +108,24 @@ if ($link == 'index.php' if (strlen($link) == 0) { $link = 'index.php'; } - // redirect for old access-key - $keys = array( - array('ezin_article_key', 'article_id'), - array('ezin_section_key', 'section_id'), - array('ezin_author_key', 'author_id') - ); - foreach ($keys as $key) { - $id_param = Platon::parse_id_param($key[0]); - $ar = ezin_validate_IDs(array($key[1] => $id_param)); - if (isset($ar['redirect']) - && $ar['redirect']) - { - ezin_redirect_auto($ar); + if ($ezin_cfg['redirect_equal_url'] == 1) { + // redirect for old access-key + $keys = array( + array('ezin_article_key', 'article_id'), + array('ezin_section_key', 'section_id'), + array('ezin_author_key', 'author_id') + ); + foreach ($keys as $key) { + $id_param = Platon::parse_id_param($key[0]); + $ar = ezin_validate_IDs(array($key[1] => $id_param)); + if (isset($ar['redirect']) + && $ar['redirect']) + { + ezin_redirect_auto($ar); + } } + // end redirect for old access-key } - // end redirect for old access-key require_once $link; } @@ -157,25 +159,27 @@ if (in_array($link, array('section.php', } } else { // normal - // redirect for old access-key - $id_param = Platon::parse_id_param(); - switch($link) { - case 'article.php': - $ar = ezin_validate_IDs(array('article_id' => $id_param)); - break; - case 'section.php': - $ar = ezin_validate_IDs(array('section_id' => $id_param)); - break; - case 'author.php': - $ar = ezin_validate_IDs(array('author_id' => $id_param)); - break; - } - if (isset($ar['redirect']) - && $ar['redirect']) - { - ezin_redirect_auto($ar); + if ($ezin_cfg['redirect_equal_url'] == 1) { + // redirect for old access-key + $id_param = Platon::parse_id_param(); + switch($link) { + case 'article.php': + $ar = ezin_validate_IDs(array('article_id' => $id_param)); + break; + case 'section.php': + $ar = ezin_validate_IDs(array('section_id' => $id_param)); + break; + case 'author.php': + $ar = ezin_validate_IDs(array('author_id' => $id_param)); + break; + } + if (isset($ar['redirect']) + && $ar['redirect']) + { + ezin_redirect_auto($ar); + } + // end redirect for old access-key } - // end redirect for old access-key require_once $link; } } @@ -241,14 +245,23 @@ if (strlen($link) > 0 && strlen($args[0]) > 0) { require_once 'cfgldr.inc.php'; - // redirect for old access-key - $ar = ezin_validate_IDs(array('article_id' => $args[0])); - if (isset($ar['redirect']) - && $ar['redirect']) + // check article + if (ezin_exists_article($args[0]) + && ezin_exists_section($args[0])) { - ezin_redirect_auto($ar); + $ar = ezin_validate_IDs(array('article_id' => $args[0])); + } else { + $ar = ezin_validate_IDs(array('section_id' => $args[0])); + } + if ($ezin_cfg['redirect_equal_url'] == 1) { + // redirect for old access-key + if (isset($ar['redirect']) + && $ar['redirect']) + { + ezin_redirect_auto($ar); + } + // end redirect for old access-key } - // end redirect for old access-key if (intval($ar['article_id']) > 0) { $ezin_cgi['query_string'] = $args; @@ -269,14 +282,16 @@ if (strlen($link) > 0 $showed = false; if (ezin_get_rewrite_key($args[0]) == 'author') { array_shift($args); - // redirect for old access-key - $ar = ezin_validate_IDs(array('author_id' => $args[0])); - if (isset($ar['redirect']) - && $ar['redirect']) - { - ezin_redirect_auto($ar); + if ($ezin_cfg['redirect_equal_url'] == 1) { + // redirect for old access-key + $ar = ezin_validate_IDs(array('author_id' => $args[0])); + if (isset($ar['redirect']) + && $ar['redirect']) + { + ezin_redirect_auto($ar); + } + // end redirect for old access-key } - // end redirect for old access-key $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'author'; $showed = true; @@ -288,15 +303,22 @@ if (strlen($link) > 0 $showed = true; } if (!$showed) { - array_shift($args); - // redirect for old access-key - $ar = ezin_validate_IDs(array('article_id' => $args[0])); - if (isset($ar['redirect']) - && $ar['redirect']) - { - ezin_redirect_auto($ar); + $section_id = array_shift($args); + if ($ezin_cfg['redirect_equal_url'] == 1) { + // redirect for old access-key + if ($section_id == $args[0]) { + $ar = ezin_validate_IDs(array('section_id' => $args[0])); + $ar['redirect'] = true; + } else { + $ar = ezin_validate_IDs(array('article_id' => $args[0])); + } + if (isset($ar['redirect']) + && $ar['redirect']) + { + ezin_redirect_auto($ar); + } + // end redirect for old access-key } - // end redirect for old access-key $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'article'; }