/    Sign up×
Community /Pin to ProfileBookmark

Remove code from files

This is supposed to remove all the code between the script tags, and between the style tags, It doesn’t seem to be working.

$source is what is supposed to remove the script, and style.

[code=php]<?php
$html = file_get_contents(trim($_POST[“url”]));
if($html !== FALSE){
if(preg_match(‘/<body[^>]*>(.*)</body>/is’, $html, $matches)){
$source = /*addslashes(strip_tags(*/preg_replace(‘/<script.*.script>/’, ‘ ‘, $matches[0])/*))*/.”n”;
$source = /*addslashes(strip_tags(*/preg_replace(‘/<style.*.style>/’, ‘ ‘, $matches[1])/*))*/.”n”;
}else{
echo “<p>No match found</p>n”;
$source = ‘ ‘;
}
}else{
echo “<p>Unable to get html from site.</p>n”;
}
?>[/code]

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@ShrineDesignsDec 07.2006 — use the "s" modifierpreg_replace("/&lt;((?:style|script)).*&gt;.*&lt;/\1&gt;/si", '', $matches[0]);
Copy linkTweet thisAlerts:
@The_Little_GuyauthorDec 07.2006 — Cool Thanks!
×

Success!

Help @The_Little_Guy spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.29,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...