So I found a issue with my plugin, when add something in the text area it will make a box in the footer/header displaying what was inserted into the text area(like it should). Now when you change what you put in that text area, instead of just replacing what was recently in the box that was made, it makes a whole new one instead of replacing the current text in the box!? here is my code.
<?php
// 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.");
}
$plugins->add_hook('global_start','adsense_code_insert');
$plugins->add_hook('index_start','adsense_code_insert_footer');
function adsense_info()
{
global $db;
return array(
'name' => 'AdSense Code',
'description' => 'Add your adsense code (or any ad!) to your index.',
'website' => 'http://mods.mybb.com/',
'author' => 'Blake',
'authorsite' => 'http://mcmines.com',
'version' => '1.1',
'compatibility' => '16*',
'guid' => 'dc9443796a5dfaeb9d75fd5d0bf08be2'
);
}
function adsense_activate()
{
global $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$confirm_group = array(
'gid' => 'NULL',
'name' => 'google_adsense',
'title' => 'Ad Code',
'description' => 'Edit your Ad details in here.',
'disporder' => "1",
'isdefault' => '0',
);
$db->insert_query('settinggroups', $confirm_group);
$gid = $db->insert_id();
$adsense_setting_1 = array(
"sid" => "NULL",
"name" => "adsense_on_off",
"title" => "Is the plugin active for the header?",
"description" => "No means off",
"optionscode" => "yesno",
"value" => "no",
"disporder" => "1",
"gid" => intval($gid),
);
$adsense_setting_2 = array(
"sid" => "NULL",
"name" => "adsense_code_header",
"title" => "Ad Code",
"description" => "Post your Ad Code in here",
"optionscode" => "textarea",
"value" => '',
"disporder" => "2",
"gid" => intval($gid),
);
$adsense_setting_3 = array(
"sid" => "NULL",
"name" => "adsense_on_off_footer",
"title" => "Is the plugin active for the footer?",
"description" => "No means off",
"optionscode" => "yesno",
"value" => "no",
"disporder" => "3",
"gid" => intval($gid),
);
$adsense_setting_4 = array(
"sid" => "NULL",
"name" => "adsense_code_footer",
"title" => "Ad Code",
"description" => "Post your Ad Code in here",
"optionscode" => "textarea",
"value" => '',
"disporder" => "4",
"gid" => intval($gid),
);
$db->insert_query('settings', $adsense_setting_1);
$db->insert_query('settings', $adsense_setting_2);
$db->insert_query('settings', $adsense_setting_3);
$db->insert_query('settings', $adsense_setting_4);
}
function adsense_deactivate()
{
global $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
$db->delete_query("settings", "name='adsense_on_off'");
$db->delete_query("settings", "name='adsense_on_off_footer'");
$db->delete_query("settings", "name='adsense_code_footer'");
$db->delete_query("settings", "name='adsense_code_header'");
$db->delete_query("settinggroups", "name='google_adsense'");
rebuild_settings();
}
//Header insert
function adsense_code_insert(){
global $mybb, $templates, $theme, $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
if(intval($mybb->settings['adsense_on_off']) == "1"){
find_replace_templatesets("header", "#".preg_quote("<navigation>")."#i", "<navigation> <div style=\"padding: 6px 0px 0px 0px\">
<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\">
<tr>
<td class=\"thead\">
Sponsored Links
</td>
</tr>
<tr>
<td class=\"alt1\" align=\"center\">
{$mybb->settings['adsense_code_header']}
</td>
</tr>
</table>
<br>
</div> "
);
}
}
//Footer insert
function adsense_code_insert_footer(){
global $mybb, $templates, $theme, $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
if(intval($mybb->settings['adsense_on_off_footer']) == "1"){
find_replace_templatesets("index", "#".preg_quote("</dl>")."#i", "</dl> <br /> <div style=\"padding: 6px 0px 0px 0px\">
<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\">
<tr>
<td class=\"thead\">
Sponsored Links
</td>
</tr>
<tr>
<td class=\"alt1\" align=\"center\">
{$mybb->settings['adsense_code_footer']}
</td>
</tr>
</table>
<br>
</div> "
);
}
}
//Header remove
global $mybb, $templates, $theme, $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
if(intval($mybb->settings['adsense_on_off']) == "0"){
find_replace_templatesets("header", "#".preg_quote("<div style=\"padding: 6px 0px 0px 0px\">
<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\">
<tr>
<td class=\"thead\">
Sponsored Links
</td>
</tr>
<tr>
<td class=\"alt1\" align=\"center\">
{$mybb->settings['adsense_code_header']}
</td>
</tr>
</table>
<br>
</div> ")."#i", '', 0);
}
//Footer remove
global $mybb, $templates, $theme, $db;
require MYBB_ROOT."/inc/adminfunctions_templates.php";
if(intval($mybb->settings['adsense_on_off_footer']) == "0"){
find_replace_templatesets("index", "#".preg_quote("<br /><div style=\"padding: 6px 0px 0px 0px\">
<table class=\"tborder\" cellpadding=\"6\" cellspacing=\"1\" border=\"0\" width=\"100%\" align=\"center\">
<tr>
<td class=\"thead\">
Sponsored Links
</td>
</tr>
<tr>
<td class=\"alt1\" align=\"center\">
{$mybb->settings['adsense_code_footer']}
</td>
</tr>
</table>
<br>
</div> ")."#i", '', 0);
}
?>
Ansem Wrote:Lets admit, phpbb is a joke, smf is a joke but atleast thats a little funny, things like xmb or punbb just don't cut it and vb is like the douchbag of them all. Mybb wins.My mods Clicky!