Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Old 09-09-2009, 06:14 AM Bad word filter
Banned

Posts: 25
Trades: 0
Please somebody tell me how to add bad word filter to php search engine

i want to add in my site <link removed>

Last edited by chrishirst; 09-09-2009 at 06:21 AM..
googledaily.com is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-09-2009, 07:40 AM Re: Bad word filter
lynxus's Avatar
Awesomeo-Maximo

Posts: 1,618
Location: UK
Trades: 1
Something like:
<?php
$var = "Some nasty words";

$var= str_replace('Some nasty words','<link removed>',$var);

?>

This would replace anything in a var that says "Some nasty words" and change to "<link removed>"

Sorta like a find & replace.
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE


lynxus is offline
Reply With Quote
View Public Profile Visit lynxus's homepage!
 
Old 09-09-2009, 08:28 AM Re: Bad word filter
Banned

Posts: 25
Trades: 0
i was wondig if i coul do write all words in a text file which is cordinated by php..so that it can ban sexy searches at my site
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-10-2009, 02:43 AM Re: Bad word filter
Knight13's Avatar
Defies a Status

Posts: 10,289
Name: Knight13
Location: Cleveland, Ohio
Trades: 0
What do you mean by sexy searches?

And you could use an array of bad words and replace them with an array of good words.
Knight13 is offline
Reply With Quote
View Public Profile
 
Old 09-10-2009, 03:52 PM Re: Bad word filter
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
filter.txt
Code:
badword1,badword2,badword3
PHP Code:
<?php
//Input
$content 'This is some content with a badword2 in it!';
//Take the file and put the bad words (separated by commas) in an array
$badwords explode(','file_get_contents('filter.txt'));
//Replace any bad words with a string
$content str_replace($badwords'**REMOVED**'$content);

echo 
$content;
?>
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Old 09-18-2009, 12:39 PM Re: Bad word filter
Banned

Posts: 25
Trades: 0
following is the code where i need to put bad word filter code. actually its a youtube search engine which line up result of video and user can download video by just one click.
Quote:
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
<TITLE>::TubeDown.Googledaily.Com:: YouTube Downloader - Search And download And Convert YouTube Video Into FLV or Hight

Quality MP4</TITLE>
<META HTTP-EQUIV="Content-Language" CONTENT="en-us">
<META NAME="author" CONTENT="googledaily.com">
<META NAME="distribution" CONTENT="Global">
<META NAME="robots" CONTENT="FOLLOW,INDEX">
<LINK REL="SHORTCUT ICON" HREF="http://www.googledaily.com/favicon.ico">
<link rel="stylesheet" type="text/css" href="ajaxtabs/ajaxtabs.css" />

<script type="text/javascript" src="ajaxtabs/ajaxtabs.js">

/***********************************************
* Ajax Tabs Content script v2.2- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/



</script>

<style>



.side-module a {color: #FF9;}
.side-module a.btn {color: #FFFF00;}
.side-module {
width: 260px;
clear: both;
margin-bottom: 10px;
color: #CCC;
background: url(image/side-module-foot.gif) bottom left no-repeat;
overflow: hidden;
}
.side-module .head {
background: url(image/side-module-head.gif) right;
height: 29px;
margin: 0;
padding-right: 10px;
font: normal 11px/29px Arial;
color: #999;
}
.side-module .head h2 {
font: bold 12px/29px Arial;
color: #FFF;
margin: 0;
padding: 0 2px 0 10px;
background: url(image/side-module-head.gif) left #C3C6CC;
float: left;
}
.side-module .head span {
font: normal 11px/29px Arial;
color: #FFF;
float: right;
padding: 0;
}
.side-module .body {
background-color: #000;
border: 1px solid #40444A;
border-bottom: 0;
padding: 10px 10px 0;
clear: both;
}
.side-module .body ul li {
position: relative;
}
.side-module .foot {
background: url(image/side-module-foot.gif) bottom right no-repeat;
height: 11px;
font-size: 0;
margin-left: 10px;
clear: both;
}
.tiny-thumb {
width: 22px;
height: 22px;
margin-right: 10px;
display: inline;
float: left;
display: inline;
background: center no-repeat #FFF;
border: 2px solid #666;
}

.top-list {margin:0;padding:0; width:250px;float:left;position:relative;}
.top-list li {width:250px;float:left;position:relative;margin:0 0 5px 0;padding:0 0 5px 0;list-style:none;border-bottom:1px

solid #40444A;}
.top-list a.f-EEE {color: #EEE;}

.top-list .iteration {width:27px;float:left;font:bold 11px/27px

Arial;text-align:center;background:url(image/top-number-bg.gif) center no-repeat;color:#000;margin-right:5px;display:inline;}
.f-bold {font-weight: bold;}
.f-bold a {color: #FFCC00;}
.clear {clear: both;height: 0;font-size: 0;overflow: hidden;}
a{
color: #FF9;;
text-decoration: none;
}
a:hover{
color: #FFFFFF;
}
</style>
</head>

<body bgcolor="#000000" text="#FFFFFF">
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="899" height="567">
<tr>
<td width="899" height="30" colspan="3"></td>
</tr>
<tr>
<td width="39" height="510"></td>
<td width="812" height="510" valign="top" background="http://googledaily.com/tubedown/image/tubedown.jpg">
</center>
<div id="countrydivcontainer">
<form method="GET" action="video/index.php">
<p align="center">
<input name="search" type="text" value="Type Video Name " class="searchtext" size="42" style="background-color:#E6E6E6;

margin-right: 20px;" onFocus="if(this.value=='Type Video Name '){this.value='';this.style.color='#666';}">
&nbsp;
<p align="center">
&nbsp;
<input type="submit" value="Search Video" style="background-color:#000000; color: #FFFFFF; font-weight: bolder; font-size:

14px; margin-left: 10px;" >
<p align="center">
<input type="radio" name="source" value="all" checked style="visibility:hidden"> </form>
</div>
<p align="center" style="margin-top: 100">
</td>
<center>
<td width="46" height="511"></td>
</tr>
<tr>
<td width="899" height="26" colspan="3">
<p align="center">
<br><fieldset style="background-color:#333333">
<LEGEND style="background-color:#000000; color: #FFFFFF; border-color: #000000; border: 1px; "><b> <font face="Century

Gothic" color="#C0C0C0"> Latest Search</font></b></LEGEND><span style="font-size: 9pt; text-align: justify; ">
<?php include 'video/latestsearches.php'; ?></span>
</fieldset><br>
<center>
<br>
</td>

</tr>
</table>
<div align="center" style="margin-left:60%">
Copyright © <a href="http://www.googledaily.com/" target="_blank"><b>::Googledaily.Com::</b></a>
</div>
</center>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js'

type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-8622191-4");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-18-2009, 12:42 PM Re: Bad word filter
Banned

Posts: 25
Trades: 0
should I put yout filter code above form tag?? Thats what i did exactly
actually Im not a php expert. learning so slow
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-19-2009, 03:06 PM Re: Bad word filter
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Actually, the file the code really should go in is 'video/index.php'. Play around with putting that snippet in there, and if all else fails, you can give me the code to that page.
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Old 09-20-2009, 03:51 AM Re: Bad word filter
Banned

Posts: 25
Trades: 0
i uploaded the full script..below is the link
see password in your inbox

new.rar
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-20-2009, 03:53 AM Re: Bad word filter
Banned

Posts: 25
Trades: 0
Actually i want to prevent porn searches
Thats why Im trying to do this..
I searched alot at google to slove this, but ot of methods are through sql.
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-20-2009, 05:15 PM Re: Bad word filter
Banned

Posts: 41
Trades: 0
I have a readymade script if you need
seoconsult is offline
Reply With Quote
View Public Profile
 
Old 09-21-2009, 06:16 AM Re: Bad word filter
Banned

Posts: 25
Trades: 0
yea I really need
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-21-2009, 10:28 PM Re: Bad word filter
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Sorry for the delayed answer - no need to post after yourself.

Go into 'video/index.php'.

Replace this code:
PHP Code:
<?php

if (!isset($_GET[search]) OR $_GET[search] == "") {

$_GET[search] = "muse";
include(
"includes/layout_main.php");

}else{
if(!
$_GET[page]) {
    include(
"includes/searchtracking.php");
  }
include(
"includes/layout_main.php");

}


?>
With this:
PHP Code:
<?php
if (!isset($_GET[search]) OR $_GET[search] == "") {
    
$_GET[search] = "muse";
} else {
    if(!
$_GET[page]) {
        include(
"includes/searchtracking.php");
    }
}
//Make sure you have the url to filter.txt correct
$badwords explode(','file_get_contents('filter.txt'));
$filtered str_replace($badwords''$_GET[search]);

$_GET[search] = $filtered;

//[OPTIONAL] (for testing purposes)
if($filtered) {
    echo 
'It worked!';
    echo 
$_GET[search];
} else {
    echo 
"it didn't work. :(";
}
//[/OPTIONAL]

include("includes/layout_main.php");
?>
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Old 09-22-2009, 03:15 PM Re: Bad word filter
Banned

Posts: 25
Trades: 0
thanks, let me try.
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-22-2009, 03:38 PM Re: Bad word filter
Banned

Posts: 25
Trades: 0
Thank you so much. its really working..
Its shows blank page when i enter a bad word, I wrote "waqas" in filter.txt and it worked..now all I hacve to do is, to find a huge adult keywords txt file..but im afraid that adult keywords necer ends, hehe. but we can try to reduce such things..and you really contributed to make it happen.

But your "optional" code dont work. Can we use to show a dialogue box having word "Sorry, Adult keyword are not allowed" instead of using following code??

//[OPTIONAL] (for testing purposes)
if($filtered) {
echo
'It worked!';
echo
$_GET[search];
} else {
echo
"it didn't work. ";
}
//[/OPTIONAL]
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-22-2009, 04:08 PM Re: Bad word filter
Banned

Posts: 25
Trades: 0
well i analyze about image error. its not youtube server error. its something wrong in my script. It was showing screenshots some days ago. but it might be possible that youtube have changed something at their server

Now I need to review video/sources/youtube/yt.php again

Last edited by googledaily.com; 09-22-2009 at 04:28 PM..
googledaily.com is offline
Reply With Quote
View Public Profile
 
Old 09-22-2009, 07:33 PM Re: Bad word filter
stevej's Avatar
Professional Multitasker

Posts: 996
Location: Not positive
Trades: 0
Ok. To get a popup, replace this code:

PHP Code:
$_GET[search] = $filtered;

//[OPTIONAL] (for testing purposes)
if($filtered) {
    echo 
'It worked!';
    echo 
$_GET[search];
} else {
    echo 
"it didn't work. :(";
}
//[/OPTIONAL] 
With this:

PHP Code:
if($_GET[search] == $filtered) {
    
//nothing
} else {
    echo 
"<script type='text/javascript'>alert('Sorry, adult keywords are not allowed.');</script>";
}

$_GET[search] = $filtered
__________________
if($stevej == "helpful") { $talkupation += $user_power; }
stevej is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Bad word filter
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.51072 seconds with 12 queries