• Home
  • About Me
  • Contact
  • Things to do Before I Turn 30

the bofe blog

a twenty something IT professional with a few things to say

Feeds:
Posts
Comments

Array Map

March 22, 2006 by bofe

Easily one of the most useful functions in PHP.

In order to protect against SQL/code injection attacks, developers are encouraged to sanitize your input. This gets to be a little bit of a hassle applying sanitation functions to 200 form variables and 8 URL variables.

The answer? Array Map.

$_GET = array_map(“sanitize”, $_GET);
$_POST = array_map(“sanitize”, $_POST);

Sanitize is a user-defined function that employs strip_tags and trim, among other hacker defeating elements.

It’s that easy. )

Posted in Personal | Tagged Personal | 1 Comment

One Response

  1. on March 25, 2006 at 22:40 Stephen Mizell

    Very cool, never heard of that one. I’m going to write that down for future use.

    One method I have seen before is the use of the sprintf() function and the mysql_real_escape_string() function. The page that kinda explains it better than I could is at:
    http://us2.php.net/manual/en/function.mysql-real-escape-string.php

    Of course, if you’re using Ruby on Rails, it does this all for you.

    Post.find(:all, :conditions => ["shortname = ?", shortname])

    The stuff in the square brackets works much like sprintf() in php.

    Of course you could just put Post.do_everything and rails will do everything for you, even draw your graphics in Photoshop.



Comments are closed.

  • Pages

    • About Me
    • Contact
    • Things to do Before I Turn 30
  • Recent Comments

    • Some Betty on Why the hate?
    • stinkypie on Why the hate?
    • stinkypie on Why the hate?
    • JohnO on Why the hate?
    • Yee on a pancake on Why the hate?
    • adam on Why the hate?
    • JohnO on Why the hate?
    • deezil on Why the hate?
    • Yee on a pancake on Why the hate?
    • Dave on Why the hate?
  • Recently Popular

    • Guide to Backing up your Virtual Machines with VMware Consolidated Backup (VCB)
    • Sync Google Calendar and Facebook Events
    • How to Use Excel 2007 and Goal Seek to calculate what the minimum grade you need on a final exam
    • VMware Consolidated Backup: Explained
    • Firefox 3 Constantly Crashes -- advice?
    • Problem with Orphaned Users/Logins in SQL Server 2005 Migration
    • Facebook 12 Step Program
    • Sortables with Scriptaculous, PHP, and MySQL in 6 Easy Steps
    • modifying osCommerce - [part 2 - Functions, Cases, Blocks Oh My]
    • point(x,y) versus point(lat, long) or What I Learned Today
  • Archives

  • Tags

    4815162342 advertising ajax apple bofehax byebye css dba delicious links development drm facebook finance firefox Geek gis Google imadork linux mememe Meta metoo money murray Music mysql owensboro Personal personal finance personalfinance philosophy php rss scriptaculous sqlserver sqlserver2005 Tablet PC Uncategorized vmware web Weblogs Web Standards whitewhine work wtf
  • Meta

    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.com

Blog at WordPress.com.

Theme: Mistylook by Sadish.