support for authz
[squirrelmail.git] / themes / random.php
CommitLineData
fc632e34 1<?php
fc632e34 2
d4f79d96 3/**
c4309fbd 4 * Name: Random Theme Every Login
c4309fbd 5 * Date: December 24, 2001
6 * Comment: Guess what this does!
d4f79d96 7 *
4b4abf93 8 * @author Tyler Akins
47ccfad4 9 * @copyright &copy; 2000-2006 The SquirrelMail Project Team
4b4abf93 10 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @version $Id$
7ce971d0 12 * @package squirrelmail
c4309fbd 13 * @subpackage themes
d4f79d96 14 */
fc632e34 15
2c34672a 16/** Prevent direct script loading */
17if ((isset($_SERVER['SCRIPT_FILENAME']) && $_SERVER['SCRIPT_FILENAME'] == __FILE__) ||
18 (isset($HTTP_SERVER_SERVER['SCRIPT_FILENAME']) && $HTTP_SERVER_SERVER['SCRIPT_FILENAME'] == __FILE__) ) {
19 die();
20}
21
22/** load required functions */
23include_once(SM_PATH . 'functions/global.php');
24include_once(SM_PATH . 'functions/strings.php');
25
c4309fbd 26/** Initialize the random number generator */
d4f79d96 27sq_mt_randomize();
0b97a708 28
a4edbd9f 29global $theme;
eb548244 30
d7c82551 31if (!sqsession_is_registered('random_theme_good_theme')) {
d4f79d96 32 $good_themes = array();
33 foreach ($theme as $data) {
34 if (substr($data['PATH'], -18) != '/themes/random.php') {
fc632e34 35 $good_themes[] = $data['PATH'];
d4f79d96 36 }
37 }
8905fa13 38 if (count($good_themes) == 0) {
39 $good_themes[] = '../themes/default.php';
40 }
d4f79d96 41 $which = mt_rand(0, count($good_themes));
42 $random_theme_good_theme = $good_themes[$which];
e8927b2f 43 // remove current sm_path from theme name
44 $path=preg_quote(SM_PATH,'/');
45 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
46 // store it in session
0b97a708 47 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
a4edbd9f 48} else {
49 // get random theme stored in session
50 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
d4f79d96 51}
eb548244 52
e8927b2f 53@include_once (SM_PATH . $random_theme_good_theme);