}
                if ($last !== '&') {
                    $tmp = false;
                    break;
                }
            }
        }
        if ($tmp) {
            return true;
        }
    }
    return false;
}
$_location = parse_url($current_location . $app_dirs['customer']);
$_location['path'] = cw_normalize_path($_location['path'], '/');
$current_script = substr(cw_normalize_path($REQUEST_URI, '/'), strlen($_location['path']));
$additional_query = ($QUERY_STRING ? "&" : "?") . (strstr($QUERY_STRING, APP_SESSION_NAME) ? '' : APP_SESSION_NAME . "=" . $APP_SESS_ID);
if (!preg_match("/(?:^|&)sl=/", $additional_query) && $app_http_host != $app_https_host) {
    $additional_query .= ($additional_query ? '&' : '?') . "sl=" . $current_language . "&is_https_redirect=Y";
}
if ($REQUEST_METHOD == "GET" && empty($_GET['keep_https'])) {
    $tmp_location = "";
    if (!$HTTPS && is_https_link($target, $current_script, $https_scripts)) {
        $tmp_location = $app_catalogs_secure['customer'] . $current_script . $additional_query;
    } elseif (!$HTTPS && is_https_link($target, $current_script, $https_messages) && !strncasecmp($HTTP_REFERER, $https_location, strlen($https_location))) {
        $tmp_location = $app_catalogs_secure['customer'] . $current_script . $additional_query;
    } elseif ($config['Security']['dont_leave_https'] != 'Y' && $HTTPS && !is_https_link($target, $current_script, $https_scripts) && !is_https_link($target, $current_script, $https_messages)) {
        $login_redirect =& cw_session_register("login_redirect");
        $do_redirect = empty($login_redirect);
        cw_session_unregister("login_redirect");
        if ($do_redirect) {
function cw_pathcmp($path1, $path2, $use_len = NULL)
{
    static $cw_defs = array(0 => array('strcmp', 'strncmp'), 1 => array('strcasecmp', 'strncasecmp'));
    $index = (int) CW_IS_OS_WINDOWS;
    $func = $cw_defs[$index];
    $path1 = cw_normalize_path($path1);
    $path2 = cw_normalize_path($path2);
    if (is_null($use_len)) {
        return !$func[0]($path1, $path2);
    }
    $len = $use_len == 1 ? strlen($path1) : strlen($path2);
    return !$func[1]($path1, $path2, $len);
}