Location: PHPKode > scripts > SecureLab > securelab/securelab-get.php
<?php

 class GetDataHandler implements ArrayAccess   {
	
	private $ComponentStorage;
		
	private $GETConfiguration;
		
	public function __construct( $IncomingGET ) {
		
		global $POSTSecureLabFilter;
		
		@ include_once( SECURELAB_DIRECTORY . "system\configuration\SLConfiguration.Filters.Secured.php");
		
		@ $POSTSecureLabFilter = $SLPublicFiltersConfig["POST"];
		
		@ $this->GETConfiguration = $SLPublicFiltersConfig["GET"];
		
		@ $this->ComponentStorage = $IncomingGET;
		
	}
	
	
	public function offsetGet ( $IncomingOffset ) {
	  
		try {
	  
			if( strpos ( $IncomingOffset, "#" ) ) {
			
				// We don't know is working a newborn developer or not, so let's check for errors.
				
				$CurrentFilterApply = explode ( "#", $IncomingOffset, 2 );
				
				
				
				if( $CurrentFilterApply == "nofilter") {
				
					return $this->ComponentStorage[$CurrentFilterApply[0]];
				
				} elseif( substr( $CurrentFilterApply[1], 0, 4 ) == "exp[" ) {
				
					$ExArray = explode ( "exp[", $CurrentFilterApply[1] );
					
					$ExArray = explode ( "]", $ExArray[1] );
					
					$ExArray = explode ( "|", $ExArray[0] );
					
				} elseif( strpos($CurrentFilterApply[1], ",") ) {
				
					$FiltersArray = explode ( ",", $CurrentFilterApply[1] );
					
				}  else  {
				
					return SecureLabFilters::ApplyFilter( $this->ComponentStorage[$CurrentFilterApply[0]], $CurrentFilterApply[1] );
				
				}
				
				$AllowedExpressions = array( "num", "en", "ru", "+", "-", ".", ",", "!", "*", "'", "\"", "~", "<", ">",
											 "contol-base", "control-html", "@", "$", ":", ";", "/", "\\", "%", "^", "?",
											 "(", ")", "_", "=", "symb", "#" );
				
				if( $FiltersArray != null or $ExArray != null ) {
				
					if( $ExArray != null ) {
						
						$Filter = null;
					
						foreach( $ExArray as $KeyID => $Expression ) {
							
							if( in_array( $Expression, $AllowedExpressions ) ) {

								$Expression = strtr( $Expression, array( "en" => "A-Za-z", "num" => "0-9" ) );

								$Filter .= $Expression;
							
							}
						
						}
						
						preg_match_all("/[" . $Filter . "]*/", $this->ComponentStorage[$CurrentFilterApply[0]], $Match);
						
						$ResultToReturn = "";
						
						foreach ($Match[0] as $MatchKey => $MatchValue) {
						
							$ResultToReturn .= $MatchValue;
							
						}
						
						return $ResultToReturn;
					
					}
					
					
					if( $FiltersArray ) {
						
						$Content = $this->ComponentStorage[$CurrentFilterApply[0]];
						
						foreach( $FiltersArray as $KeyID => $FilterID ) {
						
							$Content = SecureLabFilters::ApplyFilter( $Content, $FilterID );
						
						}
						
						return $Content;
						
					}
					
				}
				
			} else {
			
				// Need to check the settings
				
				global $_SecureLabMainClass;
				
				if( $_SecureLabMainClass ) {
				
					return $_SecureLabMainClass->FiltersAPI->ApplyFilter( $this->ComponentStorage[$IncomingOffset], 1 );
				
				}  else  {
				
					return SecureLabFilters::ApplyFilter( $this->ComponentStorage[$IncomingOffset], 1 );
					
				}
			}
		
		}  catch( Exception $ErrorMsg )  {
		
			global $_SecureLabMainClass;
			
			@ $_SecureLabMainClass->DumpAPI->CreateDumpEvent( array(
				
				"ErrorReporterFile" => __FILE__,
					
				"ErrorReporterMessage" => $ErrorMsg->getMessage(),
				
				"ErrorOccuredObject" => __METHOD__,
				
				"ErrorIncomingEvent" => $IncomingOffset,
				
				"ErrorFileLine" => __LINE__
				
			) );
		
		}
		
	  }
	  
	  public function __invoke( $Needle ) {
	  
		if( $Needle == "" ) {
			
			if( empty( $this->ComponentStorage ) ) {
			
				return true;
			
			}  else  {
			
				return false;
			
			}
		
		}
		
	  }
	  
	  // We need to define this functions for correct work of ArrayAccess option.
	  public function offsetExists ( $IncomingKey ) {
	  
		return isset ( $this->ComponentStorage[ $IncomingKey ] );
		
	  }

	  
	  public function offsetUnset ( $IncomingKey ) { 
	  
		unset($this->ComponentStorage[ $IncomingKey ]);
		
	  }

	  
	 

	  public function offsetSet ($IncomingKey, $ValueToRewrite) {
		
		try { 
			
			if( $this->GETConfiguration["ALLOW_REWRITING_VALUES"] == 0 ) {
			  
				throw new Exception( "Rewriting of GET is disallowed, key " . $IncomingKey );
			  
			}  else  {
		  
				$this->ComponentStorage[ $IncomingKey ] = $ValueToRewrite;
				
			}
		
		}  catch( Exception $ErrorMsg )  {

			global $_SecureLabMainClass;
			
			@ $_SecureLabMainClass->DumpAPI->CreateDumpEvent( array(
				
				"ErrorReporterFile" => __FILE__,
					
				"ErrorReporterMessage" => $ErrorMsg->getMessage(),
				
				"ErrorOccuredObject" => __METHOD__,
				
				"ErrorIncomingEvent" => $IncomingKey,
				
				"ErrorFileLine" => __LINE__
				
			) );
		
		}
	   
	  }
			
	}
	
	  
	 ?>
Return current item: SecureLab