Created
January 7, 2018 05:37
-
-
Save humbertocastelo/e6f909a4b858acfe2cd9ac6213727d95 to your computer and use it in GitHub Desktop.
Replace Scripts With SRC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function replace_scripts_with_src( $html ) { | |
$html = preg_replace( '`\<script\b[^\x3e]*\bsrc\b[\x00-\x20\x7f]*\=[\x00-\x20\x7f]*(?:[\x22](?:[^\x22]*)[\x22]|[\x27](?:[^\x27]*)[\x27]|[^\x20\x3e]*)[^\x3c]*(?:(?!\<\/script\>)\<[^\x3c]*)*\<\/script\>`i', '', $html ); | |
return $html; | |
} | |
$old_html = file_get_contents( 'https://www.facebook.com' ); | |
$new_html = replace_scripts_with_src( $old_html ); | |
print '<pre>' . htmlentities( $new_html ) . '</pre>'; | |
exit(); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment