Proxy\Plugin\ProxifyPlugin::onCompleted PHP Метод

onCompleted() публичный Метод

# Remove and record a href $input = preg_replace_callback('#]{1,2048}))(?(1)\\1|)[^>]*>#i', 'html_stripBase', $input, 1); # Proxy url= values in meta redirects $input = preg_replace_callback('#content\s*=\s*(["\\\'])?[0-9]+\s*;\s*url=([\\\'"]|&\#39;)?((?(?<=")[^"]+|(?(?<=\\\')[^\\\']+|[^\\\'" >]+)))(?(2)\\2|)(?(1)\\1|)#i', 'html_metaRefresh', $input, 1); # Process forms $input = preg_replace_callback('#]*)>(.*?)#is', 'html_form', $input);
public onCompleted ( Proxy\Event\ProxyEvent $event )
$event Proxy\Event\ProxyEvent
    public function onCompleted(ProxyEvent $event)
    {
        // to be used when proxifying all the relative links
        $this->base_url = $event['request']->getUri();
        $response = $event['response'];
        $str = $response->getContent();
        $content_type = $response->headers->get('content-type');
        // DO NOT do any proxification on .js files
        if ($content_type == 'text/javascript' || $content_type == 'application/javascript' || $content_type == 'application/x-javascript') {
            return;
        }
        // let's remove all frames?? does not protect against the frames created dynamically via javascript
        $str = preg_replace('@<iframe[^>]*>[^<]*<\\/iframe>@is', '', $str);
        // let's replace page titles with something custom
        if (Config::get('replace_title')) {
            $str = preg_replace('/<title[^>]*>(.*?)<\\/title>/ims', '<title>' . Config::get('replace_title') . '</title>', $str);
        }
        /* css
        		if {1} is not there then youtube breaks for some reason
        		*/
        $str = preg_replace_callback('@[^a-z]{1}url\\s*\\((?:\'|"|)(.*?)(?:\'|"|)\\)@im', array($this, 'css_url'), $str);
        // https://developer.mozilla.org/en-US/docs/Web/CSS/@import
        // TODO: what about @import directives that are outside <style>?
        $str = preg_replace_callback('/@import (\'|")(.*?)\\1/i', array($this, 'css_import'), $str);
        // html .*? just in case href is empty...
        $str = preg_replace_callback('@href\\s*=\\s*(["\'])(.*?)\\1@im', array($this, 'html_href'), $str);
        /*
        src= can be empty - then what?
        */
        $str = preg_replace_callback('@src\\s*=\\s*(["|\'])(.*?)\\1@i', array($this, 'html_src'), $str);
        // sometimes form action is empty - which means a postback to the current page
        $str = preg_replace_callback('@<form[^>]*action=(["\'])(.*?)\\1[^>]*>@i', array($this, 'form_action'), $str);
        //$str = str_replace('document.forms[0]', 'document.forms[1]', $str);
        $response->setContent($str);
    }