Affiliate Marketing
Forum Search

Reply
 
LinkBack Thread Tools Display Modes

  #1 (permalink)  
Old 07-03-06
scifind's Avatar
thin[box]king
 
Join Date: Aug 2003
Location: Cambridge
Posts: 1,844
Thanks: 8
Thanked 4 Times in 4 Posts
scifind is an unknown quantity at this point
  'Disinfect' User input - php

Just wondering what methods are commoly used to 'cleanse' free text input from users to combat insertion of malicious code etc.
__________________
Earn an average of £45 per sale. | New Star Trek Trailer | Looking for Mobile Phone Link Swaps
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-03-06
BFG 9000's Avatar
Coffee Drinker
 
Join Date: Jul 2005
Location: South UK
Posts: 243
Thanks: 9
Thanked 9 Times in 8 Posts
BFG 9000 is an unknown quantity at this point
I use this :-

PHP Code:
function veryClean($string$min=''$max='')
{
  
$string preg_replace("/[^a-zA-Z0-9]/"""$string);
  
$len strlen($string);
  if(((
$min != '') && ($len $min)) || (($max != '') && ($len $max)))
    return 
FALSE;
  return 
$string;


TTFN

BFG
__________________
SELECT * FROM MANAGEMENT WHERE CLUE > 0; NO RESULTS FOUND
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-03-06
Swiss's Avatar
memoryfinder.co.uk
 
Join Date: Jun 2005
Location: Wiltshire, UK
Posts: 343
Thanks: 0
Thanked 0 Times in 0 Posts
Swiss is an unknown quantity at this point
I normally just run input through htmlentities()
__________________
Kris
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-03-06
Registered User
 
Join Date: Jun 2004
Posts: 46
Thanks: 0
Thanked 0 Times in 0 Posts
markschok is an unknown quantity at this point
  javascript and php

I use a javascript that verifies each or as many of the form elements I want.
It does it by checking the form text box when it looses focus and checks the text against a list of banned words terms. It was originaly written to stop any swearies being used but stops code too. It pops up a warning if it finds any and takes the user back to the box they've just filled so the user will know you're preventing any shennanigans. If they sneak something past I haven't accounted for then a php cleaner could double check before pocessing. Remember PHP has a built in stripHTML command that you could use if you want to stop them posting tags.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #5 (permalink)  
Old 07-03-06
Registered User
 
Join Date: Mar 2004
Location: Reading, UK
Posts: 301
Thanks: 0
Thanked 0 Times in 0 Posts
dmorison is an unknown quantity at this point
Hey BFG;

A little modification to your reg_exp and you can do the length verifcation as well...

PHP Code:
<?php
  
// regular expressions to test for various input formats and database types
  
$tests["varchar_1_255"] = "^[0-9a-zA-Z[:punct:] ]{1,255}$";
  
$tests["ip_address"] = "^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$";

  function 
validate($text,$test)
  {
    return 
ereg($test,$text);
  }

  
$text "Check this!";

  if (!
validate($text,$tests["varchar_1_255"]))
  {
    print 
"Invalid entry!";
  }
?>
Of course, regardless of any client or server side form validation you must always use a function like mysql_escape_string() when using any untrusted input in the construction of an SQL statement.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Internal PHP Processing Error (#99911) Donk Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 1 20-02-06 05:50 PM
mysql user area chrissy The Affiliate Marketing Lounge 1 16-01-06 05:11 PM
Anyone anygood with xml, php, mysql and Affiliate Window AnnonnyMouse The Affiliate Marketing Lounge 1 23-09-04 11:00 AM
PHP - No input file specified. - Problem Barry Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 1 02-08-04 10:57 AM
PHP or Browser Timeout? Barry Widgets, Coding, AJAX, PHP - Technology & Affiliate Marketing 6 28-04-04 01:04 PM


Affiliate Marketing RSS Feeds - Contact Us - Affiliate Marketing - Archive - Privacy Statement - Top

Content Relevant URLs by vBSEO 3.2.0 RC7