Please make sure IN_MYBB is defined.");
$plugins->add_hook("index_start", "reklama");
$plugins->add_hook("showthread_start", "reklama");
$plugins->add_hook("forumdisplay_start", "reklama");
define('REK_ID', 'Reklama');
define('REK_NAME', 'Reklama');
define('REK_DESC', 'Plugin dodający reklamę na stronie głównej, widoku działu i widoku tematu.');
define('REK_VER', '1.0');
function reklama_info()
{
return array(
"name" => REK_NAME,
"description" => REK_DESC,
"website" => "http://mybboard.pl",
"author" => "Snake_",
"authorsite" => "http://mybboard.pl",
"version" => REK_VER,
"guid" => "",
"compatibility" => "16*"
);
}
function reklama_install()
{
global $db;
$settinggroup = array(
"name" => REK_ID,
"title" => REK_NAME,
"description" => REK_DESC,
);
$db->insert_query("settinggroups", $settinggroup);
$gid = intval($db->insert_id());
$setting[] = array(
"name" => "reklama_turn",
"title" => "Włączyć plugin?",
"optionscode" => "yesno",
"value" => 1,
);
$setting[] = array(
"name" => "reklama_code",
"title" => "Kod reklamy",
"optionscode" => "textarea",
"value" => "",
);
foreach ($setting AS $st)
{
$dorder++;
$st['disporder'] = $dorder;
$st['gid'] = $gid;
$db->insert_query("settings", $st);
}
rebuild_settings();
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets( "index", '#'.preg_quote('{$header}').'#', '{$header}{$reklama}
' );
find_replace_templatesets( "showthread", '#'.preg_quote('{$header}').'#', '{$header}{$reklama}
' );
find_replace_templatesets( "forumdisplay", '#'.preg_quote('{$header}').'#', '{$header}{$reklama}
' );
}
function reklama_activate()
{
global $db;
$db->query("UPDATE ".TABLE_PREFIX."settings SET value=1 WHERE name='reklama_turn'");
rebuild_settings();
}
function reklama_is_installed()
{
global $db;
$query = $db->query("SELECT name FROM ".TABLE_PREFIX."settinggroups WHERE name='".REK_ID."' LIMIT 1");
if($db->num_rows($query))
{
return true;
}
return false;
}
function reklama_deactivate()
{
global $db;
$db->query("UPDATE ".TABLE_PREFIX."settings SET value=0 WHERE name='reklama_turn'");
rebuild_settings();
}
function reklama_uninstall()
{
global $db;
require MYBB_ROOT.'/inc/adminfunctions_templates.php';
find_replace_templatesets( "index", '#'.preg_quote('{$reklama}
').'#', '' );
find_replace_templatesets( "showthread", '#'.preg_quote('{$reklama}
').'#', '' );
find_replace_templatesets( "forumdisplay", '#'.preg_quote('{$reklama}
').'#', '' );
$query = $db->query("SELECT gid FROM ".TABLE_PREFIX."settinggroups WHERE name='".REK_ID."' LIMIT 1");
while ($sg = $db->fetch_array($query))
{
$gid = intval($sg['gid']);
}
if ($gid) $db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE gid=$gid");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='".REK_ID."'");
rebuild_settings();
}
function reklama()
{
global $mybb, $reklama;
$reklama = $mybb->settings['reklama_code'];
}
?>