This mod can change adsense colors for muiltiforum ads depending on current template.
How it works: you create file adsense.cfg in some template's directory, put colors in it and script will replace your default colors with custom colors if forum user uses that template.
Installation:
open includes/functions.php, find this:
Code: Select all
$current_template_path = $template_path . $template_name;
@include($phpbb_root_path . $template_path . $template_name . '/' . $template_name . '.cfg');
if ( !defined('TEMPLATE_CONFIG') )
{
message_die(CRITICAL_ERROR, "Could not open $template_name template config file", '', __LINE__, __FILE__);
}
$img_lang = ( file_exists(@phpbb_realpath($phpbb_root_path . $current_template_path . '/images/lang_' . $board_config['default_lang'])) ) ? $board_config['default_lang'] : 'english';
while( list($key, $value) = @each($images) )
{
if ( !is_array($value) )
{
$images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
}
}
or, if you are using eXtreme Styles mod multiforums edition then instead of code above open includes/template.php and find this:
Code: Select all
while( list($key, $value) = @each($images) )
{
if ( !is_array($value) )
{
$images[$key] = str_replace('{LANG}', 'lang_' . $img_lang, $value);
}
}
and add after it
Code: Select all
$adsense_file = $phpbb_root_path . $template_path . $template_name . '/adsense.cfg';
if(@file_exists($adsense_file))
{
$adsense = array(
'google_color_border' => $row['td_color2'],
'google_color_bg' => $row['td_color2'],
'google_color_link' => $row['body_link'],
'google_color_url' => $row['body_hlink'],
'google_color_text' => $row['body_text'],
);
@include($adsense_file);
if(count($adsense))
{
global $multiforums_setting;
$items = array('advert_top', 'advert_bottom');
$search = array();
$replace = array();
for($i=0; $i<count($items); $i++)
{
if(strpos($multiforums_setting[$items[$i]], 'google_ad_client') > 0)
{
// do replacements
if(!count($search))
{
foreach($adsense as $var => $value)
{
if(strlen($value) == 6)
{
$search[] = '/' . $var . ' = \"([0-9a-fA-F]+)\"/';
$replace[] = $var . ' = "' . $value . '"';
}
}
}
$multiforums_setting[$items[$i]] = preg_replace($search, $replace, $multiforums_setting[$items[$i]]);
}
}
}
}
Here are few prebuilt adsense.cfg files for few styles:
http://www.trushkin.biz/temp/adsense.zip
That pack includes adsense.cfg for following styles:
- AcidTech (and its color schemes)
- Aeolus
- Artemis
- Athena
- Aphrodite (and Aphrodite Green)
- Classic (and Classic 2.0)
- Christmas
- Counter-Strike
- Eos
- Getaway
- Helius (and HeliusGray)
- Hestia
- Iris
- Jet
- Morpheus
- subSilver
Note: in prebuilt adsense.cfg pack subSilver's adsense.cfg is built in such way so if user changes colors in admin control panel adsense colors will also change to merge with forum.
Sample adsense.cfg that you should put in templates/whatever/adsense.cfg:
Code: Select all
<?php
$adsense = array(
'google_color_border' => '191919',
'google_color_bg' => '191919',
'google_color_link' => '2370B6',
'google_color_url' => 'F0E80A',
'google_color_text' => 'D0D0D0',
);
?>