'admin/settings/splash', 'title' => t('Splash'), 'description' => t('Show a splash page before going to the actual frontpage.'), 'callback' => 'drupal_get_form', 'callback arguments' => 'splash_admin', 'access' => user_access('administer splash')); // Drupal prefers this above hook_init } else { $splash = TRUE; $redirect = variable_get('splash_redirect', ''); $cookie = variable_get('splash_cookie', 'splash'); // We are not on the front page if (!drupal_is_front_page()) { $splash = FALSE; // We come from an internal page } elseif (($parsed_url = parse_url($base_url)) && stristr(referer_uri(), $parsed_url['host'])) { $splash = FALSE; // Front page is splash page?! } elseif ($_GET['q'] == drupal_get_normal_path($redirect)) { $splash = FALSE; // Someone knew this special way to get around the splash :) } elseif (isset($_GET['nosplash'])) { $splash = FALSE; // Don't show twice } else if ($_COOKIE[$cookie] && variable_get('splash_frequency', 'once') == 'once') { $splash = FALSE; // Don't show twice a day } else if ($_COOKIE[$cookie] && variable_get('splash_frequency', 'once') == 'daily' && (time() - $_COOKIE[$cookie] < 86400)) { $splash = FALSE; // Don't show twice a week } else if ($_COOKIE[$cookie] && variable_get('splash_frequency', 'once') == 'weekly' && (time() - $_COOKIE[$cookie] < 604800)) { $splash = FALSE; } if ($splash) { setcookie($cookie, time(), time() + 604800, '/'); drupal_goto($redirect); } } return $items; } function splash_admin() { $form['splash_redirect'] = array( '#type' => 'textfield', '#required' => TRUE, '#title' => t('Splash path'), '#default_value' => variable_get('splash_redirect', ''), '#description' => t('The path of your splash page.'), ); $form['splash_frequency'] = array( '#type' => 'select', '#title' => t('Frequency'), '#default_value' => variable_get('splash_frequency', 'once'), '#options' => array( 'always' => t('Always'), 'once' => t('Once'), 'daily' => t('Daily'), 'weekly' => t('Weekly'), ), '#description' => t('How often should visitors see the splash page? Please not that by saving this page, all visitors will see the page on their next visit. Also, if people have disabled cookies, the splash page will come up every visit from an external page.'), ); $form['splash_cookie'] = array( '#type' => 'hidden', '#value' => 'splash_cookie_'.time(), ); return system_settings_form($form); } ?>