Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    PHP


Advertisements:




SuperbHosting.net & Arvixe.com have generously sponsored dedicated servers and web hosting to ensure a reliable and scalable dedicated hosting solution for BigResource.com.







Removing Bad Words


Looking for suggestions on how to handle bad words that might
get passed in through $_GET['item'] variables.

My first thoughts included using str_replace() to strip out such
content, but then one ends up looking for characters that wrap
around the stripped characters and it ends up as a recursive
ordeal that fails to identify a poorly constructed $_GET['item']
variable (when someone hand-types the item into the line and
makes a simple typing error).

So the next thoughts involved employing a list of good words
and if any word in the $_GET['item'] list doesn't fall into the
list of good words, then an empty string gets returned.

Any suggestions on how to handle this?


View 7 Replies (Posted: February 22nd, 2006 07:45 PM)

Sponsored Links:

Related Forum Messages:
Array Removing Words
Is there a way I can put some sort of wildcard into the array to ignore words that contains "ing" etc at the end? It's a real hassle when I have to input two of the same words and replace/adding the ing's

$ignore = array(
'/add/',
'/adding/',
'/and/',
'/show/',
'/showing/',
);

Posted: 04-17-2007, 08:57 PM

View 2 Replies!   View Related
Removing Wildcard Words Using JQuery?
I hope I am able to explain this as easy as possible. Basically I am compiling a list and to do so I need to remove a load of text after a certain trigger word. Example of what I am trying to achieve is here Say I have just pasted a bunch of text in my text box, I want everything removed apart from the first username.

And example would be...
r-u-f-f-i-a-n reblogged this from youaref0rsaken
youaref0rsaken reblogged this from loveeoutoflust
loveeoutoflust reblogged this from yourwatchfuleye
Which I would want to turn in to
r-u-f-f-i-a-n
youaref0rsaken
loveeoutoflust

With using a textbox with the input, a button and a textbox which would display the output. I have tried doing this using jquery and php preg_replace but cannot get it to function correctly. Is anyone able to help me with this?

Posted: May 19 at 1:47

View 3 Replies!   View Related
Removing What Ever String Of Word Or Words Come After A Special Char On A Single Line?
I have a source file that file that contain to be translated strings. Each line of the translation cache files containt a Source string then a delimiter/separatpr â–ˆ then the translated string

The original old author did write a nice clean up script that cleans the cache files from duplicates or deletes entire lines from the cache if the old source did not use them anymore. Now I would like to add one more function into that existing code (relevant part below) which is : to delete the entire line when there is absolutely nothing '' coming after the separation key â–ˆ for the same line that its examining.I have the feeling it will be 1 line of code somewhere below. But where how does this line look like?

EXISTING CODE:

$translation_key_value_separator = 'â–ˆ';

// Read file contents and create a used keys array
$used_keys = array();[code]...

Posted: Mar 29 at 21:47

View 2 Replies!   View Related
$words Array Have Many Words , It Work Only With First Words?
i have array :

PHP Code:
$array1= array("donkey","cat","****"); 
[code]..

it work some times , but if $words array have many words , it work only with first words , so , what's your opinion ? and it this method is true ? or there are anothr method ?

Posted: Jul 4, 2009, 05:51

View 5 Replies!   View Related
Database Driven - Removing The Navigation Bar Instead Of Removing The Button
I understand Javascript, some intermediate Java, expert html, css, Actionscript. My company has acquired a php-based Web site. It has a button in the global main navigation header that we need to remove. Here is the following script that the php page header.inc pulls to populate the global navigation header:

$navigation = @mysql_query("SELECT * FROM navigation WHERE category='main' ORDER BY listing ASC");

Which is then placed into a table by this code:

<table border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td><img src="/_images/nav_divider_white.gif"></td>
<?php while ($nav = @mysql_fetch_array($navigation)) { ?>
<td class="<?php
[Code]....

... remaining original code, etc. Instead of removing the button from the navigation bar, it removes the navigation bar from the page "company" which I thought was interesting but not the achievement I wanted.

Posted: Sep 17th, 2010

View 2 Replies!   View Related
Calculate The Number Of Words/characters Between 2 Given Terms/words?
Basically - I want to calculate the "Proximity" of various terms. By "proximity" I means Specifically the number of spaces/characters/words that sit between them.

Example:

Terms = Word1 / Word2
Chunk = "blah Word1 blah blah blah blah blah Word2 blah"
Proximity = Word1-Word2:5

THe script would see the 2 terms, locate them and then see the distance based on the words that lay between them. A more advanced version would be to examine the semantic structure - and identify whether the terms occur within the same semantic element, or a sibling, or a parent etc. Thus proximity discovery of terms may be within the same paragraph, or in sequential paragraphs, or under the same "parent" (heading) but otherwise separate etc. Further - introducing things like word stemming/relationships/soundings at a later date may be useful too.

I've looked around the net (Google, here, php forums, php script sites). Not seeing anything like it. I can see tools on some sites that do similar (limited) - usually SEO based tools. I want to be able to apply this to "text" in general ... as I may apply it to uploaded word/txt files etc. I'm not seeing any real examples - so I can only assume it's mroe than a trifle to code it. How would I handle variant order of the words (Word1+Word2 / Word2+Word1)? How could I handle identifying proximity within/outside of the same element/structure?

Posted: Apr 7 at 13:43

View 1 Replies!   View Related
Bold Some Words In A String And Remove Some Unbold Words?
I am creating an Image Search Engine. Currently, my script does bold the matching words on the keyword. But, some keywords are too long just like the followings. When I search for shah rukh khan, there is an image with the following keyword.

25216d1235653089 shahrukh khan s
wallpaper shah rukh actor

As you see, the above keyword is too long. So, I need it to be like the following one.

[code]....

Currently, I am using the following code but it requires a space before and after the bold tags. So, if the 1st word is bold, it displays the whole keyword.

if(strlen($img_keyword)>30){
$img_keyword = preg_replace('/(.*?) <b>(.*?)</b> (.*?)/us'," <b>$2</b> ",$img_keyword);
}

Posted: Oct 31 09 at 19:46

View 2 Replies!   View Related
Counting Words And Cut After Specific Total Words
This is my code to count words in a post: PHP Code:

Posted: July 21st, 2001, 02:14 PM

View 6 Replies!   View Related
Perform Search Onto Words And Display The 2 Words
so far on page one it takes word from text box and produces search on datebase for that word then produces correctly over the folling pages using pagination. question is i want it to now perform search onto words and display the 2 words. code is below. :_

$carrymake = (isset($_POST['carrymake']))? $_POST['carrymake'] : $_GET['carrymake'];

$carrymodal = (isset($_POST[carrymodal ]))? $_POST[carrymodal ] : $_GET[carrymodal ];

i want to know now how to include the second varible in this code here:-

// Build Previous Link
if($page > 1){
$prev = ($page - 1);
echo '<a href="'.$_SERVER['PHP_SELF'].'?page='.$prev.'&carrymake='.$carrymake.'"><<Previous</a>&nbsp;'
}

Posted: 4:33 pm on Dec. 21, 2004

View 1 Replies!   View Related
Preg_match_all : Replace Multiple Words With Different Words?
$post[message] is the text of a post from my forum.

I wanted to take out all the text and keep only the text between [TAG1] tags

here is a part of the code i am using to do that:

Code:
<?php
$string = $post[message];
$tag = "TAG1";
preg_match_all("#[".$tag."](.*)[/".$tag."]#Ui", $string, $matches);

[Code]....

Posted: 06-05-2009, 02:53 AM

View 14 Replies!   View Related
Replace Words - Ignore Words Between Brackets?
I'm using an ubb parser to convert several codes within brackets to html codes. I want to use a string replacer aswell to replace some unwanted words.

Now, I'm using this:

foreach($f AS $value) {
$escapeNamesArray[] = '/'.$value['woord'].'/i';
$escapeNamesReplace[] = '<span style="color: gray;">'.$value['vervanging'].'</span>';

[code]....

When I want to replace the word "Hello" to "Hey", everything is working fine. But when I place the word "Hello" between brackets, for example:

[code]...

The word "Hello" is replaced aswell. How can I change the pattern of the preg_replace function to ignore words between brackets?

Posted: Jun 21 10 at 18:42

View 4 Replies!   View Related
Wrap Words Or Words Sequences Which Have Not Been Already Wrapped?
I'm trying to wrap words and words sequence from a given list with preg_replace. It almost works, but there are some use cases it doesn't and I can't figure it how. For instance I do this:

// sort by descending length
usort($this->_keywords, function($a,$b){return(strlen($a)<strlen($b));});
// wrapper is -%string%-

[code].....

From this keyword list:

lorem
ipsum
sit amet

[code]....

I'd like to result in:

-Lorem- -ipsum- dolor -sit amet-,
consectetur adipiscing elit. Phasellus
rhoncus venenatis orci sed porta. Sed

[code]....

Posted: Oct 13 10 at 13:01

View 2 Replies!   View Related
Organize Words So Can Fit The Most Number Of Words In A Given Length?
I'm looking for a way to do the following. I have a list of words of various char lengths. I have a limited number of chars I can use in a given strings size. I'd like to organize the words to fit as many of them as I can in a given string without going over the limit or cutting any of the words off.

Bobby
Sally
Joe
Sue

[code]....

I have a limit of 140 characters to fit them all in, including spaces. If I have more names than space avail in that string, I'd like to generate another string using the same function as described above until all the names in the list are used.

Posted: September 25, 2009, 04:03:12 PM

View 1 Replies!   View Related
Converts Singular Words To Plural Words
I am looking for a class that converts Singular words to Plural words. My aim is to take something like Story for a model name and create a Story.php file and a stories.php file. I already have the generator class ready to roll just hoping there is some prebuilt class for converting singular to plural word otherwise i'll start this the most expected ones and work from there.

Posted: 03-31-2010, 05:39 PM

View 2 Replies!   View Related
Punctuate Words If It Contains More Then X Number Of Words?
When a word gets to long it messes the text up.... how can I fix this?

Example:

Make a word with 4 chars like "cats" into "ca..."

How would I do this?

Posted: Sep 27 10 at 0:46

View 1 Replies!   View Related
Count The Number Of Words Between Two Words?
How can i count the number of words between two words?

[code]....

Now i have this regular expression:

[code]....

Posted: Jul 21 10 at 7:13

View 3 Replies!   View Related
Reads In A String And Reverses All Of The Words Inside Of The String (the Words Stay In The Same Position But Are Reversed)
A function that reads in a string and reverses all of the words inside of the string(the words stay in the same position, but are reversed).

Code:
function(String sentence){
String word="";
String reversedSentence;
for(int i = 0; i< sentence.length; i++){
if(sentence[i] == ' '){
reversedSentence += reverse(word);
word = "";
[Code]....

Posted: Oct 22, 2010, 09:03

View 9 Replies!   View Related
Echo 5 Words Before 5 Words After
I have a keyword "car" in the sentence. one two three four five six seven car eight nine ten eleven twelve thirteen fourteen fifteen. i'd like it to echo three four five six seven car eight nine ten eleven twelve because 5 words before and 5 words after, including car.

Posted: Mar 21st, 2010

View 4 Replies!   View Related
Removing Www.
Alot of my users are adding www. to their email when they signup, and id like to silently remove this if its the case

PHP Code:

$string = 'www.email@yahoo.com'

if(eregi('www.',$string)) echo "yes";

This doesnt work, and im wondering where i went wrong? Ive been up for a long time, and im probably just over looking somthing.

Posted: 03-29-2006, 01:48 PM

View 1 Replies!   View Related
Removing One Key
removing one key=>value element from array: I have an array of this sort:

array(

[#document]=> <?xml version ="1.0"?>
[finemae]=>2344ddd
[subscriptionstatus]=>unread
[trackingnumber]=>45566

}

I wanted to get rid of the first Key=>value element which is #document=> <?....?>

because my insert statement then gets stuck at this point because of this unwanted element:

insert into table (#document,filename,subscriptionstatus,trackingnumber) value ('"<?...?>','..',...);

Posted: 08-10-2007, 02:49 PM

View 1 Replies!   View Related
Removing &
I'm having problems when the string has &'s in it, as well as 's. I was able to remove the 's. But i get a return value of 0 when trying to do the same thing with &'s. If i take out the part where I'm trying to remove &, the value of $replace is OK.
 
Quote//PARSE INI FILE.
$ini = parse_ini_file('config.ini');

//REMOVE APOSTROPHES FROM NAME.
$and="&";
$ini1=$ini['UNITNAME'];
$unitname=str_replace($and,"AND",$ini1);
echo $unitname;
$replace=str_replace("'","",$unitname);
echo $replace;

Posted: March 27, 2007, 06:19:20 PM

View 1 Replies!   View Related
Split A String Into Words. Ex: "stringintowords" -> "String Into Words" ?
What is the right way to split a string into words ?(string doesn't contain any spaces or punctuation marks)For example: "stringintowords" -> "String Into Words"! Update: For those who think this question is just for curiosity. This algorithm could be used to camеlcase domain names [URL]...."and this algo is currently used by aboutus dot org to do this conversion dynamically.

Posted: Aug 12 10 at 11:10

View 10 Replies!   View Related
Removing PHP Coding
I have php coding that is stored in mysql blobs. Now I want to index words in these blobs in an attempt to make some sort of a search engine. Example: How can I use php to make this mysql text:

"Once upon a time there were <?php echo $num_bears ?> bears in a small cage in a zoo in Russia. They had <?php echo $num_relatives ?> relatives that lived there with them."

Change into this: "Once upon a time there were bears in a small cage in a zoo in Russia. They had relatives that lived there with them."

Point is: - remove everything between and including "<?php" and "?>" I'm trying to do some indexing, and I need to remove all my php coding... :)

Posted: May 8th, 2002, 11:24 AM

View 2 Replies!   View Related
Removing Characters
I am passing a string over to a calculator form but need to strip out the £ and ,
the string comes over as /index.php?price1=£195,000 this populates an input field as below
<input type="text" name="price1" class="fields" value="<? if ($price1 != "") { echo $price1; } else { echo "100000"; }?>"> I have added at the top of the page

<?
$price1 = str_replace("£", "", $price1);
$price1 = str_replace(",", "", $price1);?>

this strips the £ but gives an error with the comma.

Posted: April 12th, 2002, 03:02 AM

View 2 Replies!   View Related
Removing Whitespaces
I try to remove whitespaces from a string using the preg_replace function
like

preg_replace("/[ ][ ]*/"," ",$string);

This works great, but makes no handles all characters in the same way. I
want to preserve data between double quotes. So,
hello world "It is a sunny... world"
shall be reduced to
hello world "It is a sunny... world"

and should not remove the whitespaces between the quotes.

Posted: February 27th, 2006 09:05 PM

View 1 Replies!   View Related
Removing File
I created a dir with a file in it, using php. I set the file mode to 'w'. It worked and everything, but now i can't delete the file. I tried deleting it using php, in ftp, and in ssh. I can't set chmod mode either. I tried chown but that doesn't work. For anything you do, it shows "Operation not permitted".

Posted: February 8th, 2003, 08:53 AM

View 4 Replies!   View Related
Removing The .php From Pages
Hi i am new here we run a website called www.example.com and i was wondering if it is possible to remove the .php from the end of a address

For example www.example.com/newsinbrief.php, it would be nice it I could have it as www.example.com/newsinbrief

Is this possible does anyone know how to do it and if so where i could look for the code advise etc.

Posted: 12:07 pm on Sep. 24, 2007

View 1 Replies!   View Related
Removing Duplicates
I'm getting some data from a database, but there are duplicates for every entry. For instance, if you looked a table of posts for this forum, you'd see posts and the author.  I'm getting the author, so there could be hundreds or more of repeats. I'd like to basically get all the uniques in a column. 

Posted: August 14, 2007, 04:12:14 PM

View 2 Replies!   View Related
Removing Value From Echo
For example.  If had the following coordinates in the database:

-5.717979 54.728432,-5.672246 54.757900,-5.621388 54.786976,

If I then echo them how would I remove the , (comma) at the end?  As I will echoing multiple coordinates from the database, some longer than others I can't simply remove the comma after a certin about numbers.

Posted: September 21, 2007, 09:55:50 AM

View 5 Replies!   View Related
Removing Delimiter?
I'm trying to remove the delimiter when I use my functions and replace it like PHPBB does {CODE}  instead of <?CODE()?>

What would be a easy way to do that?

Posted: September 11, 2007, 11:38:14 PM

View 3 Replies!   View Related
Removing Non Characters......
I wanna remove everything else but a-z in my source file ........and replace everything that is not a-z with nothing. I have the below example (but it's getting a parse error). Actually is there an easier way to remove noncharacters (e.g. !@$*$%) from my source file.

<?
$q = $stringoftext
$search = array (""'#'","'$'","'%'","'&'","''","'/'","'@'","'!'","'('","')'","'['","']'","'.'","'+'","'-'","'*'","'{'","'}'","'?'"");
$replace = array ("");
$body = preg_replace ($search, $replace, $q);
?>

Posted: 07-27-2007, 12:53 PM

View 3 Replies!   View Related
Removing Character
how do i remove the right most character from a string, and store this in another variable,i want to keep the original variable but without the removed character.

Posted: 11-05-2007, 09:00 AM

View 1 Replies!   View Related
Removing Comments
I happen to have a bunch of stuff in a database(who here doesn't right?)and in one of the feilds I have a list of html snidbits that are deliniated by html style comments. I did this so the whole field could be displayed in an html page and the user would never see the delination. However the bossman is for whatever reason very parinoid about having comments in the end html.

Anyways enough backstory - I need to write a script that will take html comments out of a given string without removing other html tags.

Posted: 12:54 am on Dec. 31, 2003

View 1 Replies!   View Related
Removing Leading 0
is there a function for removing a leading 0 from expample 09 or 03 so they will become plain 9 and 3.

Posted: 03-02-2006, 08:59 AM

View 10 Replies!   View Related
Removing A Leading Zero
for example I want to remove the leading 0 from this var

$var = 01

how would I do this ?
at the moment im using
ereg_replace("0", "", $test[&#392;']);

but this deletes all the 0 zeros.

so

$var = 30;

becomes 3 which i dont want,

Posted: 11-27-2005, 12:51 PM

View 5 Replies!   View Related
Removing In Email
I have a simple html form going to email (no db). I've tried both using htmlentities() and stipslashes() on my $POST variables but still the email shows a backslash before special characters.

Posted: 03-01-2006, 10:58 AM

View 1 Replies!   View Related
Removing Rows
is there a way to remove rows that contain duplicate data in a specific row. For example, Table A has columns X, Y, Z. if a few entries were like:

1, 2, 3
g, v, d
6, 5, 3
7, 5, 5
4, 3, 3

As you can see, in column Z, 3 appears three times. Is there a way to delete two of them? (does not matter which one is left). This is only a simplified example, in reality there are four-five columns that must be unique like this. If there is a SELECT statement that could produce these results that would work too.

Posted: 03-09-2006, 04:08 PM

View 3 Replies!   View Related
Removing Whitespace
Here is the code I use to change whitespace from a string $test to hypen -.

<?Php

$test="Teststring test test hay man test test test test";

// Chr(32) is ASCI code for whitespace and Chr(45) is for -

$test = str_replace(Chr(32), Chr(45), $test);

echo $test;
?>

I have to take out the whitespace completely form the string. I will be thankful if anyone can help me, or guide me to the function name that can be used for this.

Posted: July 17th, 2005 11:53 AM

View 5 Replies!   View Related
Removing .jpg Extension
How would I go about removing the file extension of a variables contents?

$variable = "imageone.jpg";

?

Posted: 03-31-2006, 09:06 AM

View 1 Replies!   View Related
Copyright © 2005-08 www.BigResource.com, All rights reserved