ultimix
database_logger.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 $UserAlgorithms = false;
39 
50  static $QueryName = 'undefined';
51 
66  function __construct()
67  {
68  try
69  {
70  }
71  catch( Exception $e )
72  {
73  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
74  }
75  }
76 
91  function set_query_name( $theQueryName )
92  {
93  self::$QueryName = $theQueryName;
94  }
95 
114  private function get_owner()
115  {
116  try
117  {
118  if( $this->UserAlgorithms === false )
119  {
120  $this->UserAlgorithms = get_package( 'user::user_algorithms' );
121  }
122 
123  $Owner = $this->UserAlgorithms->get_login();
124 
125  return( $Owner );
126  }
127  catch( Exception $e )
128  {
129  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
130  }
131  }
132 
159  function log_query( $Query , $Start , $DBLogging )
160  {
161  try
162  {
163  $End = microtime( true );
164  if( $DBLogging )
165  {
166  $Owner = $this->get_owner();
167  $DBO->query(
168  "INSERT INTO umx_action ".
169  "( alias , description , owner , ip , action_date, execute_time , session ) VALUES ( '".
170  htmlspecialchars( self::$QueryName , ENT_QUOTES )."' , '".
171  htmlspecialchars( $Query , ENT_QUOTES )."' , '$Owner' , '".$_SERVER[ 'REMOTE_ADDR' ].
172  "' , NOW() , '".( $End - $Start )."' , '".self::$Session."' )"
173  );
174  $DBO->query( 'COMMIT' );
175  }
176  }
177  catch( Exception $e )
178  {
179  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
180  }
181  }
182  }
183 
184 ?>