ultimix

- Main Page
- Data Structures
- Files
- Examples

- File List
- Globals

data_filtration.php
Go to the documentation of this file.
1 <?php
2
3 /*
4 * This source code is a part of the Ultimix Project.
5 * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6 * it's own license wich could be found from the corresponding files or sources.
7 * This source code is provided "as is" without any warranties or garanties.
8 *
9 * Have a nice day!
10 *
11 * @url http://ultimix.sorceforge.net
12 *
13 * @author Alexey "gdever" Dodonov
14 */
15
26 class data_filtration_1_0_0{
27
38 var $String = false;
39
50 function __construct()
51 {
52 try
53 {
54 $this->String = get_package( 'string' , 'last' , __FILE__ );
55 }
56 catch( Exception $e )
57 {
58 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
59 }
60 }
61
84 function filter_http_data( $FiltrationScript )
85 {
86 try
87 {
88 return( $this->filter_data( array_merge( $_GET , $_POST ) , $FiltrationScript ) );
89 }
90 catch( Exception $e )
91 {
92 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
93 }
94 }
95
122 private function skip_element( &$Settings , $k )
123 {
124 try
125 {
126 if( $Settings->get_setting( 'keys' ) && is_integer( $k ) === false )
127 {
128 if( array_search( $k , $Settings->get_setting( 'keys' ) ) === false )
129 {
130 return( true );
131 }
132 }
133
134 return( false );
135 }
136 catch( Exception $e )
137 {
138 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
139 }
140 }
141
172 private function filter_data_by_keys( $Data , $FiltrationScript , &$Settings )
173 {
174 try
175 {
176 $Ret = array();
177 foreach( $Data as $k => $v )
178 {
179 if( $this->skip_element( $Settings , $k ) )
180 {
181 continue;
182 }
183 if( is_array( $v ) || is_object( $v ) )
184 {
185 if( ( $Tmp = $this->filter_data_by_keys( $v , $FiltrationScript , $Settings ) ) !== false )
186 {
187 $Ret[ $k ] = $Tmp;
188 }
189 }
190 elseif( !( $Settings->get_setting( 'filled' , false ) && strlen( $v ) == 0 ) )
191 {
192 $Ret[ $k ] = $v;
193 }
194 }
195 return( $Ret );
196 }
197 catch( Exception $e )
198 {
199 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
200 }
201 }
202
229 function filter_data( $Data , $FiltrationScript )
230 {
231 try
232 {
233 $Settings = get_package_object( 'settings::settings' , 'last' , __FILE__ );
234 $Settings->load_settings( $FiltrationScript );
235
236 if( $Settings->get_setting( 'keys' , false ) )
237 {
238 $Settings->set_setting( 'keys' , explode( ',' , $Settings->get_setting( 'keys' ) ) );
239 }
240
241 $Ret = $this->filter_data_by_keys( $Data , $FiltrationScript , $Settings );
242
243 return( count( $Ret ) ? $Ret : false );
244 }
245 catch( Exception $e )
246 {
247 $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
248 }
249 }
250 }
251
252 ?>