#################################################################
## Mod Title: File Attachment Mod Addon (Enable/Add Debug Mode)
## Mod Version: 1.1 for Version 2.3.x
## Author: Acyd Burn < acyd.burn@gmx.de > - Meik Sievertsen - http://www.opentools.de/
## Description:
## This Addon enables the Debug Mode for the Attachment Mod.
## If enabled, the Attachment Mod displays the number of querys consumed by the Attachment Mod itself
## on the buttom of the screen.
## This Version works with phpBB 2.0.x and the Attachment Mod V2.3.x installed.
##
## Installation Level: easy
## Installation Time: 5 Minutes
## Files to Edit:
##
##############################################################
## This MOD is released under the GPL License.
##############################################################
There are three Modes you can choose from.
The first one (Noted as 'ONLY ATTACHMENT QUERY') is for only displaying the following line:
For the Attachment Mod x queries were executed.
The second one (Noted as 'PHPBB2 DEBUG') is for displaying the phpBB2 Queries. The following lines is displayed:
phpBB Created this page in x seconds : x queries executed : GZIP compression enabled/disabled : Debug Mode
The third one (Noted as 'ADDITIONAL ATTACHMENT QUERY') is for displaying the following line:
Attachment Mod - [ Time : 0.001s | 1 Queries | Explain ]
Explain is a Link to an additional Page showing all Queries in detail, it's from the phpBB 2.2 CVS Code, this
feature is original made by Ashe.
--------------- ONLY ATTACHMENT QUERY ------------------
#
#-----[ OPEN ]---------------------------------------------
#
extension.inc
#
#-----[ FIND ]---------------------------------------------
# around line 22
$phpEx = "php";
#
#-----[ AFTER, ADD ]--------------------------------------
#
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
$attach_num_queries = 0;
#
#-----[ OPEN ]---------------------------------------------
#
attach_mod/includes/constants.php
#
#-----[ FIND ]---------------------------------------------
# around line 30
define('ATTACH_DEBUG', 0);
// define('ATTACH_DEBUG', 1);
#
#-----[ REPLACE WITH ]---------------------------------------
#
// define('ATTACH_DEBUG', 0);
define('ATTACH_DEBUG', 1);
#
#-----[ OPEN ]---------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]---------------------------------------------
# Around line 494
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header;
#
#-----[ AFTER, ADD ]---------------------------------------
#
global $starttime, $attach_num_queries;
#
#-----[ OPEN ]---------------------------------------------
#
includes/page_tail.php
#
#-----[ FIND ]---------------------------------------------
# Around line 89
exit;
#
#-----[ BEFORE, ADD ]---------------------------------------
#
if ( ATTACH_DEBUG )
{
print "
For the Attachment Mod " . $attach_num_queries . " queries were executed.";
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
--------------- PHPBB2 DEBUG ------------------
#
#-----[ OPEN ]---------------------------------------------
#
extension.inc
#
#-----[ FIND ]---------------------------------------------
# around line 22
$phpEx = "php";
#
#-----[ AFTER, ADD ]--------------------------------------
#
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
#
#-----[ OPEN ]---------------------------------------------
#
includes/constants.php
#
#-----[ FIND ]---------------------------------------------
# around line 29
//define('DEBUG', 1); // Debugging on
define('DEBUG', 0); // Debugging off
#
#-----[ REPLACE WITH ]---------------------------------------
#
define('DEBUG', 1); // Debugging on
// define('DEBUG', 0); // Debugging off
#
#-----[ OPEN ]---------------------------------------------
#
includes/page_tail.php
#
#-----[ FIND ]---------------------------------------------
# Around line 89
exit;
#
#-----[ BEFORE, ADD ]---------------------------------------
#
$generation_time = printf("
phpBB Created this page in %f seconds : " . $db->num_queries . " queries executed : $gzip_text".$debug_mode."", $totaltime);
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
--------------- ADDITIONAL ATTACHMENT QUERY ------------------
#
#-----[ OPEN ]---------------------------------------------
#
extension.inc
#
#-----[ FIND ]---------------------------------------------
# around line 22
$starttime = 0;
#
#-----[ REPLACE WITH ]--------------------------------------
#
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;
$attach_num_queries = 0;
$attach_sql_report = '';
$attach_sql_time = 0;
#
#-----[ OPEN ]---------------------------------------------
#
attach_mod/includes/constants.php
#
#-----[ FIND ]---------------------------------------------
# around line 30
define('ATTACH_DEBUG', 0); // Attachment Mod Debugging off
//define('ATTACH_DEBUG', 1); // Attachment Mod Debugging on
// define('ATTACH_QUERY_DEBUG', 1);
#
#-----[ REPLACE WITH ]---------------------------------------
#
// define('ATTACH_DEBUG', 0); // Attachment Mod Debugging off
define('ATTACH_DEBUG', 1); // Attachment Mod Debugging on
define('ATTACH_QUERY_DEBUG', 1);
#
#-----[ OPEN ]---------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]---------------------------------------------
# Around line 494
function message_die($msg_code, $msg_text = '', $msg_title = '', $err_line = '', $err_file = '', $sql = '')
{
global $db, $template, $board_config, $theme, $lang, $phpEx, $phpbb_root_path, $nav_links, $gen_simple_header, $images;
#
#-----[ AFTER, ADD ]---------------------------------------
#
global $attach_num_queries, $attach_sql_report, $attach_sql_time;
#
#-----[ OPEN ]---------------------------------------------
#
includes/page_tail.php
#
#-----[ FIND ]---------------------------------------------
# Around line 48
$db->sql_close();
#
#-----[ AFTER, ADD ]---------------------------------------
#
if ( ATTACH_DEBUG )
{
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
if ( defined('ATTACH_QUERY_DEBUG') )
{
if ($attach_sql_time > 0)
{
$fp = fopen('explain/e' . $userdata['user_id'] . '.html', 'wt');
fwrite($fp, $attach_sql_report);
$str = "The Attachment Mod generated " . $attach_num_queries . " queries,\nspending " . $attach_sql_time . ' doing MySQL queries and ' . ($totaltime - $attach_sql_time) . ' doing PHP things.
';
fwrite($fp, $str);
fclose($fp);
}
}
$debug_output = 'Attachment Mod - [ ';
if ( defined('ATTACH_QUERY_DEBUG') )
{
$debug_output .= sprintf(' Time : %.3fs | ', $attach_sql_time);
}
$debug_output .= $attach_num_queries . ' Queries ';
if ( defined('ATTACH_QUERY_DEBUG') )
{
$debug_output .= ' | Explain';
}
$debug_output .= ' ]';
print $debug_output;
}
#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
Now you have to create the directory explain within your phpBB2 Directory and you have to chmod it to 777.
# EoM