function fu_make_url($obj) { global $fc; // return "category_{$obj['categoryID']}.html"; // Check if it's a correct object if (isset($obj['categoryID'])) { if (isset($obj['productID'])) { // Product if ($obj['uri']) { // Rewrite URL // Get category slug if (isset($fc[$obj['categoryID']]) && $fc[$obj['categoryID']]['uri']) { $pCatSlug = $fc[$obj['categoryID']]['uri']; } else { $pCatSlug = 'category_' . $obj['categoryID']; } // Get option slug if (-1 == $obj['uri_opt_val']) { // undefined - define option slug // Get slug and update slug field $pOptSlug = fu_get_option_slug($obj['productID']); } else { // Slug already defined, just use it $pOptSlug = $obj['uri_opt_val']; } $url = FU_OPTION_ID ? FU_CATALOG_ROOT . '/' . $pCatSlug . '/' . $pOptSlug . '/' . $obj['uri'] : FU_CATALOG_ROOT . '/' . $pCatSlug . '/' . $obj['uri']; } else { // Common URL $url = "product_{$obj['productID']}.html"; } } else { // Category if ($obj['uri']) { // Rewrite URL $url = FU_CATALOG_ROOT . '/' . $obj['uri']; } else { // Common URL $url = "category_{$obj['categoryID']}.html"; } } } else { $url = ''; } return '/' . $url; }
if ($queryResult = mysql_query($sql)) { if ($row = mysql_fetch_row($queryResult)) { // Item has valid URI, redirect to it if ($itemURI = $row[0]) { // Load engine settings if (!defined('CONF_FU_DEMO_MODE')) { define('CONF_FU_DEMO_MODE', 1); } // Generate new URL $newUrl = 'http://' . CONF_SHOP_URL . '/'; if (isset($_GET['productID'])) { // Product $newUrl .= FU_CATALOG_ROOT; $categorySlug = $row[2] ? $row[2] : 'category_' . $row[3]; $newUrl .= '/' . $categorySlug . '/'; $newUrl .= FU_OPTION_ID ? fu_get_option_slug($_GET['productID']) . '/' . urlencode($itemURI) : urlencode($itemURI); } elseif (isset($_GET['categoryID'])) { // Category $newUrl .= FU_CATALOG_ROOT; $newUrl .= '/' . urlencode($itemURI); } elseif (isset($_GET['fullnews'])) { // News $newUrl .= FU_NEWS_ROOT; $newUrl .= '/' . urlencode($itemURI); } elseif (isset($_GET['show_aux_page'])) { // Pages $newUrl .= FU_PAGES_ROOT; $newUrl .= '/' . urlencode($itemURI); } header('Content-Type: text/html; charset=utf-8'); header('HTTP/1.1 301 Moved Permanently');