* Copyright (c) 2001-2012 Platon Group, http://platon.sk/ * All rights reserved. * * See README file for more information about this software. * See COPYING file for license information. * * Download the latest version from * http://opensource.platon.sk/projects/Metafox/ */ /* * Logical schema: * ---------------- * * if (actual_url == first_type_url) { // index.php?ezin_section_id=name * if (actual_type_url != config_type_url) { * redirect to_config_type_url * } else { * continue actual_url * } * } * * repeat this for second (section.php?name) and third (name/) type of URL * * Debug levels: * -------------- * * 0 - auto redirect according actual configuration for Link redirect * 1 - temporary auto redirect (without 301, 302 or similar) * >1 - show only link (no redirect) * */ $link = $_GET['link']; require_once 'cfgldr.inc.php'; //ezin_cgi_parse(); trouble with link type 1 and redirects, for link type 2 no need $link_file_type = -1; // type 0 if ($link == 'index.php' || strlen($link) <= 0) { $link_file_type = 0; $setvars = array_keys($_GET); if ( $ezin_cfg['link_file_type'] != 0 && $ezin_cfg['link_redirect'] > 0 && (in_array('ezin_section_key', $setvars) || in_array('ezin_section_id', $setvars) || in_array('ezin_article_key', $setvars) || in_array('ezin_article_id', $setvars) || in_array('ezin_author_key', $setvars) || in_array('ezin_author_id', $setvars) || in_array('ezin_print', $setvars) || in_array('ezin_print', $setvars)) ) { // redirect // section if (in_array('ezin_section_key', $setvars)) { ezin_redirect_section($_GET['ezin_section_key']); } if (in_array('ezin_section_id', $setvars)) { ezin_redirect_section($_GET['ezin_section_id']); } // article if (in_array('ezin_article_key', $setvars) && !in_array('ezin_print', $setvars)) { ezin_redirect_article($_GET['ezin_article_key']); } if (in_array('ezin_article_id', $setvars) && !in_array('ezin_print', $setvars)) { ezin_redirect_article($_GET['ezin_article_id']); } // author if (in_array('ezin_author_key', $setvars)) { ezin_redirect_author($_GET['ezin_author_key']); } if (in_array('ezin_author_id', $setvars)) { ezin_redirect_author($_GET['ezin_author_id']); } // print if (in_array('ezin_print', $setvars)) { if (isset($_GET['ezin_article_key'])) { ezin_redirect_print($_GET['ezin_article_key']); } else { ezin_redirect_print($_GET['ezin_article_id']); } } } else { // normal if (strlen($link) == 0) { $link = 'index.php'; } 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 } require_once $link; } } // type 1 if (in_array($link, array('section.php', 'article.php', 'author.php', 'print.php'))) { $link_file_type = 1; if ( $ezin_cfg['link_file_type'] != 1 && $ezin_cfg['link_redirect'] > 0) { // redirect switch ($link) { case 'section.php': $section_id = Platon::parse_id_param(); ezin_redirect_section($section_id); break; case 'article.php': $article_id = Platon::parse_id_param(); ezin_redirect_article($article_id); break; case 'author.php': $author_id = Platon::parse_id_param(); ezin_redirect_author($author_id); break; case 'print.php': $article_id = Platon::parse_id_param(); ezin_redirect_print($article_id); break; } } else { // normal 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 } require_once $link; } } // type 2 if (strlen($link) > 0 && strtolower(substr($link, -4)) != '.php') { $link_file_type = 2; $args = explode('/', $link); //print_r($args); if ( $ezin_cfg['link_file_type'] != 2 && $ezin_cfg['link_redirect'] > 0) { // redirect // section if (count($args) == 1 && strlen($args[0]) > 0) { $ar = ezin_validate_IDs(array('section_id' => $args[0])); if (intval($ar['section_id']) > 0) { ezin_redirect_section($args[0]); } else { $ar = ezin_validate_IDs(array('article_id' => $args[0])); if (intval($ar['article_id']) > 0) { ezin_redirect_article($args[0]); } } } // others, default: article if (count($args) > 1 && strlen($args[0]) > 0) { $showed = false; if (ezin_get_rewrite_key($args[0]) == 'author') { ezin_redirect_author($args[1]); $showed = true; } if (ezin_get_rewrite_key($args[0]) == 'print') { ezin_redirect_print($args[1]); $showed = true; } if (!$showed) { ezin_redirect_article($args[1]); } } } else { // normal // homepage if (count($args) <= 0 || (count($args) == 1 && strlen($args[0]) == 0)) { require_once 'index.php'; } // section if (count($args) == 1 && strlen($args[0]) > 0) { require_once 'cfgldr.inc.php'; // check article if (ezin_exists_article($args[0]) && ezin_exists_section($args[0])) { $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 } if (intval($ar['article_id']) > 0) { $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'article'; } else { $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'section'; } require_once 'index.php'; } // others, default: article if (count($args) > 1 && strlen($args[0]) > 0) { require_once 'cfgldr.inc.php'; $showed = false; if (ezin_get_rewrite_key($args[0]) == 'author') { array_shift($args); 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 } $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'author'; $showed = true; } if (ezin_get_rewrite_key($args[0]) == 'print') { array_shift($args); $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'print'; $showed = true; } if (!$showed) { array_shift($args); if ($ezin_cfg['redirect_equal_url'] == 1) { // redirect for old access-key $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 } $ezin_cgi['query_string'] = $args; $ezin_cgi['input'] = 'article'; } require_once 'index.php'; } } } // notfound if ($link_file_type == -1) { require_once 'cfgldr.inc.php'; $ezin_cgi['input'] = 'notfound'; require_once 'index.php'; } ?>