Displays best in notepad, I would update the wiki but the formatting goes strange and I'm bored now ... v1.2.13 found 642 calls to run_hooks[_by_ref]
Heres the code that made it ...
<?php
$config['path'] = 'C:\\xampp\\htdocs\\MyBB';
$config['seperator'] = '\\';
$config['version'] = '1.2.13';
$config['output'] = 'mybb_hooks_1_2_13.txt';
$config['files'] = array( );
$config['hooks'] = array( );
$config['filec'] = 0;
$config['dirc'] = 0;
function scan_mybb_for_files( $path )
{
global $config ;
$files = array( );
if( ( $handle = opendir( $path ) ) )
{
while( ( $entry = readdir( $handle ) ) )
{
if( ( $entry != "." and $entry != ".." ) and ( $full = sprintf( "%s%s%s", $path, $config['seperator'], $entry ) ) )
{
if( is_dir( $full ) )
{
$config['dirc']++;
$files = array_merge( $files, scan_mybb_for_files( $full ) );
}
else
{
$files[] = $full;
printf( "\rWork\t%d files in %d sub-directories", ++$config['filec'], $config['dirc'] );
}
}
}
}
return $files ;
}
if( ( $output = fopen( $config['output'], 'w+' ) ) )
{
printf( "Done\tOpened %s for writing\r\n", $config['output'] );
if( ( $config['files'] = scan_mybb_for_files( $config['path'] ) ) )
{
printf( "\rDone\t%d files in %d sub-directories\r\n", $config['filec'], $config['dirc'] );
foreach( $config['files'] as $file )
{
$line = 0;
if( ( $contents = file( $file ) ) )
{
for( $line = 0; $line < count( $contents ); $line++ )
{
if( preg_match( '~((\$.*?) = )?\$plugins->run_hooks\("(.*?)"(, (.*))?\)~is', $contents[$line], $hook ) )
{
if( $long < strlen( $hook[3] ) ) $long = strlen( $hook[3] );
if( $longr < strlen( trim( $hook[2] ) ) ) $longr = strlen( trim( $hook[2] ) );
$config['hooks'][substr( $file, strlen( $config['path'] ) + 1 )][] = array
(
'line' => $line + 1,
'hook' => trim( $hook[3] ),
'args' => trim( $hook[5] ),
'return' => trim( $hook[2] )
);
$config['hookc']++;
}
else if( preg_match( '~((\$.*?) = )?\$plugins->run_hooks_by_ref\("(.*?)"(, (.*))?\)~is', $contents[$line], $hook ) )
{
if( $long < strlen( $hook[3] ) ) $long = strlen( $hook[3] );
if( $longr < strlen( trim( $hook[2] ) ) ) $longr = strlen( trim( $hook[2] ) );
$config['hooks'][substr( $file, strlen( $config['path'] ) + 1 )][] = array
(
'line' => $line + 1,
'hook' => trim( $hook[3] ),
'args' => trim( $hook[5] ),
'return' => trim( $hook[2] )
);
$config['hookc']++;
}
}
}
}
fprintf( $output, "Line\tHook%s\tReturn%s\tArguments\r\n", str_repeat( " ", $long - strlen( "Hook" ) ), str_repeat( " ", $longr - strlen( "Return" ) ) );
foreach( $config['hooks'] as $file => $hooks )
{
$config['fileuc']++;
if( count( $hooks ) ) fprintf( $output, "%s\r\n", $file );
foreach( $hooks as $hook ) fprintf
(
$output,
"%04d\t%s%s\t%s%s\t%s\r\n",
$hook['line'], $hook['hook'], str_repeat( " ", $long - strlen( $hook['hook'] ) ), $hook['return'] ? $hook['return'] : 'none', str_repeat( " ", $longr - strlen( $hook['return'] ) ), $hook['args'] ? $hook['args'] : 'none'
);
}
printf( "Done\t%d hooks in %d files in %d sub-directories", $config['hookc'], $config['fileuc'], $config['dirc'] );
}
}
?>
Have fun ...