Example #1
0
/**
 * Rewriter of URLs, used as replace-callback.
 *
 * Called by #scossdl_off_filter.
 */
function scossdl_off_rewriter($match)
{
    global $ossdl_off_blog_url, $ossdl_off_cdn_url, $arr_of_excludes, $arr_of_cnames, $ossdl_https;
    static $offset = -1;
    static $rewritten_urls = array();
    if ($ossdl_https && substr($match[0], 0, 5) == 'https') {
        return $match[0];
    }
    if (isset($rewritten_urls[$match[0]])) {
        return $rewritten_urls[$match[0]];
    }
    if (false == in_array($ossdl_off_cdn_url, $arr_of_cnames)) {
        $arr_of_cnames[] = $ossdl_off_cdn_url;
    }
    if (scossdl_off_exclude_match($match[0], $arr_of_excludes)) {
        return $match[0];
    } else {
        $include_dirs = scossdl_off_additional_directories();
        if (preg_match('/' . $include_dirs . '/', $match[0])) {
            $offset++;
            $offset %= count($arr_of_cnames);
            $url = str_replace($ossdl_off_blog_url, $arr_of_cnames[$offset], $match[0]);
            if (count($rewritten_urls) < 30) {
                // don't use too much memory please
                $rewritten_urls[$match[0]] = $url;
            }
            return $url;
        } else {
            return $match[0];
        }
    }
}
Example #2
0
/**
 * Rewriter of URLs, used as replace-callback.
 *
 * Called by #scossdl_off_filter.
 */
function scossdl_off_rewriter($match)
{
    global $ossdl_off_blog_url, $ossdl_off_cdn_url, $arr_of_excludes;
    if (scossdl_off_exclude_match($match[0], $arr_of_excludes)) {
        return $match[0];
    } else {
        $include_dirs = scossdl_off_additional_directories();
        if (preg_match('/' . $include_dirs . '/', $match[0])) {
            return str_replace($ossdl_off_blog_url, $ossdl_off_cdn_url, $match[0]);
        } else {
            return $match[0];
        }
    }
}
Example #3
0
/**
 * Rewriter of URLs, used as replace-callback.
 *
 * Called by #scossdl_off_filter.
 */
function scossdl_off_rewriter($match)
{
    global $ossdl_off_blog_url, $ossdl_off_cdn_url, $arr_of_excludes, $arr_of_cnames, $ossdl_https;
    if ($ossdl_off_cdn_url == '') {
        return $match[0];
    }
    if ($ossdl_https && substr($match[0], 0, 5) == 'https') {
        return $match[0];
    }
    if (false == in_array($ossdl_off_cdn_url, $arr_of_cnames)) {
        $arr_of_cnames[] = $ossdl_off_cdn_url;
    }
    if (scossdl_off_exclude_match($match[0], $arr_of_excludes)) {
        return $match[0];
    } else {
        $include_dirs = scossdl_off_additional_directories();
        if (preg_match('/' . $include_dirs . '/', $match[0])) {
            $offset = scossdl_string_mod($match[1], count($arr_of_cnames));
            return str_replace($ossdl_off_blog_url, $arr_of_cnames[$offset], $match[0]);
        } else {
            return $match[0];
        }
    }
}