58 $this->SecurityParser =
get_package(
'security::security_parser' ,
'last' , __FILE__ );
59 $this->String =
get_package(
'string' ,
'last' , __FILE__ );
60 $this->SupportedDataTypes =
get_package(
'security::supported_data_types' ,
'last' , __FILE__ );
104 foreach( $Array as $k => $v )
106 if( strpos( $k , $Prefix ) !==
false )
114 catch( Exception $e )
171 catch( Exception $e )
211 function get_value( &$Array , $Field , $Type =
'set' , $DefaultValue =
'_throw_exception' )
215 if( isset( $Array[ $Field ] ) && $Type !==
'set' )
217 if( $this->Security ===
false )
219 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
221 return( $this->Security->get( $Array[ $Field ] , $Type ) );
224 return( $this->handle_default_set( $Array , $Field , $Type , $DefaultValue ) );
226 catch( Exception $e )
254 private function merge_globals( $Mode )
260 $Data = $Mode &
POST ? array_merge( $Data , $_POST ) : $Data;
262 $Data = $Mode &
GET ? array_merge( $Data , $_GET ) : $Data;
264 $Data = $Mode &
COOKIE ? array_merge( $Data , $_COOKIE ) : $Data;
266 $Data = $Mode &
SESSION ? array_merge( $Data , $_SESSION ) : $Data;
268 $Data = $Mode &
SERVER ? array_merge( $Data , $_SERVER ) : $Data;
272 catch( Exception $e )
312 private function handle_default_set( &$Data , $Field , $Type , $DefaultValue )
316 if( $Type ===
'set' )
318 return( isset( $Data[ $Field ] ) );
322 if( $DefaultValue ===
'_throw_exception' )
324 throw(
new Exception(
"Field '$Field' was not found" ) );
328 return( $DefaultValue );
332 catch( Exception $e )
364 private function handle_get( $Field , $Mode )
368 if( ( $Mode &
POST ) && isset( $_POST[ $Field ] ) )
370 return( $_POST[ $Field ] );
372 elseif( ( $Mode &
GET ) && isset( $_GET[ $Field ] ) )
374 return( $_GET[ $Field ] );
376 elseif( ( $Mode &
COOKIE ) && isset( $_COOKIE[ $Field ] ) )
378 return( $_COOKIE[ $Field ] );
380 elseif( ( $Mode &
SESSION ) && isset( $_SESSION[ $Field ] ) )
382 return( $_SESSION[ $Field ] );
384 elseif( ( $Mode &
SERVER ) && isset( $_SERVER[ $Field ] ) )
386 return( $_SERVER[ $Field ] );
390 catch( Exception $e )
426 private function fetch_data( $Field , $Data , $Mode , &$Return )
432 $Data = array_keys( $Data );
433 $FilterFunction = create_function(
'$e' ,
"return( strpos( \$e , '$Field' ) === 0 );" );
434 $Data = array_filter( $Data , $FilterFunction );
435 foreach( $Data as $d )
437 $Return [] = str_replace( $Field ,
'' , $d );
442 foreach( $Data as $k => $v )
444 if( strpos( $k , $Field ) === 0 )
446 $Return[ str_replace( $Field ,
'' , $k ) ] = $v;
451 catch( Exception $e )
491 function get_global( $Field , $Type , $Mode , $DefaultValue =
'_throw_exception' )
495 if( $this->Security ===
false )
497 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
501 $Data = $this->merge_globals( $Mode );
504 $this->fetch_data( $Field , $Data , $Mode , $Return );
506 return( $this->Security->get( $Return , $Type ) );
509 if( $Type !==
'set' && ( $Value = $this->handle_get( $Field , $Mode ) ) !== false )
511 return( $this->Security->get( $Value , $Type ) );
513 $Data = $this->merge_globals( $Mode );
514 return( $this->handle_default_set( $Data , $Field , $Type , $DefaultValue ) );
516 catch( Exception $e )
544 if( $this->Security ===
false )
546 $this->Security =
get_package(
'security' ,
'last' , __FILE__ );
549 return( $this->Security->get( $_POST ,
'string' ) );
551 catch( Exception $e )