templates
[squirrelmail.git] / themes / random.php
CommitLineData
fc632e34 1<?php
fc632e34 2
d4f79d96 3/**
c4309fbd 4 * Name: Random Theme Every Login
5 * @author Tyler Akins
6 * Date: December 24, 2001
7 * Comment: Guess what this does!
d4f79d96 8 *
6c84ba1e 9 * Copyright (c) 2000-2005 The SquirrelMail Project Team
d4f79d96 10 * Licensed under the GNU GPL. For full terms see the file COPYING.
11 *
12 * $Id$
7ce971d0 13 * @package squirrelmail
c4309fbd 14 * @subpackage themes
d4f79d96 15 */
fc632e34 16
c4309fbd 17/** Initialize the random number generator */
d4f79d96 18sq_mt_randomize();
0b97a708 19
20require_once(SM_PATH . 'functions/global.php');
eb548244 21
a4edbd9f 22global $theme;
eb548244 23
d7c82551 24if (!sqsession_is_registered('random_theme_good_theme')) {
d4f79d96 25 $good_themes = array();
26 foreach ($theme as $data) {
27 if (substr($data['PATH'], -18) != '/themes/random.php') {
fc632e34 28 $good_themes[] = $data['PATH'];
d4f79d96 29 }
30 }
8905fa13 31 if (count($good_themes) == 0) {
32 $good_themes[] = '../themes/default.php';
33 }
d4f79d96 34 $which = mt_rand(0, count($good_themes));
35 $random_theme_good_theme = $good_themes[$which];
e8927b2f 36 // remove current sm_path from theme name
37 $path=preg_quote(SM_PATH,'/');
38 $random_theme_good_theme=preg_replace("/^$path/",'',$random_theme_good_theme);
39 // store it in session
0b97a708 40 sqsession_register($random_theme_good_theme, 'random_theme_good_theme');
a4edbd9f 41} else {
42 // get random theme stored in session
43 sqgetGlobalVar('random_theme_good_theme',$random_theme_good_theme);
d4f79d96 44}
eb548244 45
e8927b2f 46@include_once (SM_PATH . $random_theme_good_theme);
fc632e34 47
eb548244 48?>