1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
| public static function link($page, $parameters = null, $add_session_id = true, $search_engine_safe = true) {
$page = HTML::sanitize($page);
$site = $req_site = static::$site;
if ((strpos($page, '/') !== false) && (preg_match('/^([A-Z][A-Za-z0-9-_]*)\/(.*)$/', $page, $matches) === 1) && OSCOM::siteExists($matches[1], false)) {
$req_site = $matches[1];
$page = $matches[2];
}
if (!is_bool($add_session_id)) {
$add_session_id = true;
}
if (!is_bool($search_engine_safe)) {
$search_engine_safe = true;
}
if (($add_session_id === true) && ($site !== $req_site)) {
$add_session_id = false;
}
$link = static::getConfig('http_server', $req_site) . static::getConfig('http_path', $req_site) . $page;
if (!empty($parameters)) {
$p = HTML::sanitize($parameters);
// pb lien
$p = str_replace([
"\\", // apps
'{', // product attributes
'}' // product attributes
], [
'%5C',
'%7B',
'%7D'
], $p);
$link .= '?' . $p;
$separator = '&';
} else {
$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) && Registry::exists('Session')) {
$OSCOM_Session = Registry::get('Session');
if ($OSCOM_Session->hasStarted() && ($OSCOM_Session->isForceCookies() === false)) {
if ((strlen(SID) > 0) || (((HTTP::getRequestType() == 'NONSSL') && (parse_url(static::getConfig('http_server', $req_site), PHP_URL_SCHEME) == 'https')) || ((HTTP::getRequestType() == 'SSL') && (parse_url(static::getConfig('http_server', $req_site), PHP_URL_SCHEME) == 'http')))) {
$link .= $separator . HTML::sanitize(session_name() . '=' . session_id());
}
}
}
while(strpos($link, '&&') !== false) {
$link = str_replace('&&', '&', $link);
}
if ($search_engine_safe === true && defined('SEARCH_ENGINE_FRIENDLY_URLS') && (SEARCH_ENGINE_FRIENDLY_URLS == 'true' && SEFU::start()) && static::getSite() != 'ClicShoppingAdmin') {
// $link = str_replace(['?', '&', '='], '/', $link);
$link = str_replace(['?', '&', '='], ['/', '/', ','], $link);
}
return $link;
} |