base_url), $matches[0]); } // this.params.logoImg&&(e="background-image: url("+this.params.logoImg+")") private function css_import($matches){ return str_replace($matches[2], proxify_url($matches[2], $this->base_url), $matches[0]); } // replace src= and href= private function html_attr($matches){ // could be empty? $url = trim($matches[2]); if(stripos($url, 'data:') === 0 || stripos($url, 'magnet:') === 0 ){ return $matches[0]; } return str_replace($url, proxify_url($url, $this->base_url), $matches[0]); } private function form_action($matches){ // sometimes form action is empty - which means a postback to the current page // $matches[1] holds single or double quote - whichever was used by webmaster // $matches[2] holds form submit URL - can be empty which in that case should be replaced with current URL if(!$matches[2]){ $matches[2] = $this->base_url; } $new_action = proxify_url($matches[2], $this->base_url); // what is form method? $form_post = preg_match('@method=(["\'])post\1@i', $matches[0]) == 1; // take entire form string - find real url and replace it with proxified url $result = str_replace($matches[2], $new_action, $matches[0]); // must be converted to POST otherwise GET form would just start appending name=value pairs to your proxy url if(!$form_post){ // may throw Duplicate Attribute warning but only first method matters $result = str_replace("