From 40acb0f99fe7fad6ee3231c653811e5453d3a844 Mon Sep 17 00:00:00 2001 From: z0rglub Date: Sat, 3 Jan 2004 19:47:36 +0000 Subject: add functions pwg_write_debug, pwg_debug, pwg_query git-svn-id: http://piwigo.org/svn/branches/release-1_3@243 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/functions.inc.php b/include/functions.inc.php index 5eeb2f4a7..8f0011756 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -423,4 +423,47 @@ function notify( $type, $infos = '' ) @mail( $to, $subject, $content, $headers, $options ); } } + +function pwg_write_debug() +{ + global $debug; + + $fp = @fopen( './log/debug.log', 'a+' ); + fwrite( $fp, "\n\n" ); + fwrite( $fp, $debug ); + fclose( $fp ); +} + +function pwg_query( $query ) +{ + global $count_queries,$queries_time; + + $start = get_moment(); + $output = ''; + + $count_queries++; + $output.= '

['.$count_queries.'] '.$query; + $result = mysql_query( $query ); + $time = get_moment() - $start; + $queries_time+= $time; + $output.= '('.number_format( $time, 3, '.', ' ').' s)'; + $output.= '('.number_format( $queries_time, 3, '.', ' ').' s)'; + + // echo $output; + + return $result; +} + +function pwg_debug( $string ) +{ + global $debug,$t2,$count_queries; + + $now = explode( ' ', microtime() ); + $now2 = explode( '.', $now[0] ); + $now2 = $now[1].'.'.$now2[1]; + $time = number_format( $now2 - $t2, 3, '.', ' ').' s'; + $debug.= '['.$time.', '; + $debug.= $count_queries.' queries] : '.$string; + $debug.= "\n"; +} ?> \ No newline at end of file -- cgit v1.2.3