/    Sign up×
Community /Pin to ProfileBookmark

redirect page if title contains bad words

Hello guys, I hope you can help me with this
I was looking for a script that can redirect to a different page if the meta tags of a page contains bad words.
I have a site that collects its content from other sites, so I would like to control it a bit!

any suggestions, help this newbie ?

hope to hear from u soon!
Peace

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@SephrDec 24.2008 — First of all, this is something you would want to do server-side (ie. "Location: $redirect") as the title of a page will show before a script can read it. Second of all, are you checking the title or meta tags?
Copy linkTweet thisAlerts:
@ma7museauthorDec 24.2008 — Hey thanks for replying,

actually I want the easiest way to do it, even if the page has to load a bit before it executes that script.

I'm an IT guy but i'm not a developer, so I can understand code, (maybe edit variables) but no programing!

I'd really apreciate your help

thanks a lot
Copy linkTweet thisAlerts:
@SephrDec 24.2008 — The PHP way is the easiest way as it requires less code, works on browsers that don't support JavaScript, and doesn't even let the user load the original page.

I'm assuming that there is a php file with "<title>" somewhere in it. whatever PHP is going to output there, store it as a variable like $pagetitle, use that code before it outputs ANYTHING and put it in this if statement:
[code=php]
$page_title = ''; //whatever the code inbetween the <title> tags is
$redirect_uri = 'http://somewhere/'; //URI to redirect to if page title is profane
if ( preg_match('/(s?((mother)?fu_ck(ing|er|tard)?|bit_ch|bastard|(co_ck|dick)sucker|cu_nt|kike|(dumb)?ass(hole)?)s?)+/', $page_title) )
{
header("Location: $redirect_uri", true, 302);
exit();
}[/code]

I don't recommend ever redirecting due to bad words. In the worst case scenario I would only censor the words but still let the user view the page.

This forum would censor my code if I kept the words there without underscores, just remove the underscores to use the code.
Copy linkTweet thisAlerts:
@ma7museauthorDec 25.2008 — hey thank s alot, I haven't tried it yet cause I can't quit fully understand the syntax

can you tell me when we use ? or | or ()

so I can place the bad words

thanks a lot
Copy linkTweet thisAlerts:
@ma7museauthorDec 25.2008 — hey thank s alot, I haven't tried it yet cause I can't quit fully understand the syntax

can you tell me when we use ? or | or ()

so I can place the bad words

thanks a lot
Copy linkTweet thisAlerts:
@SephrDec 25.2008 — Use ? to make the last character or multiple characters in a () optional. Use | to as an "OR" operator. ie. (a|b) matches a OR b.

Also, don't remove the underscored in the $variable_names like that.
Copy linkTweet thisAlerts:
@ma7museauthorDec 25.2008 — thanks for replying

so can I use the or one like this
[code=php]
if ( preg_match('word1|word2|word3|word4|word5|word6|word7|word8', $page_title) )[/code]

or is a wrong syntax

is there a better way?

if I wanted to include words that ends or starts with certain letters what should I add,

thanks a lot ? and thanks for trying to make it simple, keep doing that lol
Copy linkTweet thisAlerts:
@ma7museauthorJan 01.2009 — Use ? to make the last character or multiple characters in a () optional. Use | to as an "OR" operator. ie. (a|b) matches a OR b.

Also, don't remove the underscored in the $variable_names like that.[/QUOTE]


hey can u help please look at my previos msg
×

Success!

Help @ma7muse 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...