ultimix
security_markup.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 
27 
38  var $Security = false;
39 
50  function __construct()
51  {
52  try
53  {
54  $this->Security = get_package( 'security' , 'last' , __FILE__ );
55  }
56  catch( Exception $e )
57  {
58  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
59  }
60  }
61 
88  private function get_data_by_settings( $Name , &$Settings )
89  {
90  try
91  {
92  if( $Settings->get_setting( 'get' , false ) != false && $this->Security->get_g( $Name , 'set' ) )
93  {
94  return( $_GET );
95  }
96  elseif( $Settings->get_setting( 'post' , false ) != false && $this->Security->get_p( $Name , 'set' ) )
97  {
98  return( $_POST );
99  }
100  elseif( $Settings->get_setting( 'session' , false ) != false &&
101  $this->Security->get_s( $Name , 'set' ) )
102  {
103  return( $_SESSION );
104  }
105  elseif( $Settings->get_setting( 'cookie' , false ) != false && $this->Security->get_c( $Name , 'set' ) )
106  {
107  return( $_COOKIE );
108  }
109 
110  return( false );
111  }
112  catch( Exception $e )
113  {
114  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
115  }
116  }
117 
118  //TODO: cache content line for the main page
119 
150  private function get_value( $Name , $Type , &$Settings )
151  {
152  try
153  {
154  $Data = $this->get_data_by_settings( $Name , $Settings );
155 
156  if( $Data === false )
157  {
158  return( $Settings->get_setting( 'default' , '' ) );
159  }
160  else
161  {
162  return( $this->Security->get( $Data[ $Name ] , $Type ) );
163  }
164  }
165  catch( Exception $e )
166  {
167  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
168  }
169  }
170 
193  function compile_page_parameters( &$Settings )
194  {
195  try
196  {
197  $JSON = get_package( 'json' , 'last' , __FILE__ );
198 
199  $Code = $JSON->encode( array_merge( $_GET , $_POST ) );
200  $Code = str_replace( "'" , '&#039;' , $Code );
201 
202  return( $Code );
203  }
204  catch( Exception $e )
205  {
206  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
207  }
208  }
209 
240  function compile_http_param( &$Settings )
241  {
242  try
243  {
244  $Name = $Settings->get_setting( 'name' );
245  $Type = $Settings->get_setting( 'type' , 'string' );
246 
247  $Value = $this->get_value( $Name , $Type , $Settings );
248 
249  return( $Value );
250  }
251  catch( Exception $e )
252  {
253  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
254  }
255  }
256  }
257 
258 ?>