Skip to content

Instantly share code, notes, and snippets.

@hearvox
Created April 5, 2011 22:01
Show Gist options
  • Save hearvox/904678 to your computer and use it in GitHub Desktop.
Save hearvox/904678 to your computer and use it in GitHub Desktop.
Splashscreening: for KUHF.org Pubradio Pledge Drive: Here's a bit of PHP kit my associate here wrote that you guys might find useful.. we put this into our generic header include for duration of the fund drive, so pretty much every page on kuhf.org will
<?php
/*
Splashscreening: for KUHF.org Pubradio Pledge Drive:
*/
// Splash Page Display for Campaign
$current = time();
if ($current <= mktime(5, 0, 0, 4, 4, 2011) || $current >= mktime (12, 0, 0, 4, 15, 2011))
//if current time is earlier than 5am on 4/4/2011, or later than noon on 4/15/2011, then ignore this code
{
echo '';
} else {
if (isset($_COOKIE['DonatedCookie'])) //check for the donation cookie. If the user has donated, the splash page will not display
{
$cookie = $_COOKIE['DonatedCookie'];
} else {
$cookie = NULL;
}
if (isset($_SESSION['seen_splash'])) //check for the "Seen Splash" session variable. If the user has recently seen the splash page, it will no longer display until the session variable has been reset
{
$seen_splash = $_SESSION['seen_splash'];
} else {
$seen_splash = NULL;
}
if (isset($cookie)) //check for the cookie. If it doesn't exist, check for the session variable. If neither exists, set the session variable and display the splash page in a modal popup
{
echo '';
}
else
{
if (isset($seen_splash))
{
echo '';
}
else
{
//------ this variable triggers the splashscreen to echo below
$show_splashscreen_please = 'yes';
}
}
}
//------ show the splashscreen if requested for troubleshooting
if ($_GET['showsplash'] == "yes")
{
$show_splashscreen_please = 'yes';
}
//------ if requested above for any reason, show the splashscreen now -------
if ($show_splashscreen_please == 'yes')
{
$_SESSION['seen_splash'] = 'yes';
echo "<link media=\"screen\" rel=\"stylesheet\" href=\"/test/ajax/colorbox/colorbox.css\" />\n
<script type=\"text/javascript\" src=\"/test/ajax/jquery-latest.min.js\"></script>\n
<script type=\"text/javascript\" src=\"/test/ajax/colorbox/jquery.colorbox-min.js\"></script>\n
<script type=\"text/javascript\">\n
$(document).ready(function(){\n
$.colorbox({href:\"campaign-spring2011-splashscreen.php\",
open:true});\n
});\n
</script>\n";
}
/*
Setting the cookie.. iframe this on your donation 'thank you' page:
<?php
setcookie("DonatedCookie", "I Donated!", time()+1209600, "/", ".kuhf.org", FALSE, FALSE);
?>
<!DOCTYPE html>
<html>
<head>
<title>Set Donate Cookie</title>
</head>
<body>Success!</body>
</html>
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment