MyBB Community Forums

Full Version: Plugin 1.6.10 compatibility check
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi guys I have downloaded this plugin that was written for mybb 1.4 but I am using 1.6.10 could you please update this code to mybb 1.6.10?

<?php
/**
 * Konu Þeklinde Google Reklamlarý - Adsense Ads. on Forumdisplay
 * Copyright 2008 -  LowBattery - www.lowbattery.info
 */

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("forumdisplay_start", "gadsp_index_start");

function gadsp_info()
{	
	return array(
		"name" => "Adsense Ads. on Forumdisplay",
		"description" => "Show your adsense ads. on forumdisplay.",
		"website" => "http://www.mybbturkiye.com",
		"author" => "LowBattery",
		"authorsite" => "http://www.lowbattery.info",
		"version" => "1.0",
		"compatibility" => "14*",
	);
}

function gadsp_install()
{
    global $settings, $mybb, $db;
	
if($db->field_exists("gadsenses", "users"))
	{
	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP gadsenses"); 
	}
	
    $settings_group = array(
        'gid'          => 'NULL',
        'name'         => 'gadsa',
        'title'        => 'Adsense Ads. on Forumdisplay Settings',
        'description'  => 'Adsense Ads. on Forumdisplay Settings.',
        'disporder'    => '2',
        'isdefault'    => 'no'
    );
    $db->insert_query('settinggroups', $settings_group);
    $gid = $db->insert_id();
	
    $setting = array(
        'sid'          => 'NULL',
        'name'         => 'pub',
        'title'        => 'Write your PUB Number',
        'description'  => 'Write your PUB Number.',
        'optionscode'  => 'textarea',
        'value'        => '0345086024375267',
        'disporder'    => '1',
        'gid'          => intval( $gid )
    );
    $db->insert_query( 'settings', $setting );		
		
	$db->write_query("ALTER TABLE ".TABLE_PREFIX."users ADD gadsenses int NOT NULL default 0");

	rebuild_settings();
	
	$insertarray = array(
		"title" => "gadsense",
		"template" => "<td class=\"trow1\" align=\"center\" width=\"2%\"><img src=\"images/dot_hotfolder.gif\" alt=\"Contains posts by you. No new posts.Hot posts.\" title=\"Contains posts by you. No new posts.Hot posts.\"></td>
    <td class=\"trow2\" align=\"center\" width=\"2%\"><img src=\"images/icons/information.gif\" alt=\"Google Ads.\"></td>
    <td class=\"trow1\">
        <center>
<script type=\"text/javascript\"><!--
google_ad_client = \"pub-{\$mybb->settings[\'pub\']}\";
google_ad_width = 468;
google_ad_height = 60;
google_ad_format = \"468x60_as\";
google_ad_type = \"text_image\";
google_ad_channel = \"\";
google_color_border = \"CCCCCC\";
google_color_bg = \"CCCCCC\";
google_color_link = \"808080\";
google_color_text = \"000000\";
google_color_url = \"000033\";
//--></script>
<script type=\"text/javascript\"
  src=\"http://pagead2.googlesyndication.com/pagead/show_ads.js\">
</script></center>
    </td>
    <td class=\"trow2\" align=\"center\">-</a></td>
    <td class=\"trow1\" align=\"center\">-</td>
    <td class=\"trow2\" align=\"center\"><img src=\"images/star.gif\"><img src=\"images/star.gif\"><img src=\"images/star.gif\"><img src=\"images/star.gif\"><img src=\"images/star.gif\"></td>
    <!-- start: forumdisplay_thread_rating -->
<td class=\"trow2\" align=\"center\">GoogleBot</td>
		",
		"sid" => -1,
		"dateline" => TIME_NOW
	);
	
	$db->insert_query("templates", $insertarray);
}

function gadsp_is_installed()
{
	global $db;
	
	if($db->field_exists("gadsenses", "users"))
	{
		return true;
	}
	
	return false;
}

function gadsp_activate()
{
	global $db;
	
	include MYBB_ROOT."/inc/adminfunctions_templates.php";
	
	find_replace_templatesets("forumdisplay_threadlist", "#".preg_quote("{\$announcementlist}")."#i", "{\$announcementlist}\r\n{\$gadsense}");
}

function gadsp_deactivate()
{
	global $db;
	
	include MYBB_ROOT."/inc/adminfunctions_templates.php";
	
	find_replace_templatesets("forumdisplay_threadlist", "#".preg_quote("\r\n{\$gadsense}")."#i", "", 0);
}

function gadsp_uninstall()
{
	global $db;
	
	if($db->field_exists("gadsenses", "users"))
	{
		$db->write_query("ALTER TABLE ".TABLE_PREFIX."users DROP gadsenses"); 
	}
	$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='gadsa'");
	$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name='pub'");
	
	rebuild_settings();
	
	$db->delete_query("templates", "title = 'gadsense'");
}

function gadsp_index_start()
{
	global $db, $mybb, $templates, $gadsense;
	
	eval("\$gadsense = \"".$templates->get("gadsense")."\";");
}
?>
Set the compatibility key to 16* instead of 14*.
That is it you don't have to twig the code? It won't cause problems?
^ no need of any other changes for the referred plugin. just change the compatibility line as Nathan suggested.
Thanks guys it works great!