Kayako Logo
Consideration Queue (V4) Feature requests in this forum are queued for consideration in Version 4 of the product line.

Reply
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  (#1) Old
Jamie Edwards Offline
Operations Manager
 
Jamie Edwards's Avatar
 
Posts: 4,306
Join Date: Jan 2006
Location: UK

SupportSuite
Owned License

Code -> Automatic POST and GET data sanitization - 16-12-2007, 06:59 PM

I propose a set-it-and-forget-it sanitization technique for POST and GET data.

While not suggesting the exact code, class structure or even use of classes I have used to describe the feature, something along the same lines may be useful.

The idea is best suggested in code:

PHP Code:
<?php

    
require_once("UserDataObject.class.php");

    
// We want to get some post data.
    // Create our UserDataObject and pass it $_POST
    
$postdata = new UserDataObject$_POST );

    
// Get something out of it with the knowledge that it is safe
    
$kbid $postdata->get_var("id");        // Effectivley gets sanitzed $_POST['id']
       
?>
And the contents of UserDataObject.class.php:
PHP Code:
<?php

    
class UserDataObject
    
{
       
        private 
$data;

        
__construct$d )
        {
            
$this->data $d;
        }

        public function 
get_var$key )
        {
            return 
$this->sanitize$this->postdata[$key] );
        }

        private function 
sanitize$data )
        {
            
// data to sanitize here.. remove quotes, add slashes, whatever
        
}

        private 
__set() { }
        private 
__get() { }
       
    }
       
?>


Jamie Edwards (jamie.edwards ]at[ kayako.com)
----------------------------------------------------------------
---
  • New to the forum? New user's guide here.
  • Submit bug reports here.
  • Submit support tickets via the members area.
  • Submit sales queries either via live chat or via e-mail.
  • There is no official ETA on Version 4.

Last edited by Jamie Edwards : 16-12-2007 at 07:02 PM.
   
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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

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




Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.1.0

Kayako provides online help desk software and support solutions; enabling companies to improve their support and reduce costs.

Our three main products include: SupportSuite, eSupport and LiveResponse



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46