//========================= VALIDATION methods =======================
	
	/** Main method for validating GET, POST and COOKIE data.
	 * To be called AFTER validateServerVars so that $this->validServerVars can be used as a context
	 * (like for browser specific sanitization)
	 * @param array $data, if magic_quotes_gpc slashes must be stripped beforehand
	 * @throws PntValidationException if $this->gpcValidationFatal with message about the last validation that failed
	 * @return array with valid data 
	 */
	function validateGpc($data, $cookies=false, $context='') {
		$result = array();
		$this->error = false;
    	forEach($data as $key => $value) {
    		$errorMessage = $cookies 
    			? $this->validateCookieName($key)
    			: $this->validateParamName($key);
    		if ($errorMessage) {
    			$this->error = $cookies ? 'cookie name' : 'param name';
    			$this->logValidationWarning($this->error, $context.$key, $errorMessage);
    			continue; //do not return the param or cookie with the invalid name
    		}
    		if (is_array($value)) {
    			$result[$key] = $this->validateGpc($value, $cookies, $context.$key.'.');
    		} else {
	    		$sanitizedValue = $this->sanitizeGpc($key, $value);
	    		$errorMessage = $this->validateGpcValue($key, $sanitizedValue);
	    		if ($errorMessage) {
	    			$this->logValidationWarning($context.$key, $sanitizedValue, $errorMessage);
	    			$this->error = $context.$key;
	    		} else {
	    			$result[$key] = $sanitizedValue;
	    		}
    		}
    	}
    	if ($this->error && $this->gpcValidationFatal)
    		throw new PntValidationException("$this->gpcValidationFailed $this->error");
    	
		return $result;
	}