Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions cdn-linker-base.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Target_URL_Strategy
* @param String $url will either be something like 'http://test.local/xyz/zdf.ext' or '/xyz/zdf.ext'
* @return String contains the CDN url - e.g. 'http://cdn.test.local'
*/
public function for_source(&$url);
public function for_source($url);

}

Expand All @@ -29,7 +29,7 @@ function __construct($cdn_url) {
$this->cdn_url = $cdn_url;
}

public function for_source(&$url) {
public function for_source($url) {
return $this->cdn_url;
}

Expand All @@ -54,7 +54,7 @@ function __construct($cdn_pattern) {
$this->fragment = $m[0];
}

public function for_source(&$url) {
public function for_source($url) {
$n = ( hexdec(substr(md5($url), 0, 1)) % $this->variations ) + 1;
return str_replace($this->fragment, $n, $this->cdn_pattern);
}
Expand Down Expand Up @@ -120,7 +120,7 @@ function __construct($blog_url, Target_URL_Strategy $get_target_url, $include_di
* @param String $match URI to examine
* @return Boolean true if to exclude given match from rewriting
*/
protected function exclude_single(&$match) {
protected function exclude_single($match) {
foreach ($this->excludes as $badword) {
if (!!$badword && stristr($match, $badword) != false) {
return true;
Expand Down Expand Up @@ -189,7 +189,7 @@ protected function blog_url_to_pattern() {
* @param String $content the raw HTML of the page from Wordpress, meant to be returned to the requester but intercepted here
* @return String modified HTML with replaced links - will be served by the HTTP server to the requester
*/
public function rewrite(&$content) {
public function rewrite($content) {
if ($this->https_deactivates_rewriting && isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on') {
return $content;
}
Expand All @@ -210,7 +210,7 @@ public function rewrite(&$content) {
$regex .= '(?=[\"\')])#';
}

$new_content = preg_replace_callback($regex, array(&$this, 'rewrite_single'), $content);
$new_content = preg_replace_callback($regex, array($this, 'rewrite_single'), $content);
return $new_content;
}

Expand All @@ -235,5 +235,5 @@ function register_as_output_buffer_handler() {
!!trim(get_option('ossdl_off_disable_cdnuris_if_https'))
);

ob_start(array(&$rewriter, 'rewrite'));
ob_start(array($rewriter, 'rewrite'));
}