/** * Sestaveni url z casti * Kompatibilni s vystupem funkce parse_url() * @param array $parts asociativni pole s castmi url (scheme, host, port, user, pass, path, query, fragment) * @return string */ function _buildURL($parts) { $output = ''; // zakladni casti if (!empty($parts['host'])) { if (!empty($parts['scheme'])) { $output .= $parts['scheme'] . '://'; } // scheme if (!empty($parts['user'])) { $output .= $parts['user']; } // username if (!empty($parts['pass'])) { $output .= ':' . $parts['pass']; } // password if (!empty($parts['user']) || !empty($parts['pass'])) { $output .= '@'; } // @ $output .= $parts['host']; // host if (!empty($parts['port'])) { $output .= ':' . $parts['port']; } // port } // path if (!empty($parts['path'])) { $output .= ($parts['path'][0] !== '/' ? '/' : '') . $parts['path']; } else { $output .= '/'; } // query if (!empty($parts['query']) && is_array($parts['query'])) { $output .= '?'; $output .= _buildQuery($parts['query']); } // fragment if (!empty($parts['fragment'])) { $output .= '#' . $parts['fragment']; } // return output return $output; }
} $id = intval($_GET['redir_id']); $type = intval($_GET['redir_type']); if ($type !== 1) { $type = 0; } /* --- test existence --- */ if (0 === $type) { $query = DB::query('SELECT `id`,`title_seo` FROM `' . _mysql_prefix . '-root` WHERE `id`=' . $id); } else { $query = DB::query('SELECT art.`id`,art.`title_seo`,cat.`title_seo` AS cat_title_seo FROM `' . _mysql_prefix . '-articles` AS art JOIN `' . _mysql_prefix . '-root` AS cat ON(cat.id=art.home1) WHERE art.`id`=' . $id); } $query = DB::row($query); if ($query === false) { // neexistuje $_GET = array('m' => '404'); define('_index_noinit', true); require _indexroot . 'index.php'; die; } /* --- presmerovani --- */ // sestavit adresu $redir = $type === 0 ? _linkRoot($query['id'], $query['title_seo']) : _linkArticle($query['id'], $query['title_seo'], $query['cat_title_seo']); unset($_GET['redir_id'], $_GET['redir_type']); if (!empty($_GET)) { $redir = _addGetToLink($redir, _buildQuery($_GET), false); } // poslat hlavicky header("HTTP/1.1 301 Moved Permanently"); header("Location: " . _url . "/" . $redir); die;
define('_indexOutput_content', $content); define('_indexOutput_title', $title); } elseif ($access == 2) { $notpublic_form = true; } } } else { /* -- plugin -- */ // konstanty define('_indexOutput_url', _linkCustom($ids_full)); define('_indexOutput_ptype', 'plugin_handler'); // presmerovani na mod_rewrite adresu if (_modrewrite && !$rewritten) { parse_str($_SERVER['QUERY_STRING'], $redir_query); unset($redir_query['p']); define('_redirect_to', _url . '/' . _addGetToLink(_indexOutput_url, _buildQuery($redir_query), false)); } else { // spusteni handleru $title = $content = ''; call_user_func($plugin_handler, array('title' => &$title, 'content' => &$content, 'ids' => $ids, 'ids_first' => $ids_first, 'ids_full' => $ids_full)); // konstanty obsahu define('_indexOutput_content', $content); define('_indexOutput_title', $title); } } } else { /* --- neexistujici stranka --- */ do { // pouzit presmerovani, pokud existuje $q = DB::query_row('SELECT new FROM `' . _mysql_prefix . '-redir` WHERE old=\'' . DB::esc($ids_full) . '\' AND active=1'); if (false !== $q) {