MyBB Community Forums

Full Version: Plugin handles and locations
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3
I tried that. What I am trying to do is rewrite the adsafp (Ads after first post) mod so that it doesn't require any core file changes. It shouldn't be too hard but so far I am having a bit of an issue with getting the function to display. I have thought of replacing the $seperator completely instead of adding the $adsafp in the seperator template.

I have to run out now but I will come back in a couple hours and tackle this. Any help would be appreciated. This should be an easy mod for someone that understands how the plugins work.
CraKteR Wrote:Look here: http://mcdcpp.net/hooks.php
Thnx for this great job CraKteR.
Is this list of hooks updated to 1.2.2?
I updated the file in the first post for MyBB 1.2.x. Thanks to Poncho from the german community who made the list.
pepotiger Wrote:
CraKteR Wrote:Look here: http://mcdcpp.net/hooks.php
Thnx for this great job CraKteR.
Is this list of hooks updated to 1.2.2?

that site look down??
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 ...
very thanx Big Grin
Pages: 1 2 3