Ejemplo n.º 1
0
function tep_get_url_data()
{
    global $_SERVER, $REQUEST_TYPE, $_GET, $languages_id, $cPath;
    $url_data = array();
    if ($REQUEST_TYPE == 'SSL') {
        $comparison_array = explode('/', HTTPS_SERVER . DIR_WS_HTTPS_CATALOG, 4);
    } else {
        $comparison_array = explode('/', HTTP_SERVER . DIR_WS_HTTP_CATALOG, 4);
    }
    $comparison = $comparison_array[3];
    $parts = explode('?', str_replace($comparison, '', $_SERVER['REQUEST_URI']), 2);
    if (sizeof($parts) == 2) {
        $parameters = explode('&', $parts[1]);
        foreach ($parameters as $pair) {
            $pieces = explode('=', $pair);
            $_GET[$pieces[0]] = $pieces[1];
            $url_data['get'][$pieces[0]] = $pieces[1];
        }
    }
    $get_seo_item_query = tep_db_query("select categories_id, products_id, manufacturers_id, infopages_id from seo_urls where url = '" . $parts[0] . "' AND language_id = '" . (int) $languages_id . "'");
    if (tep_db_num_rows($get_seo_item_query) > 0) {
        $get_seo_item = tep_db_fetch_array($get_seo_item_query);
        if ((int) $get_seo_item['categories_id'] > 0) {
            //categorie
            $category_query = tep_db_query("select categories_id, parent_id from categories where categories_id='" . $get_seo_item['categories_id'] . "'");
            $category_array = tep_db_fetch_array($category_query);
            $cPath = tep_get_full_cpath($category_array['categories_id']);
            $current_category_id = $category_array['categories_id'];
            $url_data['get']['cPath'] = $cPath;
            $url_data['page'] = FILENAME_DEFAULT;
        } else {
            if ((int) $get_seo_item['products_id'] > 0) {
                //product
                $product_query = tep_db_query("select pd.products_id, pd.products_name from products_description pd, products_to_categories p2c, products p where p.products_id = pd.products_id and p.products_status = '1' and pd.products_id=p2c.products_id and pd.products_id='" . $get_seo_item['products_id'] . "'" . $parent_where_string);
                $product_array = tep_db_fetch_array($product_query);
                $cPath = tep_get_product_path($product_array['products_id']);
                $url_data['get']['products_id'] = $product_array['products_id'];
                $url_data['page'] = FILENAME_PRODUCT_INFO;
            } else {
                if ((int) $get_seo_item['manufacturers_id'] > 0) {
                    //manufacturer
                    if (strstr($get_seo_item['manufacturers_id'], '_')) {
                        $seo_item_ids = explode('_', $get_seo_item['manufacturers_id']);
                        $manufacturers_id = $seo_item_ids[0];
                    } else {
                        $manufacturers_id = $get_seo_item['manufacturers_id'];
                    }
                    $manufacturers_query = tep_db_query("select manufacturers_id, manufacturers_name from manufacturers where manufacturers_id='" . $manufacturers_id . "'");
                    $manufacturers_array = tep_db_fetch_array($manufacturers_query);
                    if (isset($seo_item_ids[1])) {
                        $filter_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . (int) $seo_item_ids[1] . '" AND language_id = "' . (int) $languages_id . '"');
                        $filter = tep_db_fetch_array($filter_query);
                        $_GET['filter_id'] = $seo_item_ids[1];
                    }
                    $url_data['get']['manufacturers_id'] = $manufacturers_array['manufacturers_id'];
                    $url_data['page'] = FILENAME_DEFAULT;
                } else {
                    if ((int) $get_seo_item['infopages_id'] > 0) {
                        $test_query = tep_db_query("select it.infopages_id from infopages i, infopages_text it where i.infopages_id = it.infopages_id AND i.infopages_id = '" . $get_seo_item['infopages_id'] . "'");
                        $infopages_array = tep_db_fetch_array($test_query);
                        $url_data['get']['page'] = $infopages_array['infopages_id'];
                        $url_data['page'] = FILENAME_INFOPAGE;
                    }
                }
            }
        }
    }
    return $url_data;
}
Ejemplo n.º 2
0
function tep_get_full_cpath($path)
{
    $parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $path . "'");
    while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {
        $parent_categories_query = tep_db_query("select parent_id from " . TABLE_CATEGORIES . " where categories_id = '" . (int) $path . "'");
        while ($parent_categories = tep_db_fetch_array($parent_categories_query)) {
            if ($parent_categories['parent_id'] != $path && $parent_categories['parent_id'] != 0) {
                $path = tep_get_full_cpath($parent_categories['parent_id']) . '_' . $path;
            }
        }
    }
    return $path;
}
Ejemplo n.º 3
0
function tep_href_link($page = '', $parameters = '', $connection = 'NONSSL', $add_session_id = true, $force_language_id = false, $cPath = '')
{
    global $request_type, $session_started, $SID, $languages_id;
    if ($force_language_id !== false) {
        $newlanguages_id = $force_language_id;
    } else {
        $newlanguages_id = $languages_id;
    }
    /********************/
    /*	We need a page	*/
    /********************/
    if (!tep_not_null($page)) {
        echo '<font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine the page link!<br>';
        echo '<pre>';
        /********************/
        /*	easy to debug	*/
        /********************/
        print_r(debug_backtrace());
        die;
    }
    if ($connection == 'NONSSL') {
        $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
    } elseif ($connection == 'SSL') {
        if (ENABLE_SSL == true) {
            $link = HTTPS_SERVER . DIR_WS_HTTPS_CATALOG;
        } else {
            $link = HTTP_SERVER . DIR_WS_HTTP_CATALOG;
        }
    } else {
        echo '<font color="#ff0000"><b>Error!</b></font><br><br><b>Unable to determine connection method on a link!<br><br>Known methods: NONSSL SSL</b><br>';
        /********************/
        /*	easy to debug	*/
        /********************/
        print_r(debug_backtrace());
        die;
    }
    $separator = '?';
    $seolink = '';
    if (tep_not_null($parameters)) {
        $parameters = explode('&', $parameters);
        $new_parameter_list = array();
        switch ($page) {
            case 'product_info.php':
                foreach ($parameters as $pair) {
                    $pair_array = explode('=', $pair);
                    switch ($pair_array[0]) {
                        case 'products_id':
                            /****************************/
                            /*	check if seo url exists	*/
                            /****************************/
                            $seo_query = tep_db_query('SELECT url FROM seo_urls WHERE products_id = "' . $pair_array[1] . '"' . (!empty($cPath) ? ' AND cpath = "' . $cPath . '"' : '') . ' AND language_id = "' . (int) $newlanguages_id . '"');
                            if (tep_db_num_rows($seo_query) > 0) {
                                /********************/
                                /*	seo url exists	*/
                                /********************/
                                $seo_url = tep_db_fetch_array($seo_query);
                                $seolink .= $seo_url['url'];
                            } else {
                                /****************************/
                                /*	seo url doesn't exist	*/
                                /****************************/
                                if (!empty($cPath)) {
                                    /************************************************************/
                                    /*	this way, we can force the category structure			*/
                                    /*	can be necessary for products in multiple categories	*/
                                    /************************************************************/
                                    $cpath_array = explode('_', $cPath);
                                    foreach ($cpath_array as $key => $value) {
                                        /********************************************/
                                        /*	check if url exists for this category	*/
                                        /*	usefull for working with duplicate urls	*/
                                        /********************************************/
                                        $seo_url_query = tep_db_query('SELECT url FROM seo_urls WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                        if (tep_db_num_rows($seo_url_query) > 0) {
                                            $seo_url = tep_db_fetch_array($seo_url_query);
                                            $seolink = $seo_url['url'] . '/';
                                        } else {
                                            $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                            $category = tep_db_fetch_array($cat_query);
                                            $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($category['categories_name']))))) . '/';
                                        }
                                    }
                                } else {
                                    /************************************************/
                                    /*	Get the category structure for this produt	*/
                                    /************************************************/
                                    $cat_query = tep_db_query('SELECT categories_id FROM products_to_categories WHERE products_id = "' . $pair_array[1] . '"');
                                    $products_cat = tep_db_fetch_array($cat_query);
                                    $cpath_array = array_reverse(tep_get_category_tree_db($products_cat['categories_id'], 'parents'));
                                    foreach ($cpath_array as $value) {
                                        /********************************************/
                                        /*	check if url exists for this category	*/
                                        /*	usefull for working with duplicate urls	*/
                                        /********************************************/
                                        $seo_url_query = tep_db_query('SELECT url FROM seo_urls WHERE categories_id = "' . $value['categories_id'] . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                        if (tep_db_num_rows($seo_url_query) > 0) {
                                            $seo_url = tep_db_fetch_array($seo_url_query);
                                            $seolink = $seo_url['url'] . '/';
                                        } else {
                                            $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($value['categories_name']))))) . '/';
                                        }
                                    }
                                }
                                $prod_query = tep_db_query('SELECT pd.products_name, p.products_model FROM products p, products_description pd WHERE p.products_id = pd.products_id AND p.products_id = "' . $pair_array[1] . '" AND pd.language_id = "' . (int) $newlanguages_id . '"');
                                $product = tep_db_fetch_array($prod_query);
                                $products_name = RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($product['products_name'])))));
                                $product['products_model'] = str_replace("/", "", $product['products_model']);
                                $product['products_model'] = str_replace("-", "", $product['products_model']);
                                $products_model = RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($product['products_model'])))));
                                if (SEO_URL_PRODUCTS_MODEL != 'false') {
                                    if (SEO_URL_PRODUCTS_MODEL == 'only') {
                                        $seolink .= $products_model;
                                    } else {
                                        if (SEO_URL_PRODUCTS_MODEL == 'after') {
                                            $seolink .= $products_name . '-' . $products_model;
                                        } else {
                                            if (SEO_URL_PRODUCTS_MODEL == 'before') {
                                                $seolink .= $products_model . '-' . $products_name;
                                            } else {
                                                $seolink .= $products_name;
                                            }
                                        }
                                    }
                                } else {
                                    $seolink .= $products_name;
                                }
                                /****************************/
                                /*	add seo url to database	*/
                                /****************************/
                                $seolink = add_seo_url_to_db($newlanguages_id, '', $pair_array[1], '', '', '', $seolink, $cPath, '');
                            }
                            break;
                        case '':
                            break;
                        default:
                            if (!empty($pair_array[1])) {
                                $new_parameter_list[] = $pair_array[0] . '=' . $pair_array[1];
                            }
                            break;
                    }
                }
                $link .= preg_replace('/%2F/', '%20', $seolink);
                if (!empty($new_parameter_list)) {
                    $link .= $separator . implode('&', $new_parameter_list);
                    $separator = '&';
                }
                break;
            case 'index.php':
                foreach ($parameters as $pair) {
                    $pair_array = explode('=', $pair);
                    switch ($pair_array[0]) {
                        case 'action':
                            if (is_array($parameters)) {
                                $parameters = implode("&", $parameters);
                            }
                            $link .= $page . '?' . tep_output_string($parameters);
                            $separator = '&';
                            break 3;
                        case 'manufacturers_id':
                            /************************************************/
                            /*	check if there is a filter_id				*/
                            /************************************************/
                            $filter_id = '';
                            foreach ($parameters as $params) {
                                $params_data = explode('=', $params);
                                if (in_array('filter_id', $params_data)) {
                                    $filter_id = $params_data[1];
                                }
                            }
                            /****************************/
                            /*	check if seo url exists	*/
                            /****************************/
                            $seo_query = tep_db_query('SELECT url FROM seo_urls WHERE manufacturers_id = "' . $pair_array[1] . '"' . (!empty($cPath) ? ' AND cpath = "' . $cPath . '"' : '') . (!empty($filter_id) ? ' AND filter_id = "' . $filter_id . '"' : '') . ' AND language_id = "' . (int) $newlanguages_id . '"');
                            if (tep_db_num_rows($seo_query) > 0) {
                                /********************/
                                /*	seo url exists	*/
                                /********************/
                                $seo_url = tep_db_fetch_array($seo_query);
                                $seolink .= $seo_url['url'];
                            } else {
                                /****************************/
                                /*	seo url doesn't exist	*/
                                /****************************/
                                $man_query = tep_db_query('SELECT manufacturers_name FROM manufacturers WHERE manufacturers_id = "' . $pair_array[1] . '"');
                                $manufacturer = tep_db_fetch_array($man_query);
                                $manufacturers_name = $manufacturer['manufacturers_name'];
                                $cpath_array = array();
                                if (!empty($cPath)) {
                                    /****************************************************************/
                                    /*	this way, we can force the category structure				*/
                                    /*	can be necessary for manufacturers in multiple categories	*/
                                    /****************************************************************/
                                    if (SEO_URL_MAN_CAT == 'full cpath') {
                                        $cpath_array = explode('_', $cPath);
                                    } else {
                                        $cpath_array = end(explode('_', $cPath));
                                    }
                                } else {
                                    /****************************************/
                                    /*	if there is a filter_id, 			*/
                                    /*	get category, full path or singular	*/
                                    /****************************************/
                                    if (!empty($filter_id)) {
                                        if (SEO_URL_MAN_CAT == 'full cpath') {
                                            $thiscat_array = array_reverse(tep_get_category_tree_db($filter_id, 'parents'));
                                            foreach ($thiscat_array as $thiscat) {
                                                $cpath_array[] = $thiscat['categories_id'];
                                            }
                                        } else {
                                            $cpath_array[] = $filter_id;
                                        }
                                    }
                                }
                                if (SEO_URL_MAN_POS == 'after') {
                                    foreach ($cpath_array as $key => $value) {
                                        $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                        $category = tep_db_fetch_array($cat_query);
                                        $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($category['categories_name']))))) . '/';
                                    }
                                    $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($manufacturers_name)))));
                                } else {
                                    $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($manufacturers_name))))) . '/';
                                    foreach ($cpath_array as $key => $value) {
                                        $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                        $category = tep_db_fetch_array($cat_query);
                                        $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($category['categories_name']))))) . '/';
                                    }
                                    $seolink = substr($seolink, 0, -1);
                                }
                                /****************************/
                                /*	add seo url to database	*/
                                /****************************/
                                $seolink = add_seo_url_to_db($newlanguages_id, '', '', $pair_array[1], '', '', $seolink, $cPath, $filter_id);
                            }
                            break;
                        case 'cPath':
                            /************************************************/
                            /*	check if there is a filter_id				*/
                            /************************************************/
                            $filter_id = '';
                            foreach ($parameters as $params) {
                                $params_data = explode('=', $params);
                                if (in_array('filter_id', $params_data)) {
                                    $filter_id = $params_data[1];
                                }
                            }
                            /****************************/
                            /*	check if seo url exists	*/
                            /****************************/
                            if (strstr($pair_array[1], '_')) {
                                $categories_id = end(explode('_', $pair_array[1]));
                            } else {
                                $categories_id = $pair_array[1];
                            }
                            $seo_query = tep_db_query('SELECT url FROM seo_urls WHERE categories_id = "' . $categories_id . '"' . (!empty($cPath) ? ' AND cpath = "' . $cPath . '"' : '') . (!empty($filter_id) ? ' AND filter_id = "' . $filter_id . '"' : '') . ' AND language_id = "' . (int) $newlanguages_id . '"');
                            if (tep_db_num_rows($seo_query) > 0) {
                                /********************/
                                /*	seo url exists	*/
                                /********************/
                                $seo_url = tep_db_fetch_array($seo_query);
                                $seolink .= $seo_url['url'];
                            } else {
                                /****************************/
                                /*	seo url doesn't exist	*/
                                /****************************/
                                $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $categories_id . '"');
                                $category = tep_db_fetch_array($cat_query);
                                $categories_name = $category['categories_name'];
                                $cpath_array = array();
                                if (!empty($cPath)) {
                                    /************************************************************/
                                    /*	this way, we can force the category structure			*/
                                    /*	can be necessary for categories in multiple categories	*/
                                    /************************************************************/
                                    $cpath_array = explode('_', $cPath);
                                } else {
                                    $catpath = tep_get_full_cpath($categories_id);
                                    $cpath_array = explode('_', $catpath);
                                }
                                /****************************************/
                                /*	if there is a filter_id, 			*/
                                /*	get category, full path or singular	*/
                                /****************************************/
                                if (!empty($filter_id)) {
                                    if (SEO_URL_MAN_CAT == 'singular') {
                                        $cpath_array[] = $filter_id;
                                    }
                                    if (SEO_URL_MAN_POS == 'after') {
                                        foreach ($cpath_array as $key => $value) {
                                            /********************************************/
                                            /*	check if url exists for this category	*/
                                            /*	usefull for working with duplicate urls	*/
                                            /********************************************/
                                            $seo_url_query = tep_db_query('SELECT url FROM seo_urls WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                            if (tep_db_num_rows($seo_url_query) > 0) {
                                                $seo_url = tep_db_fetch_array($seo_url_query);
                                                $seolink = $seo_url['url'] . '/';
                                            } else {
                                                $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                                $category = tep_db_fetch_array($cat_query);
                                                $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($category['categories_name']))))) . '/';
                                            }
                                        }
                                        $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($manufacturers_name)))));
                                    } else {
                                        $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($manufacturers_name))))) . '/';
                                        foreach ($cpath_array as $key => $value) {
                                            /********************************************/
                                            /*	check if url exists for this category	*/
                                            /*	usefull for working with duplicate urls	*/
                                            /********************************************/
                                            $seo_url_query = tep_db_query('SELECT url FROM seo_urls WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                            if (tep_db_num_rows($seo_url_query) > 0) {
                                                $seo_url = tep_db_fetch_array($seo_url_query);
                                                $seolink = $seo_url['url'] . '/';
                                            } else {
                                                $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                                $category = tep_db_fetch_array($cat_query);
                                                $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($category['categories_name']))))) . '/';
                                            }
                                        }
                                        $seolink = substr($seolink, 0, -1);
                                    }
                                } else {
                                    /********************/
                                    /*	No filter_id	*/
                                    /********************/
                                    foreach ($cpath_array as $key => $value) {
                                        /********************************************/
                                        /*	check if url exists for this category	*/
                                        /*	usefull for working with duplicate urls	*/
                                        /********************************************/
                                        $seo_url_query = tep_db_query('SELECT url FROM seo_urls WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                        if (tep_db_num_rows($seo_url_query) > 0) {
                                            $seo_url = tep_db_fetch_array($seo_url_query);
                                            $seolink = $seo_url['url'] . '/';
                                        } else {
                                            $cat_query = tep_db_query('SELECT categories_name FROM categories_description WHERE categories_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                            $category = tep_db_fetch_array($cat_query);
                                            $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($category['categories_name']))))) . '/';
                                        }
                                    }
                                    $seolink = substr($seolink, 0, -1);
                                }
                                /****************************/
                                /*	add seo url to database	*/
                                /****************************/
                                $seolink = add_seo_url_to_db($newlanguages_id, $categories_id, '', '', '', '', $seolink, $cPath, $filter_id);
                            }
                            break;
                        case 'filter_id':
                        case '':
                            break;
                        default:
                            if (!empty($pair_array[1])) {
                                $new_parameter_list[] = $pair_array[0] . '=' . $pair_array[1];
                            }
                            break;
                    }
                }
                $link .= preg_replace('/%2F/', '%20', $seolink);
                if (tep_not_null($new_parameter_list)) {
                    $link .= $separator . implode('&', $new_parameter_list);
                    $separator = '&';
                }
                break;
            case 'infopage.php':
                foreach ($parameters as $pair) {
                    $pair_array = explode('=', $pair);
                    switch ($pair_array[0]) {
                        case 'action':
                            $link .= $page . '?' . tep_output_string($parameters);
                            $separator = '&';
                            break 3;
                        case 'page':
                            /****************************/
                            /*	check if seo url exists	*/
                            /****************************/
                            $seo_query = tep_db_query('SELECT url FROM seo_urls WHERE infopages_id = "' . $pair_array[1] . '"' . (!empty($cPath) ? ' AND cpath = "' . $cPath . '"' : '') . ' AND language_id = "' . (int) $newlanguages_id . '"');
                            if (tep_db_num_rows($seo_query) > 0) {
                                /********************/
                                /*	seo url exists	*/
                                /********************/
                                $seo_url = tep_db_fetch_array($seo_query);
                                $seolink .= $seo_url['url'];
                            } else {
                                /****************************/
                                /*	seo url doesn't exist	*/
                                /****************************/
                                $page_query = tep_db_query('SELECT i.infopages_id, i.type, it.infopages_title, i.parent_id FROM infopages i, infopages_text it WHERE i.infopages_id = it.infopages_id AND it.language_id = "' . (int) $newlanguages_id . '" AND i.infopages_id = "' . $pair_array[1] . '"');
                                $infopage = tep_db_fetch_array($page_query);
                                $infopage_title = $infopage['infopages_title'];
                                $infopage_id = $infopage['infopages_id'];
                                $infopage_type = $infopage['type'];
                                $infopage_parent = $infopage['parent_id'];
                                $cpath_array = array();
                                if (!empty($cPath)) {
                                    /****************************************************/
                                    /*	this way, we can force the infopage structure	*/
                                    /****************************************************/
                                    $cpath_array = explode('_', $cPath);
                                    foreach ($cpath_array as $key => $value) {
                                        /********************************************/
                                        /*	check if url exists for this page		*/
                                        /*	usefull for working with duplicate urls	*/
                                        /********************************************/
                                        $seo_url_query = tep_db_query('SELECT url FROM seo_urls WHERE infopages_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                        if (tep_db_num_rows($seo_url_query) > 0) {
                                            $seo_url = tep_db_fetch_array($seo_url_query);
                                            $seolink = $seo_url['url'] . '/';
                                        } else {
                                            $page_query = tep_db_query('SELECT infopages_title FROM infopages_text WHERE infopages_id = "' . $value . '" AND language_id = "' . (int) $newlanguages_id . '"');
                                            $infopage = tep_db_fetch_array($page_query);
                                            $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($infopage['infopages_title']))))) . '/';
                                        }
                                    }
                                    $seolink = substr($seolink, 0, -1);
                                } else {
                                    $navpath = tep_get_navigation_tree($newlanguages_id, 'i_' . $infopage_id);
                                    if (count($navpath) > 0) {
                                        reset($navpath);
                                        $navpath = array_reverse($navpath[key($navpath)]);
                                        foreach ($navpath as $nav_data) {
                                            $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($nav_data['name']))))) . '/';
                                        }
                                        $seolink = substr($seolink, 0, -1);
                                    } else {
                                        $pagepath = array_reverse(tep_get_infopages_tree($infopage_id));
                                        foreach ($pagepath as $page_data) {
                                            $seolink .= RemoveUnwantedCharacters(str_replace("+", "-", strtolower(urlencode(trim($page_data['infopages_title']))))) . '/';
                                        }
                                        $seolink = substr($seolink, 0, -1);
                                    }
                                }
                                /****************************/
                                /*	add seo url to database	*/
                                /****************************/
                                $seolink = add_seo_url_to_db($newlanguages_id, '', '', '', $infopage_id, '', $seolink, $cPath, '');
                            }
                            break;
                        case '':
                            break;
                        default:
                            if (!empty($pair_array[1])) {
                                $new_parameter_list[] = $pair_array[0] . '=' . $pair_array[1];
                            }
                            break;
                    }
                }
                $link .= preg_replace('/%2F/', '%20', $seolink);
                if (tep_not_null($new_parameter_list)) {
                    $link .= $separator . implode('&', $new_parameter_list);
                    $separator = '&';
                }
                break;
            default:
                $link .= $page . '?' . implode('&', $parameters);
                $separator = '&';
                break;
        }
    } else {
        $link .= $page;
        $separator = '?';
    }
    while (substr($link, -1) == '&' || substr($link, -1) == '?') {
        $link = substr($link, 0, -1);
    }
    // Add the session ID when moving from different HTTP and HTTPS servers, or when SID is defined
    if ($add_session_id == true && $session_started == true && SESSION_FORCE_COOKIE_USE == 'False') {
        if (tep_not_null($SID)) {
            /*FORUM*/
            //$_sid = $SID;
            /*FORUM*/
        } elseif ($request_type == 'NONSSL' && $connection == 'SSL' && ENABLE_SSL == true || $request_type == 'SSL' && $connection == 'NONSSL') {
            if (HTTP_COOKIE_DOMAIN != HTTPS_COOKIE_DOMAIN) {
                $_sid = tep_session_name() . '=' . tep_session_id();
            }
        }
    }
    //SAVE TO DB
    if (isset($_sid)) {
        $link .= $separator . $_sid;
    }
    //SAVE TO DB
    return $link;
}