<?php
/**
* Splash Page Plugin For MyBBoard
*
* Shows a page when users first visit your site.
*
* By: Nick Palmer
* Website: http://e-xarx.net
*/
$plugins->add_hook('index_start', 'splash');
function splash_info()
{
return array(
"name" => "Splash!",
"description" => "Adds a customizable splash page for your forum",
"website" => "http://www.e-xarx.net",
"author" => "Nickman",
"authorsite" => "http://www.e-xarx.net",
"version" => "1.0",
);
}
function splash_activate()
{
require '../inc/adminfunctions_templates.php';
global $db;
$splash_group = array(
"gid" => "NULL",
"name" => "splash",
"title" =>"Splash Page Settings",
"description" => "Settings for the Splash Page plugin.",
"disporder" => "3",
"isdefault" => "no",
);
$db->insert_query("settinggroups", $splash_group);
$gid = $db->insert_id();
$splash_setting_1 = array(
"sid" => "NULL",
"name" => "enablesplash",
"title" => "Show The Splash Page",
"description" => "Display the Splash Page To Users?",
"optionscode" => "yesno",
"value" => "yes",
"disporder" => "1",
"gid" => intval($gid),
);
$splash_setting_2 = array(
"sid" => "NULL",
"name" => "splashdays",
"title" => "Expires At...",
"description" => "How long until the user should see the page, Put none For End Of The Users Browsing Session",
"optionscode" => "text",
"value" => "30",
"disporder" => "1",
"gid" => intval($gid),
);
$db->insert_query("settings", $splash_setting_1);
$db->insert_query("settings", $splash_setting_2);
$splash_template = array(
"tid" => "NULL",
"title" => "global_splash",
"template" => "<html><head><title>Welcome!</title></head><body>Welcome To My Site</body></html>",
"sid" => "-1",
"version" => "100.07",
"status" => "",
"dateline" => "1134703642",
);
$db->insert_query("templates", $splash_template);
}
function splash_deactivate()
{
require '../inc/adminfunctions_templates.php';
global $db;
$db->query("DELETE FROM ".TABLE_PREFIX."settings WHERE name IN ('enablespash','splashdays')");
$db->query("DELETE FROM ".TABLE_PREFIX."settinggroups WHERE name='splash'");
$db->query("DELETE FROM ".TABLE_PREFIX."templates WHERE title='global_splash'");
}
function splash()
{
global $theme,$session,$user,$mybb,$templates,$collapsed;
if ($mybb->settings['enablesplash'] !='no')
{
if ($_COOKIE['mybbseensplash'] != 'yes')
{
if ($mybb->settings['splashdays'] == 'none')
{
my_setcookie("mybbseensplash",'yes',-1);
}
else {
$days=$mybb->settings['splashdays'];
$time=time()+(86400*$days);
my_setcookie("mybbseensplash",'yes',86400*$days);
}
eval("\$splash = \"".$templates->get("global_splash")."\";");
output_page($splash);
exit;
}
}
}