diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.inc.php | 43 | ||||
-rw-r--r-- | include/functions_category.inc.php | 13 | ||||
-rw-r--r-- | include/functions_user.inc.php | 5 | ||||
-rw-r--r-- | include/page_tail.php | 10 |
4 files changed, 51 insertions, 20 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php index 999b4f8b8..c7f42ab0c 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -486,21 +486,31 @@ function pwg_write_debug() function pwg_query($query) { - global $conf,$count_queries,$queries_time; + global $conf,$page; $start = get_moment(); - $result = mysql_query($query); + $result = mysql_query($query) or my_error($query."\n"); $time = get_moment() - $start; - $count_queries++; - $queries_time+= $time; + + if (!isset($page['count_queries'])) + { + $page['count_queries'] = 0; + $page['queries_time'] = 0; + } + + $page['count_queries']++; + $page['queries_time']+= $time; if ($conf['show_queries']) { $output = ''; - $output.= '<pre>['.$count_queries.'] '."\n".$query; - $output.= "\n".'(this query time : '.number_format( $time, 3, '.', ' ').' s)</b>'; - $output.= "\n".'(total SQL time : '.number_format( $queries_time, 3, '.', ' ').' s)'; + $output.= '<pre>['.$page['count_queries'].'] '; + $output.= "\n".$query; + $output.= "\n".'(this query time : '; + $output.= number_format($time, 3, '.', ' ').' s)</b>'; + $output.= "\n".'(total SQL time : '; + $output.= number_format($page['queries_time'], 3, '.', ' ').' s)'; $output.= '</pre>'; echo $output; @@ -624,4 +634,23 @@ function get_thumbnail_src($path, $tn_ext = '') return $src; } + +// my_error returns (or send to standard output) the message concerning the +// error occured for the last mysql query. +function my_error($header, $echo = true) +{ + $error = '<pre>'; + $error.= $header; + $error.= '[mysql error '.mysql_errno().'] '; + $error.= mysql_error(); + $error.= '</pre>'; + if ($echo) + { + echo $error; + } + else + { + return $error; + } +} ?> diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index 287075d43..cb532c01a 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -221,18 +221,23 @@ SELECT '.implode(',', $infos).' } $cat['comment'] = nl2br($cat['comment']); - $cat['name'] = array(); - + $names = array(); $query = ' SELECT name,id FROM '.CATEGORIES_TABLE.' WHERE id IN ('.$cat['uppercats'].') - ORDER BY id ASC ;'; $result = pwg_query($query); while($row = mysql_fetch_array($result)) { - $cat['name'][$row['id']] = $row['name']; + $names[$row['id']] = $row['name']; + } + + // category names must be in the same order than uppercats list + $cat['name'] = array(); + foreach (explode(',', $cat['uppercats']) as $cat_id) + { + $cat['name'][$cat_id] = $names[$cat_id]; } return $cat; diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index 750f4602f..2a44c785a 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -208,10 +208,7 @@ function check_login_authorization($guest_allowed = true) function setup_style($style) { - $template_path = 'template/' ; - $template_name = $style ; - $template = new Template(PHPWG_ROOT_PATH . $template_path . $template_name); - return $template; + return new Template(PHPWG_ROOT_PATH.'template/'.$style); } function getuserdata($user) diff --git a/include/page_tail.php b/include/page_tail.php index e8b4ae349..f5c5eaf3f 100644 --- a/include/page_tail.php +++ b/include/page_tail.php @@ -42,17 +42,17 @@ if ($conf['show_gt']) { $time = get_elapsed_time($t2, get_moment()); - if (!isset($count_queries)) + if (!isset($page['count_queries'])) { - $count_queries = 0; - $queries_time = 0; + $page['count_queries'] = 0; + $page['queries_time'] = 0; } $template->assign_block_vars( 'debug', array('TIME' => $time, - 'NB_QUERIES' => $count_queries, - 'SQL_TIME' => number_format($queries_time, 3, '.', ' ').' s')); + 'NB_QUERIES' => $page['count_queries'], + 'SQL_TIME' => number_format($page['queries_time'],3,'.',' ').' s')); } // |