<?
//    FormCheck by Brian Bothwell (sysrage@sysrage.net)
//    Class for all GET/POST data. If stupid magic_quotes_gpc is on,
//    slashes will be stripped.
//
// Example Usage (checks if $_POST['testVar'] is a 3-5 character string):
//        require('forms.php');
//        if ($aForm->checksize('post','testVar'),3,5) {
//            if (!$aForm->validate('post','testVar','str')) {
//                $errorMsg = 'Error in validation.';
//            }
//        } else { $errorMsg = 'Error in size check'; }
//
//    -------------------------
//    showVars() - print out arrays of get/post vars.
//    showGets() - print out array of get vars.
//    showPosts() - print out array of post vars.
//
//    checksize($ftype,$fname,$smin,$smax) - Check the size of a form item.
//        NOTE: $validData array is not altered but $error array is. Use validate()
//        AFTER you call this function.
//            $ftype - Field type. Either 'POST' or 'GET'.
//            $fname - Name of input field. Can be the name of a field (name), the
//            name of an array of fields (name[]), or the name of a specific index
//            in an array (name[1]).
//            $smin - Minimum size/length of field.
//            $smax - Minimum size/length of field.
//
//    validate($ftype,$fname,$vtype='any',$emsg='',$req=True) -
//        Validate form item. If only $ftype and $fname are set,
//        it will be assumed that the field is required but can
//        contain any type of data. An appropriate $error message will
//        be set if the field is empty. If a non-required item fails
//        check, it will be unset in $validData array but not $[pg]Var array! 
//            $ftype - Field type. Either 'POST' or 'GET'.
//            $fname - Name of input field. Can be the name of a field (name), the
//            name of an array of fields (name[]), or the name of a specific index
//            in an array (name[1]).
//            $vtype - Valid data type:
//                'any' - non-empty value (DEFAULT)
//                'str' - string value
//                'int' - integer
//                'num' - numeric value
//                'nozero' - non-zero number 
//                'money' - currency format
//                'alpha' - alphabetic characters
//                'yesno' - One of: YES, NO, Y, N
//                'state' - U.S. state. (2 letter abrv.)
//                'uszip' - U.S. Zipcode. (98765 or 98765-4321)
//                'phone' - U.S. Phone Number
//                'email' - valid e-mail address
//                'year' - year or range of years
//                'date' - date
//                'pass' - valid password
//                'ip' - ip address
//                'url' - valid URL
//            $emsg - Error message to use if data is invalid.
//            $req - This field is required. (TRUE or FALSE) (Default is TRUE)
//            If a field is not required no errors will be added to $error array.
//
//    _getData() - Read GET/POST vars into arrays.
//    _isAny() - Check if input contains any data.
//    _isString() - Check if input contains a string.
//    _isInteger() - Check if input contains an integer.
//    _isNumber() - Check if input contains a numeric value.
//    _isNozero() - Check if input contains a non-zero numeric value.
//    _isMoney() - Check if input contains a currency value.
//    _isAlpha() - Check if input contains alphabetic characters.
//    _isYesNo() - Check if input contains YES/Y/NO/N.    
//    _isState() - Check if input contains a US state abbreviation.
//    _isUSZip() - Check if input contains a U.S. Zipcode.
//    _isUSPhone() - Check if input contains a U.S. phone number.
//    _isEmail() - Check if input contains a valid e-mail address.
//    _isYear() - Check if input contains a year or range of years.
//    _isDate() - Check if input contains a date value.
//    _isPassword() - Check if input contains a valid password.
//    _isIP() - Check if input contains an IP address.
//    _isURL() - Check if input contains a valid URL.
//
// ----------------------------------------------------------------
class FormCheck
{   
    var 
$pVar = array(); // Array of POST vars.
    
var $gVar = array(); // Array of GET vars.
    
var $error = array(); // Array of errors.
    
var $validData = array(); // Array of validated data.

    
function FormCheck()
    {
        
$this->_validData = array();
        
$this->_getData();
    }

// showVars() - print out arrays of get/post vars.
    
function showVars()
    {
        echo 
"<hr />POST:<pre>";
        
print_r($this->pVar);
        echo 
"</pre>";
        echo 
"<hr />GET:<pre>";
        
print_r($this->gVar);
        echo 
"</pre><hr />";
    }

// showGets() - print out array of get vars.    
    
function showGets()
    {
        echo 
"<hr />GET:<pre>";
        
print_r($this->gVar);
        echo 
"</pre><hr />";
    }

// showPosts() - print out array of post vars.
    
function showPosts()
    {
        echo 
"<hr />POST:<pre>";
        
print_r($this->pVar);
        echo 
"</pre><hr />";
    }

//    checksize($ftype,$fname,$smin,$smax) - Check the size of a form item.
    
function checksize($ftype,$fname,$smin=0,$smax='')
    {
        
// Read in data to validate.
        
if (strtoupper($ftype) == "POST") {
            if (
preg_match("/^(.+)\[(.+)\]/i",$fname,$varRegs)) {
                
$varData $this->pVar[$varRegs[1]][$varRegs[2]];
            } elseif (
preg_match("/^(.+)\[\]/i",$fname,$varRegs)) {
                
$varData $this->pVar[$varRegs[1]];
            } else { 
$varData $this->pVar[$fname]; }
        }
        if (
strtoupper($ftype) == "GET") {
            if (
preg_match("/^(.+)\[(.*)?\]/i",$fname,$varRegs)) {
                
$varData $this->gVar[$varRegs[1]][$varRegs[2]];
            } elseif (
preg_match("/^(.+)\[\]/i",$fname,$varRegs)) {
                
$varData $this->gVar[$varRegs[1]];
            } else { 
$varData $this->gVar[$fname]; }
        }

        
// Validate.
        
if (is_array($varData)) {
            foreach(
$varData as $vData) {
                if (
strlen($vData) < $smin) {
                    
$emsg "Length of field is too short.";
                    
$this->error[$fname] = array('name'=>$fname,'value'=>$vData,'emsg'=>$emsg);
                    return 
false;
                } elseif (
strlen($vData) > $smax && $smax 0) {
                    
$emsg "Length of field is too long.";
                    
$this->error[$fname] = array('name'=>$fname,'value'=>$vData,'emsg'=>$emsg);
                    return 
false;
                }
            }
            return 
true;
        } else {
            if (
strlen($varData) < $smin) {
                
$emsg "Length of field is too short.";
                
$this->error[$fname] = array('name'=>$fname,'value'=>$varData,'emsg'=>$emsg);
                return 
false;
            } elseif (
strlen($varData) > $smax && $smax 0) {
                
$emsg "Length of field is too long.";
                
$this->error[$fname] = array('name'=>$fname,'value'=>$varData,'emsg'=>$emsg);
                return 
false;
            } else { return 
true; }
        }
    }
    
// validate() - validate a form item.
    
function validate($ftype,$fname,$vtype='any',$emsg='',$req=True)
    {
        
// Read in data to validate.
        
if (strtoupper($ftype) == "POST") {
            if (
preg_match("/^(.+)\[(.+)\]/i",$fname,$varRegs)) {
                
$varData $this->pVar[$varRegs[1]][$varRegs[2]];
            } elseif (
preg_match("/^(.+)\[\]/i",$fname,$varRegs)) {
                
$varData $this->pVar[$varRegs[1]];
            } else { 
$varData $this->pVar[$fname]; }
        }
        if (
strtoupper($ftype) == "GET") {
            if (
preg_match("/^(.+)\[(.*)?\]/i",$fname,$varRegs)) {
                
$varData $this->gVar[$varRegs[1]][$varRegs[2]];
            } elseif (
preg_match("/^(.+)\[\]/i",$fname,$varRegs)) {
                
$varData $this->gVar[$varRegs[1]];
            } else { 
$varData $this->gVar[$fname]; }
        }

        
// Validate.
        
$funky = array('any'=>'_isAny''str'=>'_isString''int'=>'_isInteger',
                    
'num'=>'_isNumber''nozero'=>'_isNozero''money'=>'_isMoney',
                    
'alpha'=>'_isAlpha''yesno'=>'_isYesNo''state'=>'_isState',
                    
'uszip'=>'_isUSZip''phone'=>'_isUSPhone''email'=>'_isEmail',
                    
'year'=>'_isYear''date'=>'_isDate''pass'=>'_isPassword',
                    
'ip'=>'_isIP''url'=>'_isURL');

        
$errMsgs = array(
            
'any' => 'This field is required.',
            
'str' => 'This field must contain a string.',
            
'int' => 'This field must contain an integer.',
            
'num' => 'This field must contain a numeric value.',
            
'nozero' => 'This field must contain a non-zero numeric value.',
            
'money' => 'This field must contain a currency value.',
            
'alpha' => 'This field must contain alphabetic characters.',
            
'yesno' => 'This field must contain a yes or no value.',
            
'state' => 'This field must contain a 2 letter US state abbr.',
            
'uszip' => 'This field must contain a U.S. Zipcode.',
            
'phone' => 'This field must contain a U.S. phone number.',
            
'email' => 'This field must contain an e-mail address.',
            
'year' => 'This field must contain a year or range of years.',
            
'date' => 'This field must contain a date value.',
            
'pass' => 'This field must contain a valid password.',
            
'ip' => 'This field must contain an IP address.',
            
'url' => 'This field must contain a valid URL.'
        
);
        if (
array_key_exists($vtype,$funky)) {
            
$valFunc $funky[$vtype];
            if (!
$this->{$valFunc}($varData)) {
                if (
$req) {
                    if (
trim($emsg)=="") { $emsg $errMsgs[$vtype]; }
                    
$this->error[$fname] = array('name'=>$fname,'value'=>$varData,'emsg'=>$emsg);
                }
                return 
false;
            }
        }

        
// If valid, add to $validData array.
        
if (is_array($varData)) {
            foreach(
$varData as $vData) { $this->validData[$fname][] = $vData; }
        } elseif (
preg_match("/^(.+)\[(.+)\]/i",$fname,$varRegs)) {
                
$this->validData[$varRegs[1]][$varRegs[2]] = $varData;
        } else { 
$this->validData[$fname] = $varData; }

        return 
true;
    }

/* *** Start of validation functions *** */

// _isAny() - Check if input contains any data.
    
function _isAny($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) { if (trim($v) == "") { return false; } }
            return 
true;
        } else {
            if (
trim($value) == "") { return false; } else { return true; }
        }
    }

// _isString() - Check if input contains a string.
    
function _isString($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (!
is_string($v) || strlen($v) < 1) { return false; }
            }
            return 
true;
        } else {
            if (!
is_string($value) || strlen($value) < 1) { return false; } else { return true; }
        }
    }
    
// _isInteger() - Check if input contains an integer.
    
function _isInteger($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                
$valuecp $v;
                
settype($valuecp,"integer");
                if (
strval($valuecp) != $v) { return false; }
            }
            return 
true;
        } else {
            
$valuecp $value;
            
settype($valuecp,"integer");
            if (
strval($valuecp) != $value) { return false; }
            return 
true;
        }
    }

// _isNumber() - Check if input contains a numeric value.    
    
function _isNumber($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                
$valuecp $v;
                
settype($valuecp"double");
                if (
strval($valuecp) != $v) { return false; }
            }
            return 
true;
        } else {
            
$valuecp $value;
            
settype($valuecp"double");
            if (
strval($valuecp) != $value) { return false; }
            return 
true;
        }
    }

// _isNozero() - Check if input contains a non-zero numeric value.    
    
function _isNozero($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (!
$this->_isNumber($v) || $v == 0) { return false; }
            }
            return 
true;
        } else {
            if (!
$this->_isNumber($value) || $value == 0) { return false; }
            return 
true;
        }
    }

// _isMoney() - Check if input contains a currency value.    
    
function _isMoney($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^(\\\$)?\d+(,\d+)?(\.\d{2})?$/",$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^(\\\$)?\d+(,\d+)?(\.\d{2})?$/",$value)) { return false; }
            return 
true;
        }
    }

// _isAlpha() - Check if input contains alphabetic characters.    
    
function _isAlpha($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^[a-zA-Z]+$/",$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^[a-zA-Z]+$/",$value)) { return false; }
            return 
true;
        }
    }

// _isYesNo() - Check if input contains YES/Y/NO/N.    
    
function _isYesNo($value)
    {
        
$matches = array('YES','NO','Y','N');
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
in_array(strtoupper($v),$matches)) { return false; }
            }
            return 
true;
        } else {
            if (! 
in_array(strtoupper($value),$matches)) { return false; }
            return 
true;
        }
    }
    
// _isState() - Check if input contains a US state abbreviation.    
    
function _isState($value)
    {
        
// 50 states, Washington DC, Puerto Rico and the US Virgin Islands
        
$SCodes = array (
                
"AK"    =>    1,    "AL"    =>    1,    "AR"    =>    1,    "AZ"    =>    1,    "CA"    =>    1,
                
"CO"    =>    1,    "CT"    =>    1,    "DC"    =>    1,    "DE"    =>    1,    "FL"    =>    1,
                
"GA"    =>    1,    "HI"    =>    1,    "IA"    =>    1,    "ID"    =>    1,    "IL"    =>    1,
                
"IN"    =>    1,    "KS"    =>    1,    "KY"    =>    1,    "LA"    =>    1,    "MA"    =>    1,
                
"MD"    =>    1,    "ME"    =>    1,    "MI"    =>    1,    "MN"    =>    1,    "MO"    =>    1,
                
"MS"    =>    1,    "MT"    =>    1,    "NC"    =>    1,    "ND"    =>    1,    "NE"    =>    1,
                
"NH"    =>    1,    "NJ"    =>    1,    "NM"    =>    1,    "NV"    =>    1,    "NY"    =>    1,
                
"OH"    =>    1,    "OK"    =>    1,    "OR"    =>    1,    "PA"    =>    1,    "PR"    =>    1,
                
"RI"    =>    1,    "SC"    =>    1,    "SD"    =>    1,    "TN"    =>    1,    "TX"    =>    1,
                
"UT"    =>    1,    "VA"    =>    1,    "VI"    =>    1,    "VT"    =>    1,    "WA"    =>    1,
                
"WI"    =>    1,    "WV"    =>    1,    "WY"    =>    );

        if (
is_array($value)) {
            foreach(
$value as $v) {
                
$v strtoupper($v);
                if(!isset(
$SCodes[$v])) { return false; }
            }
            return 
true;
        } else {
            
$value strtoupper($value);
            if(!isset(
$SCodes[$value])) { return false; }
            return 
true;
        }
    }

// _isUSZip() - Check if input contains a U.S. Zipcode.    
    
function _isUSZip($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^[0-9]{5}(-[0-9]{4})?$/",$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^[0-9]{5}(-[0-9]{4})?$/",$value)) { return false; }
            return 
true;
        }
    }

// _isUSPhone() - Check if input contains a U.S. phone number.    
    
function _isUSPhone($value)
    {
        
$strippers = array('(',')','-',' ');
        if (
is_array($value)) {
            foreach(
$value as $v) {
                
$v str_replace($strippers,'',$v);
                if (!
$this->_isInteger($v)) { return false; }
                if (
strlen($v) != && strlen($v) != 10 && strlen($v) != 11) { return false; }
            }
            return 
true;
        } else {
            
$value str_replace($strippers,'',$value);
            if (!
$this->_isInteger($value)) { return false; }
            if (
strlen($value) != && strlen($value) != 10 && strlen($value) != 11) { return false; }
            return 
true;
        }
    }

// _isEmail() - Check if input contains a valid e-mail address.    
    
function _isEmail($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^(([^<>;()[\]\\.,;:@\"]+(\.[^<>()[\]\\.,;:@\"]+)*)|(\".+\"))@((([a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))\.)*(([a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))$/"$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^(([^<>;()[\]\\.,;:@\"]+(\.[^<>()[\]\\.,;:@\"]+)*)|(\".+\"))@((([a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))\.)*(([a-zA-Z]([-a-zA-Z0-9]*[a-zA-Z0-9])?)|(#[0-9]+)|(\[((([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\.){3}(([01]?[0-9]{0,2})|(2(([0-4][0-9])|(5[0-5]))))\]))$/"$value)) { return false; }
            return 
true;
        }
    }

// _isYear() - Check if input contains a year or range of years. Can be 2 or 4 digits.    
    
function _isYear($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^\d{2,4}(-\d{2,4})?$/"$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^\d{2,4}(-\d{2,4})?$/"$value)) { return false; }
            return 
true;
        }
    }

// _isDate() - Check if input contains a date value.    
    
function _isDate($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^((((0?[13578])|(1[02]))[\/|\-|\.]?((0?[1-9]|[0-2][0-9])|(3[01])))|(((0?[469])|(11))[\/|\-|\.]?((0?[1-9]|[0-2][0-9])|(30)))|(0?[2][\/\-\.]?(0?[1-9]|[0-2][0-9])))[\/\-\.]?\d{2,4}$/"$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^((((0?[13578])|(1[02]))[\/|\-|\.]?((0?[1-9]|[0-2][0-9])|(3[01])))|(((0?[469])|(11))[\/|\-|\.]?((0?[1-9]|[0-2][0-9])|(30)))|(0?[2][\/\-\.]?(0?[1-9]|[0-2][0-9])))[\/\-\.]?\d{2,4}$/"$value)) { return false; }
            return 
true;
        }
    }

// _isPassword() - Check if input contains a password value.    
    
function _isPassword($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^[a-zA-Z0-9]+[a-zA-Z0-9\-_\.\,\$!@#%\^&\*~`\'\"\|]+$/"$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^[a-zA-Z0-9]+[a-zA-Z0-9\-_\.\,\$!@#%\^&\*~`\'\"\|]+$/"$value)) { return false; }
            return 
true;
        }
    }

// _isIP() - Check if input contains an IP address.
    
function _isIP($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/"$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])$/"$value)) { return false; }
            return 
true;
        }
    }

// _isURL() - Check if input contains a valid URL.
    
function _isURL($value)
    {
        if (
is_array($value)) {
            foreach(
$value as $v) {
                if (! 
preg_match("/^(http|https|ftp)\:\/\/([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$/"$v)) { return false; }
            }
            return 
true;
        } else {
            if (! 
preg_match("/^(http|https|ftp)\:\/\/([a-zA-Z0-9\.\-]+(\:[a-zA-Z0-9\.&%\$\-]+)*@)*((25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9])\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[1-9]|0)\.(25[0-5]|2[0-4][0-9]|[0-1]{1}[0-9]{2}|[1-9]{1}[0-9]{1}|[0-9])|localhost|([a-zA-Z0-9\-]+\.)*[a-zA-Z0-9\-]+\.(com|edu|gov|int|mil|net|org|biz|arpa|info|name|pro|aero|coop|museum|[a-zA-Z]{2}))(\:[0-9]+)*(\/($|[a-zA-Z0-9\.\,\?\'\\\+&%\$#\=~_\-]+))*$/"$value)) { return false; }
            return 
true;
        }
    }

    
/* *** End of validation functions *** */

// _getData() - Read GET/POST vars into arrays.
    
function _getData()
    {
        foreach(
$_POST as $newVal => $newData) {
            if (
is_array($newData)) {
                
$this->pVar[$newVal] = array();
                foreach(
$newData as $nData) {
                    if (
get_magic_quotes_gpc() == 0) { $this->pVar[$newVal][] = $nData; } 
                    else { 
$this->pVar[$newVal][] = stripslashes($nData); }
                }
            } else {
                    if (
get_magic_quotes_gpc() == 0) { $this->pVar[$newVal] = $newData; } 
                    else { 
$this->pVar[$newVal] = stripslashes($newData); }
            }
        }
        foreach(
$_GET as $newVal => $newData) {
            if (
is_array($newData)) {
                
$this->gVar[$newVal] = array();
                foreach(
$newData as $nData) {
                    if (
get_magic_quotes_gpc() == 0) { $this->gVar[$newVal][] = $nData; } 
                    else { 
$this->gVar[$newVal][] = stripslashes($nData); }
                }
            } else {
                    if (
get_magic_quotes_gpc() == 0) { $this->gVar[$newVal] = $newData; } 
                    else { 
$this->gVar[$newVal] = stripslashes($newData); }
            }
        }
    }

}

$aForm = new FormCheck();
?>