Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /** @closure $replaces; status: working */
- $replaces = function ($subject, $patterns, $replaces)
- {
- $patterns = array_values($patterns);
- $replaces = array_values($replaces);
- if (count($patterns) !== count($replaces)) return false;
- for ($i=0;$i<count($patterns);$i++)
- $subject = preg_replace($patterns[$i], $replaces[$i], $subject);
- return $subject;
- };
- $cpath = "/website-capture/$cdir/";
- // run as closure
- $body = $replaces($body,
- array (
- '~<script\b(?>[^<]++|<(?!/script))*<\/script>(*SKIP)(?!)|\b(?:href|src)\s*=\s*(["\']?+)\K(?:/(?!/)|(?=[\s>]|\1))~i', # html
- '~\b(?::url)\s*\(\s*(["\']?+)\K(?:/(?!/)|(?=[\s>]|\1))~i', # css
- ),
- array (
- $cpath, # /html
- $cpath, # /css
- )
- );
Advertisement
Add Comment
Please, Sign In to add comment