MyBB Hacks

Full Version: problem with removing welcomeblock
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I am trying many regex and other ways to remove welcomeblock

I really hate mybb's find_replace_templatesets


PHP Code:
<?php
/**
 * Mod Name: Remove Welcome Block links
 */


$plugins->add_hook("global_start", "removewelcome_header");
//$plugins->add_hook("global_end", "removewelcome_header");
//$plugins->add_hook("post_output_page", "removewelcome_header");


// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
	die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}

function removewelcome_info()
{
	return array(
		"name"				=> "Remove Welcome Block",
		"description"		=> "Remove Welcome Block",
		"website"			=> "",
		"author"			=> "ELY M.",
		"authorsite"		=> "",
		"version"			=> "1.0.3",
		"guid" => "",
		"compatibility" => "*"
		);
}

function removewelcome_activate()
{
}


function removewelcome_deactivate()
{
}


/*

		<template name="header" version="1600"><![CDATA[	<div id="container">
		<a name="top" id="top"></a>
		<div id="header">
			<div class="logo"><a href="{$mybb->settings['bburl']}/index.php"><img src="{$theme['logo']}" alt="{$mybb->settings['bbname']}" title="{$mybb->settings['bbname']}" /></a></div>
			<div class="menu">
				<ul>
					<li><a href="{$mybb->settings['bburl']}/search.php"><img src="{$theme['imgdir']}/toplinks/search.gif" alt="" title="" />{$lang->toplinks_search}</a></li>
					<li><a href="{$mybb->settings['bburl']}/memberlist.php"><img src="{$theme['imgdir']}/toplinks/memberlist.gif" alt="" title="" />{$lang->toplinks_memberlist}</a></li>
					<li><a href="{$mybb->settings['bburl']}/calendar.php"><img src="{$theme['imgdir']}/toplinks/calendar.gif" alt="" title="" />{$lang->toplinks_calendar}</a></li>
					<li><a href="{$mybb->settings['bburl']}/misc.php?action=help"><img src="{$theme['imgdir']}/toplinks/help.gif" alt="" title="" />{$lang->toplinks_help}</a></li>
				</ul>
			</div>
			<hr class="hidden" />
			<div id="panel">
				{$welcomeblock}
			</div>
		</div>
		<hr class="hidden" />
		<br class="clear" />
		<div id="content">
			{$pm_notice}
			{$bannedwarning}
			{$bbclosedwarning}
			{$unreadreports}
			{$pending_joinrequests}
			<navigation>
			<br />
]]></template>

*/

function removewelcome_header()
{

global $mybb, $cache, $lang, $welcomeblock, $templates;


echo "TESTHEADER4";



    $template = &$GLOBALS['templates']->cache['header'];
    $template = strtr($template, array(
    // two copies of this replacement for MyBB 1.4 (uses Windows newlines) and 1.6 (Nix newlines)
    '				{$welcomeblock}'."\r" => '<!-- stupid welcomeblock was here -->'."\r",
    '				{$welcomeblock}'."\n" => '<!-- stupid welcomeblock was here -->'."\n",
    //"\t\t\t\t".'{$welcomeblock}'."\n" => 'TESTING....'."\n",
    '       {$welcomeblock}'."\n" => 'testing....'."\n",
    
        ));
        




//$templates->cache['header'] = preg_replace('#(.*?){$welcomeblock}(.*?)#si', 'TEST', $templates->cache['header']);


        

//if(!$templates->cache['header']) $templates->cache('header');
//$templates->cache['header'] = str_replace('				{$welcomeblock}', 'testing2222222', $templates->cache['header']);


//if(!$templates->cache['header']) $templates->cache('header');
//$templates->cache['header'] = preg_replace("~welcomeblock~", "testing...", $templates->cache['header']);

//$welcomeblock = "FUCK!!!";



}





?>

Because the template cache isn't loaded when the global_start hook is fired.
Try modifying the $header global variable on global_end
Reference URL's