Home  |  About  | Last |  Submit  |  Contact
AllQuests.com

Previous Question:  Memory Sticks  PSP DiscussionNext Question:  campaign to disable mics in COD4  Call of Duty 4 (COD4) PS3 Discussions
Question Remove all Ads from external website ( CodeGuru Forums Scripting Server Side (PHP, Perl, etc.) )
Updated: 2008-08-12 06:07:52 (5)
Remove all Ads from external website

I am sure somebody already designed a function...
If you know it or know where I could find it that would be great...

I have a open source script http://205.122.94.228/Student_files...acheBrowser.php

What would be a correct way of doing preg_replace("src='*ads*'","<!-- src='*ads*' -->,$mcache)? (I want the * to be like dos * = anything in any amount)

Thanks in advance

Alex


Answers: Remove all Ads from external website ( CodeGuru Forums Scripting Server Side (PHP, Perl, etc.) )
Remove all Ads from external website

You wouldn't want to use <!--*--> in the middle of the src attribute because that would leave you with invalid HTML. Instead, it's best to just empty the src.

PHP Code:
$pattern = '/src="[^>]+ads[^>]+."/i';
$contents = preg_replace($pattern, 'src=""', $contents);


Just remember, there are a lot more to ads than just that...and many words that have ads in them that are found in the src. The biggest one is downloads.



Remove all Ads from external website

out of forum answer: http://www.admuncher.com
does the job pretty well

Xeel

Remove all Ads from external website

Xeel, he isn't looking for an ad blocker.



Remove all Ads from external website

Split the string with src=' as needle
Than do a for/next loop on the elements of that array
check for the first ' in each element (what will be the end of that url)
Check if you have the substring ads in that first part of the string


if yes replace that until the position of the '
after doing all elements implode them together again with src' as glue

or

put all add urls into a new array and in the end replace them in the original string

Teranoz

Remove all Ads from external website

No. Don't split the string. As I mentioned in post #2, use regular expressions. They process faster than splitting strings, and use a lot less code.



Previous Question:  Memory Sticks  PS3Forums  PSP DiscussionNext Question:  campaign to disable mics in COD4  AVForums  Call of Duty 4 (COD4) PS3 Discussions

- Source: Remove all Ads from external website CodeGuru Forums Scripting Server Side (PHP, Perl, etc.)
- Previous Question: Memory Sticks PS3Forums PSP Discussion
- Next Question: campaign to disable mics in COD4 AVForums Call of Duty 4 (COD4) PS3 Discussions





AllQuests.com


Best dedicated servers   Top dedicated servers   Cheap dedicated servers   Linux dedicated servers   Windows dedicated servers   Unmetered dedicated servers